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.

141 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. #ifdef CARLA_OS_WIN
  39. # define OS_SEP '\\'
  40. #else
  41. # define OS_SEP '/'
  42. #endif
  43. // Check for C++11 support
  44. #if defined(HAVE_CPP11_SUPPORT)
  45. # define CARLA_PROPER_CPP11_SUPPORT
  46. #elif defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__)
  47. # if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405
  48. # define CARLA_PROPER_CPP11_SUPPORT
  49. # endif
  50. #endif
  51. #ifndef CARLA_PROPER_CPP11_SUPPORT
  52. # define noexcept
  53. # define nullptr (0)
  54. #endif
  55. // Common includes
  56. #ifdef CARLA_OS_WIN
  57. # include <winsock2.h>
  58. # include <windows.h>
  59. #else
  60. # include <unistd.h>
  61. # ifndef __cdecl
  62. # define __cdecl
  63. # endif
  64. #endif
  65. // Define various string format types
  66. #if defined(CARLA_OS_WIN64)
  67. # define P_INT64 "%I64i"
  68. # define P_INTPTR "%I64i"
  69. # define P_UINTPTR "%I64x"
  70. # define P_SIZE "%I64u"
  71. #elif defined(CARLA_OS_WIN32)
  72. # define P_INT64 "%I64i"
  73. # define P_INTPTR "%i"
  74. # define P_UINTPTR "%x"
  75. # define P_SIZE "%u"
  76. #elif __WORDSIZE == 64
  77. # define P_INT64 "%li"
  78. # define P_INTPTR "%li"
  79. # define P_UINTPTR "%lx"
  80. # define P_SIZE "%lu"
  81. #else
  82. # define P_INT64 "%lli"
  83. # define P_INTPTR "%i"
  84. # define P_UINTPTR "%x"
  85. # define P_SIZE "%u"
  86. #endif
  87. // Define BINARY_NATIVE
  88. #if defined(CARLA_OS_HAIKU) || defined(CARLA_OS_UNIX)
  89. # ifdef __LP64__
  90. # define BINARY_NATIVE BINARY_POSIX64
  91. # else
  92. # define BINARY_NATIVE BINARY_POSIX32
  93. # endif
  94. #elif defined(CARLA_OS_WIN)
  95. # ifdef CARLA_OS_WIN64
  96. # define BINARY_NATIVE BINARY_WIN64
  97. # else
  98. # define BINARY_NATIVE BINARY_WIN32
  99. # endif
  100. #else
  101. # warning Unknown binary native
  102. # define BINARY_NATIVE BINARY_OTHER
  103. #endif
  104. // Define CARLA_ASSERT*
  105. #define CARLA_SAFE_ASSERT(cond) ((!(cond)) ? carla_assert(#cond, __FILE__, __LINE__) : pass())
  106. #define CARLA_SAFE_ASSERT_INT(cond, value) ((!(cond)) ? carla_assert_int(#cond, __FILE__, __LINE__, value) : pass())
  107. #define CARLA_SAFE_ASSERT_INT2(cond, v1, v2) ((!(cond)) ? carla_assert_int2(#cond, __FILE__, __LINE__, v1, v2) : pass())
  108. #ifdef 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_EXPORT
  118. #ifdef BUILD_BRIDGE
  119. # define CARLA_EXPORT extern "C"
  120. #else
  121. # if defined(CARLA_OS_WIN) && ! defined(__WINE__)
  122. # define CARLA_EXPORT extern "C" __declspec (dllexport)
  123. # else
  124. # define CARLA_EXPORT extern "C" __attribute__ ((visibility("default")))
  125. # endif
  126. #endif
  127. #endif // __CARLA_DEFINES_HPP__