misc/winutils/include/begin_code.h
branchui-scaling
changeset 15283 c4fd2813b127
parent 13390 0135e64c6c66
parent 15279 7ab5cf405686
child 15663 d92eeb468dad
equal deleted inserted replaced
13390:0135e64c6c66 15283:c4fd2813b127
     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 __WATCOMC__
       
    62 #   ifdef BUILD_SDL
       
    63 #    define DECLSPEC    __declspec(dllexport)
       
    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
       
    81 #   define DECLSPEC __attribute__ ((visibility("default")))
       
    82 #  else
       
    83 #   define DECLSPEC
       
    84 #  endif
       
    85 # endif
       
    86 #endif
       
    87 
       
    88 /**
       
    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 
       
   111 #ifdef __SYMBIAN32__
       
   112 #ifndef EKA2
       
   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.
       
   126  *  The packing is reset to the previous value in close_code.h
       
   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
       
   135 #ifdef _M_X64
       
   136 /* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */
       
   137 #pragma pack(push,8)
       
   138 #else
       
   139 #pragma pack(push,4)
       
   140 #endif
       
   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__
       
   160 #define __inline__  __inline
       
   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 */