include/begin_code.h
author Ozkan Sezer <sezeroz@gmail.com>
Sun, 14 Oct 2018 15:25:04 +0300
branchSDL-1.2
changeset 12325 c4f2eeda176f
parent 11966 0c7962a4336f
permissions -rw-r--r--
remove symlink for libSDL-1.0.so.0 from the rpm spec file.

also fix a changelog date.
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2012 Sam Lantinga
     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 
    23 /** 
    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 
    30 /** 
    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 
    39 /** 
    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__)
    46 #   define DECLSPEC
    47 #  else
    48 #   define DECLSPEC	__declspec(export)
    49 #  endif
    50 # elif defined(__WIN32__)
    51 #  ifdef __BORLANDC__
    52 #   ifdef BUILD_SDL
    53 #    define DECLSPEC 
    54 #   else
    55 #    define DECLSPEC	__declspec(dllimport)
    56 #   endif
    57 #  else
    58 #   define DECLSPEC	__declspec(dllexport)
    59 #  endif
    60 # elif defined(__OS2__)
    61 #   ifdef BUILD_SDL
    62 #    define DECLSPEC	__declspec(dllexport)
    63 #   else
    64 #    define DECLSPEC
    65 #   endif
    66 # else
    67 #  if defined(__GNUC__) && __GNUC__ >= 4
    68 #   define DECLSPEC	__attribute__ ((visibility("default")))
    69 #  else
    70 #   define DECLSPEC
    71 #  endif
    72 # endif
    73 #endif
    74 
    75 /** 
    76  *  @def SDLCALL
    77  *  By default SDL uses the C calling convention
    78  */
    79 #ifndef SDLCALL
    80 # if defined(__WIN32__) && !defined(__GNUC__)
    81 #  define SDLCALL __cdecl
    82 # elif defined(__OS2__)
    83    /* But on OS/2, we use the _System calling convention */
    84    /* to be compatible with every compiler */
    85 #  if defined (__GNUC__) && !defined(_System)
    86 #   define _System /* For compatibility with old GCC/EMX */
    87 #  endif
    88 #  define SDLCALL _System
    89 # else
    90 #  define SDLCALL
    91 # endif
    92 #endif /* SDLCALL */
    93 
    94 #ifdef __SYMBIAN32__ 
    95 #ifndef EKA2 
    96 #undef DECLSPEC
    97 #define DECLSPEC
    98 #elif !defined(__WINS__)
    99 #undef DECLSPEC
   100 #define DECLSPEC __declspec(dllexport)
   101 #endif /* !EKA2 */
   102 #endif /* __SYMBIAN32__ */
   103 
   104 /**
   105  *  @file begin_code.h
   106  *  Force structure packing at 4 byte alignment.
   107  *  This is necessary if the header is included in code which has structure
   108  *  packing set to an alternate value, say for loading structures from disk.
   109  *  The packing is reset to the previous value in close_code.h 
   110  */
   111 #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
   112 #ifdef _MSC_VER
   113 #pragma warning(disable: 4103)
   114 #endif
   115 #ifdef __BORLANDC__
   116 #pragma nopackwarning
   117 #endif
   118 #ifdef _M_X64
   119 /* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */
   120 #pragma pack(push,8)
   121 #else
   122 #pragma pack(push,4)
   123 #endif
   124 #elif (defined(__MWERKS__) && defined(__MACOS__))
   125 #pragma options align=mac68k4byte
   126 #pragma enumsalwaysint on
   127 #endif /* Compiler needs structure packing set */
   128 
   129 /**
   130  *  @def SDL_INLINE_OKAY
   131  *  Set up compiler-specific options for inlining functions
   132  */
   133 #ifndef SDL_INLINE_OKAY
   134 #ifdef __GNUC__
   135 #define SDL_INLINE_OKAY
   136 #else
   137 /* Add any special compiler-specific cases here */
   138 #if defined(_MSC_VER) || defined(__BORLANDC__) || \
   139     defined(__DMC__) || defined(__SC__) || \
   140     defined(__WATCOMC__) || defined(__LCC__) || \
   141     defined(__DECC) || defined(__EABI__)
   142 #ifndef __inline__
   143 #define __inline__	__inline
   144 #endif
   145 #define SDL_INLINE_OKAY
   146 #else
   147 #if !defined(__MRC__) && !defined(_SGI_SOURCE)
   148 #ifndef __inline__
   149 #define __inline__ inline
   150 #endif
   151 #define SDL_INLINE_OKAY
   152 #endif /* Not a funky compiler */
   153 #endif /* Visual C++ */
   154 #endif /* GNU C */
   155 #endif /* SDL_INLINE_OKAY */
   156 
   157 /**
   158  *  @def __inline__
   159  *  If inlining isn't supported, remove "__inline__", turning static
   160  *  inlined functions into static functions (resulting in code bloat
   161  *  in all files which include the offending header files)
   162  */
   163 #ifndef SDL_INLINE_OKAY
   164 #define __inline__
   165 #endif
   166 
   167 /**
   168  *  @def NULL
   169  *  Apparently this is needed by several Windows compilers
   170  */
   171 #if !defined(__MACH__)
   172 #ifndef NULL
   173 #ifdef __cplusplus
   174 #define NULL 0
   175 #else
   176 #define NULL ((void *)0)
   177 #endif
   178 #endif /* NULL */
   179 #endif /* ! Mac OS X - breaks precompiled headers */