include/SDL_stdlib.h
author Sam Lantinga <slouken@libsdl.org>
Tue, 07 Feb 2006 12:11:33 +0000
changeset 1341 d02b552e5304
parent 1336 3692456e7b0f
child 1353 7ba544e2888d
permissions -rw-r--r--
Configure dynamically generates SDL_config.h
I'm still wrestling with autoheader, but this should work for now...
Fixed lots of build problems with C library support disabled
slouken@1330
     1
/*
slouken@1330
     2
    SDL - Simple DirectMedia Layer
slouken@1330
     3
    Copyright (C) 1997-2006 Sam Lantinga
slouken@1330
     4
slouken@1330
     5
    This library is free software; you can redistribute it and/or
slouken@1330
     6
    modify it under the terms of the GNU Lesser General Public
slouken@1330
     7
    License as published by the Free Software Foundation; either
slouken@1330
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@1330
     9
slouken@1330
    10
    This library is distributed in the hope that it will be useful,
slouken@1330
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@1330
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1330
    13
    Lesser General Public License for more details.
slouken@1330
    14
slouken@1330
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1330
    16
    License along with this library; if not, write to the Free Software
slouken@1330
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@1330
    18
slouken@1330
    19
    Sam Lantinga
slouken@1330
    20
    slouken@libsdl.org
slouken@1330
    21
*/
slouken@1330
    22
slouken@1330
    23
#ifndef _SDL_stdlib_h
slouken@1330
    24
#define _SDL_stdlib_h
slouken@1330
    25
slouken@1330
    26
#include "SDL_config.h"
slouken@1330
    27
slouken@1330
    28
/* AIX requires this to be the first thing in the file.  */
slouken@1330
    29
#ifndef __GNUC__
slouken@1330
    30
# if HAVE_ALLOCA_H
slouken@1330
    31
#  include <alloca.h>
slouken@1330
    32
# else
slouken@1330
    33
#  ifdef _AIX
slouken@1330
    34
 #pragma alloca
slouken@1330
    35
#  else
slouken@1330
    36
#   ifndef alloca /* predefined by HP cc +Olibcalls */
slouken@1330
    37
char *alloca ();
slouken@1330
    38
#   endif
slouken@1330
    39
#  endif
slouken@1330
    40
# endif
slouken@1330
    41
#endif
slouken@1330
    42
slouken@1330
    43
#ifdef HAVE_STDLIB_H
slouken@1330
    44
#include <stdlib.h>
slouken@1330
    45
#endif
slouken@1330
    46
slouken@1330
    47
#ifdef HAVE_MALLOC_H
slouken@1330
    48
#include <malloc.h>
slouken@1330
    49
#endif
slouken@1330
    50
slouken@1330
    51
#include "SDL_types.h"
slouken@1330
    52
slouken@1330
    53
#include "begin_code.h"
slouken@1330
    54
/* Set up for C function definitions, even when using C++ */
slouken@1330
    55
#ifdef __cplusplus
slouken@1330
    56
extern "C" {
slouken@1330
    57
#endif
slouken@1330
    58
slouken@1330
    59
#ifdef HAVE_MALLOC
slouken@1330
    60
#define SDL_malloc	malloc
slouken@1330
    61
#else
slouken@1330
    62
extern DECLSPEC void * SDLCALL SDL_malloc(size_t size);
slouken@1330
    63
#endif
slouken@1330
    64
slouken@1341
    65
#ifdef HAVE_CALLOC
slouken@1341
    66
#define SDL_calloc	calloc
slouken@1341
    67
#else
slouken@1341
    68
extern DECLSPEC void * SDLCALL SDL_calloc(size_t nmemb, size_t size);
slouken@1341
    69
#endif
slouken@1341
    70
slouken@1330
    71
#ifdef HAVE_REALLOC
slouken@1330
    72
#define SDL_realloc	realloc
slouken@1330
    73
#else
slouken@1330
    74
extern DECLSPEC void * SDLCALL SDL_realloc(void *mem, size_t size);
slouken@1330
    75
#endif
slouken@1330
    76
slouken@1330
    77
#ifdef HAVE_FREE
slouken@1330
    78
#define SDL_free	free
slouken@1330
    79
#else
slouken@1330
    80
extern DECLSPEC void SDLCALL SDL_free(void *mem);
slouken@1330
    81
#endif
slouken@1330
    82
slouken@1330
    83
#ifdef HAVE_ALLOCA
slouken@1330
    84
#define SDL_stack_alloc(type, count)    (type*)alloca(sizeof(type)*count)
slouken@1330
    85
#define SDL_stack_free(data)
slouken@1330
    86
#else
slouken@1336
    87
#define SDL_stack_alloc(type, count)    (type*)SDL_malloc(sizeof(type)*count)
slouken@1330
    88
#define SDL_stack_free(data)            SDL_free(data)
slouken@1330
    89
#endif
slouken@1330
    90
slouken@1336
    91
#ifdef HAVE_GETENV
slouken@1336
    92
#define SDL_getenv	getenv
slouken@1336
    93
#else
slouken@1336
    94
extern DECLSPEC char * SDLCALL SDL_getenv(const char *name);
slouken@1336
    95
#endif
slouken@1336
    96
slouken@1336
    97
#ifdef HAVE_PUTENV
slouken@1336
    98
#define SDL_putenv	putenv
slouken@1336
    99
#else
slouken@1336
   100
extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
slouken@1336
   101
#endif
slouken@1336
   102
slouken@1330
   103
#ifdef HAVE_QSORT
slouken@1330
   104
#define SDL_qsort	qsort
slouken@1330
   105
#else
slouken@1330
   106
extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size,
slouken@1330
   107
           int (*compare)(const void *, const void *));
slouken@1330
   108
#endif
slouken@1330
   109
slouken@1341
   110
#ifdef HAVE_ABS
slouken@1341
   111
#define SDL_abs		abs
slouken@1341
   112
#else
slouken@1341
   113
#define SDL_abs(X)	((X) < 0 ? -(X) : (X))
slouken@1341
   114
#endif
slouken@1341
   115
slouken@1330
   116
/* Ends C function definitions when using C++ */
slouken@1330
   117
#ifdef __cplusplus
slouken@1330
   118
}
slouken@1330
   119
#endif
slouken@1330
   120
#include "close_code.h"
slouken@1330
   121
slouken@1330
   122
#endif /* _SDL_stdlib_h */