Panda3D

atomicAdjustI386Impl.h

00001 // Filename: atomicAdjustI386Impl.h
00002 // Created by:  drose (01Apr06)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef ATOMICADJUSTI386IMPL_H
00016 #define ATOMICADJUSTI386IMPL_H
00017 
00018 #include "dtoolbase.h"
00019 #include "selectThreadImpl.h"
00020 
00021 #if defined(__i386__) || defined(_M_IX86)
00022 
00023 #include "numeric_types.h"
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //       Class : AtomicAdjustI386Impl
00027 // Description : Uses assembly-language calls to atomically increment
00028 //               and decrement.  Although this class is named i386, it
00029 //               actually uses instructions that are specific to 486
00030 //               and higher.
00031 ////////////////////////////////////////////////////////////////////
00032 class EXPCL_DTOOL AtomicAdjustI386Impl {
00033 public:
00034   typedef PN_int32 Integer;
00035 
00036   INLINE static void inc(TVOLATILE Integer &var);
00037   INLINE static bool dec(TVOLATILE Integer &var);
00038   INLINE static void add(TVOLATILE Integer &var, Integer delta);
00039   INLINE static Integer set(TVOLATILE Integer &var, Integer new_value);
00040   INLINE static Integer get(const TVOLATILE Integer &var);
00041 
00042   INLINE static void *set_ptr(void * TVOLATILE &var, void *new_value);
00043   INLINE static void *get_ptr(void * const TVOLATILE &var);
00044 
00045   INLINE static Integer compare_and_exchange(TVOLATILE Integer &mem, 
00046                                               Integer old_value,
00047                                               Integer new_value);
00048 
00049   INLINE static void *compare_and_exchange_ptr(void * TVOLATILE &mem, 
00050                                                void *old_value,
00051                                                void *new_value);
00052 };
00053 
00054 #include "atomicAdjustI386Impl.I"
00055 
00056 #endif  // __i386__
00057 
00058 #endif
 All Classes Functions Variables Enumerations