1 karl 1.6 //%2006////////////////////////////////////////////////////////////////////////
|
2 mike 1.2 //
3 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
6 // IBM Corp.; EMC Corporation, The Open Group.
7 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
9 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.6 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 mike 1.2 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
15 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
18 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
|
20 karl 1.6 //
|
21 mike 1.2 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 // Author: Mike Brasher (mike-brasher@austin.rr.com) - Inova Europe
33 //
34 //%/////////////////////////////////////////////////////////////////////////////
35
36 #ifndef Pegasus_AtomicInt_h
37 #define Pegasus_AtomicInt_h
38
39 #include <Pegasus/Common/Config.h>
40
41 //#ifndef PEGASUS_INTERNALONLY
42 mike 1.2 //# error "ERROR: This header is for internal use only (AtomicInt.h)"
43 //#endif
44
45 PEGASUS_NAMESPACE_BEGIN
46
47 template<class ATOMIC_TYPE>
48 class AtomicIntTemplate
49 {
50 public:
51
52 // Constructor.
53 AtomicIntTemplate(Uint32 n = 0);
54
55 // Destructor.
56 ~AtomicIntTemplate();
57
58 // Sets value.
59 void set(Uint32 n);
60
61 // Gets value.
62 Uint32 get() const;
63 mike 1.2
64 // Increment.
65 void inc();
66
67 // Decrement.
68 void dec();
69
70 // Decrements and returns true if it is zero.
71 bool decAndTestIfZero();
72
73 // Assignment.
74 AtomicIntTemplate& operator=(Uint32 n) { set(n); return* this; }
75
76 // Post-increment.
77 void operator++(int) { inc(); }
78
79 // Post-decrement.
80 void operator--(int) { dec(); }
81
82 private:
83
84 mike 1.2 // Note: These methods are intentionally hidden (and should not be called).
85 // The implementation is much easier without having to implement these for
86 // every platform.
|
87 kumpf 1.7 AtomicIntTemplate(const AtomicIntTemplate&);
88 AtomicIntTemplate& operator=(const AtomicIntTemplate&);
89 Boolean operator==(Uint32) const;
90 void operator++();
91 void operator--();
|
92 mike 1.2
93 typedef AtomicIntTemplate<ATOMIC_TYPE> This;
94
95 ATOMIC_TYPE _rep;
96 };
97
98 PEGASUS_NAMESPACE_END
99
100 #if defined(PEGASUS_PLATFORM_LINUX_IX86_GNU)
101 # include <Pegasus/Common/AtomicInt_LINUX_IX86_GNU.h>
|
102 mike 1.3 #elif defined(PEGASUS_PLATFORM_LINUX_X86_64_GNU)
103 # include <Pegasus/Common/AtomicInt_LINUX_X86_64_GNU.h>
|
104 mike 1.2 #elif defined(PEGASUS_PLATFORM_LINUX_IA64_GNU)
105 # include <Pegasus/Common/AtomicInt_LINUX_IA64_GNU.h>
106 #elif defined(PEGASUS_PLATFORM_LINUX_PPC_GNU)
107 # include <Pegasus/Common/AtomicInt_LINUX_PPC_GNU.h>
108 #elif defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC)
109 # include <Pegasus/Common/AtomicInt_WIN32_IX86_MSVC.h>
110 #elif defined (PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
111 # include <Pegasus/Common/AtomicInt_ZOS_ZSERIES_IBM.h>
112 #elif defined (PEGASUS_PLATFORM_HPUX_PARISC_ACC)
113 # include <Pegasus/Common/AtomicInt_Generic.h>
114 #elif defined (PEGASUS_PLATFORM_HPUX_IA64_ACC)
|
115 mike 1.5 # include <Pegasus/Common/AtomicInt_HPUX_IA64_ACC.h>
|
116 jim.wunderlich 1.4 #elif defined (PEGASUS_PLATFORM_LINUX_XSCALE_GNU)
117 # include <Pegasus/Common/AtomicInt_LINUX_XSCALE_GNU.h>
|
118 mike 1.2 #else
119 # include <Pegasus/Common/AtomicInt_Generic.h>
120 #endif
121
122 PEGASUS_NAMESPACE_BEGIN
123
124 typedef AtomicIntTemplate<AtomicType> AtomicInt;
125
126 PEGASUS_NAMESPACE_END
127
128 #endif /* Pegasus_AtomicInt_h */
|