Skip to content

Latest commit

 

History

History
122 lines (100 loc) · 2.79 KB

SDL_stdlib.h

File metadata and controls

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