CMS 3D CMS Logo

IgProfAtomic.h

Go to the documentation of this file.
00001 #ifndef IG_PROF_IG_PROF_ATOMIC_H
00002 # define IG_PROF_IG_PROF_ATOMIC_H
00003 
00004 # if __i386__ || __ppc__
00005 # else
00006 #  error Sorry this platform is not supported.
00007 # endif
00008 
00009 //<<<<<< INCLUDES                                                       >>>>>>
00010 //<<<<<< PUBLIC DEFINES                                                 >>>>>>
00011 //<<<<<< PUBLIC CONSTANTS                                               >>>>>>
00012 //<<<<<< PUBLIC TYPES                                                   >>>>>>
00013 
00014 typedef int IgProfAtomic; // correct for all supported platforms for now
00015 
00016 //<<<<<< PUBLIC VARIABLES                                               >>>>>>
00017 //<<<<<< PUBLIC FUNCTIONS                                               >>>>>>
00018 //<<<<<< CLASS DECLARATIONS                                             >>>>>>
00019 //<<<<<< INLINE PUBLIC FUNCTIONS                                        >>>>>>
00020 
00021 inline IgProfAtomic
00022 IgProfAtomicInc (volatile IgProfAtomic *val)
00023 {
00024 # if __i386__
00025     IgProfAtomic result;
00026     __asm__ __volatile__
00027         ("   lock; xaddl %0, (%1); incl %0;"
00028          : "=r" (result)
00029          : "r" (val), "0" (1));
00030     return result+1;
00031 # elif __ppc__
00032     IgProfAtomic result;
00033     __asm__ __volatile__
00034         ("   lwsync\n"
00035          "1: lwarx %0, 0, %1\n"
00036          "   addic %0, %0, 1\n"
00037          "   stwcx. %0, 0, %1\n"
00038          "   bne- 1b\n"
00039          "   isync\n"
00040          : "=&r" (result)
00041          : "r" (val)
00042          : "cc", "memory");
00043     return result;
00044 # endif
00045 }
00046 
00047 inline IgProfAtomic
00048 IgProfAtomicDec (volatile IgProfAtomic *val)
00049 {
00050 # if __i386__
00051     IgProfAtomic result;
00052     __asm__ __volatile__
00053         ("lock; xaddl %0, (%1); decl %0;"
00054          : "=r" (result)
00055          : "r" (val), "0" (-1));
00056     return result;
00057 # elif __ppc__
00058     IgProfAtomic result;
00059     __asm__ __volatile__
00060         ("   lwsync\n"
00061          "1: lwarx %0, 0, %1\n"
00062          "   addic %0, %0, -1\n"
00063          "   stwcx. %0, 0, %1\n"
00064          "   bne- 1b\n"
00065          "   isync\n"
00066          : "=&r" (result)
00067          : "r" (val)
00068          : "cc", "memory");
00069     return result;
00070 # endif
00071 }
00072 
00073 //<<<<<< INLINE MEMBER FUNCTIONS                                        >>>>>>
00074 
00075 #endif // IG_PROF_IG_PROF_ATOMIC_H

Generated on Tue Jun 9 17:38:08 2009 for CMSSW by  doxygen 1.5.4