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.

180 lines
5.1KB

  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. // Check OS
  20. #if defined(WIN64) || defined(_WIN64) || defined(__WIN64__)
  21. # define CARLA_OS_WIN64
  22. #elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
  23. # define CARLA_OS_WIN32
  24. #elif defined(__APPLE__)
  25. # define CARLA_OS_MAC
  26. #elif defined(__HAIKU__)
  27. # define CARLA_OS_HAIKU
  28. #elif defined(__linux__) || defined(__linux)
  29. # define CARLA_OS_LINUX
  30. #else
  31. # warning Unsupported platform!
  32. #endif
  33. #if defined(CARLA_OS_WIN32) || defined(CARLA_OS_WIN64)
  34. # define CARLA_OS_WIN
  35. #elif ! defined(CARLA_OS_HAIKU)
  36. # define CARLA_OS_UNIX
  37. #endif
  38. // Check for C++11 support
  39. #if defined(HAVE_CPP11_SUPPORT)
  40. # define CARLA_PROPER_CPP11_SUPPORT
  41. #elif defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__)
  42. # if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405
  43. # define CARLA_PROPER_CPP11_SUPPORT
  44. # if (__GNUC__ * 100 + __GNUC_MINOR__) < 407
  45. # define override // gcc4.7+ only
  46. # define final // gcc4.7+ only
  47. # endif
  48. # endif
  49. #endif
  50. #ifndef CARLA_PROPER_CPP11_SUPPORT
  51. # define override
  52. # define final
  53. # define noexcept
  54. # define nullptr (0)
  55. #endif
  56. // Common includes
  57. #ifdef CARLA_OS_WIN
  58. # include <winsock2.h>
  59. # include <windows.h>
  60. #else
  61. # include <unistd.h>
  62. # ifndef __cdecl
  63. # define __cdecl
  64. # endif
  65. #endif
  66. // Define various string format types
  67. #if defined(CARLA_OS_WIN64)
  68. # define P_INT64 "%I64i"
  69. # define P_INTPTR "%I64i"
  70. # define P_UINTPTR "%I64x"
  71. # define P_SIZE "%I64u"
  72. #elif defined(CARLA_OS_WIN32)
  73. # define P_INT64 "%I64i"
  74. # define P_INTPTR "%i"
  75. # define P_UINTPTR "%x"
  76. # define P_SIZE "%u"
  77. #elif __WORDSIZE == 64
  78. # define P_INT64 "%li"
  79. # define P_INTPTR "%li"
  80. # define P_UINTPTR "%lx"
  81. # define P_SIZE "%lu"
  82. #else
  83. # define P_INT64 "%lli"
  84. # define P_INTPTR "%i"
  85. # define P_UINTPTR "%x"
  86. # define P_SIZE "%u"
  87. #endif
  88. // Define BINARY_NATIVE
  89. #if defined(CARLA_OS_HAIKU) || defined(CARLA_OS_UNIX)
  90. # if defined (__LP64__) || defined (_LP64)
  91. # define BINARY_NATIVE BINARY_POSIX64
  92. # else
  93. # define BINARY_NATIVE BINARY_POSIX32
  94. # endif
  95. #elif defined(CARLA_OS_WIN)
  96. # ifdef CARLA_OS_WIN64
  97. # define BINARY_NATIVE BINARY_WIN64
  98. # else
  99. # define BINARY_NATIVE BINARY_WIN32
  100. # endif
  101. #else
  102. # warning Unknown binary native
  103. # define BINARY_NATIVE BINARY_OTHER
  104. #endif
  105. // Define CARLA_ASSERT*
  106. #if defined(CARLA_NO_ASSERTS)
  107. # define CARLA_ASSERT(cond)
  108. # define CARLA_ASSERT_INT(cond, value)
  109. # define CARLA_ASSERT_INT2(cond, v1, v2)
  110. #elif defined(NDEBUG)
  111. # define CARLA_ASSERT CARLA_SAFE_ASSERT
  112. # define CARLA_ASSERT_INT CARLA_SAFE_ASSERT_INT
  113. # define CARLA_ASSERT_INT2 CARLA_SAFE_ASSERT_INT2
  114. #else
  115. # define CARLA_ASSERT(cond) assert(cond)
  116. # define CARLA_ASSERT_INT(cond, value) assert(cond)
  117. # define CARLA_ASSERT_INT2(cond, v1, v2) assert(cond)
  118. #endif
  119. // Define CARLA_SAFE_ASSERT*
  120. #define CARLA_SAFE_ASSERT(cond) if (cond) pass(); else carla_assert (#cond, __FILE__, __LINE__);
  121. #define CARLA_SAFE_ASSERT_INT(cond, value) if (cond) pass(); else carla_assert_int (#cond, __FILE__, __LINE__, value);
  122. #define CARLA_SAFE_ASSERT_INT2(cond, v1, v2) if (cond) pass(); else carla_assert_int2(#cond, __FILE__, __LINE__, v1, v2);
  123. #define CARLA_SAFE_ASSERT_CONTINUE(cond) if (cond) pass(); else { carla_assert(#cond, __FILE__, __LINE__); continue; }
  124. #define CARLA_SAFE_ASSERT_RETURN(cond, ret) if (cond) pass(); else { carla_assert(#cond, __FILE__, __LINE__); return ret; }
  125. // Define CARLA_DECLARE_NON_COPY_STRUCT
  126. #ifdef CARLA_PROPER_CPP11_SUPPORT
  127. # define CARLA_DECLARE_NON_COPY_STRUCT(StructName) \
  128. StructName(StructName&) = delete; \
  129. StructName(const StructName&) = delete; \
  130. StructName& operator=(StructName&) = delete; \
  131. StructName& operator=(const StructName&) = delete;
  132. #else
  133. # define CARLA_DECLARE_NON_COPY_STRUCT(StructName)
  134. #endif
  135. // Define CARLA_EXPORT
  136. #ifdef BUILD_BRIDGE
  137. # define CARLA_EXPORT extern "C"
  138. #else
  139. # if defined(CARLA_OS_WIN) && ! defined(__WINE__)
  140. # define CARLA_EXPORT extern "C" __declspec (dllexport)
  141. # else
  142. # define CARLA_EXPORT extern "C" __attribute__ ((visibility("default")))
  143. # endif
  144. #endif
  145. // Define PRE/POST_PACKED_STRUCTURE
  146. #if defined(__GNUC__)
  147. # define PRE_PACKED_STRUCTURE
  148. # define POST_PACKED_STRUCTURE __attribute__((__packed__))
  149. #elif defined(_MSC_VER)
  150. # define PRE_PACKED_STRUCTURE1 __pragma(pack(push,1))
  151. # define PRE_PACKED_STRUCTURE PRE_PACKED_STRUCTURE1
  152. # define POST_PACKED_STRUCTURE ;__pragma(pack(pop))
  153. #else
  154. # define PRE_PACKED_STRUCTURE
  155. # define POST_PACKED_STRUCTURE
  156. #endif
  157. // Define OS_SEP
  158. #ifdef CARLA_OS_WIN
  159. # define OS_SEP '\\'
  160. #else
  161. # define OS_SEP '/'
  162. #endif
  163. #endif // CARLA_DEFINES_HPP_INCLUDED