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.

151 lines
4.0KB

  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 GPL.txt file
  16. */
  17. #ifndef __CARLA_DEFINES_HPP__
  18. #define __CARLA_DEFINES_HPP__
  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. # ifdef __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_SAFE_ASSERT*
  104. #define CARLA_SAFE_ASSERT(cond) ((!(cond)) ? carla_assert(#cond, __FILE__, __LINE__) : pass())
  105. #define CARLA_SAFE_ASSERT_INT(cond, value) ((!(cond)) ? carla_assert_int(#cond, __FILE__, __LINE__, value) : pass())
  106. #define CARLA_SAFE_ASSERT_INT2(cond, v1, v2) ((!(cond)) ? carla_assert_int2(#cond, __FILE__, __LINE__, v1, v2) : pass())
  107. // Define CARLA_ASSERT*
  108. #if defined(CARLA_NO_ASSERTS)
  109. # define CARLA_ASSERT(cond)
  110. # define CARLA_ASSERT_INT(cond, value)
  111. # define CARLA_ASSERT_INT2(cond, v1, v2)
  112. #elif defined(NDEBUG)
  113. # define CARLA_ASSERT CARLA_SAFE_ASSERT
  114. # define CARLA_ASSERT_INT CARLA_SAFE_ASSERT_INT
  115. # define CARLA_ASSERT_INT2 CARLA_SAFE_ASSERT_INT2
  116. #else
  117. # define CARLA_ASSERT(cond) assert(cond)
  118. # define CARLA_ASSERT_INT(cond, value) assert(cond)
  119. # define CARLA_ASSERT_INT2(cond, v1, v2) assert(cond)
  120. #endif
  121. // Define CARLA_EXPORT
  122. #ifdef BUILD_BRIDGE
  123. # define CARLA_EXPORT extern "C"
  124. #else
  125. # if defined(CARLA_OS_WIN) && ! defined(__WINE__)
  126. # define CARLA_EXPORT extern "C" __declspec (dllexport)
  127. # else
  128. # define CARLA_EXPORT extern "C" __attribute__ ((visibility("default")))
  129. # endif
  130. #endif
  131. // Define OS_SEP
  132. #ifdef CARLA_OS_WIN
  133. # define OS_SEP '\\'
  134. #else
  135. # define OS_SEP '/'
  136. #endif
  137. #endif // __CARLA_DEFINES_HPP__