SDL_internal.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2022 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. #ifndef SDL_internal_h_
  19. #define SDL_internal_h_
  20. /* Many of SDL's features require _GNU_SOURCE on various platforms */
  21. #ifndef _GNU_SOURCE
  22. #define _GNU_SOURCE
  23. #endif
  24. /* Need this so Linux systems define fseek64o, ftell64o and off64_t */
  25. #ifndef _LARGEFILE64_SOURCE
  26. #define _LARGEFILE64_SOURCE
  27. #endif
  28. /* This is for a variable-length array at the end of a struct:
  29. struct x { int y; char z[SDL_VARIABLE_LENGTH_ARRAY]; };
  30. Use this because GCC 2 needs different magic than other compilers. */
  31. #if (defined(__GNUC__) && (__GNUC__ <= 2)) || defined(__CC_ARM) || defined(__cplusplus)
  32. #define SDL_VARIABLE_LENGTH_ARRAY 1
  33. #else
  34. #define SDL_VARIABLE_LENGTH_ARRAY
  35. #endif
  36. #define SDL_MAX_SMALL_ALLOC_STACKSIZE 128
  37. #define SDL_small_alloc(type, count, pisstack) ((*(pisstack) = ((sizeof(type) * (count)) < SDL_MAX_SMALL_ALLOC_STACKSIZE)), (*(pisstack) ? SDL_stack_alloc(type, count) : (type *)SDL_malloc(sizeof(type) * (count))))
  38. #define SDL_small_free(ptr, isstack) \
  39. if ((isstack)) { \
  40. SDL_stack_free(ptr); \
  41. } else { \
  42. SDL_free(ptr); \
  43. }
  44. #include "dynapi/SDL_dynapi.h"
  45. #if SDL_DYNAMIC_API
  46. #include "dynapi/SDL_dynapi_overrides.h"
  47. /* force DECLSPEC off...it's all internal symbols now.
  48. These will have actual #defines during SDL_dynapi.c only */
  49. #define DECLSPEC
  50. #endif
  51. #include "build_config/SDL_build_config.h"
  52. #ifdef __APPLE__
  53. #ifndef _DARWIN_C_SOURCE
  54. #define _DARWIN_C_SOURCE 1 /* for memset_pattern4() */
  55. #endif
  56. #endif
  57. #ifdef HAVE_SYS_TYPES_H
  58. #include <sys/types.h>
  59. #endif
  60. #ifdef HAVE_STDIO_H
  61. #include <stdio.h>
  62. #endif
  63. #if defined(HAVE_STDLIB_H)
  64. #include <stdlib.h>
  65. #elif defined(HAVE_MALLOC_H)
  66. #include <malloc.h>
  67. #endif
  68. #if defined(HAVE_STDDEF_H)
  69. #include <stddef.h>
  70. #endif
  71. #if defined(HAVE_STDARG_H)
  72. #include <stdarg.h>
  73. #endif
  74. #ifdef HAVE_STRING_H
  75. #ifdef HAVE_MEMORY_H
  76. #include <memory.h>
  77. #endif
  78. #include <string.h>
  79. #endif
  80. #ifdef HAVE_STRINGS_H
  81. #include <strings.h>
  82. #endif
  83. #ifdef HAVE_WCHAR_H
  84. #include <wchar.h>
  85. #endif
  86. #if defined(HAVE_INTTYPES_H)
  87. #include <inttypes.h>
  88. #elif defined(HAVE_STDINT_H)
  89. #include <stdint.h>
  90. #endif
  91. #ifdef HAVE_CTYPE_H
  92. #include <ctype.h>
  93. #endif
  94. #ifdef HAVE_MATH_H
  95. #include <math.h>
  96. #endif
  97. #ifdef HAVE_FLOAT_H
  98. #include <float.h>
  99. #endif
  100. /* If you run into a warning that O_CLOEXEC is redefined, update the SDL configuration header for your platform to add HAVE_O_CLOEXEC */
  101. #ifndef HAVE_O_CLOEXEC
  102. #define O_CLOEXEC 0
  103. #endif
  104. /* A few #defines to reduce SDL footprint.
  105. Only effective when library is statically linked.
  106. You have to manually edit this file. */
  107. #ifndef SDL_LEAN_AND_MEAN
  108. #define SDL_LEAN_AND_MEAN 0
  109. #endif
  110. /* Optimized functions from 'SDL_blit_0.c'
  111. - blit with source BitsPerPixel < 8, palette */
  112. #ifndef SDL_HAVE_BLIT_0
  113. #define SDL_HAVE_BLIT_0 !SDL_LEAN_AND_MEAN
  114. #endif
  115. /* Optimized functions from 'SDL_blit_1.c'
  116. - blit with source BytesPerPixel == 1, palette */
  117. #ifndef SDL_HAVE_BLIT_1
  118. #define SDL_HAVE_BLIT_1 !SDL_LEAN_AND_MEAN
  119. #endif
  120. /* Optimized functions from 'SDL_blit_A.c'
  121. - blit with 'SDL_BLENDMODE_BLEND' blending mode */
  122. #ifndef SDL_HAVE_BLIT_A
  123. #define SDL_HAVE_BLIT_A !SDL_LEAN_AND_MEAN
  124. #endif
  125. /* Optimized functions from 'SDL_blit_N.c'
  126. - blit with COLORKEY mode, or nothing */
  127. #ifndef SDL_HAVE_BLIT_N
  128. #define SDL_HAVE_BLIT_N !SDL_LEAN_AND_MEAN
  129. #endif
  130. /* Optimized functions from 'SDL_blit_N.c'
  131. - RGB565 conversion with Lookup tables */
  132. #ifndef SDL_HAVE_BLIT_N_RGB565
  133. #define SDL_HAVE_BLIT_N_RGB565 !SDL_LEAN_AND_MEAN
  134. #endif
  135. /* Optimized functions from 'SDL_blit_AUTO.c'
  136. - blit with modulate color, modulate alpha, any blending mode
  137. - scaling or not */
  138. #ifndef SDL_HAVE_BLIT_AUTO
  139. #define SDL_HAVE_BLIT_AUTO !SDL_LEAN_AND_MEAN
  140. #endif
  141. /* Run-Length-Encoding
  142. - SDL_SetColorKey() called with SDL_RLEACCEL flag */
  143. #ifndef SDL_HAVE_RLE
  144. #define SDL_HAVE_RLE !SDL_LEAN_AND_MEAN
  145. #endif
  146. /* Software SDL_Renderer
  147. - creation of software renderer
  148. - *not* general blitting functions
  149. - {blend,draw}{fillrect,line,point} internal functions */
  150. #ifndef SDL_VIDEO_RENDER_SW
  151. #define SDL_VIDEO_RENDER_SW !SDL_LEAN_AND_MEAN
  152. #endif
  153. /* YUV formats
  154. - handling of YUV surfaces
  155. - blitting and conversion functions */
  156. #ifndef SDL_HAVE_YUV
  157. #define SDL_HAVE_YUV !SDL_LEAN_AND_MEAN
  158. #endif
  159. #include <SDL3/SDL.h>
  160. /* The internal implementations of these functions have up to nanosecond precision.
  161. We can expose these functions as part of the API if we want to later.
  162. */
  163. /* Set up for C function definitions, even when using C++ */
  164. #ifdef __cplusplus
  165. extern "C" {
  166. #endif
  167. extern DECLSPEC int SDLCALL SDL_SemWaitTimeoutNS(SDL_sem *sem, Sint64 timeoutNS);
  168. extern DECLSPEC int SDLCALL SDL_CondWaitTimeoutNS(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS);
  169. extern DECLSPEC int SDLCALL SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS);
  170. /* Ends C function definitions when using C++ */
  171. #ifdef __cplusplus
  172. }
  173. #endif
  174. #endif /* SDL_internal_h_ */
  175. /* vi: set ts=4 sw=4 expandtab: */