Ptex
Classes | Macros | Typedefs | Functions
PtexPlatform.h File Reference

Platform-specific classes, functions, and includes. More...

#include "PtexInt.h"
#include <stdlib.h>
#include <alloca.h>
#include <string.h>
#include <pthread.h>
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include "PtexVersion.h"

Go to the source code of this file.

Classes

class  Mutex
 
class  SpinLock
 
struct  AtomicCompareAndSwapImpl< T, n >
 
struct  AtomicCompareAndSwapImpl< T, sizeof(uint32_t)>
 
struct  AtomicCompareAndSwapImpl< T, sizeof(uint64_t)>
 

Macros

#define PtexPlatform_h
 
#define ATOMIC_ALIGNED   __attribute__((aligned(8)))
 
#define ATOMIC_ADD32(x, y)   __sync_add_and_fetch(x,y)
 
#define ATOMIC_ADD64(x, y)   __sync_add_and_fetch(x,y)
 
#define ATOMIC_SUB32(x, y)   __sync_sub_and_fetch(x,y)
 
#define ATOMIC_SUB64(x, y)   __sync_sub_and_fetch(x,y)
 
#define MEM_FENCE()   __sync_synchronize()
 
#define BOOL_CMPXCH32(x, y, z)   __sync_bool_compare_and_swap((x),(y),(z))
 
#define BOOL_CMPXCH64(x, y, z)   __sync_bool_compare_and_swap((x),(y),(z))
 
#define PTEX_INLINE   inline __attribute__((always_inline))
 
#define CACHE_LINE_SIZE   64
 
#define CACHE_LINE_PAD(var, type)   char var##_pad[CACHE_LINE_SIZE - sizeof(type)]
 
#define CACHE_LINE_PAD_INIT(var)   memset(&var##_pad[0], 0, sizeof(var##_pad))
 

Typedefs

typedef off_t FilePos
 

Functions

template<typename T >
PTEX_INLINEAtomicAdd (volatile T *target, T value)
 
template<typename T >
PTEX_INLINEAtomicIncrement (volatile T *target)
 
template<typename T >
PTEX_INLINEAtomicSubtract (volatile T *target, T value)
 
template<typename T >
PTEX_INLINEAtomicDecrement (volatile T *target)
 
template<typename T >
PTEX_INLINE bool AtomicCompareAndSwap (T volatile *target, T oldvalue, T newvalue)
 
template<typename T >
PTEX_INLINE void AtomicStore (T volatile *target, T value)
 
PTEX_INLINE void PtexMemoryFence ()
 

Detailed Description

Platform-specific classes, functions, and includes.

Definition in file PtexPlatform.h.

Macro Definition Documentation

◆ ATOMIC_ADD32

#define ATOMIC_ADD32 (   x,
 
)    __sync_add_and_fetch(x,y)

Definition at line 183 of file PtexPlatform.h.

◆ ATOMIC_ADD64

#define ATOMIC_ADD64 (   x,
 
)    __sync_add_and_fetch(x,y)

Definition at line 184 of file PtexPlatform.h.

◆ ATOMIC_ALIGNED

#define ATOMIC_ALIGNED   __attribute__((aligned(8)))

Definition at line 182 of file PtexPlatform.h.

◆ ATOMIC_SUB32

#define ATOMIC_SUB32 (   x,
 
)    __sync_sub_and_fetch(x,y)

Definition at line 185 of file PtexPlatform.h.

◆ ATOMIC_SUB64

#define ATOMIC_SUB64 (   x,
 
)    __sync_sub_and_fetch(x,y)

Definition at line 186 of file PtexPlatform.h.

◆ BOOL_CMPXCH32

#define BOOL_CMPXCH32 (   x,
  y,
 
)    __sync_bool_compare_and_swap((x),(y),(z))

Definition at line 188 of file PtexPlatform.h.

◆ BOOL_CMPXCH64

#define BOOL_CMPXCH64 (   x,
  y,
 
)    __sync_bool_compare_and_swap((x),(y),(z))

Definition at line 189 of file PtexPlatform.h.

◆ CACHE_LINE_PAD

#define CACHE_LINE_PAD (   var,
  type 
)    char var##_pad[CACHE_LINE_SIZE - sizeof(type)]

Definition at line 290 of file PtexPlatform.h.

◆ CACHE_LINE_PAD_INIT

#define CACHE_LINE_PAD_INIT (   var)    memset(&var##_pad[0], 0, sizeof(var##_pad))

Definition at line 291 of file PtexPlatform.h.

◆ CACHE_LINE_SIZE

#define CACHE_LINE_SIZE   64

Definition at line 287 of file PtexPlatform.h.

◆ MEM_FENCE

#define MEM_FENCE ( )    __sync_synchronize()

Definition at line 187 of file PtexPlatform.h.

◆ PTEX_INLINE

#define PTEX_INLINE   inline __attribute__((always_inline))

Definition at line 192 of file PtexPlatform.h.

◆ PtexPlatform_h

#define PtexPlatform_h

Definition at line 4 of file PtexPlatform.h.

Typedef Documentation

◆ FilePos

typedef off_t FilePos

Definition at line 88 of file PtexPlatform.h.

Function Documentation

◆ AtomicAdd()

template<typename T >
PTEX_INLINE T AtomicAdd ( volatile T *  target,
value 
)

◆ AtomicCompareAndSwap()

template<typename T >
PTEX_INLINE bool AtomicCompareAndSwap ( T volatile *  target,
oldvalue,
newvalue 
)

◆ AtomicDecrement()

template<typename T >
PTEX_INLINE T AtomicDecrement ( volatile T *  target)

Definition at line 236 of file PtexPlatform.h.

References AtomicSubtract().

Referenced by PtexCachedReader::unref().

◆ AtomicIncrement()

template<typename T >
PTEX_INLINE T AtomicIncrement ( volatile T *  target)

◆ AtomicStore()

template<typename T >
PTEX_INLINE void AtomicStore ( T volatile *  target,
value 
)

◆ AtomicSubtract()

template<typename T >
PTEX_INLINE T AtomicSubtract ( volatile T *  target,
value 
)

Definition at line 220 of file PtexPlatform.h.

References ATOMIC_SUB32, and ATOMIC_SUB64.

Referenced by AtomicDecrement().

◆ PtexMemoryFence()

PTEX_INLINE void PtexMemoryFence ( )

Definition at line 279 of file PtexPlatform.h.

References MEM_FENCE.

Referenced by PtexHashMap< StringKey, PtexCachedReader * >::tryInsert().