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