Use #ifdef/#ifndef instead of #if defined/#if \!defined

This commit is contained in:
Anonymous Maarten
2023-03-30 20:26:31 +02:00
committed by Anonymous Maarten
parent 308bcbbe76
commit b6ae281e97
129 changed files with 450 additions and 450 deletions

View File

@@ -24,7 +24,7 @@
#include "../core/windows/SDL_windows.h"
#endif
#if defined(__ANDROID__)
#ifdef __ANDROID__
#include "../core/android/SDL_android.h"
#endif
@@ -36,7 +36,7 @@ static size_t SDL_envmemlen = 0;
/* Put a variable into the environment */
/* Note: Name may not contain a '=' character. (Reference: http://www.unix.com/man-page/Linux/3/setenv/) */
#if defined(HAVE_SETENV)
#ifdef HAVE_SETENV
int SDL_setenv(const char *name, const char *value, int overwrite)
{
/* Input validation */
@@ -160,11 +160,11 @@ int SDL_setenv(const char *name, const char *value, int overwrite)
#endif
/* Retrieve a variable named "name" from the environment */
#if defined(HAVE_GETENV)
#ifdef HAVE_GETENV
char *
SDL_getenv(const char *name)
{
#if defined(__ANDROID__)
#ifdef __ANDROID__
/* Make sure variables from the application manifest are available */
Android_JNI_GetManifestEnvironmentVariables();
#endif

View File

@@ -26,7 +26,7 @@
/* These are some C runtime intrinsics that need to be defined */
#if defined(_MSC_VER)
#ifdef _MSC_VER
#ifndef __FLTUSED__
#define __FLTUSED__
@@ -42,7 +42,7 @@ extern void *memcpy(void *dst, const void *src, size_t len);
#pragma intrinsic(memcpy)
#endif
#if !defined(__clang__)
#ifndef __clang__
#pragma function(memcpy)
#endif
/* NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) */
@@ -57,7 +57,7 @@ extern void *memset(void *dst, int c, size_t len);
#pragma intrinsic(memset)
#endif
#if !defined(__clang__)
#ifndef __clang__
#pragma function(memset)
#endif
/* NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) */
@@ -700,7 +700,7 @@ RETZERO:
#endif /* MSC_VER */
#if defined(__ICL)
#ifdef __ICL
/* The classic Intel compiler generates calls to _intel_fast_memcpy
* and _intel_fast_memset when building an optimized SDL library */
void *_intel_fast_memcpy(void *dst, const void *src, size_t len)

View File

@@ -21,7 +21,7 @@
#include "SDL_internal.h"
#if defined(HAVE_QSORT)
#ifdef HAVE_QSORT
void
SDL_qsort(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *))
{
@@ -531,7 +531,7 @@ extern void qsortG(void *base, size_t nmemb, size_t size,
void *
SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compare)(const void *, const void *))
{
#if defined(HAVE_BSEARCH)
#ifdef HAVE_BSEARCH
return bsearch(key, base, nmemb, size, compare);
#else
/* SDL's replacement: Taken from the Public Domain C Library (PDCLib):

View File

@@ -27,7 +27,7 @@
double
SDL_atan(double x)
{
#if defined(HAVE_ATAN)
#ifdef HAVE_ATAN
return atan(x);
#else
return SDL_uclibc_atan(x);
@@ -36,7 +36,7 @@ SDL_atan(double x)
float SDL_atanf(float x)
{
#if defined(HAVE_ATANF)
#ifdef HAVE_ATANF
return atanf(x);
#else
return (float)SDL_atan((double)x);
@@ -46,7 +46,7 @@ float SDL_atanf(float x)
double
SDL_atan2(double y, double x)
{
#if defined(HAVE_ATAN2)
#ifdef HAVE_ATAN2
return atan2(y, x);
#else
return SDL_uclibc_atan2(y, x);
@@ -55,7 +55,7 @@ SDL_atan2(double y, double x)
float SDL_atan2f(float y, float x)
{
#if defined(HAVE_ATAN2F)
#ifdef HAVE_ATAN2F
return atan2f(y, x);
#else
return (float)SDL_atan2((double)y, (double)x);
@@ -65,7 +65,7 @@ float SDL_atan2f(float y, float x)
double
SDL_acos(double val)
{
#if defined(HAVE_ACOS)
#ifdef HAVE_ACOS
return acos(val);
#else
double result;
@@ -83,7 +83,7 @@ SDL_acos(double val)
float SDL_acosf(float val)
{
#if defined(HAVE_ACOSF)
#ifdef HAVE_ACOSF
return acosf(val);
#else
return (float)SDL_acos((double)val);
@@ -93,7 +93,7 @@ float SDL_acosf(float val)
double
SDL_asin(double val)
{
#if defined(HAVE_ASIN)
#ifdef HAVE_ASIN
return asin(val);
#else
double result;
@@ -108,7 +108,7 @@ SDL_asin(double val)
float SDL_asinf(float val)
{
#if defined(HAVE_ASINF)
#ifdef HAVE_ASINF
return asinf(val);
#else
return (float)SDL_asin((double)val);
@@ -118,7 +118,7 @@ float SDL_asinf(float val)
double
SDL_ceil(double x)
{
#if defined(HAVE_CEIL)
#ifdef HAVE_CEIL
return ceil(x);
#else
double integer = SDL_floor(x);
@@ -132,7 +132,7 @@ SDL_ceil(double x)
float SDL_ceilf(float x)
{
#if defined(HAVE_CEILF)
#ifdef HAVE_CEILF
return ceilf(x);
#else
return (float)SDL_ceil((double)x);
@@ -142,7 +142,7 @@ float SDL_ceilf(float x)
double
SDL_copysign(double x, double y)
{
#if defined(HAVE_COPYSIGN)
#ifdef HAVE_COPYSIGN
return copysign(x, y);
#elif defined(HAVE__COPYSIGN)
return _copysign(x, y);
@@ -159,7 +159,7 @@ SDL_copysign(double x, double y)
float SDL_copysignf(float x, float y)
{
#if defined(HAVE_COPYSIGNF)
#ifdef HAVE_COPYSIGNF
return copysignf(x, y);
#else
return (float)SDL_copysign((double)x, (double)y);
@@ -169,7 +169,7 @@ float SDL_copysignf(float x, float y)
double
SDL_cos(double x)
{
#if defined(HAVE_COS)
#ifdef HAVE_COS
return cos(x);
#else
return SDL_uclibc_cos(x);
@@ -178,7 +178,7 @@ SDL_cos(double x)
float SDL_cosf(float x)
{
#if defined(HAVE_COSF)
#ifdef HAVE_COSF
return cosf(x);
#else
return (float)SDL_cos((double)x);
@@ -188,7 +188,7 @@ float SDL_cosf(float x)
double
SDL_exp(double x)
{
#if defined(HAVE_EXP)
#ifdef HAVE_EXP
return exp(x);
#else
return SDL_uclibc_exp(x);
@@ -197,7 +197,7 @@ SDL_exp(double x)
float SDL_expf(float x)
{
#if defined(HAVE_EXPF)
#ifdef HAVE_EXPF
return expf(x);
#else
return (float)SDL_exp((double)x);
@@ -207,7 +207,7 @@ float SDL_expf(float x)
double
SDL_fabs(double x)
{
#if defined(HAVE_FABS)
#ifdef HAVE_FABS
return fabs(x);
#else
return SDL_uclibc_fabs(x);
@@ -216,7 +216,7 @@ SDL_fabs(double x)
float SDL_fabsf(float x)
{
#if defined(HAVE_FABSF)
#ifdef HAVE_FABSF
return fabsf(x);
#else
return (float)SDL_fabs((double)x);
@@ -226,7 +226,7 @@ float SDL_fabsf(float x)
double
SDL_floor(double x)
{
#if defined(HAVE_FLOOR)
#ifdef HAVE_FLOOR
return floor(x);
#else
return SDL_uclibc_floor(x);
@@ -235,7 +235,7 @@ SDL_floor(double x)
float SDL_floorf(float x)
{
#if defined(HAVE_FLOORF)
#ifdef HAVE_FLOORF
return floorf(x);
#else
return (float)SDL_floor((double)x);
@@ -245,7 +245,7 @@ float SDL_floorf(float x)
double
SDL_trunc(double x)
{
#if defined(HAVE_TRUNC)
#ifdef HAVE_TRUNC
return trunc(x);
#else
if (x >= 0.0f) {
@@ -258,7 +258,7 @@ SDL_trunc(double x)
float SDL_truncf(float x)
{
#if defined(HAVE_TRUNCF)
#ifdef HAVE_TRUNCF
return truncf(x);
#else
return (float)SDL_trunc((double)x);
@@ -268,7 +268,7 @@ float SDL_truncf(float x)
double
SDL_fmod(double x, double y)
{
#if defined(HAVE_FMOD)
#ifdef HAVE_FMOD
return fmod(x, y);
#else
return SDL_uclibc_fmod(x, y);
@@ -277,7 +277,7 @@ SDL_fmod(double x, double y)
float SDL_fmodf(float x, float y)
{
#if defined(HAVE_FMODF)
#ifdef HAVE_FMODF
return fmodf(x, y);
#else
return (float)SDL_fmod((double)x, (double)y);
@@ -287,7 +287,7 @@ float SDL_fmodf(float x, float y)
double
SDL_log(double x)
{
#if defined(HAVE_LOG)
#ifdef HAVE_LOG
return log(x);
#else
return SDL_uclibc_log(x);
@@ -296,7 +296,7 @@ SDL_log(double x)
float SDL_logf(float x)
{
#if defined(HAVE_LOGF)
#ifdef HAVE_LOGF
return logf(x);
#else
return (float)SDL_log((double)x);
@@ -306,7 +306,7 @@ float SDL_logf(float x)
double
SDL_log10(double x)
{
#if defined(HAVE_LOG10)
#ifdef HAVE_LOG10
return log10(x);
#else
return SDL_uclibc_log10(x);
@@ -315,7 +315,7 @@ SDL_log10(double x)
float SDL_log10f(float x)
{
#if defined(HAVE_LOG10F)
#ifdef HAVE_LOG10F
return log10f(x);
#else
return (float)SDL_log10((double)x);
@@ -325,7 +325,7 @@ float SDL_log10f(float x)
double
SDL_modf(double x, double *y)
{
#if defined(HAVE_MODF)
#ifdef HAVE_MODF
return modf(x, y);
#else
return SDL_uclibc_modf(x, y);
@@ -334,7 +334,7 @@ SDL_modf(double x, double *y)
float SDL_modff(float x, float *y)
{
#if defined(HAVE_MODFF)
#ifdef HAVE_MODFF
return modff(x, y);
#else
double double_result, double_y;
@@ -347,7 +347,7 @@ float SDL_modff(float x, float *y)
double
SDL_pow(double x, double y)
{
#if defined(HAVE_POW)
#ifdef HAVE_POW
return pow(x, y);
#else
return SDL_uclibc_pow(x, y);
@@ -356,7 +356,7 @@ SDL_pow(double x, double y)
float SDL_powf(float x, float y)
{
#if defined(HAVE_POWF)
#ifdef HAVE_POWF
return powf(x, y);
#else
return (float)SDL_pow((double)x, (double)y);
@@ -407,7 +407,7 @@ long SDL_lroundf(float arg)
double
SDL_scalbn(double x, int n)
{
#if defined(HAVE_SCALBN)
#ifdef HAVE_SCALBN
return scalbn(x, n);
#elif defined(HAVE__SCALB)
return _scalb(x, n);
@@ -422,7 +422,7 @@ SDL_scalbn(double x, int n)
float SDL_scalbnf(float x, int n)
{
#if defined(HAVE_SCALBNF)
#ifdef HAVE_SCALBNF
return scalbnf(x, n);
#else
return (float)SDL_scalbn((double)x, n);
@@ -432,7 +432,7 @@ float SDL_scalbnf(float x, int n)
double
SDL_sin(double x)
{
#if defined(HAVE_SIN)
#ifdef HAVE_SIN
return sin(x);
#else
return SDL_uclibc_sin(x);
@@ -441,7 +441,7 @@ SDL_sin(double x)
float SDL_sinf(float x)
{
#if defined(HAVE_SINF)
#ifdef HAVE_SINF
return sinf(x);
#else
return (float)SDL_sin((double)x);
@@ -451,7 +451,7 @@ float SDL_sinf(float x)
double
SDL_sqrt(double x)
{
#if defined(HAVE_SQRT)
#ifdef HAVE_SQRT
return sqrt(x);
#else
return SDL_uclibc_sqrt(x);
@@ -460,7 +460,7 @@ SDL_sqrt(double x)
float SDL_sqrtf(float x)
{
#if defined(HAVE_SQRTF)
#ifdef HAVE_SQRTF
return sqrtf(x);
#else
return (float)SDL_sqrt((double)x);
@@ -470,7 +470,7 @@ float SDL_sqrtf(float x)
double
SDL_tan(double x)
{
#if defined(HAVE_TAN)
#ifdef HAVE_TAN
return tan(x);
#else
return SDL_uclibc_tan(x);
@@ -479,7 +479,7 @@ SDL_tan(double x)
float SDL_tanf(float x)
{
#if defined(HAVE_TANF)
#ifdef HAVE_TANF
return tanf(x);
#else
return (float)SDL_tan((double)x);
@@ -488,14 +488,14 @@ float SDL_tanf(float x)
int SDL_abs(int x)
{
#if defined(HAVE_ABS)
#ifdef HAVE_ABS
return abs(x);
#else
return (x < 0) ? -x : x;
#endif
}
#if defined(HAVE_CTYPE_H)
#ifdef HAVE_CTYPE_H
int SDL_isalpha(int x)
{
return isalpha(x);
@@ -589,7 +589,7 @@ SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src,
void *
SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len)
{
#if defined(HAVE_MEMSET)
#ifdef HAVE_MEMSET
return memset(dst, c, len);
#else
size_t left;

View File

@@ -24,7 +24,7 @@
#include "SDL_vacopy.h"
#if defined(__vita__)
#ifdef __vita__
#include <psp2/kernel/clib.h>
#endif
@@ -290,7 +290,7 @@ SDL_ScanFloat(const char *text, double *valuep)
void *
SDL_memmove(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
{
#if defined(HAVE_MEMMOVE)
#ifdef HAVE_MEMMOVE
return memmove(dst, src, len);
#else
char *srcp = (char *)src;
@@ -313,7 +313,7 @@ SDL_memmove(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src,
int SDL_memcmp(const void *s1, const void *s2, size_t len)
{
#if defined(__vita__)
#ifdef __vita__
/*
Using memcmp on NULL is UB per POSIX / C99 7.21.1/2.
But, both linux and bsd allow that, with an exception:
@@ -343,7 +343,7 @@ int SDL_memcmp(const void *s1, const void *s2, size_t len)
size_t
SDL_strlen(const char *string)
{
#if defined(HAVE_STRLEN)
#ifdef HAVE_STRLEN
return strlen(string);
#else
size_t len = 0;
@@ -357,7 +357,7 @@ SDL_strlen(const char *string)
size_t
SDL_wcslen(const wchar_t *string)
{
#if defined(HAVE_WCSLEN)
#ifdef HAVE_WCSLEN
return wcslen(string);
#else
size_t len = 0;
@@ -371,7 +371,7 @@ SDL_wcslen(const wchar_t *string)
size_t
SDL_wcslcpy(SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen)
{
#if defined(HAVE_WCSLCPY)
#ifdef HAVE_WCSLCPY
return wcslcpy(dst, src, maxlen);
#else
size_t srclen = SDL_wcslen(src);
@@ -387,7 +387,7 @@ SDL_wcslcpy(SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxle
size_t
SDL_wcslcat(SDL_INOUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen)
{
#if defined(HAVE_WCSLCAT)
#ifdef HAVE_WCSLCAT
return wcslcat(dst, src, maxlen);
#else
size_t dstlen = SDL_wcslen(dst);
@@ -413,7 +413,7 @@ SDL_wcsdup(const wchar_t *string)
wchar_t *
SDL_wcsstr(const wchar_t *haystack, const wchar_t *needle)
{
#if defined(HAVE_WCSSTR)
#ifdef HAVE_WCSSTR
return SDL_const_cast(wchar_t *, wcsstr(haystack, needle));
#else
size_t length = SDL_wcslen(needle);
@@ -429,7 +429,7 @@ SDL_wcsstr(const wchar_t *haystack, const wchar_t *needle)
int SDL_wcscmp(const wchar_t *str1, const wchar_t *str2)
{
#if defined(HAVE_WCSCMP)
#ifdef HAVE_WCSCMP
return wcscmp(str1, str2);
#else
while (*str1 && *str2) {
@@ -445,7 +445,7 @@ int SDL_wcscmp(const wchar_t *str1, const wchar_t *str2)
int SDL_wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen)
{
#if defined(HAVE_WCSNCMP)
#ifdef HAVE_WCSNCMP
return wcsncmp(str1, str2, maxlen);
#else
while (*str1 && *str2 && maxlen) {
@@ -466,7 +466,7 @@ int SDL_wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen)
int SDL_wcscasecmp(const wchar_t *str1, const wchar_t *str2)
{
#if defined(HAVE_WCSCASECMP)
#ifdef HAVE_WCSCASECMP
return wcscasecmp(str1, str2);
#elif defined(HAVE__WCSICMP)
return _wcsicmp(str1, str2);
@@ -503,7 +503,7 @@ int SDL_wcscasecmp(const wchar_t *str1, const wchar_t *str2)
int SDL_wcsncasecmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen)
{
#if defined(HAVE_WCSNCASECMP)
#ifdef HAVE_WCSNCASECMP
return wcsncasecmp(str1, str2, maxlen);
#elif defined(HAVE__WCSNICMP)
return _wcsnicmp(str1, str2, maxlen);
@@ -546,7 +546,7 @@ int SDL_wcsncasecmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen)
size_t
SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
{
#if defined(HAVE_STRLCPY)
#ifdef HAVE_STRLCPY
return strlcpy(dst, src, maxlen);
#else
size_t srclen = SDL_strlen(src);
@@ -628,7 +628,7 @@ SDL_utf8strnlen(const char *str, size_t bytes)
size_t
SDL_strlcat(SDL_INOUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
{
#if defined(HAVE_STRLCAT)
#ifdef HAVE_STRLCAT
return strlcat(dst, src, maxlen);
#else
size_t dstlen = SDL_strlen(dst);
@@ -654,7 +654,7 @@ SDL_strdup(const char *string)
char *
SDL_strrev(char *string)
{
#if defined(HAVE__STRREV)
#ifdef HAVE__STRREV
return _strrev(string);
#else
size_t len = SDL_strlen(string);
@@ -673,7 +673,7 @@ SDL_strrev(char *string)
char *
SDL_strupr(char *string)
{
#if defined(HAVE__STRUPR)
#ifdef HAVE__STRUPR
return _strupr(string);
#else
char *bufp = string;
@@ -688,7 +688,7 @@ SDL_strupr(char *string)
char *
SDL_strlwr(char *string)
{
#if defined(HAVE__STRLWR)
#ifdef HAVE__STRLWR
return _strlwr(string);
#else
char *bufp = string;
@@ -743,7 +743,7 @@ SDL_strrchr(const char *string, int c)
char *
SDL_strstr(const char *haystack, const char *needle)
{
#if defined(HAVE_STRSTR)
#ifdef HAVE_STRSTR
return SDL_const_cast(char *, strstr(haystack, needle));
#else
size_t length = SDL_strlen(needle);
@@ -760,7 +760,7 @@ SDL_strstr(const char *haystack, const char *needle)
char *
SDL_strcasestr(const char *haystack, const char *needle)
{
#if defined(HAVE_STRCASESTR)
#ifdef HAVE_STRCASESTR
return SDL_const_cast(char *, strcasestr(haystack, needle));
#else
size_t length = SDL_strlen(needle);
@@ -807,7 +807,7 @@ SDL_uitoa(unsigned int value, char *string, int radix)
char *
SDL_ltoa(long value, char *string, int radix)
{
#if defined(HAVE__LTOA)
#ifdef HAVE__LTOA
return _ltoa(value, string, radix);
#else
char *bufp = string;
@@ -826,7 +826,7 @@ SDL_ltoa(long value, char *string, int radix)
char *
SDL_ultoa(unsigned long value, char *string, int radix)
{
#if defined(HAVE__ULTOA)
#ifdef HAVE__ULTOA
return _ultoa(value, string, radix);
#else
char *bufp = string;
@@ -851,7 +851,7 @@ SDL_ultoa(unsigned long value, char *string, int radix)
char *
SDL_lltoa(Sint64 value, char *string, int radix)
{
#if defined(HAVE__I64TOA)
#ifdef HAVE__I64TOA
return _i64toa(value, string, radix);
#else
char *bufp = string;
@@ -870,7 +870,7 @@ SDL_lltoa(Sint64 value, char *string, int radix)
char *
SDL_ulltoa(Uint64 value, char *string, int radix)
{
#if defined(HAVE__UI64TOA)
#ifdef HAVE__UI64TOA
return _ui64toa(value, string, radix);
#else
char *bufp = string;
@@ -912,7 +912,7 @@ double SDL_atof(const char *string)
long SDL_strtol(const char *string, char **endp, int base)
{
#if defined(HAVE_STRTOL)
#ifdef HAVE_STRTOL
return strtol(string, endp, base);
#else
size_t len;
@@ -937,7 +937,7 @@ long SDL_strtol(const char *string, char **endp, int base)
unsigned long
SDL_strtoul(const char *string, char **endp, int base)
{
#if defined(HAVE_STRTOUL)
#ifdef HAVE_STRTOUL
return strtoul(string, endp, base);
#else
size_t len;
@@ -962,7 +962,7 @@ SDL_strtoul(const char *string, char **endp, int base)
Sint64
SDL_strtoll(const char *string, char **endp, int base)
{
#if defined(HAVE_STRTOLL)
#ifdef HAVE_STRTOLL
return strtoll(string, endp, base);
#else
size_t len;
@@ -987,7 +987,7 @@ SDL_strtoll(const char *string, char **endp, int base)
Uint64
SDL_strtoull(const char *string, char **endp, int base)
{
#if defined(HAVE_STRTOULL)
#ifdef HAVE_STRTOULL
return strtoull(string, endp, base);
#else
size_t len;
@@ -1012,7 +1012,7 @@ SDL_strtoull(const char *string, char **endp, int base)
double
SDL_strtod(const char *string, char **endp)
{
#if defined(HAVE_STRTOD)
#ifdef HAVE_STRTOD
return strtod(string, endp);
#else
size_t len;
@@ -1028,7 +1028,7 @@ SDL_strtod(const char *string, char **endp)
int SDL_strcmp(const char *str1, const char *str2)
{
#if defined(HAVE_STRCMP)
#ifdef HAVE_STRCMP
return strcmp(str1, str2);
#else
int result;
@@ -1047,7 +1047,7 @@ int SDL_strcmp(const char *str1, const char *str2)
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
{
#if defined(HAVE_STRNCMP)
#ifdef HAVE_STRNCMP
return strncmp(str1, str2, maxlen);
#else
int result = 0;

View File

@@ -20,7 +20,7 @@
*/
/* Do our best to make sure va_copy is working */
#if defined(__NGAGE__)
#ifdef __NGAGE__
#undef va_copy
#define va_copy(dst, src) dst = src