(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           #include <base/atomic.h>
27           
28           MI_BEGIN_NAMESPACE
29           
30           //==============================================================================
31           //
32           // AtomicType
33           //
34           //==============================================================================
35           
36           inline AtomicInt& AtomicRef(AtomicType& x)
37           {
38               return *((AtomicInt*)&x);
39           }
40           
41           inline const AtomicInt& AtomicRef(const AtomicType& x)
42           {
43 mike  1.1     return *((const AtomicInt*)&x);
44           }
45           
46           unsigned int AtomicGet(const AtomicType& x)
47           {
48               return AtomicRef(x);
49           }
50           
51           void AtomicSet(AtomicType& x, unsigned int n)
52           {
53               AtomicRef(x) = n;
54           }
55           
56           void AtomicInc(AtomicType& x)
57           {
58               ::AtomicInc(&AtomicRef(x));
59           }
60           
61           bool AtomicDec(AtomicType& x)
62           {
63               return ::AtomicDec(&AtomicRef(x)) ? true : false;
64 mike  1.1 }
65           
66           MI_END_NAMESPACE

ViewCVS 0.9.2