27#include "checkPandaVersion.h"
31#define __PDT_STDBOOL_H_
42#define ALWAYS_INLINE inline
45#define EXPORT_TEMPLATE_CLASS(expcl, exptp, classname)
50#define PUBLISHED __published
54typedef int ios_openmode;
55typedef int ios_fmtflags;
56typedef int ios_iostate;
57typedef int ios_seekdir;
74#include "fakestringstream.h"
85#ifndef HAVE_IOS_TYPEDEFS
86typedef int ios_openmode;
87typedef int ios_fmtflags;
88typedef int ios_iostate;
90typedef ios::seek_dir ios_seekdir;
92typedef std::ios::openmode ios_openmode;
93typedef std::ios::fmtflags ios_fmtflags;
94typedef std::ios::iostate ios_iostate;
95typedef std::ios::seekdir ios_seekdir;
99#define ALWAYS_INLINE __forceinline
100#elif defined(__GNUC__)
101#define ALWAYS_INLINE __attribute__((always_inline)) inline
103#define ALWAYS_INLINE inline
110#define INLINE ALWAYS_INLINE
117#if defined(__GLIBCXX__) && __GLIBCXX__ <= 20070719
122 using std::tr1::tuple;
124 using std::tr1::copysign;
126 typedef decltype(
nullptr) nullptr_t;
128 template<
class T>
struct remove_reference {
typedef T type;};
129 template<
class T>
struct remove_reference<T&> {
typedef T type;};
130 template<
class T>
struct remove_reference<T&& >{
typedef T type;};
132 template<
class T>
typename remove_reference<T>::type &&move(T &&t) {
133 return static_cast<typename remove_reference<T>::type&&
>(t);
136 template<
class T>
struct owner_less;
138 typedef enum memory_order {
139 memory_order_relaxed,
140 memory_order_consume,
141 memory_order_acquire,
142 memory_order_release,
143 memory_order_acq_rel,
144 memory_order_seq_cst,
147 #define ATOMIC_FLAG_INIT { 0 }
152 atomic_flag() noexcept = default;
153 ALWAYS_INLINE constexpr atomic_flag(
bool flag) noexcept : _flag(flag) {}
154 atomic_flag(
const atomic_flag &) =
delete;
155 ~atomic_flag() noexcept = default;
156 atomic_flag &operator = (const atomic_flag&) = delete;
158 ALWAYS_INLINE
bool test_and_set(memory_order order = memory_order_seq_cst) noexcept {
159 return __atomic_test_and_set(&_flag, order);
161 ALWAYS_INLINE
void clear(memory_order order = memory_order_seq_cst)
noexcept {
162 __atomic_clear(&_flag, order);
166 ALWAYS_INLINE
float round(
float arg) {
167 return ::roundf(arg);
169 ALWAYS_INLINE
double round(
double arg) {
172 ALWAYS_INLINE
long double round(
long double arg) {
173 return ::roundl(arg);
175 ALWAYS_INLINE
double round(
signed char arg) {
178 ALWAYS_INLINE
double round(
unsigned char arg) {
181 ALWAYS_INLINE
double round(
short arg) {
184 ALWAYS_INLINE
double round(
unsigned short arg) {
187 ALWAYS_INLINE
double round(
int arg) {
190 ALWAYS_INLINE
double round(
unsigned int arg) {
193 ALWAYS_INLINE
double round(
long arg) {
196 ALWAYS_INLINE
double round(
unsigned long arg) {
199 ALWAYS_INLINE
double round(
long long arg) {
202 ALWAYS_INLINE
double round(
unsigned long long arg) {
210#define PHAVE_ATOMIC 1
214#if defined(_MSC_VER) && _MSC_VER < 1900
215#error Microsoft Visual C++ 2015 or later is required to compile Panda3D.
219#define MOVE(x) (std::move(x))
222#ifndef LINK_ALL_STATIC
227#define EXPORT_TEMPLATE_CLASS(expcl, exptp, classname) \
228 exptp template class expcl classname;
230#define EXPORT_TEMPLATE_CLASS(expcl, exptp, classname)
236#define PUBLISHED public
247EXPCL_DTOOL_DTOOLBASE
extern MemoryHook *memory_hook;
251#ifndef USE_MEMORY_NOWRAPPERS
252#define PANDA_MALLOC_SINGLE(size) (ASSUME_ALIGNED(memory_hook->heap_alloc_single(size), MEMORY_HOOK_ALIGNMENT))
253#define PANDA_FREE_SINGLE(ptr) memory_hook->heap_free_single(ptr)
254#define PANDA_MALLOC_ARRAY(size) (ASSUME_ALIGNED(memory_hook->heap_alloc_array(size), MEMORY_HOOK_ALIGNMENT))
255#define PANDA_REALLOC_ARRAY(ptr, size) (ASSUME_ALIGNED(memory_hook->heap_realloc_array(ptr, size), MEMORY_HOOK_ALIGNMENT))
256#define PANDA_FREE_ARRAY(ptr) memory_hook->heap_free_array(ptr)
258#define PANDA_MALLOC_SINGLE(size) ::malloc(size)
259#define PANDA_FREE_SINGLE(ptr) ::free(ptr)
260#define PANDA_MALLOC_ARRAY(size) ::malloc(size)
261#define PANDA_REALLOC_ARRAY(ptr, size) ::realloc(ptr, size)
262#define PANDA_FREE_ARRAY(ptr) ::free(ptr)
265#if defined(HAVE_THREADS) && defined(SIMPLE_THREADS)
268extern EXPCL_DTOOL_DTOOLBASE void (*global_thread_yield)();
269extern EXPCL_DTOOL_DTOOLBASE void (*global_thread_consider_yield)();
271INLINE
void thread_yield() {
272 (*global_thread_yield)();
274INLINE
void thread_consider_yield() {
275 (*global_thread_consider_yield)();
279typedef struct _ts PyThreadState;
280extern EXPCL_DTOOL_DTOOLBASE PyThreadState *(*global_thread_state_swap)(PyThreadState *tstate);
282INLINE PyThreadState *thread_state_swap(PyThreadState *tstate) {
283 return (*global_thread_state_swap)(tstate);
289INLINE
void thread_yield() {
291INLINE
void thread_consider_yield() {
296#if defined(USE_TAU) && defined(WIN32)
298extern EXPCL_DTOOL_DTOOLBASE
bool __tau_shutdown;
299class EXPCL_DTOOL_DTOOLBASE TauProfile {
301 TauProfile(
void *&tautimer,
char *name,
char *type,
int group,
char *group_name) {
302 Tau_profile_c_timer(&tautimer, name, type, group, group_name);
303 _tautimer = tautimer;
304 TAU_PROFILE_START(_tautimer);
307 if (!__tau_shutdown) {
308 TAU_PROFILE_STOP(_tautimer);
317#define TAU_PROFILE(name, type, group) \
318 static void *__tautimer; \
319 TauProfile __taupr(__tautimer, name, type, group, #group)
321#undef TAU_PROFILE_EXIT
322#define TAU_PROFILE_EXIT(msg) \
323 __tau_shutdown = true; \
This class provides a wrapper around the various possible malloc schemes Panda might employ.
A base class for all things that want to be reference-counted.