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.

122 lines
2.9KB

  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. #include <QtCore/Qt>
  20. // TESTING - remove later
  21. #ifdef QTCREATOR_TEST
  22. # undef Q_COMPILER_INITIALIZER_LISTS
  23. #endif
  24. #ifndef Q_COMPILER_LAMBDA
  25. # define nullptr (0)
  26. #endif
  27. #ifdef Q_OS_WIN
  28. # include <winsock2.h>
  29. # include <windows.h>
  30. # define uintptr_t size_t // FIXME
  31. # define carla_sleep(t) Sleep(t * 1000)
  32. # define carla_msleep(t) Sleep(t)
  33. # define carla_usleep(t) Sleep(t / 1000)
  34. # define carla_setenv(key, value) SetEnvironmentVariableA(key, value)
  35. #else
  36. # include <dlfcn.h>
  37. # include <unistd.h>
  38. # define carla_sleep(t) sleep(t)
  39. # define carla_msleep(t) usleep(t * 1000)
  40. # define carla_usleep(t) usleep(t)
  41. # define carla_setenv(key, value) setenv(key, value, 1)
  42. # ifndef __cdecl
  43. # define __cdecl
  44. # endif
  45. #endif
  46. // needed for qDebug/Warning/Critical sections
  47. #if defined(Q_OS_WIN64) && ! defined(__WINE__)
  48. # define P_INTPTR "%I64i"
  49. # define P_UINTPTR "%I64x"
  50. # define P_SIZE "%I64u"
  51. #elif __WORDSIZE == 64
  52. # define P_INTPTR "%li"
  53. # define P_UINTPTR "%lx"
  54. # define P_SIZE "%lu"
  55. #else
  56. # define P_INTPTR "%i"
  57. # define P_UINTPTR "%x"
  58. # define P_SIZE "%u"
  59. #endif
  60. // set native binary type
  61. #if defined(Q_OS_HAIKU) || defined(Q_OS_UNIX)
  62. # ifdef __LP64__
  63. # define BINARY_NATIVE BINARY_POSIX64
  64. # else
  65. # define BINARY_NATIVE BINARY_POSIX32
  66. # endif
  67. #elif defined(Q_OS_WIN)
  68. # ifdef Q_OS_WIN64
  69. # define BINARY_NATIVE BINARY_WIN64
  70. # else
  71. # define BINARY_NATIVE BINARY_WIN32
  72. # endif
  73. #else
  74. # warning Unknown binary type
  75. # define BINARY_NATIVE BINARY_OTHER
  76. #endif
  77. // export symbols if needed
  78. #ifdef BUILD_BRIDGE
  79. # define CARLA_EXPORT extern "C"
  80. #else
  81. # if defined(Q_OS_WIN) && ! defined(__WINE__)
  82. # define CARLA_EXPORT extern "C" __declspec (dllexport)
  83. # else
  84. # define CARLA_EXPORT extern "C" __attribute__ ((visibility("default")))
  85. # endif
  86. #endif
  87. // carla_setprocname
  88. #ifdef Q_OS_LINUX
  89. # include <sys/prctl.h>
  90. # include <linux/prctl.h>
  91. static inline
  92. void carla_setprocname(const char* const name)
  93. {
  94. prctl(PR_SET_NAME, name);
  95. }
  96. #else
  97. static inline
  98. void carla_setprocname(const char* const /*name*/)
  99. {
  100. }
  101. #endif
  102. static inline
  103. const char* bool2str(bool yesno)
  104. {
  105. return yesno ? "true" : "false";
  106. }
  107. static inline
  108. void pass() {}
  109. #endif // CARLA_INCLUDES_H