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.

145 lines
3.7KB

  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(__APPLE__)
  21. # define CARLA_OS_MAC
  22. #elif defined(__HAIKU__)
  23. # define CARLA_OS_HAIKU
  24. #elif defined(__linux__) || defined(__linux)
  25. # define CARLA_OS_LINUX
  26. #elif defined(WIN64) || defined(_WIN64) || defined(__WIN64__)
  27. # define CARLA_OS_WIN64
  28. #elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
  29. # define CARLA_OS_WIN32
  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. # endif
  45. #endif
  46. #ifdef CARLA_PROPER_CPP11_SUPPORT
  47. # define IS_CPP11 1
  48. #else
  49. # define IS_CPP11 0
  50. # define noexcept
  51. # define nullptr (0)
  52. #endif
  53. // Common includes
  54. #ifdef CARLA_OS_WIN
  55. # include <winsock2.h>
  56. # include <windows.h>
  57. #else
  58. # include <unistd.h>
  59. # ifndef __cdecl
  60. # define __cdecl
  61. # endif
  62. #endif
  63. // Define various string format types
  64. #if defined(CARLA_OS_WIN64)
  65. # define P_INT64 "%I64i"
  66. # define P_INTPTR "%I64i"
  67. # define P_UINTPTR "%I64x"
  68. # define P_SIZE "%I64u"
  69. #elif defined(CARLA_OS_WIN32)
  70. # define P_INT64 "%I64i"
  71. # define P_INTPTR "%i"
  72. # define P_UINTPTR "%x"
  73. # define P_SIZE "%u"
  74. #elif __WORDSIZE == 64
  75. # define P_INT64 "%li"
  76. # define P_INTPTR "%li"
  77. # define P_UINTPTR "%lx"
  78. # define P_SIZE "%lu"
  79. #else
  80. # define P_INT64 "%lli"
  81. # define P_INTPTR "%i"
  82. # define P_UINTPTR "%x"
  83. # define P_SIZE "%u"
  84. #endif
  85. // Define BINARY_NATIVE
  86. #if defined(CARLA_OS_HAIKU) || defined(CARLA_OS_UNIX)
  87. # ifdef __LP64__
  88. # define BINARY_NATIVE BINARY_POSIX64
  89. # else
  90. # define BINARY_NATIVE BINARY_POSIX32
  91. # endif
  92. #elif defined(CARLA_OS_WIN)
  93. # ifdef CARLA_OS_WIN64
  94. # define BINARY_NATIVE BINARY_WIN64
  95. # else
  96. # define BINARY_NATIVE BINARY_WIN32
  97. # endif
  98. #else
  99. # warning Unknown binary native
  100. # define BINARY_NATIVE BINARY_OTHER
  101. #endif
  102. // Define CARLA_ASSERT*
  103. #define CARLA_SAFE_ASSERT(cond) ((!(cond)) ? carla_assert(#cond, __FILE__, __LINE__) : pass())
  104. #define CARLA_SAFE_ASSERT_INT(cond, value) ((!(cond)) ? carla_assert_int(#cond, __FILE__, __LINE__, value) : pass())
  105. #define CARLA_SAFE_ASSERT_INT2(cond, v1, v2) ((!(cond)) ? carla_assert_int2(#cond, __FILE__, __LINE__, v1, v2) : pass())
  106. #ifdef NDEBUG
  107. # define CARLA_ASSERT CARLA_SAFE_ASSERT
  108. # define CARLA_ASSERT_INT CARLA_SAFE_ASSERT_INT
  109. # define CARLA_ASSERT_INT2 CARLA_SAFE_ASSERT_INT2
  110. #else
  111. # define CARLA_ASSERT(cond) assert(cond)
  112. # define CARLA_ASSERT_INT(cond, value) assert(cond)
  113. # define CARLA_ASSERT_INT2(cond, v1, v2) assert(cond)
  114. #endif
  115. // Define CARLA_EXPORT
  116. #ifdef BUILD_BRIDGE
  117. # define CARLA_EXPORT extern "C"
  118. #else
  119. # if defined(CARLA_OS_WIN) && ! defined(__WINE__)
  120. # define CARLA_EXPORT extern "C" __declspec (dllexport)
  121. # else
  122. # define CARLA_EXPORT extern "C" __attribute__ ((visibility("default")))
  123. # endif
  124. #endif
  125. // Define OS_SEP
  126. #ifdef CARLA_OS_WIN
  127. # define OS_SEP '\\'
  128. #else
  129. # define OS_SEP '/'
  130. #endif
  131. #endif // __CARLA_DEFINES_HPP__