2001-04-26 16:45:43 +00:00
|
|
|
/*
|
2011-04-08 13:03:26 -07:00
|
|
|
Simple DirectMedia Layer
|
2013-02-15 08:47:44 -08:00
|
|
|
Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
|
2001-04-26 16:45:43 +00:00
|
|
|
|
2011-04-08 13:03:26 -07:00
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
warranty. In no event will the authors be held liable for any damages
|
|
|
|
arising from the use of this software.
|
2001-04-26 16:45:43 +00:00
|
|
|
|
2011-04-08 13:03:26 -07:00
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
including commercial applications, and to alter it and redistribute it
|
|
|
|
freely, subject to the following restrictions:
|
2001-04-26 16:45:43 +00:00
|
|
|
|
2011-04-08 13:03:26 -07:00
|
|
|
1. The origin of this software must not be misrepresented; you must not
|
|
|
|
claim that you wrote the original software. If you use this software
|
|
|
|
in a product, an acknowledgment in the product documentation would be
|
|
|
|
appreciated but is not required.
|
|
|
|
2. Altered source versions must be plainly marked as such, and must not be
|
|
|
|
misrepresented as being the original software.
|
|
|
|
3. This notice may not be removed or altered from any source distribution.
|
2001-04-26 16:45:43 +00:00
|
|
|
*/
|
|
|
|
|
2009-10-19 13:31:58 +00:00
|
|
|
/**
|
|
|
|
* \file begin_code.h
|
|
|
|
*
|
|
|
|
* This file sets things up for C dynamic library function definitions,
|
|
|
|
* static inlined functions, and structures aligned at 4-byte alignment.
|
|
|
|
* If you don't like ugly C preprocessor code, don't look at this file. :)
|
|
|
|
*/
|
2001-04-26 16:45:43 +00:00
|
|
|
|
|
|
|
/* This shouldn't be nested -- included it around code only. */
|
|
|
|
#ifdef _begin_code_h
|
|
|
|
#error Nested inclusion of begin_code.h
|
|
|
|
#endif
|
|
|
|
#define _begin_code_h
|
|
|
|
|
|
|
|
/* Some compilers use a special export keyword */
|
|
|
|
#ifndef DECLSPEC
|
2009-09-21 09:21:00 +00:00
|
|
|
# if defined(__BEOS__) || defined(__HAIKU__)
|
2001-04-26 16:45:43 +00:00
|
|
|
# if defined(__GNUC__)
|
|
|
|
# define DECLSPEC __declspec(dllexport)
|
|
|
|
# else
|
|
|
|
# define DECLSPEC __declspec(export)
|
|
|
|
# endif
|
2011-01-24 15:46:11 -08:00
|
|
|
# elif defined(__WIN32__)
|
2002-02-13 17:45:24 +00:00
|
|
|
# ifdef __BORLANDC__
|
|
|
|
# ifdef BUILD_SDL
|
2006-07-10 21:04:37 +00:00
|
|
|
# define DECLSPEC
|
2002-02-13 17:45:24 +00:00
|
|
|
# else
|
2006-03-22 04:51:44 +00:00
|
|
|
# define DECLSPEC __declspec(dllimport)
|
2002-02-13 17:45:24 +00:00
|
|
|
# endif
|
|
|
|
# else
|
|
|
|
# define DECLSPEC __declspec(dllexport)
|
|
|
|
# endif
|
2005-11-23 07:29:56 +00:00
|
|
|
# else
|
2006-03-23 07:34:03 +00:00
|
|
|
# if defined(__GNUC__) && __GNUC__ >= 4
|
2006-03-22 04:51:44 +00:00
|
|
|
# define DECLSPEC __attribute__ ((visibility("default")))
|
|
|
|
# else
|
|
|
|
# define DECLSPEC
|
|
|
|
# endif
|
2005-11-23 07:29:56 +00:00
|
|
|
# endif
|
2001-04-26 16:45:43 +00:00
|
|
|
#endif
|
|
|
|
|
2002-04-11 14:35:16 +00:00
|
|
|
/* By default SDL uses the C calling convention */
|
|
|
|
#ifndef SDLCALL
|
2011-01-24 15:46:11 -08:00
|
|
|
#if defined(__WIN32__) && !defined(__GNUC__)
|
2010-01-07 04:38:58 +00:00
|
|
|
#define SDLCALL __cdecl
|
|
|
|
#else
|
|
|
|
#define SDLCALL
|
|
|
|
#endif
|
2002-04-11 14:35:16 +00:00
|
|
|
#endif /* SDLCALL */
|
|
|
|
|
2001-09-11 20:38:49 +00:00
|
|
|
/* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */
|
2006-07-10 21:04:37 +00:00
|
|
|
#ifdef __SYMBIAN32__
|
2001-09-11 20:38:49 +00:00
|
|
|
#undef DECLSPEC
|
|
|
|
#define DECLSPEC
|
2001-09-23 16:53:51 +00:00
|
|
|
#endif /* __SYMBIAN32__ */
|
2001-09-11 20:38:49 +00:00
|
|
|
|
2001-04-26 16:45:43 +00:00
|
|
|
/* Force structure packing at 4 byte alignment.
|
|
|
|
This is necessary if the header is included in code which has structure
|
|
|
|
packing set to an alternate value, say for loading structures from disk.
|
|
|
|
The packing is reset to the previous value in close_code.h
|
|
|
|
*/
|
2002-02-28 00:28:26 +00:00
|
|
|
#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
|
2001-04-26 16:45:43 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma warning(disable: 4103)
|
|
|
|
#endif
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma nopackwarning
|
|
|
|
#endif
|
2012-01-09 07:07:43 -05:00
|
|
|
#ifdef _M_X64
|
|
|
|
/* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */
|
|
|
|
#pragma pack(push,8)
|
|
|
|
#else
|
2001-09-23 21:10:30 +00:00
|
|
|
#pragma pack(push,4)
|
2012-01-09 07:07:43 -05:00
|
|
|
#endif
|
2001-04-26 16:45:43 +00:00
|
|
|
#endif /* Compiler needs structure packing set */
|
|
|
|
|
|
|
|
/* Set up compiler-specific options for inlining functions */
|
|
|
|
#ifndef SDL_INLINE_OKAY
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#define SDL_INLINE_OKAY
|
|
|
|
#else
|
|
|
|
/* Add any special compiler-specific cases here */
|
2002-02-28 00:28:26 +00:00
|
|
|
#if defined(_MSC_VER) || defined(__BORLANDC__) || \
|
|
|
|
defined(__DMC__) || defined(__SC__) || \
|
2005-01-02 05:05:21 +00:00
|
|
|
defined(__WATCOMC__) || defined(__LCC__) || \
|
|
|
|
defined(__DECC)
|
2002-02-28 00:28:26 +00:00
|
|
|
#ifndef __inline__
|
2001-07-02 00:10:19 +00:00
|
|
|
#define __inline__ __inline
|
2002-02-28 00:28:26 +00:00
|
|
|
#endif
|
2001-07-02 00:10:19 +00:00
|
|
|
#define SDL_INLINE_OKAY
|
|
|
|
#else
|
|
|
|
#if !defined(__MRC__) && !defined(_SGI_SOURCE)
|
2007-06-15 07:21:01 +00:00
|
|
|
#ifndef __inline__
|
2001-04-26 16:45:43 +00:00
|
|
|
#define __inline__ inline
|
2007-06-15 07:21:01 +00:00
|
|
|
#endif
|
2001-04-26 16:45:43 +00:00
|
|
|
#define SDL_INLINE_OKAY
|
|
|
|
#endif /* Not a funky compiler */
|
2001-07-02 00:10:19 +00:00
|
|
|
#endif /* Visual C++ */
|
2001-04-26 16:45:43 +00:00
|
|
|
#endif /* GNU C */
|
|
|
|
#endif /* SDL_INLINE_OKAY */
|
|
|
|
|
|
|
|
/* If inlining isn't supported, remove "__inline__", turning static
|
|
|
|
inlined functions into static functions (resulting in code bloat
|
|
|
|
in all files which include the offending header files)
|
|
|
|
*/
|
|
|
|
#ifndef SDL_INLINE_OKAY
|
|
|
|
#define __inline__
|
|
|
|
#endif
|
|
|
|
|
2013-03-15 01:02:30 -04:00
|
|
|
#if defined(_MSC_VER)
|
|
|
|
#define SDL_FORCE_INLINE __forceinline
|
|
|
|
#elif defined(__GNUC__) || defined(__clang__)
|
|
|
|
#define SDL_FORCE_INLINE __attribute__((always_inline)) static inline
|
|
|
|
#else
|
|
|
|
#define SDL_FORCE_INLINE static __inline__
|
|
|
|
#endif
|
|
|
|
|
2002-02-28 00:28:26 +00:00
|
|
|
/* Apparently this is needed by several Windows compilers */
|
2002-04-13 20:33:15 +00:00
|
|
|
#if !defined(__MACH__)
|
2002-02-28 00:28:26 +00:00
|
|
|
#ifndef NULL
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#define NULL 0
|
|
|
|
#else
|
|
|
|
#define NULL ((void *)0)
|
|
|
|
#endif
|
|
|
|
#endif /* NULL */
|
2006-04-13 13:08:26 +00:00
|
|
|
#endif /* ! Mac OS X - breaks precompiled headers */
|