(file) Return to atomic.cpp CVS log (file) (dir) Up to [OMI] / omi / micxx

 1 mike  1.1 /*
 2           **==============================================================================
 3           **
 4           ** Open Management Infrastructure (OMI)
 5           **
 6           ** Copyright (c) Microsoft Corporation
 7           ** 
 8           ** Licensed under the Apache License, Version 2.0 (the "License"); you may not 
 9           ** use this file except in compliance with the License. You may obtain a copy 
10           ** of the License at 
11           **
12           **     http://www.apache.org/licenses/LICENSE-2.0 
13           **
14           ** THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15           ** KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 
16           ** WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 
17           ** MERCHANTABLITY OR NON-INFRINGEMENT. 
18           **
19           ** See the Apache 2 License for the specific language governing permissions 
20           ** and limitations under the License.
21           **
22 mike  1.1 **==============================================================================
23           */
24           
25           #include "atomic.h"
26 krisbash 1.3 #include <pal/atomic.h>
27 mike     1.1 
28              MI_BEGIN_NAMESPACE
29              
30              //==============================================================================
31              //
32              // AtomicType
33              //
34              //==============================================================================
35              
36              unsigned int AtomicGet(const AtomicType& x)
37              {
38 krisbash 1.3     return (unsigned int)Atomic_Read((ptrdiff_t*)&x.__opaque);
39 mike     1.1 }
40              
41              void AtomicSet(AtomicType& x, unsigned int n)
42              {
43 krisbash 1.3     *((ptrdiff_t*)&x.__opaque) = (ptrdiff_t)n;
44 mike     1.1 }
45              
46              void AtomicInc(AtomicType& x)
47              {
48 krisbash 1.3     Atomic_Inc((ptrdiff_t*)&x.__opaque);
49 mike     1.1 }
50              
51              bool AtomicDec(AtomicType& x)
52              {
53 krisbash 1.3     return Atomic_Dec((ptrdiff_t*)&x.__opaque) == 0 ? true : false;
54 mike     1.1 }
55              
56              MI_END_NAMESPACE

ViewCVS 0.9.2