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.

236 lines
7.6KB

  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. /* 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 0x01093
  32. #define CARLA_VERSION_STRING "1.9.3 (2.0-beta1)"
  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_HAIKU)
  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__) && defined(__GXX_EXPERIMENTAL_CXX0X__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 405) || __has_extension(cxx_noexcept)
  57. # define CARLA_PROPER_CPP11_SUPPORT
  58. # if (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 407) || ! __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 (0)
  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_INTPTR "%I64i"
  81. # define P_UINTPTR "%I64x"
  82. # define P_SIZE "%I64u"
  83. #elif defined(CARLA_OS_WIN32)
  84. # define P_INT64 "%I64i"
  85. # define P_INTPTR "%i"
  86. # define P_UINTPTR "%x"
  87. # define P_SIZE "%u"
  88. #elif defined(__WORDSIZE) && __WORDSIZE == 64
  89. # define P_INT64 "%li"
  90. # define P_INTPTR "%li"
  91. # define P_UINTPTR "%lx"
  92. # define P_SIZE "%lu"
  93. #else
  94. # define P_INT64 "%lli"
  95. # define P_INTPTR "%i"
  96. # define P_UINTPTR "%x"
  97. # define P_SIZE "%u"
  98. #endif
  99. /* Define BINARY_NATIVE */
  100. #if defined(CARLA_OS_HAIKU) || defined(CARLA_OS_UNIX)
  101. # if defined (__LP64__) || defined (_LP64)
  102. # define BINARY_NATIVE BINARY_POSIX64
  103. # else
  104. # define BINARY_NATIVE BINARY_POSIX32
  105. # endif
  106. #elif defined(CARLA_OS_WIN)
  107. # ifdef CARLA_OS_WIN64
  108. # define BINARY_NATIVE BINARY_WIN64
  109. # else
  110. # define BINARY_NATIVE BINARY_WIN32
  111. # endif
  112. #else
  113. # warning Unknown binary native
  114. # define BINARY_NATIVE BINARY_OTHER
  115. #endif
  116. /* Define CARLA_ASSERT* */
  117. #if defined(CARLA_NO_ASSERTS)
  118. # define CARLA_ASSERT(cond)
  119. # define CARLA_ASSERT_INT(cond, value)
  120. # define CARLA_ASSERT_INT2(cond, v1, v2)
  121. #elif defined(NDEBUG)
  122. # define CARLA_ASSERT CARLA_SAFE_ASSERT
  123. # define CARLA_ASSERT_INT CARLA_SAFE_ASSERT_INT
  124. # define CARLA_ASSERT_INT2 CARLA_SAFE_ASSERT_INT2
  125. #else
  126. # define CARLA_ASSERT(cond) assert(cond)
  127. # define CARLA_ASSERT_INT(cond, value) assert(cond)
  128. # define CARLA_ASSERT_INT2(cond, v1, v2) assert(cond)
  129. #endif
  130. /* Define CARLA_SAFE_ASSERT* */
  131. #define CARLA_SAFE_ASSERT(cond) if (! (cond)) carla_safe_assert (#cond, __FILE__, __LINE__);
  132. #define CARLA_SAFE_ASSERT_INT(cond, value) if (! (cond)) carla_safe_assert_int (#cond, __FILE__, __LINE__, static_cast<int>(value));
  133. #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));
  134. #define CARLA_SAFE_ASSERT_UINT(cond, value) if (! (cond)) carla_safe_assert_uint (#cond, __FILE__, __LINE__, static_cast<uint>(value));
  135. #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));
  136. #define CARLA_SAFE_ASSERT_BREAK(cond) if (! (cond)) { carla_safe_assert(#cond, __FILE__, __LINE__); break; }
  137. #define CARLA_SAFE_ASSERT_CONTINUE(cond) if (! (cond)) { carla_safe_assert(#cond, __FILE__, __LINE__); continue; }
  138. #define CARLA_SAFE_ASSERT_RETURN(cond, ret) if (! (cond)) { carla_safe_assert(#cond, __FILE__, __LINE__); return ret; }
  139. /* Define CARLA_SAFE_EXCEPTION */
  140. #define CARLA_SAFE_EXCEPTION(msg) catch(...) { carla_safe_exception(msg, __FILE__, __LINE__); }
  141. #define CARLA_SAFE_EXCEPTION_BREAK(msg) catch(...) { carla_safe_exception(msg, __FILE__, __LINE__); break; }
  142. #define CARLA_SAFE_EXCEPTION_CONTINUE(msg) catch(...) { carla_safe_exception(msg, __FILE__, __LINE__); continue; }
  143. #define CARLA_SAFE_EXCEPTION_RETURN(msg, ret) catch(...) { carla_safe_exception(msg, __FILE__, __LINE__); return ret; }
  144. /* Define CARLA_DECLARE_NON_COPY_CLASS */
  145. #ifdef CARLA_PROPER_CPP11_SUPPORT
  146. # define CARLA_DECLARE_NON_COPY_CLASS(ClassName) \
  147. private: \
  148. ClassName(ClassName&) = delete; \
  149. ClassName(const ClassName&) = delete; \
  150. ClassName& operator=(ClassName&) = delete; \
  151. ClassName& operator=(const ClassName&) = delete;
  152. #else
  153. # define CARLA_DECLARE_NON_COPY_CLASS(ClassName) \
  154. private: \
  155. ClassName(ClassName&); \
  156. ClassName(const ClassName&); \
  157. ClassName& operator=(ClassName&); \
  158. ClassName& operator=(const ClassName&);
  159. #endif
  160. /* Define CARLA_DECLARE_NON_COPY_STRUCT */
  161. #ifdef CARLA_PROPER_CPP11_SUPPORT
  162. # define CARLA_DECLARE_NON_COPY_STRUCT(StructName) \
  163. StructName(StructName&) = delete; \
  164. StructName(const StructName&) = delete; \
  165. StructName& operator=(StructName&) = delete; \
  166. StructName& operator=(const StructName&) = delete;
  167. #else
  168. # define CARLA_DECLARE_NON_COPY_STRUCT(StructName)
  169. #endif
  170. /* Define CARLA_PREVENT_HEAP_ALLOCATION */
  171. #ifdef CARLA_PROPER_CPP11_SUPPORT
  172. # define CARLA_PREVENT_HEAP_ALLOCATION \
  173. private: \
  174. static void* operator new(size_t) = delete; \
  175. static void operator delete(void*) = delete;
  176. #else
  177. # define CARLA_PREVENT_HEAP_ALLOCATION \
  178. private: \
  179. static void* operator new(size_t); \
  180. static void operator delete(void*);
  181. #endif
  182. /* Define EXTERN_C */
  183. #ifdef __cplusplus
  184. # define EXTERN_C extern "C"
  185. #else
  186. # define EXTERN_C
  187. #endif
  188. /* Define CARLA_EXPORT */
  189. #ifdef BUILD_BRIDGE
  190. # define CARLA_EXPORT EXTERN_C
  191. #else
  192. # if defined(CARLA_OS_WIN) && ! defined(__WINE__)
  193. # define CARLA_EXPORT EXTERN_C __declspec (dllexport)
  194. # else
  195. # define CARLA_EXPORT EXTERN_C __attribute__ ((visibility("default")))
  196. # endif
  197. #endif
  198. /* Define OS_SEP */
  199. #ifdef CARLA_OS_WIN
  200. # define OS_SEP '\\'
  201. # define OS_SEP_STR "\\"
  202. #else
  203. # define OS_SEP '/'
  204. # define OS_SEP_STR "/"
  205. #endif
  206. /* Useful typedefs */
  207. typedef unsigned char uchar;
  208. typedef unsigned long int ulong;
  209. typedef unsigned short int ushort;
  210. typedef unsigned int uint;
  211. #endif /* CARLA_DEFINES_HPP_INCLUDED */