include/SDL_stdinc.h
author Sam Lantinga <slouken@libsdl.org>
Tue, 19 Mar 2013 22:02:34 -0700
changeset 7015 e3cba60c0f0a
parent 7011 82bbfbbc720e
child 7036 8c891504e325
permissions -rw-r--r--
Fixed bug 1764 - Integer Precision Loss During Compilation Phil Sampson /Library/Frameworks/SDL2.framework/Headers/SDL_stdinc.h:345:28: Implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'unsigned int'
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
     1
/*
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5512
diff changeset
     2
  Simple DirectMedia Layer
6885
700f1b25f77f Happy New Year!
Sam Lantinga <slouken@libsdl.org>
parents: 6627
diff changeset
     3
  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
     4
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5512
diff changeset
     5
  This software is provided 'as-is', without any express or implied
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5512
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5512
diff changeset
     7
  arising from the use of this software.
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
     8
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5512
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5512
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5512
diff changeset
    11
  freely, subject to the following restrictions:
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    12
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5512
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5512
diff changeset
    14
     claim that you wrote the original software. If you use this software
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5512
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5512
diff changeset
    16
     appreciated but is not required.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5512
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5512
diff changeset
    18
     misrepresented as being the original software.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5512
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    20
*/
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    21
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    22
/**
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    23
 *  \file SDL_stdinc.h
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    24
 *  
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    25
 *  This is a general header that includes C language support.
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    26
 */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    27
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    28
#ifndef _SDL_stdinc_h
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    29
#define _SDL_stdinc_h
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    30
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    31
#include "SDL_config.h"
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    32
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    33
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    34
#ifdef HAVE_SYS_TYPES_H
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    35
#include <sys/types.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    36
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    37
#ifdef HAVE_STDIO_H
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    38
#include <stdio.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    39
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    40
#if defined(STDC_HEADERS)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    41
# include <stdlib.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    42
# include <stddef.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    43
# include <stdarg.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    44
#else
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    45
# if defined(HAVE_STDLIB_H)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    46
#  include <stdlib.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    47
# elif defined(HAVE_MALLOC_H)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    48
#  include <malloc.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    49
# endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    50
# if defined(HAVE_STDDEF_H)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    51
#  include <stddef.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    52
# endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    53
# if defined(HAVE_STDARG_H)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    54
#  include <stdarg.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    55
# endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    56
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    57
#ifdef HAVE_STRING_H
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    58
# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    59
#  include <memory.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    60
# endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    61
# include <string.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    62
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    63
#ifdef HAVE_STRINGS_H
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    64
# include <strings.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    65
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    66
#if defined(HAVE_INTTYPES_H)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    67
# include <inttypes.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    68
#elif defined(HAVE_STDINT_H)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    69
# include <stdint.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    70
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    71
#ifdef HAVE_CTYPE_H
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    72
# include <ctype.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    73
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    74
#ifdef HAVE_MATH_H
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    75
# include <math.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    76
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    77
#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    78
# include <iconv.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    79
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    80
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    81
/**
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    82
 *  The number of elements in an array.
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    83
 */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    84
#define SDL_arraysize(array)	(sizeof(array)/sizeof(array[0]))
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    85
#define SDL_TABLESIZE(table)	SDL_arraysize(table)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    86
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    87
/**
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    88
 *  \name Cast operators
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    89
 *  
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    90
 *  Use proper C++ casts when compiled as C++ to be compatible with the option
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    91
 *  -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above).
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    92
 */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    93
/*@{*/
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    94
#ifdef __cplusplus
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    95
#define SDL_reinterpret_cast(type, expression) reinterpret_cast<type>(expression)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    96
#define SDL_static_cast(type, expression) static_cast<type>(expression)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    97
#else
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    98
#define SDL_reinterpret_cast(type, expression) ((type)(expression))
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    99
#define SDL_static_cast(type, expression) ((type)(expression))
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   100
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   101
/*@}*//*Cast operators*/
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   102
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   103
/* Define a four character code as a Uint32 */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   104
#define SDL_FOURCC(A, B, C, D) \
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   105
    ((SDL_static_cast(Uint32, SDL_static_cast(Uint8, (A))) << 0) | \
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   106
     (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (B))) << 8) | \
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   107
     (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (C))) << 16) | \
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   108
     (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (D))) << 24))
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   109
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   110
/**
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   111
 *  \name Basic data types
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   112
 */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   113
/*@{*/
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   114
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   115
typedef enum
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   116
{
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   117
    SDL_FALSE = 0,
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   118
    SDL_TRUE = 1
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   119
} SDL_bool;
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   120
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   121
/**
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   122
 * \brief A signed 8-bit integer type.
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   123
 */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   124
typedef int8_t Sint8;
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   125
/**
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   126
 * \brief An unsigned 8-bit integer type.
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   127
 */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   128
typedef uint8_t Uint8;
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   129
/**
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   130
 * \brief A signed 16-bit integer type.
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   131
 */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   132
typedef int16_t Sint16;
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   133
/**
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   134
 * \brief An unsigned 16-bit integer type.
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   135
 */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   136
typedef uint16_t Uint16;
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   137
/**
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   138
 * \brief A signed 32-bit integer type.
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   139
 */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   140
typedef int32_t Sint32;
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   141
/**
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   142
 * \brief An unsigned 32-bit integer type.
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   143
 */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   144
typedef uint32_t Uint32;
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   145
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   146
/**
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   147
 * \brief A signed 64-bit integer type.
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   148
 */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   149
typedef int64_t Sint64;
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   150
/**
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   151
 * \brief An unsigned 64-bit integer type.
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   152
 */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   153
typedef uint64_t Uint64;
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   154
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   155
/*@}*//*Basic data types*/
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   156
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   157
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   158
#define SDL_COMPILE_TIME_ASSERT(name, x)               \
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   159
       typedef int SDL_dummy_ ## name[(x) * 2 - 1]
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   160
/** \cond */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   161
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   162
SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1);
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   163
SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1);
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   164
SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2);
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   165
SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2);
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   166
SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4);
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   167
SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4);
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   168
SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8);
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   169
SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   170
#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   171
/** \endcond */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   172
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   173
/* Check to make sure enums are the size of ints, for structure packing.
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   174
   For both Watcom C/C++ and Borland C/C++ the compiler option that makes
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   175
   enums having the size of an int must be enabled.
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   176
   This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11).
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   177
*/
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   178
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   179
/** \cond */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   180
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
7011
82bbfbbc720e Removed Nintendo DS support since nobody has volunteered to maintain it for over a year.
Sam Lantinga <slouken@libsdl.org>
parents: 7008
diff changeset
   181
#if !defined(__ANDROID__) 
4697
a5c4ded0c979 Fix compile errors under Android toolchain. Seems to have the same issue as the NDS.
Paul Hunkin <paul@bieh.net>
parents: 3697
diff changeset
   182
   /* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   183
typedef enum
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   184
{
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   185
    DUMMY_ENUM_VALUE
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   186
} SDL_DUMMY_ENUM;
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   187
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   188
SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int));
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   189
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   190
#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   191
/** \endcond */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   192
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   193
#include "begin_code.h"
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   194
/* Set up for C function definitions, even when using C++ */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   195
#ifdef __cplusplus
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   196
/* *INDENT-OFF* */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   197
extern "C" {
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   198
/* *INDENT-ON* */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   199
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   200
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   201
#if defined(HAVE_ALLOCA) && !defined(alloca)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   202
# if defined(HAVE_ALLOCA_H)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   203
#  include <alloca.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   204
# elif defined(__GNUC__)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   205
#  define alloca __builtin_alloca
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   206
# elif defined(_MSC_VER)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   207
#  include <malloc.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   208
#  define alloca _alloca
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   209
# elif defined(__WATCOMC__)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   210
#  include <malloc.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   211
# elif defined(__BORLANDC__)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   212
#  include <malloc.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   213
# elif defined(__DMC__)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   214
#  include <stdlib.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   215
# elif defined(__AIX__)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   216
#pragma alloca
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   217
# elif defined(__MRC__)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   218
void *alloca(unsigned);
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   219
# else
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   220
char *alloca();
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   221
# endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   222
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   223
#ifdef HAVE_ALLOCA
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   224
#define SDL_stack_alloc(type, count)    (type*)alloca(sizeof(type)*(count))
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   225
#define SDL_stack_free(data)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   226
#else
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   227
#define SDL_stack_alloc(type, count)    (type*)SDL_malloc(sizeof(type)*(count))
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   228
#define SDL_stack_free(data)            SDL_free(data)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   229
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   230
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   231
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   232
/* SDL stdinc inline functions:
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   233
7005
6c69ad0b184e Clarified inline function documentation, removed obsolete Metrowerks compiler directive.
Sam Lantinga <slouken@libsdl.org>
parents: 7003
diff changeset
   234
   The theory here is that by default we forcibly inline what we can, and your
6c69ad0b184e Clarified inline function documentation, removed obsolete Metrowerks compiler directive.
Sam Lantinga <slouken@libsdl.org>
parents: 7003
diff changeset
   235
   app will use the inline version by default. However we expose a non-inline
6c69ad0b184e Clarified inline function documentation, removed obsolete Metrowerks compiler directive.
Sam Lantinga <slouken@libsdl.org>
parents: 7003
diff changeset
   236
   version too, so the symbol is always available in the library even if your app
6c69ad0b184e Clarified inline function documentation, removed obsolete Metrowerks compiler directive.
Sam Lantinga <slouken@libsdl.org>
parents: 7003
diff changeset
   237
   bypassed the inline version. The SDL_*_inline versions aren't guaranteed to
6c69ad0b184e Clarified inline function documentation, removed obsolete Metrowerks compiler directive.
Sam Lantinga <slouken@libsdl.org>
parents: 7003
diff changeset
   238
   exist, so never call them directly; use SDL_* instead, and trust the system
6c69ad0b184e Clarified inline function documentation, removed obsolete Metrowerks compiler directive.
Sam Lantinga <slouken@libsdl.org>
parents: 7003
diff changeset
   239
   to give you the right thing.
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   240
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   241
   The benefit here is that you can dlsym() these functions, which you
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   242
   couldn't if you had macros, you can link against a foreign build of SDL
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   243
   even if you configured differently, and you can drop the unconfigured SDL
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   244
   headers into a project without #defining HAVE_MALLOC (etc) and still link.
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   245
*/
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   246
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   247
extern DECLSPEC void *SDLCALL SDL_malloc(size_t size);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   248
#ifdef HAVE_MALLOC
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   249
SDL_FORCE_INLINE void *SDL_malloc_inline(size_t size) { return malloc(size); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   250
#define SDL_malloc SDL_malloc_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   251
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   252
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   253
extern DECLSPEC void *SDLCALL SDL_calloc(size_t nmemb, size_t size);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   254
#ifdef HAVE_CALLOC
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   255
SDL_FORCE_INLINE void *SDL_calloc_inline(size_t nmemb, size_t size) { return calloc(nmemb, size); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   256
#define SDL_calloc SDL_calloc_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   257
#endif
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   258
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   259
extern DECLSPEC void *SDLCALL SDL_realloc(void *mem, size_t size);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   260
#ifdef HAVE_REALLOC
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   261
SDL_FORCE_INLINE void *SDL_realloc_inline(void *mem, size_t size) { return realloc(mem, size); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   262
#define SDL_realloc SDL_realloc_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   263
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   264
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   265
extern DECLSPEC void SDLCALL SDL_free(void *mem);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   266
#ifdef HAVE_FREE
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   267
SDL_FORCE_INLINE void SDL_free_inline(void *mem) { free(mem); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   268
#define SDL_free SDL_free_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   269
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   270
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   271
extern DECLSPEC char *SDLCALL SDL_getenv(const char *name);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   272
#ifdef HAVE_GETENV
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   273
SDL_FORCE_INLINE char *SDL_getenv_inline(const char *name) { return getenv(name); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   274
#define SDL_getenv SDL_getenv_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   275
#endif
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   276
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   277
extern DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value, int overwrite);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   278
#ifdef HAVE_SETENV
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   279
SDL_FORCE_INLINE int SDL_setenv_inline(const char *name, const char *value, int overwrite) { return setenv(name, value, overwrite); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   280
#define SDL_setenv SDL_setenv_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   281
#endif
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   282
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   283
extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *));
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   284
#ifdef HAVE_QSORT
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   285
SDL_FORCE_INLINE void SDL_qsort_inline(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *)) { return qsort(base, nmemb, size, compare); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   286
#define SDL_qsort SDL_qsort_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   287
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   288
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   289
extern DECLSPEC int SDLCALL SDL_abs(int x);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   290
#ifdef HAVE_ABS
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   291
SDL_FORCE_INLINE int SDL_abs_inline(int x) { return abs(x); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   292
#else
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   293
SDL_FORCE_INLINE int SDL_abs_inline(int x) { return ((x) < 0 ? -(x) : (x)); }
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   294
#endif
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   295
#define SDL_abs SDL_abs_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   296
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   297
/* !!! FIXME: these have side effects. You probably shouldn't use them. */
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   298
/* !!! FIXME: Maybe we do forceinline functions of SDL_mini, SDL_minf, etc? */
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   299
#define SDL_min(x, y) (((x) < (y)) ? (x) : (y))
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   300
#define SDL_max(x, y) (((x) > (y)) ? (x) : (y))
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   301
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   302
extern DECLSPEC int SDLCALL SDL_isdigit(int x);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   303
extern DECLSPEC int SDLCALL SDL_isspace(int x);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   304
extern DECLSPEC int SDLCALL SDL_toupper(int x);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   305
extern DECLSPEC int SDLCALL SDL_tolower(int x);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   306
#ifdef HAVE_CTYPE_H
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   307
SDL_FORCE_INLINE int SDL_isdigit_inline(int x) { return isdigit(x); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   308
SDL_FORCE_INLINE int SDL_isspace_inline(int x) { return isspace(x); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   309
SDL_FORCE_INLINE int SDL_toupper_inline(int x) { return toupper(x); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   310
SDL_FORCE_INLINE int SDL_tolower_inline(int x) { return tolower(x); }
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   311
#else
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   312
SDL_FORCE_INLINE int SDL_isdigit_inline(int x) { return ((x) >= '0') && ((x) <= '9'); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   313
SDL_FORCE_INLINE int SDL_isspace_inline(int x) { return ((x) == ' ') || ((x) == '\t') || ((x) == '\r') || ((x) == '\n'); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   314
SDL_FORCE_INLINE int SDL_toupper_inline(int x) { return ((x) >= 'a') && ((x) <= 'z') ? ('A'+((x)-'a')) : (x); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   315
SDL_FORCE_INLINE int SDL_tolower_inline(int x) { return ((x) >= 'A') && ((x) <= 'Z') ? ('a'+((x)-'A')) : (x); }
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   316
#endif
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   317
#define SDL_isdigit SDL_isdigit_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   318
#define SDL_isspace SDL_isspace_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   319
#define SDL_toupper SDL_toupper_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   320
#define SDL_tolower SDL_tolower_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   321
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   322
extern DECLSPEC void *SDLCALL SDL_memset(void *dst, int c, size_t len);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   323
#ifdef HAVE_MEMSET
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   324
SDL_FORCE_INLINE void *SDL_memset_inline(void *dst, int c, size_t len) { return memset(dst, c, len); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   325
#define SDL_memset SDL_memset_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   326
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   327
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   328
#define SDL_zero(x) SDL_memset(&(x), 0, sizeof((x)))
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   329
#define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x)))
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   330
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   331
/* !!! FIXME: does this _really_ beat memset() on any modern platform? */
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   332
SDL_FORCE_INLINE void SDL_memset4(void *dst, int val, size_t len)
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   333
{
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   334
#if defined(__GNUC__) && defined(i386)
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   335
    int u0, u1, u2;
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   336
    __asm__ __volatile__ (
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   337
        "cld \n\t"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   338
        "rep ; stosl \n\t"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   339
        : "=&D" (u0), "=&a" (u1), "=&c" (u2)
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   340
        : "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, len))
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   341
        : "memory"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   342
    );
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   343
/* !!! FIXME: amd64? */
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   344
#else
7015
e3cba60c0f0a Fixed bug 1764 - Integer Precision Loss During Compilation
Sam Lantinga <slouken@libsdl.org>
parents: 7011
diff changeset
   345
    size_t _n = (len + 3) / 4;
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   346
    Uint32 *_p = SDL_static_cast(Uint32 *, dst);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   347
    Uint32 _val = (val);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   348
    if (len == 0)
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   349
        return;
7015
e3cba60c0f0a Fixed bug 1764 - Integer Precision Loss During Compilation
Sam Lantinga <slouken@libsdl.org>
parents: 7011
diff changeset
   350
    switch (len % 4)
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   351
    {
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   352
        case 0: do {    *_p++ = _val;
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   353
        case 3:         *_p++ = _val;
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   354
        case 2:         *_p++ = _val;
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   355
        case 1:         *_p++ = _val;
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   356
        } while ( --_n );
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   357
    }
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   358
#endif
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   359
}
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   360
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   361
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   362
extern DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src, size_t len);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   363
#if defined(__MACOSX__)
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   364
SDL_FORCE_INLINE void *SDL_memcpy_inline(void *dst, const void *src, size_t len)
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   365
{
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   366
    /* We can count on memcpy existing on Mac OS X and being well-tuned. */
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   367
    return memcpy(dst, src, len);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   368
}
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   369
#define SDL_memcpy SDL_memcpy_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   370
#elif defined(__GNUC__) && defined(i386) && !defined(__WIN32__)
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   371
SDL_FORCE_INLINE void *SDL_memcpy_inline(void *dst, const void *src, size_t len)
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   372
{
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   373
    /* !!! FIXME: does this _really_ beat memcpy() on any modern platform? */
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   374
    /* !!! FIXME: shouldn't we just force the inputs to ecx/edi/esi instead of this tapdance with outputs? */
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   375
    /* !!! FIXME: amd64? */
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   376
    int u0, u1, u2;
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   377
    __asm__ __volatile__ (
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   378
        "cld \n\t"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   379
        "rep ; movsl \n\t"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   380
        "testb $2,%b4 \n\t"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   381
        "je 1f \n\t"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   382
        "movsw \n"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   383
        "1:\ttestb $1,%b4 \n\t"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   384
        "je 2f \n\t"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   385
        "movsb \n"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   386
        "2:"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   387
        : "=&c" (u0), "=&D" (u1), "=&S" (u2)
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   388
        : "0" (SDL_static_cast(unsigned, len)/4), "q" (len), "1" (dst), "2" (src)
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   389
        : "memory"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   390
    );
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   391
    return dst;
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   392
}
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   393
#define SDL_memcpy SDL_memcpy_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   394
#elif defined(HAVE_MEMCPY)
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   395
SDL_FORCE_INLINE void *SDL_memcpy_inline(void *dst, const void *src, size_t len)
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   396
{
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   397
    return memcpy(dst, src, len);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   398
}
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   399
#define SDL_memcpy SDL_memcpy_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   400
#elif defined(HAVE_BCOPY)  /* !!! FIXME: is there _really_ ever a time where you have bcopy and not memcpy? */
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   401
SDL_FORCE_INLINE void *SDL_memcpy_inline(void *dst, const void *src, size_t len)
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   402
{
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   403
    bcopy(src, dst, len);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   404
    return dst;
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   405
}
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   406
#define SDL_memcpy SDL_memcpy_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   407
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   408
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   409
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   410
SDL_FORCE_INLINE void *SDL_memcpy4(void *dst, const void *src, size_t dwords)
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   411
{
7006
ffcf28627e1c Fixed const correctness issue with C++, and fixed building SDL_memcpy4 with 32-bit gcc.
Sam Lantinga <slouken@libsdl.org>
parents: 7005
diff changeset
   412
#if defined(__GNUC__) && defined(i386)
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   413
    /* !!! FIXME: does this _really_ beat memcpy() on any modern platform? */
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   414
    /* !!! FIXME: shouldn't we just force the inputs to ecx/edi/esi instead of this tapdance with outputs? */
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   415
    int ecx, edi, esi;
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   416
    __asm__ __volatile__ (
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   417
        "cld \n\t"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   418
        "rep ; movsl \n\t"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   419
        : "=&c" (ecx), "=&D" (edi), "=&S" (esi)
7006
ffcf28627e1c Fixed const correctness issue with C++, and fixed building SDL_memcpy4 with 32-bit gcc.
Sam Lantinga <slouken@libsdl.org>
parents: 7005
diff changeset
   420
        : "0" (SDL_static_cast(unsigned, dwords)), "1" (dst), "2" (src)
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   421
        : "memory"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   422
    );
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   423
    return dst;
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   424
#else
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   425
    return SDL_memcpy(dst, src, dwords * 4);
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   426
#endif
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   427
}
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   428
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   429
extern DECLSPEC void *SDLCALL SDL_memmove(void *dst, const void *src, size_t len);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   430
#ifdef HAVE_MEMMOVE
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   431
SDL_FORCE_INLINE void *SDL_memmove_inline(void *dst, const void *src, size_t len) { return memmove(dst, src, len); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   432
#define SDL_memmove SDL_memmove_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   433
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   434
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   435
extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   436
#ifdef HAVE_MEMCMP
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   437
SDL_FORCE_INLINE int SDL_memcmp_inline(const void *s1, const void *s2, size_t len) { return memcmp(s1, s2, len); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   438
#define SDL_memcmp SDL_memcmp_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   439
#endif
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   440
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   441
extern DECLSPEC size_t SDLCALL SDL_strlen(const char *str);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   442
#ifdef HAVE_STRLEN
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   443
SDL_FORCE_INLINE size_t SDL_strlen_inline(const char *str) { return strlen(str); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   444
#define SDL_strlen SDL_strlen_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   445
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   446
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   447
extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t *wstr);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   448
#ifdef HAVE_WCSLEN
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   449
SDL_FORCE_INLINE size_t SDL_wcslen_inline(const wchar_t *wstr) { return wcslen(wstr); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   450
#define SDL_wcslen SDL_wcslen_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   451
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   452
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   453
extern DECLSPEC size_t SDLCALL SDL_wcslcpy(wchar_t *dst, const wchar_t *src, size_t maxlen);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   454
#ifdef HAVE_WCSLCPY
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   455
SDL_FORCE_INLINE size_t SDL_wcslcpy_inline(wchar_t *dst, const wchar_t *src, size_t maxlen) { return wcslcpy(dst, src, maxlen); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   456
#define SDL_wcslcpy SDL_wcslcpy_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   457
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   458
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   459
extern DECLSPEC size_t SDLCALL SDL_wcslcat(wchar_t *dst, const wchar_t *src, size_t maxlen);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   460
#ifdef HAVE_WCSLCAT
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   461
SDL_FORCE_INLINE size_t SDL_wcslcat_inline(wchar_t *dst, const wchar_t *src, size_t maxlen) { return wcslcat(dst, src, maxlen); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   462
#define SDL_wcslcat SDL_wcslcat_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   463
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   464
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   465
extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src, size_t maxlen);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   466
#ifdef HAVE_STRLCPY
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   467
SDL_FORCE_INLINE size_t SDL_strlcpy_inline(char *dst, const char *src, size_t maxlen) { return strlcpy(dst, src, maxlen); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   468
#define SDL_strlcpy SDL_strlcpy_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   469
#else
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   470
#endif
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   471
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   472
extern DECLSPEC size_t SDLCALL SDL_utf8strlcpy(char *dst, const char *src, size_t dst_bytes);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   473
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   474
extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src, size_t maxlen);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   475
#ifdef HAVE_STRLCAT
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   476
SDL_FORCE_INLINE size_t SDL_strlcat_inline(char *dst, const char *src, size_t maxlen) { return strlcat(dst, src, maxlen); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   477
#define SDL_strlcat SDL_strlcat_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   478
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   479
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   480
extern DECLSPEC char *SDLCALL SDL_strdup(const char *str);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   481
#ifdef HAVE_STRDUP
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   482
SDL_FORCE_INLINE char *SDL_strdup_inline(const char *str) { return strdup(str); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   483
#define SDL_strdup SDL_strdup_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   484
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   485
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   486
extern DECLSPEC char *SDLCALL SDL_strrev(char *str);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   487
#ifdef HAVE__STRREV
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   488
SDL_FORCE_INLINE char *SDL_strrev_inline(char *str) { return _strrev(str); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   489
#define SDL_strrev SDL_strrev_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   490
#endif
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   491
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   492
extern DECLSPEC char *SDLCALL SDL_strupr(char *str);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   493
#ifdef HAVE__STRUPR
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   494
SDL_FORCE_INLINE char *SDL_strupr_inline(char *str) { return _strupr(str); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   495
#define SDL_strupr SDL_strupr_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   496
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   497
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   498
extern DECLSPEC char *SDLCALL SDL_strlwr(char *str);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   499
#ifdef HAVE__STRLWR
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   500
SDL_FORCE_INLINE char *SDL_strlwr_inline(char *str) { return _strlwr(str); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   501
#define SDL_strlwr SDL_strlwr_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   502
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   503
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   504
extern DECLSPEC char *SDLCALL SDL_strchr(const char *str, int c);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   505
#ifdef HAVE_STRCHR
7006
ffcf28627e1c Fixed const correctness issue with C++, and fixed building SDL_memcpy4 with 32-bit gcc.
Sam Lantinga <slouken@libsdl.org>
parents: 7005
diff changeset
   506
SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { return (char*)strchr(str, c); }
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   507
#define SDL_strchr SDL_strchr_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   508
#elif defined(HAVE_INDEX)  /* !!! FIXME: is there anywhere that has this but not strchr? */
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   509
SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { return index(str, c); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   510
#define SDL_strchr SDL_strchr_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   511
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   512
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   513
extern DECLSPEC char *SDLCALL SDL_strrchr(const char *str, int c);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   514
#ifdef HAVE_STRRCHR
7008
e0f05e041a72 Fixed more const issues with C++
Sam Lantinga <slouken@libsdl.org>
parents: 7006
diff changeset
   515
SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) { return (char*)strrchr(str, c); }
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   516
#define SDL_strrchr SDL_strrchr_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   517
#elif defined(HAVE_RINDEX)  /* !!! FIXME: is there anywhere that has this but not strrchr? */
7008
e0f05e041a72 Fixed more const issues with C++
Sam Lantinga <slouken@libsdl.org>
parents: 7006
diff changeset
   518
SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) { return (char*)rindex(str, c); }
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   519
#define SDL_strrchr SDL_strrchr_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   520
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   521
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   522
extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   523
#ifdef HAVE_STRSTR
7008
e0f05e041a72 Fixed more const issues with C++
Sam Lantinga <slouken@libsdl.org>
parents: 7006
diff changeset
   524
SDL_FORCE_INLINE char *SDL_strstr_inline(const char *haystack, const char *needle) { return (char*)strstr(haystack, needle); }
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   525
#define SDL_strstr SDL_strstr_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   526
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   527
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   528
extern DECLSPEC char *SDLCALL SDL_ltoa(long value, char *str, int radix);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   529
#ifdef HAVE__LTOA
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   530
SDL_FORCE_INLINE char *SDL_ltoa_inline(long value, char *str, int radix) { return _ltoa(value, str, radix); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   531
#define SDL_ltoa SDL_ltoa_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   532
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   533
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   534
extern DECLSPEC char *SDLCALL SDL_itoa(int value, char *str, int radix);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   535
#ifdef HAVE_ITOA
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   536
SDL_FORCE_INLINE char *SDL_itoa_inline(int value, char *str, int radix) { return itoa(value, str, radix); }
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   537
#else
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   538
SDL_FORCE_INLINE char *SDL_itoa_inline(int value, char *str, int radix) { return SDL_ltoa((long)value, str, radix); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   539
#endif
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   540
#define SDL_itoa SDL_itoa_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   541
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   542
extern DECLSPEC char *SDLCALL SDL_ultoa(unsigned long value, char *str, int radix);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   543
#ifdef HAVE__ULTOA
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   544
SDL_FORCE_INLINE char *SDL_ultoa_inline(unsigned long value, char *str, int radix) { return _ultoa(value, str, radix); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   545
#define SDL_ultoa SDL_ultoa_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   546
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   547
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   548
extern DECLSPEC char *SDLCALL SDL_uitoa(unsigned int value, char *str, int radix);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   549
#ifdef HAVE__UITOA
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   550
SDL_FORCE_INLINE char *SDL_uitoa_inline(unsigned int value, char *str, int radix) { return _uitoa(value, str, radix); }
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   551
#else
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   552
SDL_FORCE_INLINE char *SDL_uitoa_inline(unsigned int value, char *str, int radix) { return SDL_ultoa((unsigned long)value, str, radix); }
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   553
#endif
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   554
#define SDL_uitoa SDL_uitoa_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   555
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   556
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   557
extern DECLSPEC long SDLCALL SDL_strtol(const char *str, char **endp, int base);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   558
#ifdef HAVE_STRTOL
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   559
SDL_FORCE_INLINE long SDL_strtol_inline(const char *str, char **endp, int base) { return strtol(str, endp, base); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   560
#define SDL_strtol SDL_strtol_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   561
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   562
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   563
extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *str, char **endp, int base);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   564
#ifdef HAVE_STRTOUL
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   565
SDL_FORCE_INLINE unsigned long SDLCALL SDL_strtoul_inline(const char *str, char **endp, int base) { return strtoul(str, endp, base); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   566
#define SDL_strtoul SDL_strtoul_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   567
#endif
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   568
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   569
extern DECLSPEC char *SDLCALL SDL_lltoa(Sint64 value, char *str, int radix);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   570
#ifdef HAVE__I64TOA
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   571
SDL_FORCE_INLINE char *SDL_lltoa_inline(Sint64 value, char *str, int radix) { return _i64toa(value, str, radix); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   572
#define SDL_lltoa SDL_lltoa_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   573
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   574
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   575
extern DECLSPEC char *SDLCALL SDL_ulltoa(Uint64 value, char *str, int radix);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   576
#ifdef HAVE__UI64TOA
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   577
SDL_FORCE_INLINE char *SDL_ulltoa_inline(Uint64 value, char *str, int radix) { return _ui64toa(value, str, radix); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   578
#define SDL_ulltoa SDL_ulltoa_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   579
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   580
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   581
extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *str, char **endp, int base);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   582
#ifdef HAVE_STRTOLL
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   583
SDL_FORCE_INLINE Sint64 SDL_strtoll_inline(const char *str, char **endp, int base) { return strtoll(str, endp, base); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   584
#define SDL_strtoll SDL_strtoll_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   585
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   586
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   587
extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *str, char **endp, int base);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   588
#ifdef HAVE_STRTOULL
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   589
SDL_FORCE_INLINE Uint64 SDL_strtoull_inline(const char *str, char **endp, int base) { return strtoull(str, endp, base); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   590
#define SDL_strtoull SDL_strtoull_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   591
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   592
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   593
extern DECLSPEC double SDLCALL SDL_strtod(const char *str, char **endp);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   594
#ifdef HAVE_STRTOD
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   595
SDL_FORCE_INLINE Uint64 SDL_strtod_inline(const char *str, char **endp) { return strtod(str, endp); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   596
#define SDL_strtod SDL_strtod_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   597
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   598
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   599
extern DECLSPEC int SDLCALL SDL_atoi(const char *str);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   600
#ifdef HAVE_ATOI
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   601
SDL_FORCE_INLINE int SDL_atoi_inline(const char *str) { return atoi(str); }
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   602
#else
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   603
SDL_FORCE_INLINE int SDL_atoi_inline(const char *str) { return SDL_strtol(str, NULL, 0); }
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   604
#endif
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   605
#define SDL_atoi SDL_atoi_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   606
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   607
extern DECLSPEC double SDLCALL SDL_atof(const char *str);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   608
#ifdef HAVE_ATOF
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   609
SDL_FORCE_INLINE double SDL_atof_inline(const char *str) { return (double) atof(str); }
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   610
#else
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   611
SDL_FORCE_INLINE double SDL_atof_inline(const char *str) { return SDL_strtod(str, NULL); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   612
#endif
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   613
#define SDL_atof SDL_atof_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   614
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   615
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   616
extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   617
#ifdef HAVE_STRCMP
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   618
SDL_FORCE_INLINE int SDL_strcmp_inline(const char *str1, const char *str2) { return strcmp(str1, str2); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   619
#define SDL_strcmp SDL_strcmp_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   620
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   621
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   622
extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   623
#ifdef HAVE_STRNCMP
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   624
SDL_FORCE_INLINE int SDL_strncmp_inline(const char *str1, const char *str2, size_t maxlen) { return strncmp(str1, str2, maxlen); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   625
#define SDL_strncmp SDL_strncmp_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   626
#endif
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   627
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   628
extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   629
#ifdef HAVE_STRCASECMP
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   630
SDL_FORCE_INLINE int SDL_strcasecmp_inline(const char *str1, const char *str2) { return strcasecmp(str1, str2); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   631
#define SDL_strcasecmp SDL_strcasecmp_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   632
#elif defined(HAVE__STRICMP)
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   633
SDL_FORCE_INLINE int SDL_strcasecmp_inline(const char *str1, const char *str2) { return _stricmp(str1, str2); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   634
#define SDL_strcasecmp SDL_strcasecmp_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   635
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   636
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   637
extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t len);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   638
#ifdef HAVE_STRNCASECMP
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   639
SDL_FORCE_INLINE int SDL_strncasecmp_inline(const char *str1, const char *str2, size_t len) { return strncasecmp(str1, str2, len); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   640
#define SDL_strncasecmp SDL_strncasecmp_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   641
#elif defined(HAVE__STRNICMP)
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   642
SDL_FORCE_INLINE int SDL_strncasecmp_inline(const char *str1, const char *str2, size_t len) { return _strnicmp(str1, str2, len); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   643
#define SDL_strncasecmp SDL_strncasecmp_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   644
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   645
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   646
/* Not doing SDL_*_inline functions for these, because of the varargs. */
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   647
extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, ...);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   648
#ifdef HAVE_SSCANF
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   649
#define SDL_sscanf sscanf
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   650
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   651
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   652
extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   653
#ifdef HAVE_SNPRINTF
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   654
#define SDL_snprintf snprintf
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   655
#endif
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   656
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   657
extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap);
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   658
#ifdef HAVE_VSNPRINTF
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   659
SDL_FORCE_INLINE int SDL_vsnprintf_inline(char *text, size_t maxlen, const char *fmt, va_list ap) { return vsnprintf(text, maxlen, fmt, ap); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   660
#define SDL_vsnprintf SDL_vsnprintf_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   661
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   662
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   663
#ifndef HAVE_M_PI
6627
23b7cef164ae We might actually have PI
Sam Lantinga <slouken@libsdl.org>
parents: 6610
diff changeset
   664
#ifndef M_PI
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   665
#define M_PI    3.14159265358979323846264338327950288   /* pi */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   666
#endif
6627
23b7cef164ae We might actually have PI
Sam Lantinga <slouken@libsdl.org>
parents: 6610
diff changeset
   667
#endif
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   668
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   669
extern DECLSPEC double SDLCALL SDL_atan(double x);
4873
67ad1c88dda0 Added atan implementation from uClibc
Sam Lantinga <slouken@libsdl.org>
parents: 4870
diff changeset
   670
#ifdef HAVE_ATAN
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   671
SDL_FORCE_INLINE double SDL_atan_inline(double x) { return atan(x); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   672
#define SDL_atan SDL_atan_inline
4873
67ad1c88dda0 Added atan implementation from uClibc
Sam Lantinga <slouken@libsdl.org>
parents: 4870
diff changeset
   673
#endif
67ad1c88dda0 Added atan implementation from uClibc
Sam Lantinga <slouken@libsdl.org>
parents: 4870
diff changeset
   674
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   675
extern DECLSPEC double SDLCALL SDL_atan2(double x, double y);
4870
d275c95ddc05 Added atan2 implementation from uClibc
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
   676
#ifdef HAVE_ATAN2
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   677
SDL_FORCE_INLINE double SDL_atan2_inline(double x, double y) { return atan2(x, y); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   678
#define SDL_atan2 SDL_atan2_inline
4870
d275c95ddc05 Added atan2 implementation from uClibc
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
   679
#endif
d275c95ddc05 Added atan2 implementation from uClibc
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
   680
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   681
extern DECLSPEC double SDLCALL SDL_ceil(double x);
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   682
#ifdef HAVE_CEIL
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   683
SDL_FORCE_INLINE double SDL_ceil_inline(double x) { return ceil(x); }
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   684
#else
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   685
SDL_FORCE_INLINE double SDL_ceil_inline(double x) { return (double)(int)((x)+0.5); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   686
#endif
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   687
#define SDL_ceil SDL_ceil_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   688
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   689
extern DECLSPEC double SDLCALL SDL_copysign(double x, double y);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   690
#ifdef HAVE_COPYSIGN
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   691
SDL_FORCE_INLINE double SDL_copysign_inline(double x, double y) { return copysign(x, y); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   692
#define SDL_copysign SDL_copysign_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   693
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   694
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   695
extern DECLSPEC double SDLCALL SDL_cos(double x);
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   696
#ifdef HAVE_COS
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   697
SDL_FORCE_INLINE double SDL_cos_inline(double x) { return cos(x); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   698
#define SDL_cos SDL_cos_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   699
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   700
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   701
extern DECLSPEC float SDLCALL SDL_cosf(float x);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   702
#ifdef HAVE_COSF
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   703
SDL_FORCE_INLINE float SDL_cosf_inline(float x) { return cosf(x); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   704
#else
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   705
SDL_FORCE_INLINE float SDL_cosf_inline(float x) { return (float)SDL_cos((double)x); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   706
#endif
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   707
#define SDL_cosf SDL_cosf_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   708
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   709
extern DECLSPEC double SDLCALL SDL_fabs(double x);
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   710
#ifdef HAVE_FABS
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   711
SDL_FORCE_INLINE double SDL_fabs_inline(double x) { return fabs(x); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   712
#define SDL_fabs SDL_fabs_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   713
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   714
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   715
extern DECLSPEC double SDLCALL SDL_floor(double x);
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   716
#ifdef HAVE_FLOOR
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   717
SDL_FORCE_INLINE double SDL_floor_inline(double x) { return floor(x); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   718
#define SDL_floor SDL_floor_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   719
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   720
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   721
extern DECLSPEC double SDLCALL SDL_log(double x);
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   722
#ifdef HAVE_LOG
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   723
SDL_FORCE_INLINE double SDL_log_inline(double x) { return log(x); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   724
#define SDL_log SDL_log_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   725
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   726
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   727
extern DECLSPEC double SDLCALL SDL_pow(double x, double y);
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   728
#ifdef HAVE_POW
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   729
SDL_FORCE_INLINE double SDL_pow_inline(double x, double y) { return pow(x, y); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   730
#define SDL_pow SDL_pow_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   731
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   732
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   733
extern DECLSPEC double SDLCALL SDL_scalbn(double x, int n);
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   734
#ifdef HAVE_SCALBN
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   735
SDL_FORCE_INLINE double SDL_scalbn_inline(double x, int n) { return scalbn(x, n); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   736
#define SDL_scalbn SDL_scalbn_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   737
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   738
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   739
extern DECLSPEC double SDLCALL SDL_sin(double x);
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   740
#ifdef HAVE_SIN
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   741
SDL_FORCE_INLINE double SDL_sin_inline(double x) { return sin(x); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   742
#define SDL_sin SDL_sin_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   743
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   744
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   745
extern DECLSPEC float SDLCALL SDL_sinf(float x);
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   746
#ifdef HAVE_SINF
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   747
SDL_FORCE_INLINE float SDL_sinf_inline(float x) { return sinf(x); }
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   748
#else
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   749
SDL_FORCE_INLINE float SDL_sinf_inline(float x) { return (float)SDL_sin((double)x); }
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   750
#endif
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   751
#define SDL_sinf SDL_sinf_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   752
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   753
extern DECLSPEC double SDLCALL SDL_sqrt(double x);
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   754
#ifdef HAVE_SQRT
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   755
SDL_FORCE_INLINE double SDL_sqrt_inline(double x) { return sqrt(x); }
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   756
#define SDL_sqrt SDL_sqrt_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   757
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   758
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   759
/* The SDL implementation of iconv() returns these error codes */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   760
#define SDL_ICONV_ERROR		(size_t)-1
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   761
#define SDL_ICONV_E2BIG		(size_t)-2
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   762
#define SDL_ICONV_EILSEQ	(size_t)-3
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   763
#define SDL_ICONV_EINVAL	(size_t)-4
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   764
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   765
/* SDL_iconv_* are now always real symbols/types, not macros or inlined. */
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   766
typedef struct _SDL_iconv_t *SDL_iconv_t;
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   767
extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode,
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   768
                                                   const char *fromcode);
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   769
extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd);
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   770
extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf,
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   771
                                         size_t * inbytesleft, char **outbuf,
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   772
                                         size_t * outbytesleft);
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   773
/**
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   774
 *  This function converts a string between encodings in one pass, returning a
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   775
 *  string that must be freed with SDL_free() or NULL on error.
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   776
 */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   777
extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode,
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   778
                                               const char *fromcode,
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   779
                                               const char *inbuf,
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   780
                                               size_t inbytesleft);
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   781
#define SDL_iconv_utf8_locale(S)	SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1)
6610
4032f8efdfe7 It turns out that UCS2 and UCS4 are defined as big-endian encodings
Sam Lantinga <slouken@libsdl.org>
parents: 6594
diff changeset
   782
#define SDL_iconv_utf8_ucs2(S)		(Uint16 *)SDL_iconv_string("UCS-2-INTERNAL", "UTF-8", S, SDL_strlen(S)+1)
4032f8efdfe7 It turns out that UCS2 and UCS4 are defined as big-endian encodings
Sam Lantinga <slouken@libsdl.org>
parents: 6594
diff changeset
   783
#define SDL_iconv_utf8_ucs4(S)		(Uint32 *)SDL_iconv_string("UCS-4-INTERNAL", "UTF-8", S, SDL_strlen(S)+1)
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   784
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   785
/* Ends C function definitions when using C++ */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   786
#ifdef __cplusplus
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   787
/* *INDENT-OFF* */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   788
}
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   789
/* *INDENT-ON* */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   790
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   791
#include "close_code.h"
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   792
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   793
#endif /* _SDL_stdinc_h */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   794
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   795
/* vi: set ts=4 sw=4 expandtab: */