Collection of tools useful for audio production
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.

114 lines
2.7KB

  1. /*
  2. * Carla common includes
  3. * Copyright (C) 2011-2012 Filipe Coelho <falktx@gmail.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * 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 COPYING file
  16. */
  17. #ifndef CARLA_INCLUDES_H
  18. #define CARLA_INCLUDES_H
  19. #ifdef __WINE__
  20. //# define __socklen_t_defined
  21. //# define __WINE_WINSOCK2__
  22. //# define HRESULT LONG
  23. # define Q_CORE_EXPORT
  24. # define Q_GUI_EXPORT
  25. # define QT_NO_STL
  26. #endif
  27. #include <QtCore/Qt>
  28. // TESTING - remove later
  29. #ifdef QTCREATOR_TEST
  30. #undef Q_COMPILER_INITIALIZER_LISTS
  31. #endif
  32. #ifndef Q_COMPILER_LAMBDA
  33. # define nullptr (0)
  34. #endif
  35. #ifdef Q_OS_WIN
  36. # include <winsock2.h>
  37. # include <windows.h>
  38. # define carla_sleep(t) Sleep(t * 1000)
  39. # define carla_msleep(t) Sleep(t)
  40. # define carla_usleep(t) Sleep(t / 1000)
  41. # define carla_setenv(key, value) SetEnvironmentVariableA(key, value)
  42. #else
  43. # include <dlfcn.h>
  44. # include <unistd.h>
  45. # define carla_sleep(t) sleep(t)
  46. # define carla_msleep(t) usleep(t * 1000)
  47. # define carla_usleep(t) usleep(t)
  48. # define carla_setenv(key, value) setenv(key, value, 1)
  49. # ifndef __cdecl
  50. # define __cdecl
  51. # endif
  52. #endif
  53. // needed for qDebug/Warning/Critical sections
  54. #if defined(Q_OS_WIN64) && ! defined(__WINE__)
  55. # define P_INTPTR "%I64i"
  56. # define P_UINTPTR "%I64x"
  57. # define P_SIZE "%I64u"
  58. #elif __WORDSIZE == 64
  59. # define P_INTPTR "%li"
  60. # define P_UINTPTR "%lx"
  61. # define P_SIZE "%lu"
  62. #else
  63. # define P_INTPTR "%i"
  64. # define P_UINTPTR "%x"
  65. # define P_SIZE "%u"
  66. #endif
  67. // set native binary type
  68. #if defined(Q_OS_HAIKU) || defined(Q_OS_UNIX)
  69. # ifdef __LP64__
  70. # define BINARY_NATIVE BINARY_POSIX64
  71. # else
  72. # define BINARY_NATIVE BINARY_POSIX32
  73. # endif
  74. #elif defined(Q_OS_WIN)
  75. # ifdef Q_OS_WIN64
  76. # define BINARY_NATIVE BINARY_WIN64
  77. # else
  78. # define BINARY_NATIVE BINARY_WIN32
  79. # endif
  80. #else
  81. # warning Unknown binary type
  82. # define BINARY_NATIVE BINARY_OTHER
  83. #endif
  84. // export symbols if needed
  85. #ifdef BUILD_BRIDGE
  86. # define CARLA_EXPORT
  87. #else
  88. # if defined(Q_OS_WIN) && ! defined(__WINE__)
  89. # define CARLA_EXPORT extern "C" __declspec (dllexport)
  90. # else
  91. # define CARLA_EXPORT extern "C" __attribute__ ((visibility("default")))
  92. # endif
  93. #endif
  94. static inline
  95. const char* bool2str(bool yesno)
  96. {
  97. return yesno ? "true" : "false";
  98. }
  99. static inline
  100. void pass() {}
  101. #endif // CARLA_INCLUDES_H