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) __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_INLINE T | AtomicAdd (volatile T *target, T value)
template<typename T >
PTEX_INLINE T | AtomicIncrement (volatile T *target)
template<typename T >
PTEX_INLINE T | AtomicSubtract (volatile T *target, T value)
template<typename T >
PTEX_INLINE T | AtomicDecrement (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
| ) |  | __sync_add_and_fetch(x,y)

Definition at line 193 of file PtexPlatform.h.

## ATOMIC_ADD64

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

Definition at line 194 of file PtexPlatform.h.

## ATOMIC_ALIGNED

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

Definition at line 192 of file PtexPlatform.h.

## ATOMIC_SUB32

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

Definition at line 195 of file PtexPlatform.h.

## ATOMIC_SUB64

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

Definition at line 196 of file PtexPlatform.h.

## BOOL_CMPXCH32

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

Definition at line 198 of file PtexPlatform.h.

## BOOL_CMPXCH64

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

Definition at line 199 of file PtexPlatform.h.

## CACHE_LINE_PAD

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

Definition at line 300 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 301 of file PtexPlatform.h.

## CACHE_LINE_SIZE

#define CACHE_LINE_SIZE 64

Definition at line 297 of file PtexPlatform.h.

## MEM_FENCE

#define MEM_FENCE | ( |  | ) | __sync_synchronize()

Definition at line 197 of file PtexPlatform.h.

## PTEX_INLINE

#define PTEX_INLINE inline __attribute__((always_inline))

Definition at line 202 of file PtexPlatform.h.

## PTEX_PLATFORM_UNIX

#define PTEX_PLATFORM_UNIX

Definition at line 83 of file PtexPlatform.h.

## Typedef Documentation

## FilePos

typedef off_t FilePos

Definition at line 99 of file PtexPlatform.h.

## Function Documentation

## AtomicAdd()

template<typename T >

PTEX_INLINE T AtomicAdd | ( | volatile T * | target,
|  | T | value
| ) |  |

Definition at line 209 of file PtexPlatform.h.

References ATOMIC_ADD32, and ATOMIC_ADD64.

Referenced by PtexReaderCache::adjustFilesOpen(), PtexReaderCache::adjustMemUsed(), AtomicIncrement(), and PtexReader::increaseMemUsed().

## AtomicCompareAndSwap()

template<typename T >

PTEX_INLINE bool AtomicCompareAndSwap | ( | T volatile * | target,
|  | T | oldvalue,
|  | T | newvalue
| ) |  |

Definition at line 278 of file PtexPlatform.h.

Referenced by PtexReader::TiledReducedFace::getTile(), PtexHashMap< Key, Value >::lockEntries(), PtexCachedReader::ref(), and PtexCachedReader::trylock().

## AtomicDecrement()

template<typename T >

PTEX_INLINE T AtomicDecrement | ( | volatile T * | target | ) |

Definition at line 247 of file PtexPlatform.h.

References AtomicSubtract().

Referenced by PtexCachedReader::unref().

## AtomicIncrement()

template<typename T >

PTEX_INLINE T AtomicIncrement | ( | volatile T * | target | ) |

Definition at line 225 of file PtexPlatform.h.

References AtomicAdd().

Referenced by PtexReader::logBlockRead(), PtexReader::logOpen(), and PtexReaderCache::logRecentlyUsed().

## AtomicStore()

template<typename T >

PTEX_INLINE void AtomicStore | ( | T volatile * | target,
|  | T | value
| ) |  |

Definition at line 284 of file PtexPlatform.h.

References MEM_FENCE.

Referenced by PtexReader::open(), PtexReaderCache::processMru(), PtexReader::readFaceData(), PtexReader::readLevel(), PtexReader::readMetaData(), PtexCachedReader::unlock(), and PtexHashMap< Key, Value >::unlockEntries().

## AtomicSubtract()

template<typename T >

PTEX_INLINE T AtomicSubtract | ( | volatile T * | target,
|  | T | value
| ) |  |

Definition at line 231 of file PtexPlatform.h.

References ATOMIC_SUB32, and ATOMIC_SUB64.

Referenced by AtomicDecrement().

## PtexMemoryFence()

PTEX_INLINE void PtexMemoryFence | ( |  | ) |

Definition at line 290 of file PtexPlatform.h.

References MEM_FENCE.

Referenced by PtexHashMap< Key, Value >::tryInsert().