Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CarlaDefines.h 7.3KB

10 years ago
10 years ago
11 years ago
10 years ago
10 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /*
  2. * Carla common defines
  3. * Copyright (C) 2011-2014 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #ifndef CARLA_DEFINES_HPP_INCLUDED
  18. #define CARLA_DEFINES_HPP_INCLUDED
  19. /* IDE Helper */
  20. #ifndef REAL_BUILD
  21. # include "config.h"
  22. #endif
  23. /* Set Version */
  24. #define CARLA_VERSION_HEX 0x01092
  25. #define CARLA_VERSION_STRING "1.9.2"
  26. /* Check OS */
  27. #if defined(WIN64) || defined(_WIN64) || defined(__WIN64__)
  28. # define CARLA_OS_WIN64
  29. #elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
  30. # define CARLA_OS_WIN32
  31. #elif defined(__APPLE__)
  32. # define CARLA_OS_MAC
  33. #elif defined(__HAIKU__)
  34. # define CARLA_OS_HAIKU
  35. #elif defined(__linux__) || defined(__linux)
  36. # define CARLA_OS_LINUX
  37. #else
  38. # warning Unsupported platform!
  39. #endif
  40. #if defined(CARLA_OS_WIN32) || defined(CARLA_OS_WIN64)
  41. # define CARLA_OS_WIN
  42. #elif ! defined(CARLA_OS_HAIKU)
  43. # define CARLA_OS_UNIX
  44. #endif
  45. /* Check for C++11 support */
  46. #if defined(HAVE_CPP11_SUPPORT)
  47. # define CARLA_PROPER_CPP11_SUPPORT
  48. #elif defined(__GNUC__) && defined(__cplusplus)
  49. # if (__cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 405
  50. # define CARLA_PROPER_CPP11_SUPPORT
  51. # if (__GNUC__ * 100 + __GNUC_MINOR__) < 407
  52. # define override // gcc4.7+ only
  53. # define final // gcc4.7+ only
  54. # endif
  55. # endif
  56. #endif
  57. #if defined(__cplusplus) && !defined(CARLA_PROPER_CPP11_SUPPORT)
  58. # ifndef __clang__
  59. # define noexcept throw()
  60. # else
  61. # define noexcept
  62. # endif
  63. # define override
  64. # define final
  65. # define nullptr (0)
  66. #endif
  67. /* Common includes */
  68. #ifdef __cplusplus
  69. # include <cstddef>
  70. #else
  71. # include <stdbool.h>
  72. # include <stddef.h>
  73. #endif
  74. /* Define various string format types */
  75. #if defined(CARLA_OS_WIN64)
  76. # define P_INT64 "%I64i"
  77. # define P_INTPTR "%I64i"
  78. # define P_UINTPTR "%I64x"
  79. # define P_SIZE "%I64u"
  80. #elif defined(CARLA_OS_WIN32)
  81. # define P_INT64 "%I64i"
  82. # define P_INTPTR "%i"
  83. # define P_UINTPTR "%x"
  84. # define P_SIZE "%u"
  85. #elif defined(__WORDSIZE) && __WORDSIZE == 64
  86. # define P_INT64 "%li"
  87. # define P_INTPTR "%li"
  88. # define P_UINTPTR "%lx"
  89. # define P_SIZE "%lu"
  90. #else
  91. # define P_INT64 "%lli"
  92. # define P_INTPTR "%i"
  93. # define P_UINTPTR "%x"
  94. # define P_SIZE "%u"
  95. #endif
  96. /* Define BINARY_NATIVE */
  97. #if defined(CARLA_OS_HAIKU) || defined(CARLA_OS_UNIX)
  98. # if defined (__LP64__) || defined (_LP64)
  99. # define BINARY_NATIVE BINARY_POSIX64
  100. # else
  101. # define BINARY_NATIVE BINARY_POSIX32
  102. # endif
  103. #elif defined(CARLA_OS_WIN)
  104. # ifdef CARLA_OS_WIN64
  105. # define BINARY_NATIVE BINARY_WIN64
  106. # else
  107. # define BINARY_NATIVE BINARY_WIN32
  108. # endif
  109. #else
  110. # warning Unknown binary native
  111. # define BINARY_NATIVE BINARY_OTHER
  112. #endif
  113. /* Define CARLA_ASSERT* */
  114. #if defined(CARLA_NO_ASSERTS)
  115. # define CARLA_ASSERT(cond)
  116. # define CARLA_ASSERT_INT(cond, value)
  117. # define CARLA_ASSERT_INT2(cond, v1, v2)
  118. #elif defined(NDEBUG)
  119. # define CARLA_ASSERT CARLA_SAFE_ASSERT
  120. # define CARLA_ASSERT_INT CARLA_SAFE_ASSERT_INT
  121. # define CARLA_ASSERT_INT2 CARLA_SAFE_ASSERT_INT2
  122. #else
  123. # define CARLA_ASSERT(cond) assert(cond)
  124. # define CARLA_ASSERT_INT(cond, value) assert(cond)
  125. # define CARLA_ASSERT_INT2(cond, v1, v2) assert(cond)
  126. #endif
  127. /* Define CARLA_SAFE_ASSERT* */
  128. #define CARLA_SAFE_ASSERT(cond) if (cond) pass(); else carla_safe_assert (#cond, __FILE__, __LINE__);
  129. #define CARLA_SAFE_ASSERT_INT(cond, value) if (cond) pass(); else carla_safe_assert_int (#cond, __FILE__, __LINE__, value);
  130. #define CARLA_SAFE_ASSERT_INT2(cond, v1, v2) if (cond) pass(); else carla_safe_assert_int2 (#cond, __FILE__, __LINE__, v1, v2);
  131. #define CARLA_SAFE_ASSERT_UINT(cond, value) if (cond) pass(); else carla_safe_assert_uint (#cond, __FILE__, __LINE__, value);
  132. #define CARLA_SAFE_ASSERT_UINT2(cond, v1, v2) if (cond) pass(); else carla_safe_assert_uint2(#cond, __FILE__, __LINE__, v1, v2);
  133. #define CARLA_SAFE_ASSERT_BREAK(cond) if (cond) pass(); else { carla_safe_assert(#cond, __FILE__, __LINE__); break; }
  134. #define CARLA_SAFE_ASSERT_CONTINUE(cond) if (cond) pass(); else { carla_safe_assert(#cond, __FILE__, __LINE__); continue; }
  135. #define CARLA_SAFE_ASSERT_RETURN(cond, ret) if (cond) pass(); else { carla_safe_assert(#cond, __FILE__, __LINE__); return ret; }
  136. /* Define CARLA_DECLARE_NON_COPY_CLASS */
  137. #ifdef CARLA_PROPER_CPP11_SUPPORT
  138. # define CARLA_DECLARE_NON_COPY_CLASS(ClassName) \
  139. private: \
  140. ClassName(ClassName&) = delete; \
  141. ClassName(const ClassName&) = delete; \
  142. ClassName& operator=(ClassName&) = delete; \
  143. ClassName& operator=(const ClassName&) = delete;
  144. #else
  145. # define CARLA_DECLARE_NON_COPY_CLASS(ClassName) \
  146. private: \
  147. ClassName(ClassName&); \
  148. ClassName(const ClassName&); \
  149. ClassName& operator=(ClassName&); \
  150. ClassName& operator=(const ClassName&);
  151. #endif
  152. /* Define CARLA_DECLARE_NON_COPY_STRUCT */
  153. #ifdef CARLA_PROPER_CPP11_SUPPORT
  154. # define CARLA_DECLARE_NON_COPY_STRUCT(StructName) \
  155. StructName(StructName&) = delete; \
  156. StructName(const StructName&) = delete; \
  157. StructName& operator=(StructName&) = delete; \
  158. StructName& operator=(const StructName&) = delete;
  159. #else
  160. # define CARLA_DECLARE_NON_COPY_STRUCT(StructName)
  161. #endif
  162. /* Define CARLA_PREVENT_HEAP_ALLOCATION */
  163. #ifdef CARLA_PROPER_CPP11_SUPPORT
  164. # define CARLA_PREVENT_HEAP_ALLOCATION \
  165. private: \
  166. static void* operator new(size_t) = delete; \
  167. static void operator delete(void*) = delete;
  168. #else
  169. # define CARLA_PREVENT_HEAP_ALLOCATION \
  170. private: \
  171. static void* operator new(size_t); \
  172. static void operator delete(void*);
  173. #endif
  174. /* Define EXTERN_C */
  175. #ifdef __cplusplus
  176. # define EXTERN_C extern "C"
  177. #else
  178. # define EXTERN_C
  179. #endif
  180. /* Define CARLA_EXPORT */
  181. #ifdef BUILD_BRIDGE
  182. # define CARLA_EXPORT EXTERN_C
  183. #else
  184. # if defined(CARLA_OS_WIN) && ! defined(__WINE__)
  185. # define CARLA_EXPORT EXTERN_C __declspec (dllexport)
  186. # else
  187. # define CARLA_EXPORT EXTERN_C __attribute__ ((visibility("default")))
  188. # endif
  189. #endif
  190. /* Define PRE/POST_PACKED_STRUCTURE */
  191. #if defined(__GNUC__)
  192. # define PRE_PACKED_STRUCTURE
  193. # define POST_PACKED_STRUCTURE __attribute__((__packed__))
  194. #elif defined(_MSC_VER)
  195. # define PRE_PACKED_STRUCTURE1 __pragma(pack(push,1))
  196. # define PRE_PACKED_STRUCTURE PRE_PACKED_STRUCTURE1
  197. # define POST_PACKED_STRUCTURE ;__pragma(pack(pop))
  198. #else
  199. # define PRE_PACKED_STRUCTURE
  200. # define POST_PACKED_STRUCTURE
  201. #endif
  202. /* Define OS_SEP */
  203. #ifdef CARLA_OS_WIN
  204. # define OS_SEP '\\'
  205. # define OS_SEP_STR "\\"
  206. #else
  207. # define OS_SEP '/'
  208. # define OS_SEP_STR "/"
  209. #endif
  210. /* Useful typedefs */
  211. typedef unsigned char uchar;
  212. typedef unsigned long int ulong;
  213. typedef unsigned short int ushort;
  214. typedef unsigned int uint;
  215. #endif /* CARLA_DEFINES_HPP_INCLUDED */