Panda3D
atomicAdjustI386Impl.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file atomicAdjustI386Impl.h
10  * @author drose
11  * @date 2006-04-01
12  */
13 
14 #ifndef ATOMICADJUSTI386IMPL_H
15 #define ATOMICADJUSTI386IMPL_H
16 
17 #include "dtoolbase.h"
18 #include "selectThreadImpl.h"
19 
20 #if (defined(__i386__) || defined(_M_IX86)) && !defined(__APPLE__) && !defined(__ANDROID__)
21 
22 #include "numeric_types.h"
23 
24 /**
25  * Uses assembly-language calls to atomically increment and decrement.
26  * Although this class is named i386, it actually uses instructions that are
27  * specific to 486 and higher.
28  */
29 class EXPCL_DTOOL_DTOOLBASE AtomicAdjustI386Impl {
30 public:
31  typedef ALIGN_4BYTE int32_t Integer;
32  typedef void *UnalignedPointer;
33  typedef ALIGN_4BYTE UnalignedPointer Pointer;
34 
35  INLINE static void inc(TVOLATILE Integer &var);
36  INLINE static bool dec(TVOLATILE Integer &var);
37  INLINE static Integer add(TVOLATILE Integer &var, Integer delta);
38  INLINE static Integer set(TVOLATILE Integer &var, Integer new_value);
39  INLINE static Integer get(const TVOLATILE Integer &var);
40 
41  INLINE static Pointer set_ptr(TVOLATILE Pointer &var, Pointer new_value);
42  INLINE static Pointer get_ptr(const TVOLATILE Pointer &var);
43 
44  INLINE static Integer compare_and_exchange(TVOLATILE Integer &mem,
45  Integer old_value,
46  Integer new_value);
47 
48  INLINE static Pointer compare_and_exchange_ptr(TVOLATILE Pointer &mem,
49  Pointer old_value,
50  Pointer new_value);
51 };
52 
53 #include "atomicAdjustI386Impl.I"
54 
55 #endif // __i386__
56 
57 #endif
atomicAdjustI386Impl.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
numeric_types.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
dtoolbase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
selectThreadImpl.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.