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.

240 lines
7.8KB

  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_H_INCLUDED
  18. #define CARLA_DEFINES_H_INCLUDED
  19. /* IDE Helper */
  20. #ifndef REAL_BUILD
  21. # include "config.h"
  22. #endif
  23. /* Compatibility with non-clang compilers */
  24. #ifndef __has_feature
  25. # define __has_feature(x) 0
  26. #endif
  27. #ifndef __has_extension
  28. # define __has_extension __has_feature
  29. #endif
  30. /* Set Version */
  31. #define CARLA_VERSION_HEX 0x01094
  32. #define CARLA_VERSION_STRING "1.9.4 (2.0-beta2)"
  33. /* Check OS */
  34. #if defined(WIN64) || defined(_WIN64) || defined(__WIN64__)
  35. # define CARLA_OS_WIN64
  36. #elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
  37. # define CARLA_OS_WIN32
  38. #elif defined(__APPLE__)
  39. # define CARLA_OS_MAC
  40. #elif defined(__HAIKU__)
  41. # define CARLA_OS_HAIKU
  42. #elif defined(__linux__) || defined(__linux)
  43. # define CARLA_OS_LINUX
  44. #else
  45. # warning Unsupported platform!
  46. #endif
  47. #if defined(CARLA_OS_WIN32) || defined(CARLA_OS_WIN64)
  48. # define CARLA_OS_WIN
  49. #elif defined(CARLA_OS_LINUX) || defined(CARLA_OS_MAC)
  50. # define CARLA_OS_UNIX
  51. #endif
  52. /* Check for C++11 support */
  53. #if defined(HAVE_CPP11_SUPPORT)
  54. # define CARLA_PROPER_CPP11_SUPPORT
  55. #elif defined(__cplusplus)
  56. # if __cplusplus >= 201103L || (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 && defined(__GXX_EXPERIMENTAL_CXX0X__)) || __has_extension(cxx_noexcept)
  57. # define CARLA_PROPER_CPP11_SUPPORT
  58. # if (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 407) || (defined(__CLANG__) && ! __has_extension(cxx_override_control))
  59. # define override // gcc4.7+ only
  60. # define final // gcc4.7+ only
  61. # endif
  62. # endif
  63. #endif
  64. #if defined(__cplusplus) && ! defined(CARLA_PROPER_CPP11_SUPPORT)
  65. # define noexcept throw()
  66. # define override
  67. # define final
  68. # define nullptr NULL
  69. #endif
  70. /* Common includes */
  71. #ifdef __cplusplus
  72. # include <cstddef>
  73. #else
  74. # include <stdbool.h>
  75. # include <stddef.h>
  76. #endif
  77. /* Define various string format types */
  78. #if defined(CARLA_OS_WIN64)
  79. # define P_INT64 "%I64i"
  80. # define P_UINT64 "%I64u"
  81. # define P_INTPTR "%I64i"
  82. # define P_UINTPTR "%I64x"
  83. # define P_SIZE "%I64u"
  84. #elif defined(CARLA_OS_WIN32)
  85. # define P_INT64 "%I64i"
  86. # define P_UINT64 "%I64u"
  87. # define P_INTPTR "%i"
  88. # define P_UINTPTR "%x"
  89. # define P_SIZE "%u"
  90. #elif defined(__WORDSIZE) && __WORDSIZE == 64
  91. # define P_INT64 "%li"
  92. # define P_UINT64 "%lu"
  93. # define P_INTPTR "%li"
  94. # define P_UINTPTR "%lx"
  95. # define P_SIZE "%lu"
  96. #else
  97. # define P_INT64 "%lli"
  98. # define P_UINT64 "%llu"
  99. # define P_INTPTR "%i"
  100. # define P_UINTPTR "%x"
  101. # define P_SIZE "%u"
  102. #endif
  103. /* Define BINARY_NATIVE */
  104. #if defined(CARLA_OS_HAIKU) || defined(CARLA_OS_UNIX)
  105. # if defined (__LP64__) || defined (_LP64)
  106. # define BINARY_NATIVE BINARY_POSIX64
  107. # else
  108. # define BINARY_NATIVE BINARY_POSIX32
  109. # endif
  110. #elif defined(CARLA_OS_WIN)
  111. # ifdef CARLA_OS_WIN64
  112. # define BINARY_NATIVE BINARY_WIN64
  113. # else
  114. # define BINARY_NATIVE BINARY_WIN32
  115. # endif
  116. #else
  117. # warning Unknown native binary type
  118. # define BINARY_NATIVE BINARY_OTHER
  119. #endif
  120. /* Define CARLA_ASSERT* */
  121. #if defined(CARLA_NO_ASSERTS)
  122. # define CARLA_ASSERT(cond)
  123. # define CARLA_ASSERT_INT(cond, value)
  124. # define CARLA_ASSERT_INT2(cond, v1, v2)
  125. #elif defined(NDEBUG)
  126. # define CARLA_ASSERT CARLA_SAFE_ASSERT
  127. # define CARLA_ASSERT_INT CARLA_SAFE_ASSERT_INT
  128. # define CARLA_ASSERT_INT2 CARLA_SAFE_ASSERT_INT2
  129. #else
  130. # define CARLA_ASSERT(cond) assert(cond)
  131. # define CARLA_ASSERT_INT(cond, value) assert(cond)
  132. # define CARLA_ASSERT_INT2(cond, v1, v2) assert(cond)
  133. #endif
  134. /* Define CARLA_SAFE_ASSERT* */
  135. #define CARLA_SAFE_ASSERT(cond) if (! (cond)) carla_safe_assert (#cond, __FILE__, __LINE__);
  136. #define CARLA_SAFE_ASSERT_INT(cond, value) if (! (cond)) carla_safe_assert_int (#cond, __FILE__, __LINE__, static_cast<int>(value));
  137. #define CARLA_SAFE_ASSERT_INT2(cond, v1, v2) if (! (cond)) carla_safe_assert_int2 (#cond, __FILE__, __LINE__, static_cast<int>(v1), static_cast<int>(v2));
  138. #define CARLA_SAFE_ASSERT_UINT(cond, value) if (! (cond)) carla_safe_assert_uint (#cond, __FILE__, __LINE__, static_cast<uint>(value));
  139. #define CARLA_SAFE_ASSERT_UINT2(cond, v1, v2) if (! (cond)) carla_safe_assert_uint2(#cond, __FILE__, __LINE__, static_cast<uint>(v1), static_cast<uint>(v2));
  140. #define CARLA_SAFE_ASSERT_BREAK(cond) if (! (cond)) { carla_safe_assert(#cond, __FILE__, __LINE__); break; }
  141. #define CARLA_SAFE_ASSERT_CONTINUE(cond) if (! (cond)) { carla_safe_assert(#cond, __FILE__, __LINE__); continue; }
  142. #define CARLA_SAFE_ASSERT_RETURN(cond, ret) if (! (cond)) { carla_safe_assert(#cond, __FILE__, __LINE__); return ret; }
  143. /* Define CARLA_SAFE_EXCEPTION */
  144. #define CARLA_SAFE_EXCEPTION(msg) catch(...) { carla_safe_exception(msg, __FILE__, __LINE__); }
  145. #define CARLA_SAFE_EXCEPTION_BREAK(msg) catch(...) { carla_safe_exception(msg, __FILE__, __LINE__); break; }
  146. #define CARLA_SAFE_EXCEPTION_CONTINUE(msg) catch(...) { carla_safe_exception(msg, __FILE__, __LINE__); continue; }
  147. #define CARLA_SAFE_EXCEPTION_RETURN(msg, ret) catch(...) { carla_safe_exception(msg, __FILE__, __LINE__); return ret; }
  148. /* Define CARLA_DECLARE_NON_COPY_CLASS */
  149. #ifdef CARLA_PROPER_CPP11_SUPPORT
  150. # define CARLA_DECLARE_NON_COPY_CLASS(ClassName) \
  151. private: \
  152. ClassName(ClassName&) = delete; \
  153. ClassName(const ClassName&) = delete; \
  154. ClassName& operator=(ClassName&) = delete; \
  155. ClassName& operator=(const ClassName&) = delete;
  156. #else
  157. # define CARLA_DECLARE_NON_COPY_CLASS(ClassName) \
  158. private: \
  159. ClassName(ClassName&); \
  160. ClassName(const ClassName&); \
  161. ClassName& operator=(ClassName&); \
  162. ClassName& operator=(const ClassName&);
  163. #endif
  164. /* Define CARLA_DECLARE_NON_COPY_STRUCT */
  165. #ifdef CARLA_PROPER_CPP11_SUPPORT
  166. # define CARLA_DECLARE_NON_COPY_STRUCT(StructName) \
  167. StructName(StructName&) = delete; \
  168. StructName(const StructName&) = delete; \
  169. StructName& operator=(StructName&) = delete; \
  170. StructName& operator=(const StructName&) = delete;
  171. #else
  172. # define CARLA_DECLARE_NON_COPY_STRUCT(StructName)
  173. #endif
  174. /* Define CARLA_PREVENT_HEAP_ALLOCATION */
  175. #ifdef CARLA_PROPER_CPP11_SUPPORT
  176. # define CARLA_PREVENT_HEAP_ALLOCATION \
  177. private: \
  178. static void* operator new(size_t) = delete; \
  179. static void operator delete(void*) = delete;
  180. #else
  181. # define CARLA_PREVENT_HEAP_ALLOCATION \
  182. private: \
  183. static void* operator new(size_t); \
  184. static void operator delete(void*);
  185. #endif
  186. /* Define EXTERN_C */
  187. #ifdef __cplusplus
  188. # define EXTERN_C extern "C"
  189. #else
  190. # define EXTERN_C
  191. #endif
  192. /* Define CARLA_EXPORT */
  193. #ifdef BUILD_BRIDGE
  194. # define CARLA_EXPORT EXTERN_C
  195. #else
  196. # if defined(CARLA_OS_WIN) && ! defined(__WINE__)
  197. # define CARLA_EXPORT EXTERN_C __declspec (dllexport)
  198. # else
  199. # define CARLA_EXPORT EXTERN_C __attribute__ ((visibility("default")))
  200. # endif
  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_H_INCLUDED */