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