Remove SDL_config.h from the public headers

The SDL headers are no longer dependent on the build configuration.

Fixes https://github.com/libsdl-org/SDL/issues/6643 and https://github.com/libsdl-org/SDL/issues/6641
This commit is contained in:
Sam Lantinga
2022-11-26 01:41:46 -08:00
parent bc5677db95
commit 63f307fe1f
176 changed files with 448 additions and 712 deletions

View File

@@ -36,9 +36,6 @@
#ifndef WS_OVERLAPPEDWINDOW
#define WS_OVERLAPPEDWINDOW 0
#endif
#else /* fprintf, etc. */
#include <stdio.h>
#include <stdlib.h>
#endif
#if defined(__EMSCRIPTEN__)

View File

@@ -18,6 +18,7 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "./SDL_internal.h"
#ifndef SDL_assert_c_h_
#define SDL_assert_c_h_

View File

@@ -48,7 +48,59 @@
#define DECLSPEC
#endif
#include "SDL_config.h"
#include "build_config/SDL_build_config.h"
#ifdef __APPLE__
#ifndef _DARWIN_C_SOURCE
#define _DARWIN_C_SOURCE 1 /* for memset_pattern4() */
#endif
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
#if defined(HAVE_STDLIB_H)
# include <stdlib.h>
#elif defined(HAVE_MALLOC_H)
# include <malloc.h>
#endif
#if defined(HAVE_STDDEF_H)
# include <stddef.h>
#endif
#if defined(HAVE_STDARG_H)
# include <stdarg.h>
#endif
#ifdef HAVE_STRING_H
# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
# include <memory.h>
# endif
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#ifdef HAVE_WCHAR_H
# include <wchar.h>
#endif
#if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
#elif defined(HAVE_STDINT_H)
# include <stdint.h>
#endif
#ifdef HAVE_CTYPE_H
# include <ctype.h>
#endif
#ifdef HAVE_MATH_H
# include <math.h>
#endif
#ifdef HAVE_FLOAT_H
# include <float.h>
#endif
#include "SDL_stdinc.h"
/* If you run into a warning that O_CLOEXEC is redefined, update the SDL configuration header for your platform to add HAVE_O_CLOEXEC */
#ifndef HAVE_O_CLOEXEC

View File

@@ -18,6 +18,7 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "./SDL_internal.h"
#ifndef SDL_utils_h_
#define SDL_utils_h_

View File

@@ -18,7 +18,7 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#include "../../SDL_internal.h"
#ifndef SDL_winrtapp_common_h_
#define SDL_winrtapp_common_h_

View File

@@ -18,7 +18,7 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#include "../../SDL_internal.h"
#ifndef SDL_winrtapp_xaml_h_
#define SDL_winrtapp_xaml_h_

View File

@@ -18,9 +18,7 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifdef TEST_MAIN
#include "SDL_config.h"
#else
#ifndef TEST_MAIN
#include "../SDL_internal.h"
#endif

View File

@@ -19,11 +19,15 @@
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#include "build_config/SDL_build_config.h"
#include "SDL_dynapi.h"
#if SDL_DYNAMIC_API
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
#include "SDL.h"
/* These headers have system specific definitions, so aren't included above */

View File

@@ -892,3 +892,4 @@
#define SDL_EGL_SetEGLAttributeCallbacks SDL_EGL_SetEGLAttributeCallbacks_REAL
#define SDL_GDKSuspendComplete SDL_GDKSuspendComplete_REAL
#define SDL_GetWindowWMInfo SDL_GetWindowWMInfo_REAL
#define SDL_memset4 SDL_memset4_REAL

View File

@@ -968,3 +968,4 @@ SDL_DYNAPI_PROC(void,SDL_EGL_SetEGLAttributeCallbacks,(SDL_EGLAttribArrayCallbac
SDL_DYNAPI_PROC(void,SDL_GDKSuspendComplete,(void),(),return)
#endif
SDL_DYNAPI_PROC(int,SDL_GetWindowWMInfo,(SDL_Window *a, SDL_SysWMinfo *b, Uint32 c),(a,b,c),return)
SDL_DYNAPI_PROC(void*,SDL_memset4,(void *a, Uint32 b, size_t c),(a,b,c),return)

View File

@@ -31,7 +31,7 @@
#include "SDL_events.h"
#include "SDL_events_c.h"
#if defined(HAVE_SIGNAL_H) || defined(HAVE_SIGACTION)
#if defined(HAVE_SIGNAL_H) && defined(HAVE_SIGACTION)
#define HAVE_SIGNAL_SUPPORT 1
#endif

View File

@@ -1,12 +1,30 @@
#include "SDL_config.h"
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#ifdef SDL_HAPTIC_ANDROID
extern int Android_AddHaptic(int device_id, const char *name);
extern int Android_RemoveHaptic(int device_id);
#endif /* SDL_HAPTIC_ANDROID */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -18,7 +18,7 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#include "../SDL_internal.h"
/* This is the system specific header for the SDL locale API */

View File

@@ -18,7 +18,6 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
/* Include this so we define UNICODE properly */
#include "../../core/windows/SDL_windows.h"

View File

@@ -2,7 +2,7 @@
SDL_ps2_main.c, fjtrujy@gmail.com
*/
#include "SDL_config.h"
#include "SDL_platform.h"
#ifdef __PS2__
@@ -12,6 +12,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <kernel.h>
#include <sifrpc.h>

View File

@@ -1,7 +1,7 @@
/*
SDL_psp_main.c, placed in the public domain by Sam Lantinga 3/13/14
*/
#include "SDL_config.h"
#include "SDL_platform.h"
#ifdef __PSP__

View File

@@ -3,7 +3,7 @@
The WinMain function -- calls your program's main() function
*/
#include "SDL_config.h"
#include "SDL_platform.h"
#ifdef __WIN32__

View File

@@ -18,12 +18,11 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../SDL_internal.h"
#ifndef SDL_sensor_c_h_
#define SDL_sensor_c_h_
#include "SDL_config.h"
struct _SDL_SensorDriver;
/* Useful functions and variables from SDL_sensor.c */

View File

@@ -18,12 +18,11 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../SDL_internal.h"
#ifndef SDL_syssensor_c_h_
#define SDL_syssensor_c_h_
#include "SDL_config.h"
/* This is the system specific header for the SDL sensor API */
#include "SDL_sensor.h"

View File

@@ -20,8 +20,6 @@
*/
#include "../../SDL_internal.h"
#include "SDL_config.h"
#ifdef SDL_SENSOR_ANDROID
/* This is the system specific header for the SDL sensor API */

View File

@@ -18,7 +18,7 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#include "../../SDL_internal.h"
/* The private structure used to keep track of a sensor */
struct sensor_hwdata

View File

@@ -18,7 +18,7 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#include "../../SDL_internal.h"
/* The private structure used to keep track of a sensor */
struct sensor_hwdata

View File

@@ -18,8 +18,7 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#include "../../SDL_internal.h"
#ifdef SDL_SENSOR_COREMOTION

View File

@@ -20,8 +20,6 @@
*/
#include "../../SDL_internal.h"
#include "SDL_config.h"
#if defined(SDL_SENSOR_DUMMY) || defined(SDL_SENSOR_DISABLED)
#include "SDL_error.h"

View File

@@ -18,6 +18,6 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#include "../../SDL_internal.h"
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -18,8 +18,7 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#include "../../SDL_internal.h"
#if defined(SDL_SENSOR_VITA)

View File

@@ -18,7 +18,7 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#include "../../SDL_internal.h"
/* The private structure used to keep track of a sensor */
struct sensor_hwdata

View File

@@ -20,8 +20,6 @@
*/
#include "../../SDL_internal.h"
#include "SDL_config.h"
#if defined(SDL_SENSOR_WINDOWS)
#include "SDL_error.h"

View File

@@ -18,6 +18,6 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#include "../../SDL_internal.h"
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -637,6 +637,39 @@ SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len)
#endif /* HAVE_MEMSET */
}
/* Note that memset() is a byte assignment and this is a 32-bit assignment, so they're not directly equivalent. */
void *
SDL_memset4(void *dst, Uint32 val, size_t dwords)
{
#ifdef __APPLE__
memset_pattern4(dst, &val, dwords * 4);
#elif defined(__GNUC__) && defined(__i386__)
int u0, u1, u2;
__asm__ __volatile__ (
"cld \n\t"
"rep ; stosl \n\t"
: "=&D" (u0), "=&a" (u1), "=&c" (u2)
: "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, dwords))
: "memory"
);
#else
size_t _n = (dwords + 3) / 4;
Uint32 *_p = SDL_static_cast(Uint32 *, dst);
Uint32 _val = (val);
if (dwords == 0) {
return dst;
}
switch (dwords % 4) {
case 0: do { *_p++ = _val; SDL_FALLTHROUGH;
case 3: *_p++ = _val; SDL_FALLTHROUGH;
case 2: *_p++ = _val; SDL_FALLTHROUGH;
case 1: *_p++ = _val;
} while ( --_n );
}
#endif
return dst;
}
#if defined(HAVE_CTYPE_H) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
int SDL_isblank(int x) { return isblank(x); }
#else

View File

@@ -26,7 +26,6 @@
/* This file contains portable string manipulation functions for SDL */
#include "SDL_stdinc.h"
#include "SDL_vacopy.h"
#if defined(__vita__)

View File

@@ -24,9 +24,6 @@
Used by the test framework and test cases.
*/
#include "SDL_config.h"
#include "SDL_test.h"
/* Assert check message format */

View File

@@ -20,12 +20,8 @@
*/
/* Ported from original test/common.c file. */
#include "SDL_config.h"
#include "SDL_test.h"
#include <stdio.h>
static const char *video_usage[] = {
"[--video driver]", "[--renderer driver]", "[--gldebug]",
"[--info all|video|modes|render|event|event_motion]",

View File

@@ -26,9 +26,6 @@
Rewritten for test lib by Andreas Schiffler.
*/
#include "SDL_config.h"
#include "SDL_test.h"

View File

@@ -25,9 +25,6 @@
Original source code contributed by A. Schiffler for GSOC project.
*/
#include "SDL_config.h"
#include "SDL_test.h"

View File

@@ -18,8 +18,6 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#include "SDL_test.h"
/* ---- 8x8 font definition ---- */

View File

@@ -24,27 +24,11 @@
Data generators for fuzzing test data in a reproducible way.
*/
#include "SDL_config.h"
#include <limits.h>
/* Visual Studio 2008 doesn't have stdint.h */
#if defined(_MSC_VER) && _MSC_VER <= 1500
#define UINT8_MAX _UI8_MAX
#define UINT16_MAX _UI16_MAX
#define UINT32_MAX _UI32_MAX
#define INT64_MIN _I64_MIN
#define INT64_MAX _I64_MAX
#define UINT64_MAX _UI64_MAX
#else
#include <stdint.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <float.h>
#include "SDL_test.h"
#include <float.h> /* Needed for FLT_MAX and DBL_EPSILON */
#include <limits.h> /* Needed for UCHAR_MAX, etc. */
/**
* Counter for fuzzer invocations
*/

View File

@@ -18,15 +18,9 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#include "SDL_test.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <stdlib.h> /* Needed for exit() */
/* Invalid test name/description message format */
#define SDLTEST_INVALID_NAME_FORMAT "(Invalid)"

View File

@@ -18,8 +18,6 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#include "SDL_test.h"
/* GIMP RGB C-Source image dump (blit.c) */

View File

@@ -18,8 +18,6 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#include "SDL_test.h"
/* GIMP RGB C-Source image dump (alpha.c) */

View File

@@ -18,8 +18,6 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#include "SDL_test.h"
/* GIMP RGBA C-Source image dump (face.c) */

View File

@@ -18,8 +18,6 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#include "SDL_test.h"
/* GIMP RGB C-Source image dump (primitives.c) */

View File

@@ -18,8 +18,6 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#include "SDL_test.h"
/* GIMP RGB C-Source image dump (alpha.c) */

View File

@@ -29,18 +29,11 @@
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
# define _CRT_SECURE_NO_WARNINGS
#endif
#include "SDL_config.h"
#include <stdarg.h> /* va_list */
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "SDL.h"
#include "SDL_test.h"
#include <time.h> /* Needed for localtime() */
/* work around compiler warning on older GCCs. */
#if (defined(__GNUC__) && (__GNUC__ <= 2))
static size_t

View File

@@ -50,9 +50,6 @@
** documentation and/or software. **
***********************************************************************
*/
#include "SDL_config.h"
#include "SDL_test.h"
/* Forward declaration of static helper function */

View File

@@ -18,7 +18,6 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#include "SDL_assert.h"
#include "SDL_stdinc.h"
#include "SDL_log.h"

View File

@@ -27,15 +27,11 @@
Original source code contributed by A. Schiffler for GSOC project.
*/
#include "SDL_config.h"
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include "SDL_test.h"
#include <stdlib.h> /* Needed for srand() and rand() */
#include <time.h> /* Needed for time() */
/* Initialize random number generator with two integer variables */
void SDLTest_RandomInit(SDLTest_RandomContext * rndContext, unsigned int xi, unsigned int ci)

View File

@@ -18,7 +18,7 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#include "../../SDL_internal.h"
#include <mutex>

View File

@@ -18,7 +18,7 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#include "../../SDL_internal.h"
/* For a thread handle, use a void pointer to a std::thread */
typedef void * SYS_ThreadHandle;

View File

@@ -18,7 +18,7 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#include "../../SDL_internal.h"
extern "C" {
#include "../SDL_sysvideo.h"

View File

@@ -18,7 +18,7 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#include "../../SDL_internal.h"
#ifndef SDL_winrtgamebar_h_
#define SDL_winrtgamebar_h_

View File

@@ -18,7 +18,7 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#include "../../SDL_internal.h"
#ifndef SDL_winrtmouse_h_
#define SDL_winrtmouse_h_

View File

@@ -18,7 +18,7 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#include "../../SDL_internal.h"
#ifndef SDL_winrtopengles_h_
#define SDL_winrtopengles_h_