include/begin_code.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 21 Sep 2009 09:21:00 +0000
changeset 3292 245a7d79577c
parent 3269 a67a961e2171
child 3407 d3baf5ac4e37
permissions -rw-r--r--
Fixed bug #615

Scott McCreary 2008-08-21 10:48:14 PDT

This patch adds support for Haiku.
http://ports.haiku-files.org/browser/haikuports/trunk/media-libs/libsdl/SDL-1.2.13-haiku.diff
Haiku is an open-source recreation of BeOS. It has better POSIX compliance
than beOS did, and other improved features, which in some cases causes us to
have to "undo" previous BeOS workarounds.
Here's our port log entry for it, showing the steps to force the changes into
configure and Makefile:
http://ports.haiku-files.org/wiki/media-libs/libsdl/1.2.13/1
Note that this was only tried on 1.2.13 stable so far.
Haiku is using a newer config.guess / config.sub that doesn't yet seem to be in
the released libtool, so we are having to copy it in for now.
http://haiku-files.org/files/optional-packages/
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2009 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 /* This file sets things up for C dynamic library function definitions,
    24    static inlined functions, and structures aligned at 4-byte alignment.
    25    If you don't like ugly C preprocessor code, don't look at this file. :)
    26 */
    27 
    28 /* This shouldn't be nested -- included it around code only. */
    29 #ifdef _begin_code_h
    30 #error Nested inclusion of begin_code.h
    31 #endif
    32 #define _begin_code_h
    33 
    34 /* Some compilers use a special export keyword */
    35 #ifndef DECLSPEC
    36 # if defined(__BEOS__) || defined(__HAIKU__)
    37 #  if defined(__GNUC__)
    38 #   define DECLSPEC	__declspec(dllexport)
    39 #  else
    40 #   define DECLSPEC	__declspec(export)
    41 #  endif
    42 # elif defined(__WIN32__)
    43 #  ifdef __BORLANDC__
    44 #   ifdef BUILD_SDL
    45 #    define DECLSPEC
    46 #   else
    47 #    define DECLSPEC	__declspec(dllimport)
    48 #   endif
    49 #  else
    50 #   define DECLSPEC	__declspec(dllexport)
    51 #  endif
    52 # else
    53 #  if defined(__GNUC__) && __GNUC__ >= 4
    54 #   define DECLSPEC	__attribute__ ((visibility("default")))
    55 #  else
    56 #   define DECLSPEC
    57 #  endif
    58 # endif
    59 #endif
    60 
    61 /* By default SDL uses the C calling convention */
    62 #ifndef SDLCALL
    63 #if defined(__WIN32__) && !defined(__GNUC__)
    64 #define SDLCALL __cdecl
    65 #else
    66 #define SDLCALL
    67 #endif
    68 #endif /* SDLCALL */
    69 
    70 /* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */
    71 #ifdef __SYMBIAN32__
    72 #undef DECLSPEC
    73 #define DECLSPEC
    74 #endif /* __SYMBIAN32__ */
    75 
    76 /* Force structure packing at 4 byte alignment.
    77    This is necessary if the header is included in code which has structure
    78    packing set to an alternate value, say for loading structures from disk.
    79    The packing is reset to the previous value in close_code.h
    80  */
    81 #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
    82 #ifdef _MSC_VER
    83 #pragma warning(disable: 4103)
    84 #endif
    85 #ifdef __BORLANDC__
    86 #pragma nopackwarning
    87 #endif
    88 #pragma pack(push,4)
    89 #endif /* Compiler needs structure packing set */
    90 
    91 /* Set up compiler-specific options for inlining functions */
    92 #ifndef SDL_INLINE_OKAY
    93 #ifdef __GNUC__
    94 #define SDL_INLINE_OKAY
    95 #else
    96 /* Add any special compiler-specific cases here */
    97 #if defined(_MSC_VER) || defined(__BORLANDC__) || \
    98     defined(__DMC__) || defined(__SC__) || \
    99     defined(__WATCOMC__) || defined(__LCC__) || \
   100     defined(__DECC)
   101 #ifndef __inline__
   102 #define __inline__	__inline
   103 #endif
   104 #define SDL_INLINE_OKAY
   105 #else
   106 #if !defined(__MRC__) && !defined(_SGI_SOURCE)
   107 #ifndef __inline__
   108 #define __inline__ inline
   109 #endif
   110 #define SDL_INLINE_OKAY
   111 #endif /* Not a funky compiler */
   112 #endif /* Visual C++ */
   113 #endif /* GNU C */
   114 #endif /* SDL_INLINE_OKAY */
   115 
   116 /* If inlining isn't supported, remove "__inline__", turning static
   117    inlined functions into static functions (resulting in code bloat
   118    in all files which include the offending header files)
   119 */
   120 #ifndef SDL_INLINE_OKAY
   121 #define __inline__
   122 #endif
   123 
   124 /* Apparently this is needed by several Windows compilers */
   125 #if !defined(__MACH__)
   126 #ifndef NULL
   127 #ifdef __cplusplus
   128 #define NULL 0
   129 #else
   130 #define NULL ((void *)0)
   131 #endif
   132 #endif /* NULL */
   133 #endif /* ! Mac OS X - breaks precompiled headers */