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.

107 lines
2.5KB

  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. #ifndef Q_COMPILER_LAMBDA
  29. # define nullptr (0)
  30. #endif
  31. #ifdef Q_OS_WIN
  32. # include <winsock2.h>
  33. # include <windows.h>
  34. # define carla_sleep(t) Sleep(t * 1000)
  35. # define carla_msleep(t) Sleep(t)
  36. # define carla_usleep(t) Sleep(t / 1000)
  37. # define carla_setenv(key, value) SetEnvironmentVariableA(key, value)
  38. #else
  39. # include <dlfcn.h>
  40. # include <unistd.h>
  41. # define carla_sleep(t) sleep(t)
  42. # define carla_msleep(t) usleep(t * 1000)
  43. # define carla_usleep(t) usleep(t)
  44. # define carla_setenv(key, value) setenv(key, value, 1)
  45. # ifndef __cdecl
  46. # define __cdecl
  47. # endif
  48. #endif
  49. // needed for qDebug/Warning/Critical sections (FIXME)
  50. #if __WORDSIZE == 64
  51. # define P_INT64 "%li"
  52. # define P_INTPTR "%li"
  53. # define P_UINTPTR "%llx"
  54. # define P_SIZE "%lu"
  55. #else
  56. # define P_INT64 "%lli"
  57. # define P_INTPTR "%i"
  58. # define P_UINTPTR "%x"
  59. # define P_SIZE "%u"
  60. #endif
  61. // set native binary type
  62. #if defined(Q_OS_UNIX)
  63. # if __LP64__
  64. # define BINARY_NATIVE BINARY_UNIX64
  65. # else
  66. # define BINARY_NATIVE BINARY_UNIX32
  67. # endif
  68. #elif defined(Q_OS_WIN)
  69. # ifdef Q_OS_WIN64
  70. # define BINARY_NATIVE BINARY_WIN64
  71. # else
  72. # define BINARY_NATIVE BINARY_WIN32
  73. # endif
  74. #else
  75. # warning Unknown binary type
  76. # define BINARY_NATIVE BINARY_NONE
  77. #endif
  78. // export symbols if needed
  79. #ifdef BUILD_BRIDGE
  80. # define CARLA_EXPORT
  81. #else
  82. # if defined(Q_OS_WIN) && ! defined(__WINE__)
  83. # define CARLA_EXPORT extern "C" __declspec (dllexport)
  84. # else
  85. # define CARLA_EXPORT extern "C" __attribute__ ((visibility("default")))
  86. # endif
  87. #endif
  88. static inline
  89. const char* bool2str(bool yesno)
  90. {
  91. return yesno ? "true" : "false";
  92. }
  93. static inline
  94. void pass(void) {}
  95. #endif // CARLA_INCLUDES_H