Atlas - SDL_internal.h
Home / ext / SDL / src Lines: 1 | Size: 9757 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)][FILE BEGIN]1/* 2 Simple DirectMedia Layer 3 Copyright (C) 1997-2026 Sam Lantinga <[email protected]> 4 5 This software is provided 'as-is', without any express or implied 6 warranty. In no event will the authors be held liable for any damages 7 arising from the use of this software. 8 9 Permission is granted to anyone to use this software for any purpose, 10 including commercial applications, and to alter it and redistribute it 11 freely, subject to the following restrictions: 12 13 1. The origin of this software must not be misrepresented; you must not 14 claim that you wrote the original software. If you use this software 15 in a product, an acknowledgment in the product documentation would be 16 appreciated but is not required. 17 2. Altered source versions must be plainly marked as such, and must not be 18 misrepresented as being the original software. 19 3. This notice may not be removed or altered from any source distribution. 20*/ 21#ifndef SDL_internal_h_ 22#define SDL_internal_h_ 23 24// Many of SDL's features require _GNU_SOURCE on various platforms 25#ifndef _GNU_SOURCE 26#define _GNU_SOURCE 27#endif 28 29// Need this so Linux systems define fseek64o, ftell64o and off64_t 30#ifndef _LARGEFILE64_SOURCE 31#define _LARGEFILE64_SOURCE 1 32#endif 33 34/* This is for a variable-length array at the end of a struct: 35 struct x { int y; char z[SDL_VARIABLE_LENGTH_ARRAY]; }; 36 Use this because GCC 2 needs different magic than other compilers. */ 37#if (defined(__GNUC__) && (__GNUC__ <= 2)) || defined(__CC_ARM) || defined(__cplusplus) 38#define SDL_VARIABLE_LENGTH_ARRAY 1 39#else 40#define SDL_VARIABLE_LENGTH_ARRAY 41#endif 42 43#if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))) || defined(__clang__) 44#define HAVE_GCC_DIAGNOSTIC_PRAGMA 1 45#endif 46 47#ifdef _MSC_VER // We use constant comparison for generated code 48#pragma warning(disable : 6326) 49#endif 50 51#ifdef _MSC_VER // SDL_MAX_SMALL_ALLOC_STACKSIZE is smaller than _ALLOCA_S_THRESHOLD and should be generally safe 52#pragma warning(disable : 6255) 53#endif 54#define SDL_MAX_SMALL_ALLOC_STACKSIZE 128 55#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)))) 56#define SDL_small_free(ptr, isstack) \ 57 if ((isstack)) { \ 58 SDL_stack_free(ptr); \ 59 } else { \ 60 SDL_free(ptr); \ 61 } 62 63#include "SDL_build_config.h" 64 65#include "dynapi/SDL_dynapi.h" 66 67#if SDL_DYNAMIC_API 68#include "dynapi/SDL_dynapi_overrides.h" 69/* force SDL_DECLSPEC off...it's all internal symbols now. 70 These will have actual #defines during SDL_dynapi.c only */ 71#ifdef SDL_DECLSPEC 72#undef SDL_DECLSPEC 73#endif 74#define SDL_DECLSPEC 75#endif 76 77#ifdef SDL_PLATFORM_APPLE 78#ifndef _DARWIN_C_SOURCE 79#define _DARWIN_C_SOURCE 1 // for memset_pattern4() 80#endif 81#include <Availability.h> 82 83#ifndef __IPHONE_OS_VERSION_MAX_ALLOWED 84#define __IPHONE_OS_VERSION_MAX_ALLOWED 0 85#endif 86#ifndef __APPLETV_OS_VERSION_MAX_ALLOWED 87#define __APPLETV_OS_VERSION_MAX_ALLOWED 0 88#endif 89#ifndef __MAC_OS_X_VERSION_MAX_ALLOWED 90#define __MAC_OS_X_VERSION_MAX_ALLOWED 0 91#endif 92#endif // SDL_PLATFORM_APPLE 93 94#ifdef HAVE_SYS_TYPES_H 95#include <sys/types.h> 96#endif 97#ifdef HAVE_STDIO_H 98#include <stdio.h> 99#endif 100#ifdef HAVE_STDLIB_H 101#include <stdlib.h> 102#elif defined(HAVE_MALLOC_H) 103#include <malloc.h> 104#endif 105#ifdef HAVE_STDDEF_H 106#include <stddef.h> 107#endif 108#ifdef HAVE_STDARG_H 109#include <stdarg.h> 110#endif 111#ifdef HAVE_STRING_H 112#ifdef HAVE_MEMORY_H 113#include <memory.h> 114#endif 115#include <string.h> 116#endif 117#ifdef HAVE_STRINGS_H 118#include <strings.h> 119#endif 120#ifdef HAVE_WCHAR_H 121#include <wchar.h> 122#endif 123#ifdef HAVE_INTTYPES_H 124#include <inttypes.h> 125#elif defined(HAVE_STDINT_H) 126#include <stdint.h> 127#endif 128#ifdef HAVE_MATH_H 129#include <math.h> 130#endif 131#ifdef HAVE_FLOAT_H 132#include <float.h> 133#endif 134 135// If you run into a warning that O_CLOEXEC is redefined, update the SDL configuration header for your platform to add HAVE_O_CLOEXEC 136#ifndef HAVE_O_CLOEXEC 137#define O_CLOEXEC 0 138#endif 139 140/* A few #defines to reduce SDL footprint. 141 Only effective when library is statically linked. */ 142 143/* Optimized functions from 'SDL_blit_0.c' 144 - blit with source bits_per_pixel < 8, palette */ 145#if !defined(SDL_HAVE_BLIT_0) && !defined(SDL_LEAN_AND_MEAN) 146#define SDL_HAVE_BLIT_0 1 147#endif 148 149/* Optimized functions from 'SDL_blit_1.c' 150 - blit with source bytes_per_pixel == 1, palette */ 151#if !defined(SDL_HAVE_BLIT_1) && !defined(SDL_LEAN_AND_MEAN) 152#define SDL_HAVE_BLIT_1 1 153#endif 154 155/* Optimized functions from 'SDL_blit_A.c' 156 - blit with 'SDL_BLENDMODE_BLEND' blending mode */ 157#if !defined(SDL_HAVE_BLIT_A) && !defined(SDL_LEAN_AND_MEAN) 158#define SDL_HAVE_BLIT_A 1 159#endif 160 161/* Optimized functions from 'SDL_blit_N.c' 162 - blit with COLORKEY mode, or nothing */ 163#if !defined(SDL_HAVE_BLIT_N) && !defined(SDL_LEAN_AND_MEAN) 164#define SDL_HAVE_BLIT_N 1 165#endif 166 167/* Optimized functions from 'SDL_blit_N.c' 168 - RGB565 conversion with Lookup tables */ 169#if !defined(SDL_HAVE_BLIT_N_RGB565) && !defined(SDL_LEAN_AND_MEAN) 170#define SDL_HAVE_BLIT_N_RGB565 1 171#endif 172 173/* Optimized functions from 'SDL_blit_AUTO.c' 174 - blit with modulate color, modulate alpha, any blending mode 175 - scaling or not */ 176#if !defined(SDL_HAVE_BLIT_AUTO) && !defined(SDL_LEAN_AND_MEAN) 177#define SDL_HAVE_BLIT_AUTO 1 178#endif 179 180/* Run-Length-Encoding 181 - SDL_SetSurfaceColorKey() called with SDL_RLEACCEL flag */ 182#if !defined(SDL_HAVE_RLE) && !defined(SDL_LEAN_AND_MEAN) 183#define SDL_HAVE_RLE 1 184#endif 185 186/* Software SDL_Renderer 187 - creation of software renderer 188 - *not* general blitting functions 189 - {blend,draw}{fillrect,line,point} internal functions */ 190#if !defined(SDL_VIDEO_RENDER_SW) && !defined(SDL_LEAN_AND_MEAN) 191#define SDL_VIDEO_RENDER_SW 1 192#endif 193 194/* YUV formats 195 - handling of YUV surfaces 196 - blitting and conversion functions */ 197#if !defined(SDL_HAVE_YUV) && !defined(SDL_LEAN_AND_MEAN) 198#define SDL_HAVE_YUV 1 199#endif 200 201#ifdef SDL_CAMERA_DISABLED 202#undef SDL_CAMERA_DRIVER_ANDROID 203#undef SDL_CAMERA_DRIVER_COREMEDIA 204#undef SDL_CAMERA_DRIVER_DUMMY 205#undef SDL_CAMERA_DRIVER_EMSCRIPTEN 206#undef SDL_CAMERA_DRIVER_MEDIAFOUNDATION 207#undef SDL_CAMERA_DRIVER_PIPEWIRE 208#undef SDL_CAMERA_DRIVER_V4L2 209#undef SDL_CAMERA_DRIVER_VITA 210#endif 211 212#ifdef SDL_RENDER_DISABLED 213#undef SDL_VIDEO_RENDER_SW 214#undef SDL_VIDEO_RENDER_D3D 215#undef SDL_VIDEO_RENDER_D3D11 216#undef SDL_VIDEO_RENDER_D3D12 217#undef SDL_VIDEO_RENDER_GPU 218#undef SDL_VIDEO_RENDER_METAL 219#undef SDL_VIDEO_RENDER_OGL 220#undef SDL_VIDEO_RENDER_OGL_ES2 221#undef SDL_VIDEO_RENDER_PS2 222#undef SDL_VIDEO_RENDER_PSP 223#undef SDL_VIDEO_RENDER_VITA_GXM 224#undef SDL_VIDEO_RENDER_VULKAN 225#endif // SDL_RENDER_DISABLED 226 227#ifdef SDL_GPU_DISABLED 228#undef SDL_GPU_D3D12 229#undef SDL_GPU_METAL 230#undef SDL_GPU_VULKAN 231#undef HAVE_GPU_OPENXR 232#undef SDL_VIDEO_RENDER_GPU 233#endif // SDL_GPU_DISABLED 234 235#if !defined(HAVE_LIBC) 236// If not using _any_ C runtime, these have to be defined before SDL_thread.h 237// gets included, so internal SDL_CreateThread calls will not try to reference 238// the (unavailable and unneeded) _beginthreadex/_endthreadex functions. 239#define SDL_BeginThreadFunction NULL 240#define SDL_EndThreadFunction NULL 241#endif 242 243#ifdef SDL_NOLONGLONG 244#error We cannot build a valid SDL3 library without long long support 245#endif 246 247/* Enable internal definitions in SDL API headers */ 248#define SDL_INTERNAL 249 250#include <SDL3/SDL.h> 251#include <SDL3/SDL_intrin.h> 252 253#define SDL_MAIN_NOIMPL // don't drag in header-only implementation of SDL_main 254#include <SDL3/SDL_main.h> 255 256// Set up for C function definitions, even when using C++ 257#ifdef __cplusplus 258extern "C" { 259#endif 260 261#include "SDL_utils_c.h" 262#include "SDL_hashtable.h" 263 264 265/* SDL_ExitProcess is not declared in any public header, although 266 it is shared between some parts of SDL, because we don't want 267 anything calling it without an extremely good reason. */ 268extern SDL_NORETURN void SDL_ExitProcess(int exitcode); 269 270#ifdef HAVE_LIBC 271#define SDL_abort() abort() 272#else 273#define SDL_abort() do { \ 274 SDL_TriggerBreakpoint(); \ 275 SDL_ExitProcess(42); \ 276 } while (0) 277#endif 278 279#define PUSH_SDL_ERROR() \ 280 { char *_error = SDL_strdup(SDL_GetError()); 281 282#define POP_SDL_ERROR() \ 283 SDL_SetError("%s", _error); SDL_free(_error); } 284 285#if defined(SDL_DISABLE_INVALID_PARAMS) 286#ifdef DEBUG 287// If you define SDL_DISABLE_INVALID_PARAMS, you're promising that you'll 288// never pass an invalid parameter to SDL, since it may crash or lead to 289// hard to diagnose bugs. Let's assert that this is true in debug builds. 290#define OBJECT_VALIDATION_REQUIRED 291#define CHECK_PARAM(invalid) SDL_assert_always(!(invalid)); if (false) 292#else 293#define CHECK_PARAM(invalid) if (false) 294#endif 295#elif defined(SDL_ASSERT_INVALID_PARAMS) 296#define OBJECT_VALIDATION_REQUIRED 297#define CHECK_PARAM(invalid) SDL_assert_always(!(invalid)); if (invalid) 298#else 299#define CHECK_PARAM(invalid) if (invalid) 300#endif 301 302// Do any initialization that needs to happen before threads are started 303extern void SDL_InitMainThread(void); 304 305// Return true if this thread has initialized video 306extern bool SDL_IsVideoThread(void); 307 308/* The internal implementations of these functions have up to nanosecond precision. 309 We can expose these functions as part of the API if we want to later. 310*/ 311extern bool SDLCALL SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS); 312extern bool SDLCALL SDL_WaitConditionTimeoutNS(SDL_Condition *cond, SDL_Mutex *mutex, Sint64 timeoutNS); 313extern bool SDLCALL SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS); 314 315// Ends C function definitions when using C++ 316#ifdef __cplusplus 317} 318#endif 319 320#endif // SDL_internal_h_ 321[FILE END](C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.