Main Page   Class Hierarchy   Compound List   File List   Compound Members  

csosdefs.h

00001 #ifndef __NeXT_csosdefs_h
00002 #define __NeXT_csosdefs_h
00003 //=============================================================================
00004 //
00005 //      Copyright (C)1999-2001 by Eric Sunshine <sunshine@sunshineco.com>
00006 //
00007 // The contents of this file are copyrighted by Eric Sunshine.  This work is
00008 // distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
00009 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
00010 // PARTICULAR PURPOSE.  You may distribute this file provided that this
00011 // copyright notice is retained.  Send comments to <sunshine@sunshineco.com>.
00012 //
00013 //=============================================================================
00014 //-----------------------------------------------------------------------------
00015 // csosdefs.h
00016 //
00017 //      Platform-specific interface to common functionality.  Compatible
00018 //      with MacOS/X, MacOS/X Server 1.0 (Rhapsody), OpenStep, and NextStep.
00019 //
00020 //-----------------------------------------------------------------------------
00021 
00022 //-----------------------------------------------------------------------------
00023 // Define the appropriate PROC_ flag for the current architecture for MacOS/X
00024 // Server, OpenStep, and NextStep multi-architecture binary (MAB) compilations.
00025 // It is necessary to perform this step here since this information is not
00026 // known at makefile configuration time or even at the time when the compiler
00027 // is invoked on account of the ability to build multi-architecture binaries
00028 // with a single invocation of the compiler.  Therefore, this is the first
00029 // chance we have of actually determining the proper PROC_ flag.  Also set
00030 // CS_PROCESSOR_NAME to an appropriate value.
00031 //-----------------------------------------------------------------------------
00032 #if defined(__m68k__)
00033 #  if !defined(PROC_M68K)
00034 #    define PROC_M68K
00035 #    undef  CS_PROCESSOR_NAME
00036 #    define CS_PROCESSOR_NAME "M68K"
00037 #  endif
00038 #elif defined(__i386__)
00039 #  if !defined(PROC_X86)
00040 #    define PROC_X86
00041 #    undef  CS_PROCESSOR_NAME
00042 #    define CS_PROCESSOR_NAME "X86"
00043 #  endif
00044 #elif defined(__sparc__)
00045 #  if !defined(PROC_SPARC)
00046 #    define PROC_SPARC
00047 #    undef  CS_PROCESSOR_NAME
00048 #    define CS_PROCESSOR_NAME "Sparc"
00049 #  endif
00050 #elif defined(__hppa__)
00051 #  if !defined(PROC_HPPA)
00052 #    define PROC_HPPA
00053 #    undef  CS_PROCESSOR_NAME
00054 #    define CS_PROCESSOR_NAME "PA-RISC"
00055 #  endif
00056 #elif defined(__ppc__)
00057 #  if !defined(PROC_POWERPC)
00058 #    define PROC_POWERPC
00059 #    undef  CS_PROCESSOR_NAME
00060 #    define CS_PROCESSOR_NAME "PowerPC"
00061 #  endif
00062 #else
00063 #  if !defined(PROC_UNKNOWN)
00064 #    define PROC_UNKNOWN
00065 #    undef  CS_PROCESSOR_NAME
00066 #    define CS_PROCESSOR_NAME "Unknown"
00067 #  endif
00068 #endif
00069 
00070 
00071 //-----------------------------------------------------------------------------
00072 // The 2D graphics driver used by the software renderer on this platform.
00073 //-----------------------------------------------------------------------------
00074 #undef  CS_SOFTWARE_2D_DRIVER
00075 #define CS_SOFTWARE_2D_DRIVER "crystalspace.graphics2d.next"
00076 
00077 #undef  CS_OPENGL_2D_DRIVER
00078 #define CS_OPENGL_2D_DRIVER   "crystalspace.graphics2d.glnext"
00079 
00080 //-----------------------------------------------------------------------------
00081 // NeXT does not supply strdup() so fake one up.
00082 //-----------------------------------------------------------------------------
00083 #include <stdlib.h>
00084 #include <string.h>
00085 
00086 #if defined(OS_NEXT_NEXTSTEP) || defined(OS_NEXT_OPENSTEP)
00087 
00088 static inline char* strdup(char const* s)
00089 {
00090   if (s == 0) s = "";
00091   char* p = (char*)malloc(strlen(s) + 1);
00092   strcpy(p, s);
00093   return p;
00094 }
00095 
00096 #endif
00097 
00098 
00099 //-----------------------------------------------------------------------------
00100 // Pull in definitions for getwd(), ntohl(), htonl(), select(), etc.
00101 // *NOTE* On MacOS/X Server 1.0, libc.h pulls in sys/mount.h which pulls in
00102 // net/radix.h which defines a macro named Free().  This macro interferes with
00103 // several Crystal Space classes which have methods named Free(), so we must
00104 // #undef it.
00105 //-----------------------------------------------------------------------------
00106 #if defined(CS_SYSDEF_PROVIDE_GETCWD)  || \
00107     defined(CS_SYSDEF_PROVIDE_SOCKETS) || \
00108     defined(CS_SYSDEF_PROVIDE_SELECT)  || \
00109     defined(CS_SYSDEF_PROVIDE_ACCESS)
00110 #include <libc.h>
00111 #undef Free
00112 #endif
00113 
00114 #if defined(CS_SYSDEF_PROVIDE_SOCKETS)
00115 #define CS_USE_FAKE_SOCKLEN_TYPE
00116 #endif
00117 
00118 #if defined(CS_SYSDEF_PROVIDE_SELECT)
00119 #include <string.h> // For memset()
00120 #define bzero(b,len) memset(b,0,len) /* bzero used by FD_ZERO */
00121 #undef CS_SYSDEF_PROVIDE_SELECT
00122 #endif
00123 
00124 
00125 //-----------------------------------------------------------------------------
00126 // NeXT does not supply getcwd() so fake one up using getwd().
00127 //-----------------------------------------------------------------------------
00128 #if defined(OS_NEXT_NEXTSTEP) || \
00129     defined(OS_NEXT_OPENSTEP) || \
00130     defined(OS_NEXT_MACOSXS)
00131 
00132 #if defined(CS_SYSDEF_PROVIDE_GETCWD)
00133 #undef CS_SYSDEF_PROVIDE_GETCWD
00134 
00135 #include <sys/param.h>
00136 
00137 static inline char* getcwd(char* p, size_t size)
00138 {
00139   char s[ MAXPATHLEN ];
00140   char* r = getwd(s);
00141   if (r != 0)
00142   {
00143     strncpy(p, r, size - 1);
00144     p[ size - 1 ] = '\0';
00145     r = p;
00146   }
00147   return r;
00148 }
00149 
00150 #endif // CS_SYSDEF_PROVIDE_GETCWD
00151 #endif // OS_NEXT_NEXTSTEP || OS_NEXT_OPENSTEP || OS_NEXT_MACOSXS
00152 
00153 
00154 //-----------------------------------------------------------------------------
00155 // NeXT does not properly support Posix 'dirent', so fake it with 'direct'.
00156 //-----------------------------------------------------------------------------
00157 #ifdef CS_SYSDEF_PROVIDE_DIR
00158 
00159 #ifdef _POSIX_SOURCE
00160 #  undef _POSIX_SOURCE
00161 #  include <sys/dir.h>
00162 #  define _POSIX_SOURCE
00163 #else
00164 #  include <sys/dir.h>
00165 #endif
00166 #include <sys/dirent.h> // Just so it gets included *before* #define below.
00167 #define dirent direct
00168 
00169 #define __NEED_GENERIC_ISDIR
00170 #endif // CS_SYSDEF_PROVIDE_DIR
00171 
00172 
00173 //-----------------------------------------------------------------------------
00174 // NeXT uses built-in alloca().
00175 //-----------------------------------------------------------------------------
00176 #ifdef CS_SYSDEF_PROVIDE_ALLOCA
00177 #undef CS_SYSDEF_PROVIDE_ALLOCA
00178 #define alloca(x) __builtin_alloca(x)
00179 #define ALLOC_STACK_ARRAY(var,type,size) type var[size]
00180 #endif // CS_SYSDEF_PROVIDE_ALLOCA
00181 
00182 
00183 //-----------------------------------------------------------------------------
00184 // Endian support.
00185 //-----------------------------------------------------------------------------
00186 #if defined (__LITTLE_ENDIAN__)
00187 #  define CS_LITTLE_ENDIAN
00188 #elif defined (__BIG_ENDIAN__)
00189 #  define CS_BIG_ENDIAN
00190 #else
00191 #  error "Please define a suitable CS_XXX_ENDIAN macro in next/csosdefs.h!"
00192 #endif
00193 
00194 
00195 //-----------------------------------------------------------------------------
00196 // NextStep's gcc infrequently throws an exception when confronted with an
00197 // expression such as `static const Foo[] = {...};'.  There are two ways to
00198 // work around this problem.  (1) Remove the `const' or (2) specify the exact
00199 // table size, as in `Foo[3]'.  This patch employs work-around #1.
00200 //-----------------------------------------------------------------------------
00201 #undef CS_STATIC_TABLE
00202 #define CS_STATIC_TABLE static
00203 
00204 
00205 //-----------------------------------------------------------------------------
00206 // Although the IEEE double-format optimizations of QInt() and QRound() work
00207 // on M68K, there are cases (particularly in the software renderer) where the
00208 // compiler corrupts the emitted code for these functions.  Therefore, disable
00209 // these optimizations.
00210 //-----------------------------------------------------------------------------
00211 #if !defined(PROC_X86)
00212 #  define CS_NO_IEEE_OPTIMIZATIONS
00213 #endif
00214 
00215 
00216 //-----------------------------------------------------------------------------
00217 // The special assembly version of qsqrt() (from CS/include/qsqrt.h) fails to
00218 // compile on NeXT.
00219 //-----------------------------------------------------------------------------
00220 #define CS_NO_QSQRT
00221 
00222 
00223 //-----------------------------------------------------------------------------
00224 // The "extensive debug" facility of cssysdef.h is incompatible with some of
00225 // the Apple/NeXT compilers.
00226 //-----------------------------------------------------------------------------
00227 #define CS_EXTENSIVE_MEMDEBUG 0
00228 
00229 #endif // __NeXT_csosdefs_h

Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000