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.

135 lines
3.6KB

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