Panda3D

Loading...
Searching...
No Matches
atomicAdjust.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file atomicAdjust.h
10 * @author drose
11 * @date 2002-08-09
12 */
13
14#ifndef ATOMICADJUST_H
15#define ATOMICADJUST_H
16
17#include "dtoolbase.h"
18#include "selectThreadImpl.h"
19
20#if defined(CPPPARSER)
21
22 struct AtomicAdjust {
23 typedef long Integer;
24 typedef void *UnalignedPointer;
25 typedef UnalignedPointer Pointer;
26};
27
28#elif defined(THREAD_DUMMY_IMPL) || defined(THREAD_SIMPLE_IMPL)
29
30#include "atomicAdjustDummyImpl.h"
31 typedef AtomicAdjustDummyImpl AtomicAdjust;
32
33#elif (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))) || (defined(__clang__) && (__clang_major__ >= 3))
34// GCC 4.7 and above has built-in __atomic functions for atomic operations.
35// Clang 3.0 and above also supports them.
36
37#include "atomicAdjustGccImpl.h"
38 typedef AtomicAdjustGccImpl AtomicAdjust;
39
40#if (__GCC_ATOMIC_INT_LOCK_FREE + __GCC_ATOMIC_LONG_LOCK_FREE) > 0
41#define HAVE_ATOMIC_COMPARE_AND_EXCHANGE 1
42#endif
43#if __GCC_ATOMIC_POINTER_LOCK_FREE > 0
44#define HAVE_ATOMIC_COMPARE_AND_EXCHANGE_PTR 1
45#endif
46
47#elif (defined(__i386__) || defined(_M_IX86)) && !defined(__APPLE__)
48// For an i386 architecture, we'll always use the i386 implementation. It
49// should be safe for any OS, and it might be a bit faster than any OS-
50// provided calls.
51
52#include "atomicAdjustI386Impl.h"
53 typedef AtomicAdjustI386Impl AtomicAdjust;
54
55// These symbols are defined if the compare_and_exchange() methods are
56// implemented natively, without recourse to external locks. If these are not
57// defined, users may elect to implement an operation with some other method
58// than compare_and_exchange(), which might be faster.
59#define HAVE_ATOMIC_COMPARE_AND_EXCHANGE 1
60#define HAVE_ATOMIC_COMPARE_AND_EXCHANGE_PTR 1
61
62#elif defined(THREAD_WIN32_IMPL)
63
64#include "atomicAdjustWin32Impl.h"
65 typedef AtomicAdjustWin32Impl AtomicAdjust;
66
67#define HAVE_ATOMIC_COMPARE_AND_EXCHANGE 1
68#define HAVE_ATOMIC_COMPARE_AND_EXCHANGE_PTR 1
69
70#elif defined(THREAD_LINUX_IMPL)
71
72#error Linux native threads are currently implemented only for i386; use Posix threads instead.
73
74#elif defined(THREAD_POSIX_IMPL)
75
76#include "atomicAdjustPosixImpl.h"
77 typedef AtomicAdjustPosixImpl AtomicAdjust;
78
79#endif
80
81#endif
atomicAdjustDummyImpl.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
atomicAdjustGccImpl.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
atomicAdjustI386Impl.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
atomicAdjustPosixImpl.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
atomicAdjustWin32Impl.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
AtomicAdjustDummyImpl
A trivial implementation for atomic adjustments for systems that don't require multiprogramming,...
Definition atomicAdjustDummyImpl.h:27
dtoolbase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
selectThreadImpl.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.