🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
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.

170 lines
4.7 KiB

  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /**
  19. * \file begin_code.h
  20. *
  21. * This file sets things up for C dynamic library function definitions,
  22. * static inlined functions, and structures aligned at 4-byte alignment.
  23. * If you don't like ugly C preprocessor code, don't look at this file. :)
  24. */
  25. /* This shouldn't be nested -- included it around code only. */
  26. #ifdef _begin_code_h
  27. #error Nested inclusion of begin_code.h
  28. #endif
  29. #define _begin_code_h
  30. #ifndef SDL_DEPRECATED
  31. # if (__GNUC__ >= 4) /* technically, this arrived in gcc 3.1, but oh well. */
  32. # define SDL_DEPRECATED __attribute__((deprecated))
  33. # else
  34. # define SDL_DEPRECATED
  35. # endif
  36. #endif
  37. #ifndef SDL_UNUSED
  38. # ifdef __GNUC__
  39. # define SDL_UNUSED __attribute__((unused))
  40. # else
  41. # define SDL_UNUSED
  42. # endif
  43. #endif
  44. /* Some compilers use a special export keyword */
  45. #ifndef DECLSPEC
  46. # if defined(__WIN32__) || defined(__WINRT__)
  47. # ifdef __BORLANDC__
  48. # ifdef BUILD_SDL
  49. # define DECLSPEC
  50. # else
  51. # define DECLSPEC __declspec(dllimport)
  52. # endif
  53. # else
  54. # define DECLSPEC __declspec(dllexport)
  55. # endif
  56. # elif defined(__OS2__)
  57. # ifdef BUILD_SDL
  58. # define DECLSPEC __declspec(dllexport)
  59. # else
  60. # define DECLSPEC
  61. # endif
  62. # else
  63. # if defined(__GNUC__) && __GNUC__ >= 4
  64. # define DECLSPEC __attribute__ ((visibility("default")))
  65. # else
  66. # define DECLSPEC
  67. # endif
  68. # endif
  69. #endif
  70. /* By default SDL uses the C calling convention */
  71. #ifndef SDLCALL
  72. #if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
  73. #define SDLCALL __cdecl
  74. #elif defined(__OS2__) || defined(__EMX__)
  75. #define SDLCALL _System
  76. # if defined (__GNUC__) && !defined(_System)
  77. # define _System /* for old EMX/GCC compat. */
  78. # endif
  79. #else
  80. #define SDLCALL
  81. #endif
  82. #endif /* SDLCALL */
  83. /* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */
  84. #ifdef __SYMBIAN32__
  85. #undef DECLSPEC
  86. #define DECLSPEC
  87. #endif /* __SYMBIAN32__ */
  88. /* Force structure packing at 4 byte alignment.
  89. This is necessary if the header is included in code which has structure
  90. packing set to an alternate value, say for loading structures from disk.
  91. The packing is reset to the previous value in close_code.h
  92. */
  93. #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
  94. #ifdef _MSC_VER
  95. #pragma warning(disable: 4103)
  96. #endif
  97. #ifdef __clang__
  98. #pragma clang diagnostic ignored "-Wpragma-pack"
  99. #endif
  100. #ifdef __BORLANDC__
  101. #pragma nopackwarning
  102. #endif
  103. #ifdef _M_X64
  104. /* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */
  105. #pragma pack(push,8)
  106. #else
  107. #pragma pack(push,4)
  108. #endif
  109. #endif /* Compiler needs structure packing set */
  110. #ifndef SDL_INLINE
  111. #if defined(__GNUC__)
  112. #define SDL_INLINE __inline__
  113. #elif defined(_MSC_VER) || defined(__BORLANDC__) || \
  114. defined(__DMC__) || defined(__SC__) || \
  115. defined(__WATCOMC__) || defined(__LCC__) || \
  116. defined(__DECC) || defined(__CC_ARM)
  117. #define SDL_INLINE __inline
  118. #ifndef __inline__
  119. #define __inline__ __inline
  120. #endif
  121. #else
  122. #define SDL_INLINE inline
  123. #ifndef __inline__
  124. #define __inline__ inline
  125. #endif
  126. #endif
  127. #endif /* SDL_INLINE not defined */
  128. #ifndef SDL_FORCE_INLINE
  129. #if defined(_MSC_VER)
  130. #define SDL_FORCE_INLINE __forceinline
  131. #elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
  132. #define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
  133. #else
  134. #define SDL_FORCE_INLINE static SDL_INLINE
  135. #endif
  136. #endif /* SDL_FORCE_INLINE not defined */
  137. #ifndef SDL_NORETURN
  138. #if defined(__GNUC__)
  139. #define SDL_NORETURN __attribute__((noreturn))
  140. #elif defined(_MSC_VER)
  141. #define SDL_NORETURN __declspec(noreturn)
  142. #else
  143. #define SDL_NORETURN
  144. #endif
  145. #endif /* SDL_NORETURN not defined */
  146. /* Apparently this is needed by several Windows compilers */
  147. #if !defined(__MACH__)
  148. #ifndef NULL
  149. #ifdef __cplusplus
  150. #define NULL 0
  151. #else
  152. #define NULL ((void *)0)
  153. #endif
  154. #endif /* NULL */
  155. #endif /* ! Mac OS X - breaks precompiled headers */