include/SDL_stdinc.h
author Ryan C. Gordon <icculus@icculus.org>
Mon, 08 Apr 2013 18:37:50 -0400
changeset 7059 cd194e03c1da
parent 7057 c1563f514b5b
child 7076 1666f7a7494e
child 8460 f483e8bdae3c
permissions -rw-r--r--
More const_cast fixes for C++ apps using the public headers (thanks, Martin!).
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
#ifdef HAVE_SYS_TYPES_H
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    34
#include <sys/types.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    35
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    36
#ifdef HAVE_STDIO_H
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    37
#include <stdio.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    38
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    39
#if defined(STDC_HEADERS)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    40
# include <stdlib.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    41
# include <stddef.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    42
# include <stdarg.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    43
#else
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    44
# if defined(HAVE_STDLIB_H)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    45
#  include <stdlib.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    46
# elif defined(HAVE_MALLOC_H)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    47
#  include <malloc.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    48
# endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    49
# if defined(HAVE_STDDEF_H)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    50
#  include <stddef.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    51
# endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    52
# if defined(HAVE_STDARG_H)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    53
#  include <stdarg.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    54
# endif
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
#ifdef HAVE_STRING_H
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    57
# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    58
#  include <memory.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    59
# endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    60
# include <string.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    61
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    62
#ifdef HAVE_STRINGS_H
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    63
# include <strings.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    64
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    65
#if defined(HAVE_INTTYPES_H)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    66
# include <inttypes.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    67
#elif defined(HAVE_STDINT_H)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    68
# include <stdint.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    69
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    70
#ifdef HAVE_CTYPE_H
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    71
# include <ctype.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    72
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    73
#ifdef HAVE_MATH_H
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    74
# include <math.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    75
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    76
#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    77
# include <iconv.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    78
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    79
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
 *  The number of elements in an array.
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    82
 */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    83
#define SDL_arraysize(array)	(sizeof(array)/sizeof(array[0]))
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    84
#define SDL_TABLESIZE(table)	SDL_arraysize(table)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    85
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
 *  \name Cast operators
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    88
 *  
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    89
 *  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
    90
 *  -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
    91
 */
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
#ifdef __cplusplus
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    94
#define SDL_reinterpret_cast(type, expression) reinterpret_cast<type>(expression)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    95
#define SDL_static_cast(type, expression) static_cast<type>(expression)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    96
#else
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    97
#define SDL_reinterpret_cast(type, expression) ((type)(expression))
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    98
#define SDL_static_cast(type, expression) ((type)(expression))
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
    99
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   100
/*@}*//*Cast operators*/
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   101
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   102
/* Define a four character code as a Uint32 */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   103
#define SDL_FOURCC(A, B, C, D) \
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   104
    ((SDL_static_cast(Uint32, SDL_static_cast(Uint8, (A))) << 0) | \
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   105
     (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (B))) << 8) | \
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   106
     (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (C))) << 16) | \
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   107
     (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (D))) << 24))
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   108
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
 *  \name Basic data types
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   111
 */
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
typedef enum
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   115
{
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   116
    SDL_FALSE = 0,
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   117
    SDL_TRUE = 1
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   118
} SDL_bool;
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   119
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
 * \brief A signed 8-bit integer type.
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   122
 */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   123
typedef int8_t Sint8;
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   124
/**
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   125
 * \brief An unsigned 8-bit integer type.
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   126
 */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   127
typedef uint8_t Uint8;
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   128
/**
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   129
 * \brief A signed 16-bit integer type.
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   130
 */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   131
typedef int16_t Sint16;
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   132
/**
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   133
 * \brief An unsigned 16-bit integer type.
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   134
 */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   135
typedef uint16_t Uint16;
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   136
/**
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   137
 * \brief A signed 32-bit integer type.
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   138
 */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   139
typedef int32_t Sint32;
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   140
/**
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   141
 * \brief An unsigned 32-bit integer type.
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   142
 */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   143
typedef uint32_t Uint32;
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   144
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
 * \brief A signed 64-bit integer type.
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   147
 */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   148
typedef int64_t Sint64;
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   149
/**
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   150
 * \brief An unsigned 64-bit integer type.
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   151
 */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   152
typedef uint64_t Uint64;
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   153
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   154
/*@}*//*Basic data types*/
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   155
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
#define SDL_COMPILE_TIME_ASSERT(name, x)               \
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   158
       typedef int SDL_dummy_ ## name[(x) * 2 - 1]
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   159
/** \cond */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   160
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   161
SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1);
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   162
SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1);
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   163
SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2);
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   164
SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2);
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   165
SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4);
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   166
SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4);
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   167
SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8);
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   168
SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   169
#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   170
/** \endcond */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   171
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   172
/* 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
   173
   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
   174
   enums having the size of an int must be enabled.
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   175
   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
   176
*/
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
/** \cond */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   179
#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
   180
#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
   181
   /* 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
   182
typedef enum
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   183
{
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   184
    DUMMY_ENUM_VALUE
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   185
} SDL_DUMMY_ENUM;
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   186
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   187
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
   188
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   189
#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   190
/** \endcond */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   191
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   192
#include "begin_code.h"
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   193
/* Set up for C function definitions, even when using C++ */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   194
#ifdef __cplusplus
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   195
/* *INDENT-OFF* */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   196
extern "C" {
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   197
/* *INDENT-ON* */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   198
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   199
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   200
#if defined(HAVE_ALLOCA) && !defined(alloca)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   201
# if defined(HAVE_ALLOCA_H)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   202
#  include <alloca.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   203
# elif defined(__GNUC__)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   204
#  define alloca __builtin_alloca
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   205
# elif defined(_MSC_VER)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   206
#  include <malloc.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   207
#  define alloca _alloca
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   208
# elif defined(__WATCOMC__)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   209
#  include <malloc.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   210
# elif defined(__BORLANDC__)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   211
#  include <malloc.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   212
# elif defined(__DMC__)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   213
#  include <stdlib.h>
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   214
# elif defined(__AIX__)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   215
#pragma alloca
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   216
# elif defined(__MRC__)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   217
void *alloca(unsigned);
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   218
# else
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   219
char *alloca();
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   220
# endif
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
#ifdef HAVE_ALLOCA
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   223
#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
   224
#define SDL_stack_free(data)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   225
#else
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   226
#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
   227
#define SDL_stack_free(data)            SDL_free(data)
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   228
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   229
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   230
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   231
/* SDL stdinc inline functions:
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   232
7005
6c69ad0b184e Clarified inline function documentation, removed obsolete Metrowerks compiler directive.
Sam Lantinga <slouken@libsdl.org>
parents: 7003
diff changeset
   233
   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
   234
   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
   235
   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
   236
   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
   237
   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
   238
   to give you the right thing.
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   239
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   240
   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
   241
   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
   242
   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
   243
   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
   244
*/
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   245
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   246
extern DECLSPEC void *SDLCALL SDL_malloc(size_t size);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   247
#ifdef HAVE_MALLOC
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   248
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
   249
#define SDL_malloc SDL_malloc_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   250
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   251
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   252
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
   253
#ifdef HAVE_CALLOC
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   254
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
   255
#define SDL_calloc SDL_calloc_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   256
#endif
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   257
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   258
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
   259
#ifdef HAVE_REALLOC
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   260
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
   261
#define SDL_realloc SDL_realloc_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   262
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   263
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   264
extern DECLSPEC void SDLCALL SDL_free(void *mem);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   265
#ifdef HAVE_FREE
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   266
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
   267
#define SDL_free SDL_free_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   268
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   269
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   270
extern DECLSPEC char *SDLCALL SDL_getenv(const char *name);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   271
#ifdef HAVE_GETENV
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   272
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
   273
#define SDL_getenv SDL_getenv_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   274
#endif
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   275
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   276
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
   277
#ifdef HAVE_SETENV
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   278
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
   279
#define SDL_setenv SDL_setenv_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   280
#endif
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   281
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   282
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
   283
#ifdef HAVE_QSORT
7057
c1563f514b5b Corrected some stdinc inline functions (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7036
diff changeset
   284
SDL_FORCE_INLINE void SDL_qsort_inline(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *)) { qsort(base, nmemb, size, compare); }
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   285
#define SDL_qsort SDL_qsort_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   286
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   287
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   288
extern DECLSPEC int SDLCALL SDL_abs(int x);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   289
#ifdef HAVE_ABS
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   290
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
   291
#else
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   292
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
   293
#endif
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   294
#define SDL_abs SDL_abs_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   295
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   296
/* !!! 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
   297
/* !!! 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
   298
#define SDL_min(x, y) (((x) < (y)) ? (x) : (y))
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   299
#define SDL_max(x, y) (((x) > (y)) ? (x) : (y))
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   300
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   301
extern DECLSPEC int SDLCALL SDL_isdigit(int x);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   302
extern DECLSPEC int SDLCALL SDL_isspace(int x);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   303
extern DECLSPEC int SDLCALL SDL_toupper(int x);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   304
extern DECLSPEC int SDLCALL SDL_tolower(int x);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   305
#ifdef HAVE_CTYPE_H
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   306
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
   307
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
   308
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
   309
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
   310
#else
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   311
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
   312
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
   313
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
   314
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
   315
#endif
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   316
#define SDL_isdigit SDL_isdigit_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   317
#define SDL_isspace SDL_isspace_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   318
#define SDL_toupper SDL_toupper_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   319
#define SDL_tolower SDL_tolower_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   320
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   321
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
   322
#ifdef HAVE_MEMSET
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   323
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
   324
#define SDL_memset SDL_memset_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   325
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   326
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   327
#define SDL_zero(x) SDL_memset(&(x), 0, sizeof((x)))
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   328
#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
   329
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   330
/* !!! FIXME: does this _really_ beat memset() on any modern platform? */
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   331
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
   332
{
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   333
#if defined(__GNUC__) && defined(i386)
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   334
    int u0, u1, u2;
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   335
    __asm__ __volatile__ (
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   336
        "cld \n\t"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   337
        "rep ; stosl \n\t"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   338
        : "=&D" (u0), "=&a" (u1), "=&c" (u2)
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   339
        : "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, len))
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   340
        : "memory"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   341
    );
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   342
/* !!! FIXME: amd64? */
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   343
#else
7015
e3cba60c0f0a Fixed bug 1764 - Integer Precision Loss During Compilation
Sam Lantinga <slouken@libsdl.org>
parents: 7011
diff changeset
   344
    size_t _n = (len + 3) / 4;
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   345
    Uint32 *_p = SDL_static_cast(Uint32 *, dst);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   346
    Uint32 _val = (val);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   347
    if (len == 0)
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   348
        return;
7015
e3cba60c0f0a Fixed bug 1764 - Integer Precision Loss During Compilation
Sam Lantinga <slouken@libsdl.org>
parents: 7011
diff changeset
   349
    switch (len % 4)
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   350
    {
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   351
        case 0: do {    *_p++ = _val;
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   352
        case 3:         *_p++ = _val;
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   353
        case 2:         *_p++ = _val;
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   354
        case 1:         *_p++ = _val;
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   355
        } while ( --_n );
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   356
    }
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   357
#endif
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   358
}
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   359
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   360
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   361
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
   362
#if defined(__MACOSX__)
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   363
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
   364
{
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   365
    /* 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
   366
    return memcpy(dst, src, len);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   367
}
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   368
#define SDL_memcpy SDL_memcpy_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   369
#elif defined(__GNUC__) && defined(i386) && !defined(__WIN32__)
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   370
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
   371
{
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   372
    /* !!! FIXME: does this _really_ beat memcpy() on any modern platform? */
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   373
    /* !!! 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
   374
    /* !!! FIXME: amd64? */
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   375
    int u0, u1, u2;
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   376
    __asm__ __volatile__ (
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   377
        "cld \n\t"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   378
        "rep ; movsl \n\t"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   379
        "testb $2,%b4 \n\t"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   380
        "je 1f \n\t"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   381
        "movsw \n"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   382
        "1:\ttestb $1,%b4 \n\t"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   383
        "je 2f \n\t"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   384
        "movsb \n"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   385
        "2:"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   386
        : "=&c" (u0), "=&D" (u1), "=&S" (u2)
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   387
        : "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
   388
        : "memory"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   389
    );
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   390
    return dst;
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   391
}
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   392
#define SDL_memcpy SDL_memcpy_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   393
#elif defined(HAVE_MEMCPY)
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   394
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
   395
{
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   396
    return memcpy(dst, src, len);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   397
}
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   398
#define SDL_memcpy SDL_memcpy_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   399
#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
   400
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
   401
{
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   402
    bcopy(src, dst, len);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   403
    return dst;
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   404
}
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   405
#define SDL_memcpy SDL_memcpy_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   406
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   407
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   408
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   409
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
   410
{
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
   411
#if defined(__GNUC__) && defined(i386)
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   412
    /* !!! FIXME: does this _really_ beat memcpy() on any modern platform? */
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   413
    /* !!! 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
   414
    int ecx, edi, esi;
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   415
    __asm__ __volatile__ (
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   416
        "cld \n\t"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   417
        "rep ; movsl \n\t"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   418
        : "=&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
   419
        : "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
   420
        : "memory"
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   421
    );
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   422
    return dst;
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   423
#else
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   424
    return SDL_memcpy(dst, src, dwords * 4);
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   425
#endif
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   426
}
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   427
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   428
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
   429
#ifdef HAVE_MEMMOVE
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   430
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
   431
#define SDL_memmove SDL_memmove_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   432
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   433
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   434
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
   435
#ifdef HAVE_MEMCMP
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   436
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
   437
#define SDL_memcmp SDL_memcmp_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   438
#endif
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   439
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   440
extern DECLSPEC size_t SDLCALL SDL_strlen(const char *str);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   441
#ifdef HAVE_STRLEN
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   442
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
   443
#define SDL_strlen SDL_strlen_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   444
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   445
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   446
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
   447
#ifdef HAVE_WCSLEN
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   448
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
   449
#define SDL_wcslen SDL_wcslen_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   450
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   451
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   452
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
   453
#ifdef HAVE_WCSLCPY
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   454
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
   455
#define SDL_wcslcpy SDL_wcslcpy_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   456
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   457
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   458
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
   459
#ifdef HAVE_WCSLCAT
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   460
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
   461
#define SDL_wcslcat SDL_wcslcat_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   462
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   463
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   464
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
   465
#ifdef HAVE_STRLCPY
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   466
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
   467
#define SDL_strlcpy SDL_strlcpy_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   468
#else
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   469
#endif
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   470
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   471
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
   472
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   473
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
   474
#ifdef HAVE_STRLCAT
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   475
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
   476
#define SDL_strlcat SDL_strlcat_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   477
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   478
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   479
extern DECLSPEC char *SDLCALL SDL_strdup(const char *str);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   480
#ifdef HAVE_STRDUP
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   481
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
   482
#define SDL_strdup SDL_strdup_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   483
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   484
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   485
extern DECLSPEC char *SDLCALL SDL_strrev(char *str);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   486
#ifdef HAVE__STRREV
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   487
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
   488
#define SDL_strrev SDL_strrev_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   489
#endif
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   490
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   491
extern DECLSPEC char *SDLCALL SDL_strupr(char *str);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   492
#ifdef HAVE__STRUPR
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   493
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
   494
#define SDL_strupr SDL_strupr_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   495
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   496
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   497
extern DECLSPEC char *SDLCALL SDL_strlwr(char *str);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   498
#ifdef HAVE__STRLWR
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   499
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
   500
#define SDL_strlwr SDL_strlwr_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   501
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   502
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   503
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
   504
#ifdef HAVE_STRCHR
7059
cd194e03c1da More const_cast fixes for C++ apps using the public headers (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7057
diff changeset
   505
SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) {
cd194e03c1da More const_cast fixes for C++ apps using the public headers (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7057
diff changeset
   506
#ifdef __cplusplus
cd194e03c1da More const_cast fixes for C++ apps using the public headers (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7057
diff changeset
   507
return const_cast<char*>(strchr(str, c));
cd194e03c1da More const_cast fixes for C++ apps using the public headers (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7057
diff changeset
   508
#else
cd194e03c1da More const_cast fixes for C++ apps using the public headers (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7057
diff changeset
   509
return (char*)strchr(str, c);
cd194e03c1da More const_cast fixes for C++ apps using the public headers (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7057
diff changeset
   510
#endif
cd194e03c1da More const_cast fixes for C++ apps using the public headers (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7057
diff changeset
   511
}
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   512
#define SDL_strchr SDL_strchr_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   513
#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
   514
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
   515
#define SDL_strchr SDL_strchr_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   516
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   517
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   518
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
   519
#ifdef HAVE_STRRCHR
7057
c1563f514b5b Corrected some stdinc inline functions (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7036
diff changeset
   520
SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) {
c1563f514b5b Corrected some stdinc inline functions (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7036
diff changeset
   521
#ifdef __cplusplus
c1563f514b5b Corrected some stdinc inline functions (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7036
diff changeset
   522
return const_cast<char*>(strrchr(str, c));
c1563f514b5b Corrected some stdinc inline functions (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7036
diff changeset
   523
#else
c1563f514b5b Corrected some stdinc inline functions (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7036
diff changeset
   524
return (char*)strrchr(str, c);
c1563f514b5b Corrected some stdinc inline functions (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7036
diff changeset
   525
#endif
c1563f514b5b Corrected some stdinc inline functions (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7036
diff changeset
   526
}
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   527
#define SDL_strrchr SDL_strrchr_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   528
#elif defined(HAVE_RINDEX)  /* !!! FIXME: is there anywhere that has this but not strrchr? */
7057
c1563f514b5b Corrected some stdinc inline functions (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7036
diff changeset
   529
SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) {
c1563f514b5b Corrected some stdinc inline functions (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7036
diff changeset
   530
#ifdef __cplusplus
c1563f514b5b Corrected some stdinc inline functions (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7036
diff changeset
   531
return const_cast<char*>(rindex(str, c));
c1563f514b5b Corrected some stdinc inline functions (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7036
diff changeset
   532
#else
c1563f514b5b Corrected some stdinc inline functions (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7036
diff changeset
   533
return (char*)rindex(str, c);
c1563f514b5b Corrected some stdinc inline functions (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7036
diff changeset
   534
#endif
c1563f514b5b Corrected some stdinc inline functions (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7036
diff changeset
   535
}
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   536
#define SDL_strrchr SDL_strrchr_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   537
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   538
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   539
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
   540
#ifdef HAVE_STRSTR
7059
cd194e03c1da More const_cast fixes for C++ apps using the public headers (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7057
diff changeset
   541
SDL_FORCE_INLINE char *SDL_strstr_inline(const char *haystack, const char *needle) {
cd194e03c1da More const_cast fixes for C++ apps using the public headers (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7057
diff changeset
   542
#ifdef __cplusplus
cd194e03c1da More const_cast fixes for C++ apps using the public headers (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7057
diff changeset
   543
return const_cast<char*>(strstr(haystack, needle));
cd194e03c1da More const_cast fixes for C++ apps using the public headers (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7057
diff changeset
   544
#else
cd194e03c1da More const_cast fixes for C++ apps using the public headers (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7057
diff changeset
   545
return (char*)strstr(haystack, needle);
cd194e03c1da More const_cast fixes for C++ apps using the public headers (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7057
diff changeset
   546
#endif
cd194e03c1da More const_cast fixes for C++ apps using the public headers (thanks, Martin!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7057
diff changeset
   547
}
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   548
#define SDL_strstr SDL_strstr_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   549
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   550
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   551
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
   552
#ifdef HAVE__LTOA
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   553
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
   554
#define SDL_ltoa SDL_ltoa_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   555
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   556
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   557
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
   558
#ifdef HAVE_ITOA
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   559
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
   560
#else
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   561
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
   562
#endif
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   563
#define SDL_itoa SDL_itoa_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   564
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   565
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
   566
#ifdef HAVE__ULTOA
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   567
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
   568
#define SDL_ultoa SDL_ultoa_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   569
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   570
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   571
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
   572
#ifdef HAVE__UITOA
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   573
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
   574
#else
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   575
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
   576
#endif
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   577
#define SDL_uitoa SDL_uitoa_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   578
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   579
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   580
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
   581
#ifdef HAVE_STRTOL
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   582
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
   583
#define SDL_strtol SDL_strtol_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   584
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   585
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   586
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
   587
#ifdef HAVE_STRTOUL
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   588
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
   589
#define SDL_strtoul SDL_strtoul_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   590
#endif
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   591
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   592
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
   593
#ifdef HAVE__I64TOA
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   594
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
   595
#define SDL_lltoa SDL_lltoa_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   596
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   597
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   598
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
   599
#ifdef HAVE__UI64TOA
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   600
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
   601
#define SDL_ulltoa SDL_ulltoa_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   602
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   603
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   604
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
   605
#ifdef HAVE_STRTOLL
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   606
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
   607
#define SDL_strtoll SDL_strtoll_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   608
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   609
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   610
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
   611
#ifdef HAVE_STRTOULL
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   612
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
   613
#define SDL_strtoull SDL_strtoull_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   614
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   615
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   616
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
   617
#ifdef HAVE_STRTOD
7036
8c891504e325 Corrected function signature on SDL_strtod_inline() (thanks, Axel!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7015
diff changeset
   618
SDL_FORCE_INLINE double SDL_strtod_inline(const char *str, char **endp) { return strtod(str, endp); }
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   619
#define SDL_strtod SDL_strtod_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_atoi(const char *str);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   623
#ifdef HAVE_ATOI
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   624
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
   625
#else
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   626
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
   627
#endif
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   628
#define SDL_atoi SDL_atoi_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   629
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   630
extern DECLSPEC double SDLCALL SDL_atof(const char *str);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   631
#ifdef HAVE_ATOF
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   632
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
   633
#else
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   634
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
   635
#endif
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   636
#define SDL_atof SDL_atof_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   637
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   638
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   639
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
   640
#ifdef HAVE_STRCMP
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   641
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
   642
#define SDL_strcmp SDL_strcmp_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   643
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   644
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   645
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
   646
#ifdef HAVE_STRNCMP
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   647
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
   648
#define SDL_strncmp SDL_strncmp_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   649
#endif
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   650
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   651
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
   652
#ifdef HAVE_STRCASECMP
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   653
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
   654
#define SDL_strcasecmp SDL_strcasecmp_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   655
#elif defined(HAVE__STRICMP)
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   656
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
   657
#define SDL_strcasecmp SDL_strcasecmp_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   658
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   659
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   660
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
   661
#ifdef HAVE_STRNCASECMP
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   662
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
   663
#define SDL_strncasecmp SDL_strncasecmp_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   664
#elif defined(HAVE__STRNICMP)
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   665
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
   666
#define SDL_strncasecmp SDL_strncasecmp_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   667
#endif
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
/* 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
   670
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
   671
#ifdef HAVE_SSCANF
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   672
#define SDL_sscanf sscanf
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   673
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   674
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   675
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
   676
#ifdef HAVE_SNPRINTF
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   677
#define SDL_snprintf snprintf
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   678
#endif
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   679
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   680
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
   681
#ifdef HAVE_VSNPRINTF
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   682
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
   683
#define SDL_vsnprintf SDL_vsnprintf_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   684
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   685
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   686
#ifndef HAVE_M_PI
6627
23b7cef164ae We might actually have PI
Sam Lantinga <slouken@libsdl.org>
parents: 6610
diff changeset
   687
#ifndef M_PI
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   688
#define M_PI    3.14159265358979323846264338327950288   /* pi */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   689
#endif
6627
23b7cef164ae We might actually have PI
Sam Lantinga <slouken@libsdl.org>
parents: 6610
diff changeset
   690
#endif
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   691
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   692
extern DECLSPEC double SDLCALL SDL_atan(double x);
4873
67ad1c88dda0 Added atan implementation from uClibc
Sam Lantinga <slouken@libsdl.org>
parents: 4870
diff changeset
   693
#ifdef HAVE_ATAN
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   694
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
   695
#define SDL_atan SDL_atan_inline
4873
67ad1c88dda0 Added atan implementation from uClibc
Sam Lantinga <slouken@libsdl.org>
parents: 4870
diff changeset
   696
#endif
67ad1c88dda0 Added atan implementation from uClibc
Sam Lantinga <slouken@libsdl.org>
parents: 4870
diff changeset
   697
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   698
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
   699
#ifdef HAVE_ATAN2
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   700
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
   701
#define SDL_atan2 SDL_atan2_inline
4870
d275c95ddc05 Added atan2 implementation from uClibc
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
   702
#endif
d275c95ddc05 Added atan2 implementation from uClibc
Sam Lantinga <slouken@libsdl.org>
parents: 4763
diff changeset
   703
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   704
extern DECLSPEC double SDLCALL SDL_ceil(double x);
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   705
#ifdef HAVE_CEIL
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   706
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
   707
#else
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   708
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
   709
#endif
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   710
#define SDL_ceil SDL_ceil_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   711
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   712
extern DECLSPEC double SDLCALL SDL_copysign(double x, double y);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   713
#ifdef HAVE_COPYSIGN
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   714
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
   715
#define SDL_copysign SDL_copysign_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   716
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   717
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   718
extern DECLSPEC double SDLCALL SDL_cos(double x);
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   719
#ifdef HAVE_COS
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   720
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
   721
#define SDL_cos SDL_cos_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   722
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   723
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   724
extern DECLSPEC float SDLCALL SDL_cosf(float x);
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   725
#ifdef HAVE_COSF
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   726
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
   727
#else
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   728
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
   729
#endif
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   730
#define SDL_cosf SDL_cosf_inline
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   731
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   732
extern DECLSPEC double SDLCALL SDL_fabs(double x);
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   733
#ifdef HAVE_FABS
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   734
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
   735
#define SDL_fabs SDL_fabs_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   736
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   737
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   738
extern DECLSPEC double SDLCALL SDL_floor(double x);
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   739
#ifdef HAVE_FLOOR
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   740
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
   741
#define SDL_floor SDL_floor_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   742
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   743
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   744
extern DECLSPEC double SDLCALL SDL_log(double x);
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   745
#ifdef HAVE_LOG
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   746
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
   747
#define SDL_log SDL_log_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   748
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   749
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   750
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
   751
#ifdef HAVE_POW
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   752
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
   753
#define SDL_pow SDL_pow_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   754
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   755
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   756
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
   757
#ifdef HAVE_SCALBN
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   758
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
   759
#define SDL_scalbn SDL_scalbn_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   760
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   761
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   762
extern DECLSPEC double SDLCALL SDL_sin(double x);
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   763
#ifdef HAVE_SIN
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   764
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
   765
#define SDL_sin SDL_sin_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   766
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   767
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   768
extern DECLSPEC float SDLCALL SDL_sinf(float x);
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   769
#ifdef HAVE_SINF
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   770
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
   771
#else
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   772
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
   773
#endif
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   774
#define SDL_sinf SDL_sinf_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   775
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   776
extern DECLSPEC double SDLCALL SDL_sqrt(double x);
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   777
#ifdef HAVE_SQRT
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   778
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
   779
#define SDL_sqrt SDL_sqrt_inline
4761
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   780
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   781
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   782
/* The SDL implementation of iconv() returns these error codes */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   783
#define SDL_ICONV_ERROR		(size_t)-1
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   784
#define SDL_ICONV_E2BIG		(size_t)-2
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   785
#define SDL_ICONV_EILSEQ	(size_t)-3
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   786
#define SDL_ICONV_EINVAL	(size_t)-4
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   787
7003
eeaf77005c30 Improvements to stdlib.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   788
/* 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
   789
typedef struct _SDL_iconv_t *SDL_iconv_t;
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   790
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
   791
                                                   const char *fromcode);
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   792
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
   793
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
   794
                                         size_t * inbytesleft, char **outbuf,
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   795
                                         size_t * outbytesleft);
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   796
/**
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   797
 *  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
   798
 *  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
   799
 */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   800
extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode,
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   801
                                               const char *fromcode,
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   802
                                               const char *inbuf,
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   803
                                               size_t inbytesleft);
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   804
#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
   805
#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
   806
#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
   807
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   808
/* Ends C function definitions when using C++ */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   809
#ifdef __cplusplus
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   810
/* *INDENT-OFF* */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   811
}
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   812
/* *INDENT-ON* */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   813
#endif
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   814
#include "close_code.h"
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   815
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   816
#endif /* _SDL_stdinc_h */
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   817
bb2e32f5a556 Removed spurious carriage returns
Sam Lantinga <slouken@libsdl.org>
parents: 4758
diff changeset
   818
/* vi: set ts=4 sw=4 expandtab: */