SDL Library
SDL_stdinc.h@0:7fb6877b5d7c, 2016-09-22 (annotated)
- Committer:
- miruga27
- Date:
- Thu Sep 22 00:03:09 2016 +0000
- Revision:
- 0:7fb6877b5d7c
SDL
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
miruga27 | 0:7fb6877b5d7c | 1 | /* |
miruga27 | 0:7fb6877b5d7c | 2 | Simple DirectMedia Layer |
miruga27 | 0:7fb6877b5d7c | 3 | Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org> |
miruga27 | 0:7fb6877b5d7c | 4 | |
miruga27 | 0:7fb6877b5d7c | 5 | This software is provided 'as-is', without any express or implied |
miruga27 | 0:7fb6877b5d7c | 6 | warranty. In no event will the authors be held liable for any damages |
miruga27 | 0:7fb6877b5d7c | 7 | arising from the use of this software. |
miruga27 | 0:7fb6877b5d7c | 8 | |
miruga27 | 0:7fb6877b5d7c | 9 | Permission is granted to anyone to use this software for any purpose, |
miruga27 | 0:7fb6877b5d7c | 10 | including commercial applications, and to alter it and redistribute it |
miruga27 | 0:7fb6877b5d7c | 11 | freely, subject to the following restrictions: |
miruga27 | 0:7fb6877b5d7c | 12 | |
miruga27 | 0:7fb6877b5d7c | 13 | 1. The origin of this software must not be misrepresented; you must not |
miruga27 | 0:7fb6877b5d7c | 14 | claim that you wrote the original software. If you use this software |
miruga27 | 0:7fb6877b5d7c | 15 | in a product, an acknowledgment in the product documentation would be |
miruga27 | 0:7fb6877b5d7c | 16 | appreciated but is not required. |
miruga27 | 0:7fb6877b5d7c | 17 | 2. Altered source versions must be plainly marked as such, and must not be |
miruga27 | 0:7fb6877b5d7c | 18 | misrepresented as being the original software. |
miruga27 | 0:7fb6877b5d7c | 19 | 3. This notice may not be removed or altered from any source distribution. |
miruga27 | 0:7fb6877b5d7c | 20 | */ |
miruga27 | 0:7fb6877b5d7c | 21 | |
miruga27 | 0:7fb6877b5d7c | 22 | /** |
miruga27 | 0:7fb6877b5d7c | 23 | * \file SDL_stdinc.h |
miruga27 | 0:7fb6877b5d7c | 24 | * |
miruga27 | 0:7fb6877b5d7c | 25 | * This is a general header that includes C language support. |
miruga27 | 0:7fb6877b5d7c | 26 | */ |
miruga27 | 0:7fb6877b5d7c | 27 | |
miruga27 | 0:7fb6877b5d7c | 28 | #ifndef _SDL_stdinc_h |
miruga27 | 0:7fb6877b5d7c | 29 | #define _SDL_stdinc_h |
miruga27 | 0:7fb6877b5d7c | 30 | |
miruga27 | 0:7fb6877b5d7c | 31 | #include "SDL_config.h" |
miruga27 | 0:7fb6877b5d7c | 32 | |
miruga27 | 0:7fb6877b5d7c | 33 | #ifdef HAVE_SYS_TYPES_H |
miruga27 | 0:7fb6877b5d7c | 34 | #include <sys/types.h> |
miruga27 | 0:7fb6877b5d7c | 35 | #endif |
miruga27 | 0:7fb6877b5d7c | 36 | #ifdef HAVE_STDIO_H |
miruga27 | 0:7fb6877b5d7c | 37 | #include <stdio.h> |
miruga27 | 0:7fb6877b5d7c | 38 | #endif |
miruga27 | 0:7fb6877b5d7c | 39 | #if defined(STDC_HEADERS) |
miruga27 | 0:7fb6877b5d7c | 40 | # include <stdlib.h> |
miruga27 | 0:7fb6877b5d7c | 41 | # include <stddef.h> |
miruga27 | 0:7fb6877b5d7c | 42 | # include <stdarg.h> |
miruga27 | 0:7fb6877b5d7c | 43 | #else |
miruga27 | 0:7fb6877b5d7c | 44 | # if defined(HAVE_STDLIB_H) |
miruga27 | 0:7fb6877b5d7c | 45 | # include <stdlib.h> |
miruga27 | 0:7fb6877b5d7c | 46 | # elif defined(HAVE_MALLOC_H) |
miruga27 | 0:7fb6877b5d7c | 47 | # include <malloc.h> |
miruga27 | 0:7fb6877b5d7c | 48 | # endif |
miruga27 | 0:7fb6877b5d7c | 49 | # if defined(HAVE_STDDEF_H) |
miruga27 | 0:7fb6877b5d7c | 50 | # include <stddef.h> |
miruga27 | 0:7fb6877b5d7c | 51 | # endif |
miruga27 | 0:7fb6877b5d7c | 52 | # if defined(HAVE_STDARG_H) |
miruga27 | 0:7fb6877b5d7c | 53 | # include <stdarg.h> |
miruga27 | 0:7fb6877b5d7c | 54 | # endif |
miruga27 | 0:7fb6877b5d7c | 55 | #endif |
miruga27 | 0:7fb6877b5d7c | 56 | #ifdef HAVE_STRING_H |
miruga27 | 0:7fb6877b5d7c | 57 | # if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H) |
miruga27 | 0:7fb6877b5d7c | 58 | # include <memory.h> |
miruga27 | 0:7fb6877b5d7c | 59 | # endif |
miruga27 | 0:7fb6877b5d7c | 60 | # include <string.h> |
miruga27 | 0:7fb6877b5d7c | 61 | #endif |
miruga27 | 0:7fb6877b5d7c | 62 | #ifdef HAVE_STRINGS_H |
miruga27 | 0:7fb6877b5d7c | 63 | # include <strings.h> |
miruga27 | 0:7fb6877b5d7c | 64 | #endif |
miruga27 | 0:7fb6877b5d7c | 65 | #if defined(HAVE_INTTYPES_H) |
miruga27 | 0:7fb6877b5d7c | 66 | # include <inttypes.h> |
miruga27 | 0:7fb6877b5d7c | 67 | #elif defined(HAVE_STDINT_H) |
miruga27 | 0:7fb6877b5d7c | 68 | # include <stdint.h> |
miruga27 | 0:7fb6877b5d7c | 69 | #endif |
miruga27 | 0:7fb6877b5d7c | 70 | #ifdef HAVE_CTYPE_H |
miruga27 | 0:7fb6877b5d7c | 71 | # include <ctype.h> |
miruga27 | 0:7fb6877b5d7c | 72 | #endif |
miruga27 | 0:7fb6877b5d7c | 73 | #ifdef HAVE_MATH_H |
miruga27 | 0:7fb6877b5d7c | 74 | # include <math.h> |
miruga27 | 0:7fb6877b5d7c | 75 | #endif |
miruga27 | 0:7fb6877b5d7c | 76 | #if defined(HAVE_ICONV) && defined(HAVE_ICONV_H) |
miruga27 | 0:7fb6877b5d7c | 77 | # include <iconv.h> |
miruga27 | 0:7fb6877b5d7c | 78 | #endif |
miruga27 | 0:7fb6877b5d7c | 79 | |
miruga27 | 0:7fb6877b5d7c | 80 | /** |
miruga27 | 0:7fb6877b5d7c | 81 | * The number of elements in an array. |
miruga27 | 0:7fb6877b5d7c | 82 | */ |
miruga27 | 0:7fb6877b5d7c | 83 | #define SDL_arraysize(array) (sizeof(array)/sizeof(array[0])) |
miruga27 | 0:7fb6877b5d7c | 84 | #define SDL_TABLESIZE(table) SDL_arraysize(table) |
miruga27 | 0:7fb6877b5d7c | 85 | |
miruga27 | 0:7fb6877b5d7c | 86 | /** |
miruga27 | 0:7fb6877b5d7c | 87 | * \name Cast operators |
miruga27 | 0:7fb6877b5d7c | 88 | * |
miruga27 | 0:7fb6877b5d7c | 89 | * Use proper C++ casts when compiled as C++ to be compatible with the option |
miruga27 | 0:7fb6877b5d7c | 90 | * -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above). |
miruga27 | 0:7fb6877b5d7c | 91 | */ |
miruga27 | 0:7fb6877b5d7c | 92 | /* @{ */ |
miruga27 | 0:7fb6877b5d7c | 93 | #ifdef __cplusplus |
miruga27 | 0:7fb6877b5d7c | 94 | #define SDL_reinterpret_cast(type, expression) reinterpret_cast<type>(expression) |
miruga27 | 0:7fb6877b5d7c | 95 | #define SDL_static_cast(type, expression) static_cast<type>(expression) |
miruga27 | 0:7fb6877b5d7c | 96 | #define SDL_const_cast(type, expression) const_cast<type>(expression) |
miruga27 | 0:7fb6877b5d7c | 97 | #else |
miruga27 | 0:7fb6877b5d7c | 98 | #define SDL_reinterpret_cast(type, expression) ((type)(expression)) |
miruga27 | 0:7fb6877b5d7c | 99 | #define SDL_static_cast(type, expression) ((type)(expression)) |
miruga27 | 0:7fb6877b5d7c | 100 | #define SDL_const_cast(type, expression) ((type)(expression)) |
miruga27 | 0:7fb6877b5d7c | 101 | #endif |
miruga27 | 0:7fb6877b5d7c | 102 | /* @} *//* Cast operators */ |
miruga27 | 0:7fb6877b5d7c | 103 | |
miruga27 | 0:7fb6877b5d7c | 104 | /* Define a four character code as a Uint32 */ |
miruga27 | 0:7fb6877b5d7c | 105 | #define SDL_FOURCC(A, B, C, D) \ |
miruga27 | 0:7fb6877b5d7c | 106 | ((SDL_static_cast(Uint32, SDL_static_cast(Uint8, (A))) << 0) | \ |
miruga27 | 0:7fb6877b5d7c | 107 | (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (B))) << 8) | \ |
miruga27 | 0:7fb6877b5d7c | 108 | (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (C))) << 16) | \ |
miruga27 | 0:7fb6877b5d7c | 109 | (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (D))) << 24)) |
miruga27 | 0:7fb6877b5d7c | 110 | |
miruga27 | 0:7fb6877b5d7c | 111 | /** |
miruga27 | 0:7fb6877b5d7c | 112 | * \name Basic data types |
miruga27 | 0:7fb6877b5d7c | 113 | */ |
miruga27 | 0:7fb6877b5d7c | 114 | /* @{ */ |
miruga27 | 0:7fb6877b5d7c | 115 | |
miruga27 | 0:7fb6877b5d7c | 116 | typedef enum |
miruga27 | 0:7fb6877b5d7c | 117 | { |
miruga27 | 0:7fb6877b5d7c | 118 | SDL_FALSE = 0, |
miruga27 | 0:7fb6877b5d7c | 119 | SDL_TRUE = 1 |
miruga27 | 0:7fb6877b5d7c | 120 | } SDL_bool; |
miruga27 | 0:7fb6877b5d7c | 121 | |
miruga27 | 0:7fb6877b5d7c | 122 | /** |
miruga27 | 0:7fb6877b5d7c | 123 | * \brief A signed 8-bit integer type. |
miruga27 | 0:7fb6877b5d7c | 124 | */ |
miruga27 | 0:7fb6877b5d7c | 125 | typedef int8_t Sint8; |
miruga27 | 0:7fb6877b5d7c | 126 | /** |
miruga27 | 0:7fb6877b5d7c | 127 | * \brief An unsigned 8-bit integer type. |
miruga27 | 0:7fb6877b5d7c | 128 | */ |
miruga27 | 0:7fb6877b5d7c | 129 | typedef uint8_t Uint8; |
miruga27 | 0:7fb6877b5d7c | 130 | /** |
miruga27 | 0:7fb6877b5d7c | 131 | * \brief A signed 16-bit integer type. |
miruga27 | 0:7fb6877b5d7c | 132 | */ |
miruga27 | 0:7fb6877b5d7c | 133 | typedef int16_t Sint16; |
miruga27 | 0:7fb6877b5d7c | 134 | /** |
miruga27 | 0:7fb6877b5d7c | 135 | * \brief An unsigned 16-bit integer type. |
miruga27 | 0:7fb6877b5d7c | 136 | */ |
miruga27 | 0:7fb6877b5d7c | 137 | typedef uint16_t Uint16; |
miruga27 | 0:7fb6877b5d7c | 138 | /** |
miruga27 | 0:7fb6877b5d7c | 139 | * \brief A signed 32-bit integer type. |
miruga27 | 0:7fb6877b5d7c | 140 | */ |
miruga27 | 0:7fb6877b5d7c | 141 | typedef int32_t Sint32; |
miruga27 | 0:7fb6877b5d7c | 142 | /** |
miruga27 | 0:7fb6877b5d7c | 143 | * \brief An unsigned 32-bit integer type. |
miruga27 | 0:7fb6877b5d7c | 144 | */ |
miruga27 | 0:7fb6877b5d7c | 145 | typedef uint32_t Uint32; |
miruga27 | 0:7fb6877b5d7c | 146 | |
miruga27 | 0:7fb6877b5d7c | 147 | /** |
miruga27 | 0:7fb6877b5d7c | 148 | * \brief A signed 64-bit integer type. |
miruga27 | 0:7fb6877b5d7c | 149 | */ |
miruga27 | 0:7fb6877b5d7c | 150 | typedef int64_t Sint64; |
miruga27 | 0:7fb6877b5d7c | 151 | /** |
miruga27 | 0:7fb6877b5d7c | 152 | * \brief An unsigned 64-bit integer type. |
miruga27 | 0:7fb6877b5d7c | 153 | */ |
miruga27 | 0:7fb6877b5d7c | 154 | typedef uint64_t Uint64; |
miruga27 | 0:7fb6877b5d7c | 155 | |
miruga27 | 0:7fb6877b5d7c | 156 | /* @} *//* Basic data types */ |
miruga27 | 0:7fb6877b5d7c | 157 | |
miruga27 | 0:7fb6877b5d7c | 158 | |
miruga27 | 0:7fb6877b5d7c | 159 | #define SDL_COMPILE_TIME_ASSERT(name, x) \ |
miruga27 | 0:7fb6877b5d7c | 160 | typedef int SDL_dummy_ ## name[(x) * 2 - 1] |
miruga27 | 0:7fb6877b5d7c | 161 | /** \cond */ |
miruga27 | 0:7fb6877b5d7c | 162 | #ifndef DOXYGEN_SHOULD_IGNORE_THIS |
miruga27 | 0:7fb6877b5d7c | 163 | SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1); |
miruga27 | 0:7fb6877b5d7c | 164 | SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1); |
miruga27 | 0:7fb6877b5d7c | 165 | SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2); |
miruga27 | 0:7fb6877b5d7c | 166 | SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2); |
miruga27 | 0:7fb6877b5d7c | 167 | SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4); |
miruga27 | 0:7fb6877b5d7c | 168 | SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4); |
miruga27 | 0:7fb6877b5d7c | 169 | SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8); |
miruga27 | 0:7fb6877b5d7c | 170 | SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8); |
miruga27 | 0:7fb6877b5d7c | 171 | #endif /* DOXYGEN_SHOULD_IGNORE_THIS */ |
miruga27 | 0:7fb6877b5d7c | 172 | /** \endcond */ |
miruga27 | 0:7fb6877b5d7c | 173 | |
miruga27 | 0:7fb6877b5d7c | 174 | /* Check to make sure enums are the size of ints, for structure packing. |
miruga27 | 0:7fb6877b5d7c | 175 | For both Watcom C/C++ and Borland C/C++ the compiler option that makes |
miruga27 | 0:7fb6877b5d7c | 176 | enums having the size of an int must be enabled. |
miruga27 | 0:7fb6877b5d7c | 177 | This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11). |
miruga27 | 0:7fb6877b5d7c | 178 | */ |
miruga27 | 0:7fb6877b5d7c | 179 | |
miruga27 | 0:7fb6877b5d7c | 180 | /** \cond */ |
miruga27 | 0:7fb6877b5d7c | 181 | #ifndef DOXYGEN_SHOULD_IGNORE_THIS |
miruga27 | 0:7fb6877b5d7c | 182 | #if !defined(__ANDROID__) |
miruga27 | 0:7fb6877b5d7c | 183 | /* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */ |
miruga27 | 0:7fb6877b5d7c | 184 | typedef enum |
miruga27 | 0:7fb6877b5d7c | 185 | { |
miruga27 | 0:7fb6877b5d7c | 186 | DUMMY_ENUM_VALUE |
miruga27 | 0:7fb6877b5d7c | 187 | } SDL_DUMMY_ENUM; |
miruga27 | 0:7fb6877b5d7c | 188 | |
miruga27 | 0:7fb6877b5d7c | 189 | SDL_COMPILE_TIME_ASSERT(enum, sizeof(4) == sizeof(int));//SDL_DUMMY_ENUM instead of '4' |
miruga27 | 0:7fb6877b5d7c | 190 | #endif |
miruga27 | 0:7fb6877b5d7c | 191 | #endif /* DOXYGEN_SHOULD_IGNORE_THIS */ |
miruga27 | 0:7fb6877b5d7c | 192 | /** \endcond */ |
miruga27 | 0:7fb6877b5d7c | 193 | |
miruga27 | 0:7fb6877b5d7c | 194 | #include "begin_code.h" |
miruga27 | 0:7fb6877b5d7c | 195 | /* Set up for C function definitions, even when using C++ */ |
miruga27 | 0:7fb6877b5d7c | 196 | #ifdef __cplusplus |
miruga27 | 0:7fb6877b5d7c | 197 | extern "C" { |
miruga27 | 0:7fb6877b5d7c | 198 | #endif |
miruga27 | 0:7fb6877b5d7c | 199 | |
miruga27 | 0:7fb6877b5d7c | 200 | #if defined(HAVE_ALLOCA) && !defined(alloca) |
miruga27 | 0:7fb6877b5d7c | 201 | # if defined(HAVE_ALLOCA_H) |
miruga27 | 0:7fb6877b5d7c | 202 | # include <alloca.h> |
miruga27 | 0:7fb6877b5d7c | 203 | # elif defined(__GNUC__) |
miruga27 | 0:7fb6877b5d7c | 204 | # define alloca __builtin_alloca |
miruga27 | 0:7fb6877b5d7c | 205 | # elif defined(_MSC_VER) |
miruga27 | 0:7fb6877b5d7c | 206 | # include <malloc.h> |
miruga27 | 0:7fb6877b5d7c | 207 | # define alloca _alloca |
miruga27 | 0:7fb6877b5d7c | 208 | # elif defined(__WATCOMC__) |
miruga27 | 0:7fb6877b5d7c | 209 | # include <malloc.h> |
miruga27 | 0:7fb6877b5d7c | 210 | # elif defined(__BORLANDC__) |
miruga27 | 0:7fb6877b5d7c | 211 | # include <malloc.h> |
miruga27 | 0:7fb6877b5d7c | 212 | # elif defined(__DMC__) |
miruga27 | 0:7fb6877b5d7c | 213 | # include <stdlib.h> |
miruga27 | 0:7fb6877b5d7c | 214 | # elif defined(__AIX__) |
miruga27 | 0:7fb6877b5d7c | 215 | #pragma alloca |
miruga27 | 0:7fb6877b5d7c | 216 | # elif defined(__MRC__) |
miruga27 | 0:7fb6877b5d7c | 217 | void *alloca(unsigned); |
miruga27 | 0:7fb6877b5d7c | 218 | # else |
miruga27 | 0:7fb6877b5d7c | 219 | char *alloca(); |
miruga27 | 0:7fb6877b5d7c | 220 | # endif |
miruga27 | 0:7fb6877b5d7c | 221 | #endif |
miruga27 | 0:7fb6877b5d7c | 222 | #ifdef HAVE_ALLOCA |
miruga27 | 0:7fb6877b5d7c | 223 | #define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count)) |
miruga27 | 0:7fb6877b5d7c | 224 | #define SDL_stack_free(data) |
miruga27 | 0:7fb6877b5d7c | 225 | #else |
miruga27 | 0:7fb6877b5d7c | 226 | #define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*(count)) |
miruga27 | 0:7fb6877b5d7c | 227 | #define SDL_stack_free(data) SDL_free(data) |
miruga27 | 0:7fb6877b5d7c | 228 | #endif |
miruga27 | 0:7fb6877b5d7c | 229 | |
miruga27 | 0:7fb6877b5d7c | 230 | extern DECLSPEC void *SDLCALL SDL_malloc(size_t size); |
miruga27 | 0:7fb6877b5d7c | 231 | extern DECLSPEC void *SDLCALL SDL_calloc(size_t nmemb, size_t size); |
miruga27 | 0:7fb6877b5d7c | 232 | extern DECLSPEC void *SDLCALL SDL_realloc(void *mem, size_t size); |
miruga27 | 0:7fb6877b5d7c | 233 | extern DECLSPEC void SDLCALL SDL_free(void *mem); |
miruga27 | 0:7fb6877b5d7c | 234 | |
miruga27 | 0:7fb6877b5d7c | 235 | extern DECLSPEC char *SDLCALL SDL_getenv(const char *name); |
miruga27 | 0:7fb6877b5d7c | 236 | extern DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value, int overwrite); |
miruga27 | 0:7fb6877b5d7c | 237 | |
miruga27 | 0:7fb6877b5d7c | 238 | extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *)); |
miruga27 | 0:7fb6877b5d7c | 239 | |
miruga27 | 0:7fb6877b5d7c | 240 | extern DECLSPEC int SDLCALL SDL_abs(int x); |
miruga27 | 0:7fb6877b5d7c | 241 | |
miruga27 | 0:7fb6877b5d7c | 242 | /* !!! FIXME: these have side effects. You probably shouldn't use them. */ |
miruga27 | 0:7fb6877b5d7c | 243 | /* !!! FIXME: Maybe we do forceinline functions of SDL_mini, SDL_minf, etc? */ |
miruga27 | 0:7fb6877b5d7c | 244 | #define SDL_min(x, y) (((x) < (y)) ? (x) : (y)) |
miruga27 | 0:7fb6877b5d7c | 245 | #define SDL_max(x, y) (((x) > (y)) ? (x) : (y)) |
miruga27 | 0:7fb6877b5d7c | 246 | |
miruga27 | 0:7fb6877b5d7c | 247 | extern DECLSPEC int SDLCALL SDL_isdigit(int x); |
miruga27 | 0:7fb6877b5d7c | 248 | extern DECLSPEC int SDLCALL SDL_isspace(int x); |
miruga27 | 0:7fb6877b5d7c | 249 | extern DECLSPEC int SDLCALL SDL_toupper(int x); |
miruga27 | 0:7fb6877b5d7c | 250 | extern DECLSPEC int SDLCALL SDL_tolower(int x); |
miruga27 | 0:7fb6877b5d7c | 251 | |
miruga27 | 0:7fb6877b5d7c | 252 | extern DECLSPEC void *SDLCALL SDL_memset(void *dst, int c, size_t len); |
miruga27 | 0:7fb6877b5d7c | 253 | |
miruga27 | 0:7fb6877b5d7c | 254 | #define SDL_zero(x) SDL_memset(&(x), 0, sizeof((x))) |
miruga27 | 0:7fb6877b5d7c | 255 | #define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x))) |
miruga27 | 0:7fb6877b5d7c | 256 | |
miruga27 | 0:7fb6877b5d7c | 257 | /* Note that memset() is a byte assignment and this is a 32-bit assignment, so they're not directly equivalent. */ |
miruga27 | 0:7fb6877b5d7c | 258 | SDL_FORCE_INLINE void SDL_memset4(void *dst, Uint32 val, size_t dwords) |
miruga27 | 0:7fb6877b5d7c | 259 | { |
miruga27 | 0:7fb6877b5d7c | 260 | #if defined(__GNUC__) && defined(i386) |
miruga27 | 0:7fb6877b5d7c | 261 | int u0, u1, u2; |
miruga27 | 0:7fb6877b5d7c | 262 | __asm__ __volatile__ ( |
miruga27 | 0:7fb6877b5d7c | 263 | "cld \n\t" |
miruga27 | 0:7fb6877b5d7c | 264 | "rep ; stosl \n\t" |
miruga27 | 0:7fb6877b5d7c | 265 | : "=&D" (u0), "=&a" (u1), "=&c" (u2) |
miruga27 | 0:7fb6877b5d7c | 266 | : "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, dwords)) |
miruga27 | 0:7fb6877b5d7c | 267 | : "memory" |
miruga27 | 0:7fb6877b5d7c | 268 | ); |
miruga27 | 0:7fb6877b5d7c | 269 | #else |
miruga27 | 0:7fb6877b5d7c | 270 | size_t _n = (dwords + 3) / 4; |
miruga27 | 0:7fb6877b5d7c | 271 | Uint32 *_p = SDL_static_cast(Uint32 *, dst); |
miruga27 | 0:7fb6877b5d7c | 272 | Uint32 _val = (val); |
miruga27 | 0:7fb6877b5d7c | 273 | if (dwords == 0) |
miruga27 | 0:7fb6877b5d7c | 274 | return; |
miruga27 | 0:7fb6877b5d7c | 275 | switch (dwords % 4) |
miruga27 | 0:7fb6877b5d7c | 276 | { |
miruga27 | 0:7fb6877b5d7c | 277 | case 0: do { *_p++ = _val; |
miruga27 | 0:7fb6877b5d7c | 278 | case 3: *_p++ = _val; |
miruga27 | 0:7fb6877b5d7c | 279 | case 2: *_p++ = _val; |
miruga27 | 0:7fb6877b5d7c | 280 | case 1: *_p++ = _val; |
miruga27 | 0:7fb6877b5d7c | 281 | } while ( --_n ); |
miruga27 | 0:7fb6877b5d7c | 282 | } |
miruga27 | 0:7fb6877b5d7c | 283 | #endif |
miruga27 | 0:7fb6877b5d7c | 284 | } |
miruga27 | 0:7fb6877b5d7c | 285 | |
miruga27 | 0:7fb6877b5d7c | 286 | |
miruga27 | 0:7fb6877b5d7c | 287 | extern DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src, size_t len); |
miruga27 | 0:7fb6877b5d7c | 288 | |
miruga27 | 0:7fb6877b5d7c | 289 | SDL_FORCE_INLINE void *SDL_memcpy4(void *dst, const void *src, size_t dwords) |
miruga27 | 0:7fb6877b5d7c | 290 | { |
miruga27 | 0:7fb6877b5d7c | 291 | return SDL_memcpy(dst, src, dwords * 4); |
miruga27 | 0:7fb6877b5d7c | 292 | } |
miruga27 | 0:7fb6877b5d7c | 293 | |
miruga27 | 0:7fb6877b5d7c | 294 | extern DECLSPEC void *SDLCALL SDL_memmove(void *dst, const void *src, size_t len); |
miruga27 | 0:7fb6877b5d7c | 295 | extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len); |
miruga27 | 0:7fb6877b5d7c | 296 | |
miruga27 | 0:7fb6877b5d7c | 297 | extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t *wstr); |
miruga27 | 0:7fb6877b5d7c | 298 | extern DECLSPEC size_t SDLCALL SDL_wcslcpy(wchar_t *dst, const wchar_t *src, size_t maxlen); |
miruga27 | 0:7fb6877b5d7c | 299 | extern DECLSPEC size_t SDLCALL SDL_wcslcat(wchar_t *dst, const wchar_t *src, size_t maxlen); |
miruga27 | 0:7fb6877b5d7c | 300 | |
miruga27 | 0:7fb6877b5d7c | 301 | extern DECLSPEC size_t SDLCALL SDL_strlen(const char *str); |
miruga27 | 0:7fb6877b5d7c | 302 | extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src, size_t maxlen); |
miruga27 | 0:7fb6877b5d7c | 303 | extern DECLSPEC size_t SDLCALL SDL_utf8strlcpy(char *dst, const char *src, size_t dst_bytes); |
miruga27 | 0:7fb6877b5d7c | 304 | extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src, size_t maxlen); |
miruga27 | 0:7fb6877b5d7c | 305 | extern DECLSPEC char *SDLCALL SDL_strdup(const char *str); |
miruga27 | 0:7fb6877b5d7c | 306 | extern DECLSPEC char *SDLCALL SDL_strrev(char *str); |
miruga27 | 0:7fb6877b5d7c | 307 | extern DECLSPEC char *SDLCALL SDL_strupr(char *str); |
miruga27 | 0:7fb6877b5d7c | 308 | extern DECLSPEC char *SDLCALL SDL_strlwr(char *str); |
miruga27 | 0:7fb6877b5d7c | 309 | extern DECLSPEC char *SDLCALL SDL_strchr(const char *str, int c); |
miruga27 | 0:7fb6877b5d7c | 310 | extern DECLSPEC char *SDLCALL SDL_strrchr(const char *str, int c); |
miruga27 | 0:7fb6877b5d7c | 311 | extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle); |
miruga27 | 0:7fb6877b5d7c | 312 | |
miruga27 | 0:7fb6877b5d7c | 313 | extern DECLSPEC char *SDLCALL SDL_itoa(int value, char *str, int radix); |
miruga27 | 0:7fb6877b5d7c | 314 | extern DECLSPEC char *SDLCALL SDL_uitoa(unsigned int value, char *str, int radix); |
miruga27 | 0:7fb6877b5d7c | 315 | extern DECLSPEC char *SDLCALL SDL_ltoa(long value, char *str, int radix); |
miruga27 | 0:7fb6877b5d7c | 316 | extern DECLSPEC char *SDLCALL SDL_ultoa(unsigned long value, char *str, int radix); |
miruga27 | 0:7fb6877b5d7c | 317 | extern DECLSPEC char *SDLCALL SDL_lltoa(Sint64 value, char *str, int radix); |
miruga27 | 0:7fb6877b5d7c | 318 | extern DECLSPEC char *SDLCALL SDL_ulltoa(Uint64 value, char *str, int radix); |
miruga27 | 0:7fb6877b5d7c | 319 | |
miruga27 | 0:7fb6877b5d7c | 320 | extern DECLSPEC int SDLCALL SDL_atoi(const char *str); |
miruga27 | 0:7fb6877b5d7c | 321 | extern DECLSPEC double SDLCALL SDL_atof(const char *str); |
miruga27 | 0:7fb6877b5d7c | 322 | extern DECLSPEC long SDLCALL SDL_strtol(const char *str, char **endp, int base); |
miruga27 | 0:7fb6877b5d7c | 323 | extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *str, char **endp, int base); |
miruga27 | 0:7fb6877b5d7c | 324 | extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *str, char **endp, int base); |
miruga27 | 0:7fb6877b5d7c | 325 | extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *str, char **endp, int base); |
miruga27 | 0:7fb6877b5d7c | 326 | extern DECLSPEC double SDLCALL SDL_strtod(const char *str, char **endp); |
miruga27 | 0:7fb6877b5d7c | 327 | |
miruga27 | 0:7fb6877b5d7c | 328 | extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2); |
miruga27 | 0:7fb6877b5d7c | 329 | extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen); |
miruga27 | 0:7fb6877b5d7c | 330 | extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2); |
miruga27 | 0:7fb6877b5d7c | 331 | extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t len); |
miruga27 | 0:7fb6877b5d7c | 332 | |
miruga27 | 0:7fb6877b5d7c | 333 | extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, ...); |
miruga27 | 0:7fb6877b5d7c | 334 | extern DECLSPEC int SDLCALL SDL_vsscanf(const char *text, const char *fmt, va_list ap); |
miruga27 | 0:7fb6877b5d7c | 335 | extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...); |
miruga27 | 0:7fb6877b5d7c | 336 | extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap); |
miruga27 | 0:7fb6877b5d7c | 337 | |
miruga27 | 0:7fb6877b5d7c | 338 | #ifndef HAVE_M_PI |
miruga27 | 0:7fb6877b5d7c | 339 | #ifndef M_PI |
miruga27 | 0:7fb6877b5d7c | 340 | #define M_PI 3.14159265358979323846264338327950288 /* pi */ |
miruga27 | 0:7fb6877b5d7c | 341 | #endif |
miruga27 | 0:7fb6877b5d7c | 342 | #endif |
miruga27 | 0:7fb6877b5d7c | 343 | |
miruga27 | 0:7fb6877b5d7c | 344 | extern DECLSPEC double SDLCALL SDL_acos(double x); |
miruga27 | 0:7fb6877b5d7c | 345 | extern DECLSPEC double SDLCALL SDL_asin(double x); |
miruga27 | 0:7fb6877b5d7c | 346 | extern DECLSPEC double SDLCALL SDL_atan(double x); |
miruga27 | 0:7fb6877b5d7c | 347 | extern DECLSPEC double SDLCALL SDL_atan2(double x, double y); |
miruga27 | 0:7fb6877b5d7c | 348 | extern DECLSPEC double SDLCALL SDL_ceil(double x); |
miruga27 | 0:7fb6877b5d7c | 349 | extern DECLSPEC double SDLCALL SDL_copysign(double x, double y); |
miruga27 | 0:7fb6877b5d7c | 350 | extern DECLSPEC double SDLCALL SDL_cos(double x); |
miruga27 | 0:7fb6877b5d7c | 351 | extern DECLSPEC float SDLCALL SDL_cosf(float x); |
miruga27 | 0:7fb6877b5d7c | 352 | extern DECLSPEC double SDLCALL SDL_fabs(double x); |
miruga27 | 0:7fb6877b5d7c | 353 | extern DECLSPEC double SDLCALL SDL_floor(double x); |
miruga27 | 0:7fb6877b5d7c | 354 | extern DECLSPEC double SDLCALL SDL_log(double x); |
miruga27 | 0:7fb6877b5d7c | 355 | extern DECLSPEC double SDLCALL SDL_pow(double x, double y); |
miruga27 | 0:7fb6877b5d7c | 356 | extern DECLSPEC double SDLCALL SDL_scalbn(double x, int n); |
miruga27 | 0:7fb6877b5d7c | 357 | extern DECLSPEC double SDLCALL SDL_sin(double x); |
miruga27 | 0:7fb6877b5d7c | 358 | extern DECLSPEC float SDLCALL SDL_sinf(float x); |
miruga27 | 0:7fb6877b5d7c | 359 | extern DECLSPEC double SDLCALL SDL_sqrt(double x); |
miruga27 | 0:7fb6877b5d7c | 360 | |
miruga27 | 0:7fb6877b5d7c | 361 | /* The SDL implementation of iconv() returns these error codes */ |
miruga27 | 0:7fb6877b5d7c | 362 | #define SDL_ICONV_ERROR (size_t)-1 |
miruga27 | 0:7fb6877b5d7c | 363 | #define SDL_ICONV_E2BIG (size_t)-2 |
miruga27 | 0:7fb6877b5d7c | 364 | #define SDL_ICONV_EILSEQ (size_t)-3 |
miruga27 | 0:7fb6877b5d7c | 365 | #define SDL_ICONV_EINVAL (size_t)-4 |
miruga27 | 0:7fb6877b5d7c | 366 | |
miruga27 | 0:7fb6877b5d7c | 367 | /* SDL_iconv_* are now always real symbols/types, not macros or inlined. */ |
miruga27 | 0:7fb6877b5d7c | 368 | typedef struct _SDL_iconv_t *SDL_iconv_t; |
miruga27 | 0:7fb6877b5d7c | 369 | extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode, |
miruga27 | 0:7fb6877b5d7c | 370 | const char *fromcode); |
miruga27 | 0:7fb6877b5d7c | 371 | extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd); |
miruga27 | 0:7fb6877b5d7c | 372 | extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf, |
miruga27 | 0:7fb6877b5d7c | 373 | size_t * inbytesleft, char **outbuf, |
miruga27 | 0:7fb6877b5d7c | 374 | size_t * outbytesleft); |
miruga27 | 0:7fb6877b5d7c | 375 | /** |
miruga27 | 0:7fb6877b5d7c | 376 | * This function converts a string between encodings in one pass, returning a |
miruga27 | 0:7fb6877b5d7c | 377 | * string that must be freed with SDL_free() or NULL on error. |
miruga27 | 0:7fb6877b5d7c | 378 | */ |
miruga27 | 0:7fb6877b5d7c | 379 | extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode, |
miruga27 | 0:7fb6877b5d7c | 380 | const char *fromcode, |
miruga27 | 0:7fb6877b5d7c | 381 | const char *inbuf, |
miruga27 | 0:7fb6877b5d7c | 382 | size_t inbytesleft); |
miruga27 | 0:7fb6877b5d7c | 383 | #define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1) |
miruga27 | 0:7fb6877b5d7c | 384 | #define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2-INTERNAL", "UTF-8", S, SDL_strlen(S)+1) |
miruga27 | 0:7fb6877b5d7c | 385 | #define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4-INTERNAL", "UTF-8", S, SDL_strlen(S)+1) |
miruga27 | 0:7fb6877b5d7c | 386 | |
miruga27 | 0:7fb6877b5d7c | 387 | /* Ends C function definitions when using C++ */ |
miruga27 | 0:7fb6877b5d7c | 388 | #ifdef __cplusplus |
miruga27 | 0:7fb6877b5d7c | 389 | } |
miruga27 | 0:7fb6877b5d7c | 390 | #endif |
miruga27 | 0:7fb6877b5d7c | 391 | #include "close_code.h" |
miruga27 | 0:7fb6877b5d7c | 392 | |
miruga27 | 0:7fb6877b5d7c | 393 | #endif /* _SDL_stdinc_h */ |
miruga27 | 0:7fb6877b5d7c | 394 | |
miruga27 | 0:7fb6877b5d7c | 395 | /* vi: set ts=4 sw=4 expandtab: */ |