6560
|
1 |
/*
|
|
2 |
SDL - Simple DirectMedia Layer
|
7809
|
3 |
Copyright (C) 1997-2012 Sam Lantinga
|
6560
|
4 |
|
|
5 |
This library is free software; you can redistribute it and/or
|
|
6 |
modify it under the terms of the GNU Library General Public
|
|
7 |
License as published by the Free Software Foundation; either
|
|
8 |
version 2 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 |
Library General Public License for more details.
|
|
14 |
|
|
15 |
You should have received a copy of the GNU Library General Public
|
|
16 |
License along with this library; if not, write to the Free
|
|
17 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
18 |
|
|
19 |
Sam Lantinga
|
|
20 |
slouken@libsdl.org
|
|
21 |
*/
|
|
22 |
|
10017
|
23 |
/**
|
6560
|
24 |
* @file begin_code.h
|
|
25 |
* This file sets things up for C dynamic library function definitions,
|
|
26 |
* static inlined functions, and structures aligned at 4-byte alignment.
|
|
27 |
* If you don't like ugly C preprocessor code, don't look at this file. :)
|
|
28 |
*/
|
|
29 |
|
10017
|
30 |
/**
|
6560
|
31 |
* @file begin_code.h
|
|
32 |
* This shouldn't be nested -- included it around code only.
|
|
33 |
*/
|
|
34 |
#ifdef _begin_code_h
|
|
35 |
#error Nested inclusion of begin_code.h
|
|
36 |
#endif
|
|
37 |
#define _begin_code_h
|
|
38 |
|
10017
|
39 |
/**
|
6560
|
40 |
* @def DECLSPEC
|
|
41 |
* Some compilers use a special export keyword
|
|
42 |
*/
|
|
43 |
#ifndef DECLSPEC
|
|
44 |
# if defined(__BEOS__) || defined(__HAIKU__)
|
|
45 |
# if defined(__GNUC__)
|
7809
|
46 |
# define DECLSPEC
|
6560
|
47 |
# else
|
10017
|
48 |
# define DECLSPEC __declspec(export)
|
6560
|
49 |
# endif
|
|
50 |
# elif defined(__WIN32__)
|
|
51 |
# ifdef __BORLANDC__
|
|
52 |
# ifdef BUILD_SDL
|
10017
|
53 |
# define DECLSPEC
|
6560
|
54 |
# else
|
10017
|
55 |
# define DECLSPEC __declspec(dllimport)
|
6560
|
56 |
# endif
|
|
57 |
# else
|
10017
|
58 |
# define DECLSPEC __declspec(dllexport)
|
6560
|
59 |
# endif
|
|
60 |
# elif defined(__OS2__)
|
|
61 |
# ifdef __WATCOMC__
|
|
62 |
# ifdef BUILD_SDL
|
10017
|
63 |
# define DECLSPEC __declspec(dllexport)
|
6560
|
64 |
# else
|
|
65 |
# define DECLSPEC
|
|
66 |
# endif
|
|
67 |
# elif defined (__GNUC__) && __GNUC__ < 4
|
|
68 |
# /* Added support for GCC-EMX <v4.x */
|
|
69 |
# /* this is needed for XFree86/OS2 developement */
|
|
70 |
# /* F. Ambacher(anakor@snafu.de) 05.2008 */
|
|
71 |
# ifdef BUILD_SDL
|
|
72 |
# define DECLSPEC __declspec(dllexport)
|
|
73 |
# else
|
|
74 |
# define DECLSPEC
|
|
75 |
# endif
|
|
76 |
# else
|
|
77 |
# define DECLSPEC
|
|
78 |
# endif
|
|
79 |
# else
|
|
80 |
# if defined(__GNUC__) && __GNUC__ >= 4
|
10017
|
81 |
# define DECLSPEC __attribute__ ((visibility("default")))
|
6560
|
82 |
# else
|
|
83 |
# define DECLSPEC
|
|
84 |
# endif
|
|
85 |
# endif
|
|
86 |
#endif
|
|
87 |
|
10017
|
88 |
/**
|
6560
|
89 |
* @def SDLCALL
|
|
90 |
* By default SDL uses the C calling convention
|
|
91 |
*/
|
|
92 |
#ifndef SDLCALL
|
|
93 |
# if defined(__WIN32__) && !defined(__GNUC__)
|
|
94 |
# define SDLCALL __cdecl
|
|
95 |
# elif defined(__OS2__)
|
|
96 |
# if defined (__GNUC__) && __GNUC__ < 4
|
|
97 |
# /* Added support for GCC-EMX <v4.x */
|
|
98 |
# /* this is needed for XFree86/OS2 developement */
|
|
99 |
# /* F. Ambacher(anakor@snafu.de) 05.2008 */
|
|
100 |
# define SDLCALL _cdecl
|
|
101 |
# else
|
|
102 |
# /* On other compilers on OS/2, we use the _System calling convention */
|
|
103 |
# /* to be compatible with every compiler */
|
|
104 |
# define SDLCALL _System
|
|
105 |
# endif
|
|
106 |
# else
|
|
107 |
# define SDLCALL
|
|
108 |
# endif
|
|
109 |
#endif /* SDLCALL */
|
|
110 |
|
10017
|
111 |
#ifdef __SYMBIAN32__
|
|
112 |
#ifndef EKA2
|
6560
|
113 |
#undef DECLSPEC
|
|
114 |
#define DECLSPEC
|
|
115 |
#elif !defined(__WINS__)
|
|
116 |
#undef DECLSPEC
|
|
117 |
#define DECLSPEC __declspec(dllexport)
|
|
118 |
#endif /* !EKA2 */
|
|
119 |
#endif /* __SYMBIAN32__ */
|
|
120 |
|
|
121 |
/**
|
|
122 |
* @file begin_code.h
|
|
123 |
* Force structure packing at 4 byte alignment.
|
|
124 |
* This is necessary if the header is included in code which has structure
|
|
125 |
* packing set to an alternate value, say for loading structures from disk.
|
10017
|
126 |
* The packing is reset to the previous value in close_code.h
|
6560
|
127 |
*/
|
|
128 |
#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
|
|
129 |
#ifdef _MSC_VER
|
|
130 |
#pragma warning(disable: 4103)
|
|
131 |
#endif
|
|
132 |
#ifdef __BORLANDC__
|
|
133 |
#pragma nopackwarning
|
|
134 |
#endif
|
7809
|
135 |
#ifdef _M_X64
|
|
136 |
/* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */
|
|
137 |
#pragma pack(push,8)
|
|
138 |
#else
|
6560
|
139 |
#pragma pack(push,4)
|
7809
|
140 |
#endif
|
6560
|
141 |
#elif (defined(__MWERKS__) && defined(__MACOS__))
|
|
142 |
#pragma options align=mac68k4byte
|
|
143 |
#pragma enumsalwaysint on
|
|
144 |
#endif /* Compiler needs structure packing set */
|
|
145 |
|
|
146 |
/**
|
|
147 |
* @def SDL_INLINE_OKAY
|
|
148 |
* Set up compiler-specific options for inlining functions
|
|
149 |
*/
|
|
150 |
#ifndef SDL_INLINE_OKAY
|
|
151 |
#ifdef __GNUC__
|
|
152 |
#define SDL_INLINE_OKAY
|
|
153 |
#else
|
|
154 |
/* Add any special compiler-specific cases here */
|
|
155 |
#if defined(_MSC_VER) || defined(__BORLANDC__) || \
|
|
156 |
defined(__DMC__) || defined(__SC__) || \
|
|
157 |
defined(__WATCOMC__) || defined(__LCC__) || \
|
|
158 |
defined(__DECC) || defined(__EABI__)
|
|
159 |
#ifndef __inline__
|
10017
|
160 |
#define __inline__ __inline
|
6560
|
161 |
#endif
|
|
162 |
#define SDL_INLINE_OKAY
|
|
163 |
#else
|
|
164 |
#if !defined(__MRC__) && !defined(_SGI_SOURCE)
|
|
165 |
#ifndef __inline__
|
|
166 |
#define __inline__ inline
|
|
167 |
#endif
|
|
168 |
#define SDL_INLINE_OKAY
|
|
169 |
#endif /* Not a funky compiler */
|
|
170 |
#endif /* Visual C++ */
|
|
171 |
#endif /* GNU C */
|
|
172 |
#endif /* SDL_INLINE_OKAY */
|
|
173 |
|
|
174 |
/**
|
|
175 |
* @def __inline__
|
|
176 |
* If inlining isn't supported, remove "__inline__", turning static
|
|
177 |
* inlined functions into static functions (resulting in code bloat
|
|
178 |
* in all files which include the offending header files)
|
|
179 |
*/
|
|
180 |
#ifndef SDL_INLINE_OKAY
|
|
181 |
#define __inline__
|
|
182 |
#endif
|
|
183 |
|
|
184 |
/**
|
|
185 |
* @def NULL
|
|
186 |
* Apparently this is needed by several Windows compilers
|
|
187 |
*/
|
|
188 |
#if !defined(__MACH__)
|
|
189 |
#ifndef NULL
|
|
190 |
#ifdef __cplusplus
|
|
191 |
#define NULL 0
|
|
192 |
#else
|
|
193 |
#define NULL ((void *)0)
|
|
194 |
#endif
|
|
195 |
#endif /* NULL */
|
|
196 |
#endif /* ! Mac OS X - breaks precompiled headers */
|