Ptex
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, sizeof(uint32_t)>
 
struct  AtomicCompareAndSwapImpl< T, sizeof(uint64_t)>
 

Macros

#define PTEX_PLATFORM_UNIX
 
#define ATOMIC_ALIGNED   __attribute__((aligned(8)))
 
#define ATOMIC_ADD32(x, y)
 
#define ATOMIC_ADD64(x, y)
 
#define ATOMIC_SUB32(x, y)
 
#define ATOMIC_SUB64(x, y)
 
#define MEM_FENCE()
 
#define BOOL_CMPXCH32(x, y, z)
 
#define BOOL_CMPXCH64(x, y, z)
 
#define PTEX_INLINE   inline __attribute__((always_inline))
 
#define CACHE_LINE_SIZE   64
 
#define CACHE_LINE_PAD(var, type)
 
#define CACHE_LINE_PAD_INIT(var)
 

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,
y )
Value:
__sync_add_and_fetch(x,y)

Definition at line 195 of file PtexPlatform.h.

Referenced by AtomicAdd().

◆ ATOMIC_ADD64

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

Definition at line 196 of file PtexPlatform.h.

Referenced by AtomicAdd().

◆ ATOMIC_ALIGNED

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

Definition at line 194 of file PtexPlatform.h.

◆ ATOMIC_SUB32

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

Definition at line 197 of file PtexPlatform.h.

Referenced by AtomicSubtract().

◆ ATOMIC_SUB64

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

Definition at line 198 of file PtexPlatform.h.

Referenced by AtomicSubtract().

◆ BOOL_CMPXCH32

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

Definition at line 200 of file PtexPlatform.h.

Referenced by AtomicCompareAndSwapImpl< T, sizeof(uint32_t)>::operator()().

◆ BOOL_CMPXCH64

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

Definition at line 201 of file PtexPlatform.h.

Referenced by AtomicCompareAndSwapImpl< T, sizeof(uint64_t)>::operator()().

◆ CACHE_LINE_PAD

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

Definition at line 302 of file PtexPlatform.h.

◆ CACHE_LINE_PAD_INIT

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

Definition at line 303 of file PtexPlatform.h.

Referenced by PtexReaderCache::PtexReaderCache().

◆ CACHE_LINE_SIZE

#define CACHE_LINE_SIZE   64

Definition at line 299 of file PtexPlatform.h.

◆ MEM_FENCE

#define MEM_FENCE ( )
Value:
__sync_synchronize()

Definition at line 199 of file PtexPlatform.h.

Referenced by AtomicStore(), and PtexMemoryFence().

◆ PTEX_INLINE

◆ PTEX_PLATFORM_UNIX

#define PTEX_PLATFORM_UNIX

Definition at line 85 of file PtexPlatform.h.

Typedef Documentation

◆ FilePos

typedef off_t FilePos

Definition at line 101 of file PtexPlatform.h.

Function Documentation

◆ AtomicAdd()

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

◆ AtomicCompareAndSwap()

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

◆ AtomicDecrement()

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

Definition at line 249 of file PtexPlatform.h.

References AtomicSubtract(), and PTEX_INLINE.

Referenced by PtexCachedReader::unref().

◆ AtomicIncrement()

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

◆ AtomicStore()

◆ AtomicSubtract()

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

Definition at line 233 of file PtexPlatform.h.

References ATOMIC_SUB32, ATOMIC_SUB64, and PTEX_INLINE.

Referenced by AtomicDecrement().

◆ PtexMemoryFence()

PTEX_INLINE void PtexMemoryFence ( )

Definition at line 292 of file PtexPlatform.h.

References MEM_FENCE, and PTEX_INLINE.

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