Atlas - SDL_internal.h
Home / ext / SDL / src Lines: 1 | Size: 9783 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/* STB image conversion */ 195#if !defined(SDL_HAVE_STB) && !defined(SDL_LEAN_AND_MEAN) 196#define SDL_HAVE_STB 1 197#endif 198 199/* YUV formats 200 - handling of YUV surfaces 201 - blitting and conversion functions */ 202#if !defined(SDL_HAVE_YUV) && !defined(SDL_LEAN_AND_MEAN) 203#define SDL_HAVE_YUV 1 204#endif 205 206#ifdef SDL_CAMERA_DISABLED 207#undef SDL_CAMERA_DRIVER_ANDROID 208#undef SDL_CAMERA_DRIVER_COREMEDIA 209#undef SDL_CAMERA_DRIVER_DUMMY 210#undef SDL_CAMERA_DRIVER_EMSCRIPTEN 211#undef SDL_CAMERA_DRIVER_MEDIAFOUNDATION 212#undef SDL_CAMERA_DRIVER_PIPEWIRE 213#undef SDL_CAMERA_DRIVER_V4L2 214#undef SDL_CAMERA_DRIVER_VITA 215#endif 216 217#ifdef SDL_RENDER_DISABLED 218#undef SDL_VIDEO_RENDER_SW 219#undef SDL_VIDEO_RENDER_D3D 220#undef SDL_VIDEO_RENDER_D3D11 221#undef SDL_VIDEO_RENDER_D3D12 222#undef SDL_VIDEO_RENDER_GPU 223#undef SDL_VIDEO_RENDER_METAL 224#undef SDL_VIDEO_RENDER_OGL 225#undef SDL_VIDEO_RENDER_OGL_ES2 226#undef SDL_VIDEO_RENDER_PS2 227#undef SDL_VIDEO_RENDER_PSP 228#undef SDL_VIDEO_RENDER_VITA_GXM 229#undef SDL_VIDEO_RENDER_VULKAN 230#endif // SDL_RENDER_DISABLED 231 232#ifdef SDL_GPU_DISABLED 233#undef SDL_GPU_D3D12 234#undef SDL_GPU_METAL 235#undef SDL_GPU_VULKAN 236#undef HAVE_GPU_OPENXR 237#undef SDL_VIDEO_RENDER_GPU 238#endif // SDL_GPU_DISABLED 239 240#if !defined(HAVE_LIBC) 241// If not using _any_ C runtime, these have to be defined before SDL_thread.h 242// gets included, so internal SDL_CreateThread calls will not try to reference 243// the (unavailable and unneeded) _beginthreadex/_endthreadex functions. 244#define SDL_BeginThreadFunction NULL 245#define SDL_EndThreadFunction NULL 246#endif 247 248#ifdef SDL_NOLONGLONG 249#error We cannot build a valid SDL3 library without long long support 250#endif 251 252/* Enable internal definitions in SDL API headers */ 253#define SDL_INTERNAL 254 255#include <SDL3/SDL.h> 256#include <SDL3/SDL_intrin.h> 257 258#define SDL_MAIN_NOIMPL // don't drag in header-only implementation of SDL_main 259#include <SDL3/SDL_main.h> 260 261// Set up for C function definitions, even when using C++ 262#ifdef __cplusplus 263extern "C" { 264#endif 265 266#include "SDL_utils_c.h" 267#include "SDL_hashtable.h" 268 269 270/* SDL_ExitProcess is not declared in any public header, although 271 it is shared between some parts of SDL, because we don't want 272 anything calling it without an extremely good reason. */ 273extern SDL_NORETURN void SDL_ExitProcess(int exitcode); 274 275#ifdef HAVE_LIBC 276#define SDL_abort() abort() 277#else 278#define SDL_abort() do { \ 279 SDL_TriggerBreakpoint(); \ 280 SDL_ExitProcess(42); \ 281 } while (0) 282#endif 283 284#define PUSH_SDL_ERROR() \ 285 { char *_error = SDL_strdup(SDL_GetError()); 286 287#define POP_SDL_ERROR() \ 288 SDL_SetError("%s", _error); SDL_free(_error); } 289 290#if defined(SDL_DISABLE_INVALID_PARAMS) 291#ifdef DEBUG 292// If you define SDL_DISABLE_INVALID_PARAMS, you're promising that you'll 293// never pass an invalid parameter to SDL, since it may crash or lead to 294// hard to diagnose bugs. Let's assert that this is true in debug builds. 295#define OBJECT_VALIDATION_REQUIRED 296#define CHECK_PARAM(invalid) SDL_assert_always(!(invalid)); if (false) 297#else 298#define CHECK_PARAM(invalid) if (false) 299#endif 300#elif defined(SDL_ASSERT_INVALID_PARAMS) 301#define OBJECT_VALIDATION_REQUIRED 302#define CHECK_PARAM(invalid) SDL_assert_always(!(invalid)); if (invalid) 303#else 304#define CHECK_PARAM(invalid) if (invalid) 305#endif 306 307// Do any initialization that needs to happen before threads are started 308extern void SDL_InitMainThread(void); 309 310/* The internal implementations of these functions have up to nanosecond precision. 311 We can expose these functions as part of the API if we want to later. 312*/ 313extern bool SDLCALL SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS); 314extern bool SDLCALL SDL_WaitConditionTimeoutNS(SDL_Condition *cond, SDL_Mutex *mutex, Sint64 timeoutNS); 315extern bool SDLCALL SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS); 316 317// Ends C function definitions when using C++ 318#ifdef __cplusplus 319} 320#endif 321 322#endif // SDL_internal_h_ 323[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.