SDL standard library

Dependents:   H261_encoder

Committer:
miruga27
Date:
Wed Sep 07 18:46:53 2016 +0000
Revision:
0:dda4f4550403
7/09/2016;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
miruga27 0:dda4f4550403 1 /*
miruga27 0:dda4f4550403 2 Simple DirectMedia Layer
miruga27 0:dda4f4550403 3 Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
miruga27 0:dda4f4550403 4
miruga27 0:dda4f4550403 5 This software is provided 'as-is', without any express or implied
miruga27 0:dda4f4550403 6 warranty. In no event will the authors be held liable for any damages
miruga27 0:dda4f4550403 7 arising from the use of this software.
miruga27 0:dda4f4550403 8
miruga27 0:dda4f4550403 9 Permission is granted to anyone to use this software for any purpose,
miruga27 0:dda4f4550403 10 including commercial applications, and to alter it and redistribute it
miruga27 0:dda4f4550403 11 freely, subject to the following restrictions:
miruga27 0:dda4f4550403 12
miruga27 0:dda4f4550403 13 1. The origin of this software must not be misrepresented; you must not
miruga27 0:dda4f4550403 14 claim that you wrote the original software. If you use this software
miruga27 0:dda4f4550403 15 in a product, an acknowledgment in the product documentation would be
miruga27 0:dda4f4550403 16 appreciated but is not required.
miruga27 0:dda4f4550403 17 2. Altered source versions must be plainly marked as such, and must not be
miruga27 0:dda4f4550403 18 misrepresented as being the original software.
miruga27 0:dda4f4550403 19 3. This notice may not be removed or altered from any source distribution.
miruga27 0:dda4f4550403 20 */
miruga27 0:dda4f4550403 21
miruga27 0:dda4f4550403 22 /**
miruga27 0:dda4f4550403 23 * \file begin_code.h
miruga27 0:dda4f4550403 24 *
miruga27 0:dda4f4550403 25 * This file sets things up for C dynamic library function definitions,
miruga27 0:dda4f4550403 26 * static inlined functions, and structures aligned at 4-byte alignment.
miruga27 0:dda4f4550403 27 * If you don't like ugly C preprocessor code, don't look at this file. :)
miruga27 0:dda4f4550403 28 */
miruga27 0:dda4f4550403 29
miruga27 0:dda4f4550403 30 /* This shouldn't be nested -- included it around code only. */
miruga27 0:dda4f4550403 31 #ifdef _begin_code_h
miruga27 0:dda4f4550403 32 #error Nested inclusion of begin_code.h
miruga27 0:dda4f4550403 33 #endif
miruga27 0:dda4f4550403 34 #define _begin_code_h
miruga27 0:dda4f4550403 35
miruga27 0:dda4f4550403 36 #ifndef SDL_DEPRECATED
miruga27 0:dda4f4550403 37 # if (__GNUC__ >= 4) /* technically, this arrived in gcc 3.1, but oh well. */
miruga27 0:dda4f4550403 38 # define SDL_DEPRECATED __attribute__((deprecated))
miruga27 0:dda4f4550403 39 # else
miruga27 0:dda4f4550403 40 # define SDL_DEPRECATED
miruga27 0:dda4f4550403 41 # endif
miruga27 0:dda4f4550403 42 #endif
miruga27 0:dda4f4550403 43
miruga27 0:dda4f4550403 44 /* Some compilers use a special export keyword */
miruga27 0:dda4f4550403 45 #ifndef DECLSPEC
miruga27 0:dda4f4550403 46 # if defined(__WIN32__)
miruga27 0:dda4f4550403 47 # ifdef __BORLANDC__
miruga27 0:dda4f4550403 48 # ifdef BUILD_SDL
miruga27 0:dda4f4550403 49 # define DECLSPEC
miruga27 0:dda4f4550403 50 # else
miruga27 0:dda4f4550403 51 # define DECLSPEC __declspec(dllimport)
miruga27 0:dda4f4550403 52 # endif
miruga27 0:dda4f4550403 53 # else
miruga27 0:dda4f4550403 54 # define DECLSPEC __declspec(dllexport)
miruga27 0:dda4f4550403 55 # endif
miruga27 0:dda4f4550403 56 # else
miruga27 0:dda4f4550403 57 # if defined(__GNUC__) && __GNUC__ >= 4
miruga27 0:dda4f4550403 58 # define DECLSPEC __attribute__ ((visibility("default")))
miruga27 0:dda4f4550403 59 # elif defined(__GNUC__) && __GNUC__ >= 2
miruga27 0:dda4f4550403 60 # define DECLSPEC __declspec(dllexport)
miruga27 0:dda4f4550403 61 # else
miruga27 0:dda4f4550403 62 # define DECLSPEC
miruga27 0:dda4f4550403 63 # endif
miruga27 0:dda4f4550403 64 # endif
miruga27 0:dda4f4550403 65 #endif
miruga27 0:dda4f4550403 66
miruga27 0:dda4f4550403 67 /* By default SDL uses the C calling convention */
miruga27 0:dda4f4550403 68 #ifndef SDLCALL
miruga27 0:dda4f4550403 69 #if defined(__WIN32__) && !defined(__GNUC__)
miruga27 0:dda4f4550403 70 #define SDLCALL __cdecl
miruga27 0:dda4f4550403 71 #else
miruga27 0:dda4f4550403 72 #define SDLCALL
miruga27 0:dda4f4550403 73 #endif
miruga27 0:dda4f4550403 74 #endif /* SDLCALL */
miruga27 0:dda4f4550403 75
miruga27 0:dda4f4550403 76 /* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */
miruga27 0:dda4f4550403 77 #ifdef __SYMBIAN32__
miruga27 0:dda4f4550403 78 #undef DECLSPEC
miruga27 0:dda4f4550403 79 #define DECLSPEC
miruga27 0:dda4f4550403 80 #endif /* __SYMBIAN32__ */
miruga27 0:dda4f4550403 81
miruga27 0:dda4f4550403 82 /* Force structure packing at 4 byte alignment.
miruga27 0:dda4f4550403 83 This is necessary if the header is included in code which has structure
miruga27 0:dda4f4550403 84 packing set to an alternate value, say for loading structures from disk.
miruga27 0:dda4f4550403 85 The packing is reset to the previous value in close_code.h
miruga27 0:dda4f4550403 86 */
miruga27 0:dda4f4550403 87 #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
miruga27 0:dda4f4550403 88 #ifdef _MSC_VER
miruga27 0:dda4f4550403 89 #pragma warning(disable: 4103)
miruga27 0:dda4f4550403 90 #endif
miruga27 0:dda4f4550403 91 #ifdef __BORLANDC__
miruga27 0:dda4f4550403 92 #pragma nopackwarning
miruga27 0:dda4f4550403 93 #endif
miruga27 0:dda4f4550403 94 #ifdef _M_X64
miruga27 0:dda4f4550403 95 /* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */
miruga27 0:dda4f4550403 96 #pragma pack(push,8)
miruga27 0:dda4f4550403 97 #else
miruga27 0:dda4f4550403 98 #pragma pack(push,4)
miruga27 0:dda4f4550403 99 #endif
miruga27 0:dda4f4550403 100 #endif /* Compiler needs structure packing set */
miruga27 0:dda4f4550403 101
miruga27 0:dda4f4550403 102 #ifndef SDL_INLINE
miruga27 0:dda4f4550403 103 #if defined(__GNUC__)
miruga27 0:dda4f4550403 104 #define SDL_INLINE __inline__
miruga27 0:dda4f4550403 105 #elif defined(_MSC_VER) || defined(__BORLANDC__) || \
miruga27 0:dda4f4550403 106 defined(__DMC__) || defined(__SC__) || \
miruga27 0:dda4f4550403 107 defined(__WATCOMC__) || defined(__LCC__) || \
miruga27 0:dda4f4550403 108 defined(__DECC)
miruga27 0:dda4f4550403 109 #define SDL_INLINE __inline
miruga27 0:dda4f4550403 110 #ifndef __inline__
miruga27 0:dda4f4550403 111 #define __inline__ __inline
miruga27 0:dda4f4550403 112 #endif
miruga27 0:dda4f4550403 113 #else
miruga27 0:dda4f4550403 114 #define SDL_INLINE inline
miruga27 0:dda4f4550403 115 #ifndef __inline__
miruga27 0:dda4f4550403 116 #define __inline__ inline
miruga27 0:dda4f4550403 117 #endif
miruga27 0:dda4f4550403 118 #endif
miruga27 0:dda4f4550403 119 #endif /* SDL_INLINE not defined */
miruga27 0:dda4f4550403 120
miruga27 0:dda4f4550403 121 #ifndef SDL_FORCE_INLINE
miruga27 0:dda4f4550403 122 #if defined(_MSC_VER)
miruga27 0:dda4f4550403 123 #define SDL_FORCE_INLINE __forceinline
miruga27 0:dda4f4550403 124 #elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
miruga27 0:dda4f4550403 125 #define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
miruga27 0:dda4f4550403 126 #else
miruga27 0:dda4f4550403 127 #define SDL_FORCE_INLINE static SDL_INLINE
miruga27 0:dda4f4550403 128 #endif
miruga27 0:dda4f4550403 129 #endif /* SDL_FORCE_INLINE not defined */
miruga27 0:dda4f4550403 130
miruga27 0:dda4f4550403 131 /* Apparently this is needed by several Windows compilers */
miruga27 0:dda4f4550403 132 #if !defined(__MACH__)
miruga27 0:dda4f4550403 133 #ifndef NULL
miruga27 0:dda4f4550403 134 #ifdef __cplusplus
miruga27 0:dda4f4550403 135 #define NULL 0
miruga27 0:dda4f4550403 136 #else
miruga27 0:dda4f4550403 137 #define NULL ((void *)0)
miruga27 0:dda4f4550403 138 #endif
miruga27 0:dda4f4550403 139 #endif /* NULL */
miruga27 0:dda4f4550403 140 #endif /* ! Mac OS X - breaks precompiled headers */