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.

224 lines
6.6KB

  1. /*
  2. * Carla common defines
  3. * Copyright (C) 2011-2013 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 0x01090
  25. #define CARLA_VERSION_STRING "1.9.0"
  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__) && (__cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__))
  49. # if (__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. #ifndef CARLA_PROPER_CPP11_SUPPORT
  58. # define override
  59. # define final
  60. # define noexcept throw()
  61. # define nullptr (0)
  62. #endif
  63. // Common includes
  64. #ifdef CARLA_OS_WIN
  65. # include <winsock2.h>
  66. # include <windows.h>
  67. #else
  68. # include <unistd.h>
  69. # ifndef __cdecl
  70. # define __cdecl
  71. # endif
  72. #endif
  73. // Define various string format types
  74. #if defined(CARLA_OS_WIN64)
  75. # define P_INT64 "%I64i"
  76. # define P_INTPTR "%I64i"
  77. # define P_UINTPTR "%I64x"
  78. # define P_SIZE "%I64u"
  79. #elif defined(CARLA_OS_WIN32)
  80. # define P_INT64 "%I64i"
  81. # define P_INTPTR "%i"
  82. # define P_UINTPTR "%x"
  83. # define P_SIZE "%u"
  84. #elif __WORDSIZE == 64
  85. # define P_INT64 "%li"
  86. # define P_INTPTR "%li"
  87. # define P_UINTPTR "%lx"
  88. # define P_SIZE "%lu"
  89. #else
  90. # define P_INT64 "%lli"
  91. # define P_INTPTR "%i"
  92. # define P_UINTPTR "%x"
  93. # define P_SIZE "%u"
  94. #endif
  95. // Define BINARY_NATIVE
  96. #if defined(CARLA_OS_HAIKU) || defined(CARLA_OS_UNIX)
  97. # if defined (__LP64__) || defined (_LP64)
  98. # define BINARY_NATIVE BINARY_POSIX64
  99. # else
  100. # define BINARY_NATIVE BINARY_POSIX32
  101. # endif
  102. #elif defined(CARLA_OS_WIN)
  103. # ifdef CARLA_OS_WIN64
  104. # define BINARY_NATIVE BINARY_WIN64
  105. # else
  106. # define BINARY_NATIVE BINARY_WIN32
  107. # endif
  108. #else
  109. # warning Unknown binary native
  110. # define BINARY_NATIVE BINARY_OTHER
  111. #endif
  112. // Define CARLA_ASSERT*
  113. #if defined(CARLA_NO_ASSERTS)
  114. # define CARLA_ASSERT(cond)
  115. # define CARLA_ASSERT_INT(cond, value)
  116. # define CARLA_ASSERT_INT2(cond, v1, v2)
  117. #elif defined(NDEBUG)
  118. # define CARLA_ASSERT CARLA_SAFE_ASSERT
  119. # define CARLA_ASSERT_INT CARLA_SAFE_ASSERT_INT
  120. # define CARLA_ASSERT_INT2 CARLA_SAFE_ASSERT_INT2
  121. #else
  122. # define CARLA_ASSERT(cond) assert(cond)
  123. # define CARLA_ASSERT_INT(cond, value) assert(cond)
  124. # define CARLA_ASSERT_INT2(cond, v1, v2) assert(cond)
  125. #endif
  126. // Define CARLA_SAFE_ASSERT*
  127. #define CARLA_SAFE_ASSERT(cond) if (cond) pass(); else carla_assert (#cond, __FILE__, __LINE__);
  128. #define CARLA_SAFE_ASSERT_INT(cond, value) if (cond) pass(); else carla_assert_int (#cond, __FILE__, __LINE__, value);
  129. #define CARLA_SAFE_ASSERT_INT2(cond, v1, v2) if (cond) pass(); else carla_assert_int2(#cond, __FILE__, __LINE__, v1, v2);
  130. #define CARLA_SAFE_ASSERT_BREAK(cond) if (cond) pass(); else { carla_assert(#cond, __FILE__, __LINE__); break; }
  131. #define CARLA_SAFE_ASSERT_CONTINUE(cond) if (cond) pass(); else { carla_assert(#cond, __FILE__, __LINE__); continue; }
  132. #define CARLA_SAFE_ASSERT_RETURN(cond, ret) if (cond) pass(); else { carla_assert(#cond, __FILE__, __LINE__); return ret; }
  133. // Define CARLA_DECLARE_NON_COPY_CLASS
  134. #ifdef CARLA_PROPER_CPP11_SUPPORT
  135. # define CARLA_DECLARE_NON_COPY_CLASS(ClassName) \
  136. private: \
  137. ClassName(ClassName&) = delete; \
  138. ClassName(const ClassName&) = delete; \
  139. ClassName& operator=(ClassName&) = delete; \
  140. ClassName& operator=(const ClassName&) = delete;
  141. #else
  142. # define CARLA_DECLARE_NON_COPY_CLASS(ClassName) \
  143. private: \
  144. ClassName(ClassName&); \
  145. ClassName(const ClassName&); \
  146. ClassName& operator=(ClassName&); \
  147. ClassName& operator=(const ClassName&);
  148. #endif
  149. // Define CARLA_DECLARE_NON_COPY_STRUCT
  150. #ifdef CARLA_PROPER_CPP11_SUPPORT
  151. # define CARLA_DECLARE_NON_COPY_STRUCT(StructName) \
  152. StructName(StructName&) = delete; \
  153. StructName(const StructName&) = delete; \
  154. StructName& operator=(StructName&) = delete; \
  155. StructName& operator=(const StructName&) = delete;
  156. #else
  157. # define CARLA_DECLARE_NON_COPY_STRUCT(StructName)
  158. #endif
  159. #ifdef CARLA_PROPER_CPP11_SUPPORT
  160. # define CARLA_PREVENT_HEAP_ALLOCATION \
  161. private: \
  162. static void* operator new(size_t) = delete; \
  163. static void operator delete(void*) = delete;
  164. #else
  165. # define CARLA_PREVENT_HEAP_ALLOCATION \
  166. private: \
  167. static void* operator new(size_t); \
  168. static void operator delete(void*);
  169. #endif
  170. // Define CARLA_EXPORT
  171. #ifdef BUILD_BRIDGE
  172. # define CARLA_EXPORT extern "C"
  173. #else
  174. # if defined(CARLA_OS_WIN) && ! defined(__WINE__)
  175. # define CARLA_EXPORT extern "C" __declspec (dllexport)
  176. # else
  177. # define CARLA_EXPORT extern "C" __attribute__ ((visibility("default")))
  178. # endif
  179. #endif
  180. // Define PRE/POST_PACKED_STRUCTURE
  181. #if defined(__GNUC__)
  182. # define PRE_PACKED_STRUCTURE
  183. # define POST_PACKED_STRUCTURE __attribute__((__packed__))
  184. #elif defined(_MSC_VER)
  185. # define PRE_PACKED_STRUCTURE1 __pragma(pack(push,1))
  186. # define PRE_PACKED_STRUCTURE PRE_PACKED_STRUCTURE1
  187. # define POST_PACKED_STRUCTURE ;__pragma(pack(pop))
  188. #else
  189. # define PRE_PACKED_STRUCTURE
  190. # define POST_PACKED_STRUCTURE
  191. #endif
  192. // Define OS_SEP
  193. #ifdef CARLA_OS_WIN
  194. # define OS_SEP '\\'
  195. #else
  196. # define OS_SEP '/'
  197. #endif
  198. // Useful typedefs
  199. typedef unsigned long int ulong;
  200. typedef unsigned short int ushort;
  201. typedef unsigned int uint;
  202. #endif // CARLA_DEFINES_HPP_INCLUDED