18#ifndef CARLA_DEFINES_H_INCLUDED
19#define CARLA_DEFINES_H_INCLUDED
23# define __has_feature(x) 0
25#ifndef __has_extension
26# define __has_extension __has_feature
30#define CARLA_VERSION_HEX 0x020591
31#define CARLA_VERSION_STRING "2.6.0-alpha1"
32#define CARLA_VERSION_STRMIN "2.6"
35#if defined(WIN64) || defined(_WIN64) || defined(__WIN64__) || defined(_M_ARM64)
36# define CARLA_OS_WIN64
37#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(_M_ARM)
38# define CARLA_OS_WIN32
39#elif defined(__APPLE__)
41#elif defined(__HAIKU__)
42# define CARLA_OS_HAIKU
43#elif defined(__linux__) || defined(__linux)
44# define CARLA_OS_LINUX
45#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
48# define CARLA_OS_GNU_HURD
49#elif defined(__EMSCRIPTEN__)
52# warning Unsupported platform!
55#if defined(CARLA_OS_WIN32) || defined(CARLA_OS_WIN64)
57#elif defined(CARLA_OS_BSD) || defined(CARLA_OS_GNU_HURD) || defined(CARLA_OS_LINUX) || defined(CARLA_OS_MAC)
61#if defined(__LP64__) || defined(_LP64) || defined(__arm64__) || defined(__aarch64__) || defined(CARLA_OS_WIN64)
62# define CARLA_OS_64BIT
66#if defined(HAVE_CPP11_SUPPORT)
67# if HAVE_CPP11_SUPPORT
68# define CARLA_PROPER_CPP11_SUPPORT
70#elif defined(__cplusplus)
71# if __cplusplus >= 201103L || (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 && defined(__GXX_EXPERIMENTAL_CXX0X__)) || __has_extension(cxx_noexcept) || defined(_MSC_VER)
72# define CARLA_PROPER_CPP11_SUPPORT
73# if (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 407 && ! defined(__clang__)) || (defined(__clang__) && ! __has_extension(cxx_override_control))
80#if defined(__cplusplus) && ! defined(CARLA_PROPER_CPP11_SUPPORT)
82# define noexcept throw()
98#if defined(CARLA_OS_WIN64)
99# define P_INT64 "%lli"
100# define P_UINT64 "%llu"
101# define P_INTPTR "%lli"
102# define P_UINTPTR "%llx"
103# define P_SIZE "%llu"
104# define P_SSIZE "%lli"
105#elif defined(CARLA_OS_WIN32)
106# define P_INT64 "%lli"
107# define P_UINT64 "%llu"
108# define P_INTPTR "%i"
109# define P_UINTPTR "%x"
112#elif defined(CARLA_OS_WASM)
113# define P_INT64 "%lli"
114# define P_UINT64 "%llu"
115# define P_INTPTR "%li"
116# define P_UINTPTR "%lx"
118# define P_SSIZE "%li"
119#elif defined(CARLA_OS_MAC)
120# define P_INT64 "%lli"
121# define P_UINT64 "%llu"
122# define P_INTPTR "%li"
123# define P_UINTPTR "%lx"
125# define P_SSIZE "%li"
126#elif (defined(__WORDSIZE) && __WORDSIZE == 64) || \
127 (defined(__SIZE_WIDTH__) && __SIZE_WIDTH__ == 64) || \
128 (defined(CARLA_OS_HAIKU) && defined(CARLA_OS_64BIT))
129# define P_INT64 "%li"
130# define P_UINT64 "%lu"
131# define P_INTPTR "%li"
132# define P_UINTPTR "%lx"
134# define P_SSIZE "%li"
136# define P_INT64 "%lli"
137# define P_UINT64 "%llu"
138# define P_INTPTR "%i"
139# define P_UINTPTR "%x"
145#if defined(CARLA_OS_WIN)
146# ifdef CARLA_OS_WIN64
147# define BINARY_NATIVE BINARY_WIN64
149# define BINARY_NATIVE BINARY_WIN32
152# ifdef CARLA_OS_64BIT
153# define BINARY_NATIVE BINARY_POSIX64
155# define BINARY_NATIVE BINARY_POSIX32
161# define unlikely(x) __builtin_expect(x,0)
163# define unlikely(x) x
167#if defined(CARLA_NO_ASSERTS)
168# define CARLA_ASSERT(cond)
169# define CARLA_ASSERT_INT(cond, value)
170# define CARLA_ASSERT_INT2(cond, v1, v2)
172# define CARLA_ASSERT CARLA_SAFE_ASSERT
173# define CARLA_ASSERT_INT CARLA_SAFE_ASSERT_INT
174# define CARLA_ASSERT_INT2 CARLA_SAFE_ASSERT_INT2
176# define CARLA_ASSERT(cond) assert(cond)
177# define CARLA_ASSERT_INT(cond, value) assert(cond)
178# define CARLA_ASSERT_INT2(cond, v1, v2) assert(cond)
182#define CARLA_SAFE_ASSERT(cond) if (unlikely(!(cond))) carla_safe_assert (#cond, __FILE__, __LINE__);
183#define CARLA_SAFE_ASSERT_INT(cond, value) if (unlikely(!(cond))) carla_safe_assert_int (#cond, __FILE__, __LINE__, static_cast<int>(value));
184#define CARLA_SAFE_ASSERT_INT2(cond, v1, v2) if (unlikely(!(cond))) carla_safe_assert_int2 (#cond, __FILE__, __LINE__, static_cast<int>(v1), static_cast<int>(v2));
185#define CARLA_SAFE_ASSERT_UINT(cond, value) if (unlikely(!(cond))) carla_safe_assert_uint (#cond, __FILE__, __LINE__, static_cast<uint>(value));
186#define CARLA_SAFE_ASSERT_UINT2(cond, v1, v2) if (unlikely(!(cond))) carla_safe_assert_uint2(#cond, __FILE__, __LINE__, static_cast<uint>(v1), static_cast<uint>(v2));
188#define CARLA_SAFE_ASSERT_BREAK(cond) if (unlikely(!(cond))) { carla_safe_assert(#cond, __FILE__, __LINE__); break; }
189#define CARLA_SAFE_ASSERT_CONTINUE(cond) if (unlikely(!(cond))) { carla_safe_assert(#cond, __FILE__, __LINE__); continue; }
190#define CARLA_SAFE_ASSERT_RETURN(cond, ret) if (unlikely(!(cond))) { carla_safe_assert(#cond, __FILE__, __LINE__); return ret; }
192#define CARLA_CUSTOM_SAFE_ASSERT(msg, cond) if (unlikely(!(cond))) carla_custom_safe_assert(msg, #cond, __FILE__, __LINE__);
193#define CARLA_CUSTOM_SAFE_ASSERT_BREAK(msg, cond) if (unlikely(!(cond))) { carla_custom_safe_assert(msg, #cond, __FILE__, __LINE__); break; }
194#define CARLA_CUSTOM_SAFE_ASSERT_CONTINUE(msg, cond) if (unlikely(!(cond))) { carla_custom_safe_assert(msg, #cond, __FILE__, __LINE__); continue; }
195#define CARLA_CUSTOM_SAFE_ASSERT_RETURN(msg, cond, ret) if (unlikely(!(cond))) { carla_custom_safe_assert(msg, #cond, __FILE__, __LINE__); return ret; }
197#define CARLA_CUSTOM_SAFE_ASSERT_ONCE_BREAK(msg, cond) if (unlikely(!(cond))) { static bool _p; if (!_p) { _p = true; carla_custom_safe_assert(msg, #cond, __FILE__, __LINE__); } break; }
198#define CARLA_CUSTOM_SAFE_ASSERT_ONCE_CONTINUE(msg, cond) if (unlikely(!(cond))) { static bool _p; if (!_p) { _p = true; carla_custom_safe_assert(msg, #cond, __FILE__, __LINE__); } continue; }
199#define CARLA_CUSTOM_SAFE_ASSERT_ONCE_RETURN(msg, cond, ret) if (unlikely(!(cond))) { static bool _p; if (!_p) { _p = true; carla_custom_safe_assert(msg, #cond, __FILE__, __LINE__); } return ret; }
201#define CARLA_SAFE_ASSERT_INT_BREAK(cond, value) if (unlikely(!(cond))) { carla_safe_assert_int(#cond, __FILE__, __LINE__, static_cast<int>(value)); break; }
202#define CARLA_SAFE_ASSERT_INT_CONTINUE(cond, value) if (unlikely(!(cond))) { carla_safe_assert_int(#cond, __FILE__, __LINE__, static_cast<int>(value)); continue; }
203#define CARLA_SAFE_ASSERT_INT_RETURN(cond, value, ret) if (unlikely(!(cond))) { carla_safe_assert_int(#cond, __FILE__, __LINE__, static_cast<int>(value)); return ret; }
205#define CARLA_SAFE_ASSERT_INT2_BREAK(cond, v1, v2) if (unlikely(!(cond))) { carla_safe_assert_int2(#cond, __FILE__, __LINE__, static_cast<int>(v1), static_cast<int>(v2)); break; }
206#define CARLA_SAFE_ASSERT_INT2_CONTINUE(cond, v1, v2) if (unlikely(!(cond))) { carla_safe_assert_int2(#cond, __FILE__, __LINE__, static_cast<int>(v1), static_cast<int>(v2)); continue; }
207#define CARLA_SAFE_ASSERT_INT2_RETURN(cond, v1, v2, ret) if (unlikely(!(cond))) { carla_safe_assert_int2(#cond, __FILE__, __LINE__, static_cast<int>(v1), static_cast<int>(v2)); return ret; }
209#define CARLA_SAFE_ASSERT_UINT_BREAK(cond, value) if (unlikely(!(cond))) { carla_safe_assert_uint(#cond, __FILE__, __LINE__, static_cast<uint>(value); break; }
210#define CARLA_SAFE_ASSERT_UINT_CONTINUE(cond, value) if (unlikely(!(cond))) { carla_safe_assert_uint(#cond, __FILE__, __LINE__, static_cast<uint>(value)); continue; }
211#define CARLA_SAFE_ASSERT_UINT_RETURN(cond, value, ret) if (unlikely(!(cond))) { carla_safe_assert_uint(#cond, __FILE__, __LINE__, static_cast<uint>(value)); return ret; }
213#define CARLA_SAFE_ASSERT_UINT2_BREAK(cond, v1, v2) if (unlikely(!(cond))) { carla_safe_assert_uint2(#cond, __FILE__, __LINE__, static_cast<uint>(v1), static_cast<uint>(v2)); break; }
214#define CARLA_SAFE_ASSERT_UINT2_CONTINUE(cond, v1, v2) if (unlikely(!(cond))) { carla_safe_assert_uint2(#cond, __FILE__, __LINE__, static_cast<uint>(v1), static_cast<uint>(v2)); continue; }
215#define CARLA_SAFE_ASSERT_UINT2_RETURN(cond, v1, v2, ret) if (unlikely(!(cond))) { carla_safe_assert_uint2(#cond, __FILE__, __LINE__, static_cast<uint>(v1), static_cast<uint>(v2)); return ret; }
217#if defined(__GNUC__) && defined(CARLA_PROPER_CPP11_SUPPORT) && ! defined(__clang__)
218# define CARLA_CATCH_UNWIND catch (abi::__forced_unwind&) { throw; }
220# pragma GCC diagnostic push
221# pragma GCC diagnostic ignored "-Wterminate"
224# define CARLA_CATCH_UNWIND
228#define CARLA_SAFE_EXCEPTION(msg) CARLA_CATCH_UNWIND catch(...) { carla_safe_exception(msg, __FILE__, __LINE__); }
229#define CARLA_SAFE_EXCEPTION_BREAK(msg) CARLA_CATCH_UNWIND catch(...) { carla_safe_exception(msg, __FILE__, __LINE__); break; }
230#define CARLA_SAFE_EXCEPTION_CONTINUE(msg) CARLA_CATCH_UNWIND catch(...) { carla_safe_exception(msg, __FILE__, __LINE__); continue; }
231#define CARLA_SAFE_EXCEPTION_RETURN(msg, ret) CARLA_CATCH_UNWIND catch(...) { carla_safe_exception(msg, __FILE__, __LINE__); return ret; }
234#ifdef CARLA_PROPER_CPP11_SUPPORT
235# define CARLA_DECLARE_NON_COPYABLE(ClassName) \
237 ClassName(ClassName&) = delete; \
238 ClassName(const ClassName&) = delete; \
239 ClassName& operator=(ClassName&) = delete; \
240 ClassName& operator=(const ClassName&) = delete;
242# define CARLA_DECLARE_NON_COPYABLE(ClassName) \
244 ClassName(ClassName&); \
245 ClassName(const ClassName&); \
246 ClassName& operator=(ClassName&); \
247 ClassName& operator=(const ClassName&);
251#ifdef CARLA_PROPER_CPP11_SUPPORT
252# define CARLA_PREVENT_HEAP_ALLOCATION \
254 static void* operator new(std::size_t) = delete; \
255 static void operator delete(void*) = delete;
257# define CARLA_PREVENT_HEAP_ALLOCATION \
259 static void* operator new(std::size_t); \
260 static void operator delete(void*);
264#ifdef CARLA_PROPER_CPP11_SUPPORT
265# define CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION \
267 static void* operator new(std::size_t) = delete;
269# define CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION \
271 static void* operator new(std::size_t);
275#if defined(CARLA_OS_WIN) && ! defined(__WINE__)
276# ifdef BUILDING_CARLA
277# define CARLA_VISIBLE_SYMBOL __declspec (dllexport)
279# define CARLA_VISIBLE_SYMBOL __declspec (dllimport)
282# define CARLA_VISIBLE_SYMBOL __attribute__ ((visibility("default")))
286#if defined(BUILD_BRIDGE) || defined(STATIC_PLUGIN_TARGET)
289# define CARLA_API CARLA_VISIBLE_SYMBOL
294# define CARLA_EXTERN_C extern "C"
296# define CARLA_EXTERN_C
300#if defined(BUILD_BRIDGE)
301# define CARLA_API_EXPORT CARLA_EXTERN_C
302# define CARLA_PLUGIN_EXPORT CARLA_EXTERN_C
303#elif defined(CARLA_OS_WASM)
304# define CARLA_API_EXPORT CARLA_EXTERN_C CARLA_API
305# define CARLA_PLUGIN_EXPORT CARLA_EXTERN_C __attribute__ ((used))
307# define CARLA_API_EXPORT CARLA_EXTERN_C CARLA_API
308# define CARLA_PLUGIN_EXPORT CARLA_EXTERN_C CARLA_VISIBLE_SYMBOL
313# define CARLA_OS_SEP '\\'
314# define CARLA_OS_SEP_STR "\\"
315# define CARLA_OS_SPLIT ';'
316# define CARLA_OS_SPLIT_STR ";"
318# define CARLA_OS_SEP '/'
319# define CARLA_OS_SEP_STR "/"
320# define CARLA_OS_SPLIT ':'
321# define CARLA_OS_SPLIT_STR ":"
332typedef SSIZE_T ssize_t;
unsigned long long int ulonglong
Definition CarlaDefines.h:329
unsigned short int ushort
Definition CarlaDefines.h:326
unsigned char uchar
Definition CarlaDefines.h:325
unsigned int uint
Definition CarlaDefines.h:327
unsigned long int ulong
Definition CarlaDefines.h:328