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.hpp 5.0KB

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