00001 #ifndef __NeXT_csosdefs_h
00002 #define __NeXT_csosdefs_h
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
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
00073
00074 #undef CS_SOFTWARE_2D_DRIVER
00075 #ifdef __APPLE__
00076 # define CS_SOFTWARE_2D_DRIVER "crystalspace.graphics2d.coregraphics"
00077 #else
00078 # define CS_SOFTWARE_2D_DRIVER "crystalspace.graphics2d.next"
00079 #endif
00080
00081 #undef CS_OPENGL_2D_DRIVER
00082 #define CS_OPENGL_2D_DRIVER "crystalspace.graphics2d.glosx"
00083
00084 #undef CS_SOUND_DRIVER
00085 #define CS_SOUND_DRIVER "crystalspace.sound.driver.coreaudio"
00086
00087
00088
00089
00090
00091 #include <stdlib.h>
00092 #include <string.h>
00093
00094 #if defined(OS_NEXT_NEXTSTEP) || defined(OS_NEXT_OPENSTEP)
00095
00096 static inline char* strdup(char const* s)
00097 {
00098 if (s == 0) s = "";
00099 char* p = (char*)malloc(strlen(s) + 1);
00100 strcpy(p, s);
00101 return p;
00102 }
00103
00104 #endif
00105
00106
00107
00108
00109
00110 #include <sys/param.h>
00111 #define CS_MAXPATHLEN MAXPATHLEN
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121 #if defined(CS_SYSDEF_PROVIDE_GETCWD) || \
00122 defined(CS_SYSDEF_PROVIDE_SOCKETS) || \
00123 defined(CS_SYSDEF_PROVIDE_SELECT) || \
00124 defined(CS_SYSDEF_PROVIDE_ACCESS)
00125 #include <libc.h>
00126 #undef Free
00127 #endif
00128
00129 #if defined(CS_SYSDEF_PROVIDE_SOCKETS)
00130 #define CS_USE_FAKE_SOCKLEN_TYPE
00131 #endif
00132
00133 #if defined(CS_SYSDEF_PROVIDE_SELECT)
00134 #include <string.h>
00135 #define bzero(b,len) memset(b,0,len)
00136 #undef CS_SYSDEF_PROVIDE_SELECT
00137 #endif
00138
00139
00140
00141
00142
00143 #if defined(OS_NEXT_NEXTSTEP) || \
00144 defined(OS_NEXT_OPENSTEP) || \
00145 defined(OS_NEXT_MACOSXS)
00146
00147 #if defined(CS_SYSDEF_PROVIDE_GETCWD)
00148 #undef CS_SYSDEF_PROVIDE_GETCWD
00149
00150 #include <sys/param.h>
00151
00152 static inline char* getcwd(char* p, size_t size)
00153 {
00154 char s[ CS_MAXPATHLEN ];
00155 char* r = getwd(s);
00156 if (r != 0)
00157 {
00158 strncpy(p, r, size - 1);
00159 p[ size - 1 ] = '\0';
00160 r = p;
00161 }
00162 return r;
00163 }
00164
00165 #endif // CS_SYSDEF_PROVIDE_GETCWD
00166 #endif // OS_NEXT_NEXTSTEP || OS_NEXT_OPENSTEP || OS_NEXT_MACOSXS
00167
00168
00169
00170
00171
00172 #ifdef CS_SYSDEF_PROVIDE_DIR
00173
00174 #ifdef _POSIX_SOURCE
00175 # undef _POSIX_SOURCE
00176 # include <sys/dir.h>
00177 # define _POSIX_SOURCE
00178 #else
00179 # include <sys/dir.h>
00180 #endif
00181 #include <sys/dirent.h>
00182 #define dirent direct
00183
00184 #define __NEED_GENERIC_ISDIR
00185 #endif // CS_SYSDEF_PROVIDE_DIR
00186
00187
00188
00189
00190
00191 #ifdef CS_SYSDEF_PROVIDE_ALLOCA
00192 #undef CS_SYSDEF_PROVIDE_ALLOCA
00193 #define alloca(x) __builtin_alloca(x)
00194 #define ALLOC_STACK_ARRAY(var,type,size) type var[size]
00195 #endif // CS_SYSDEF_PROVIDE_ALLOCA
00196
00197
00198
00199
00200
00201 #if defined (__LITTLE_ENDIAN__)
00202 # define CS_LITTLE_ENDIAN
00203 #elif defined (__BIG_ENDIAN__)
00204 # define CS_BIG_ENDIAN
00205 #else
00206 # error "Please define a suitable CS_XXX_ENDIAN macro in next/csosdefs.h!"
00207 #endif
00208
00209
00210
00211
00212
00213
00214
00215
00216 #undef CS_STATIC_TABLE
00217 #define CS_STATIC_TABLE static
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230 #if !defined(PROC_X86)
00231 # define CS_NO_IEEE_OPTIMIZATIONS
00232 #endif
00233
00234
00235
00236
00237
00238
00239
00240 #if !defined(PROC_POWERPC)
00241 # define CS_NO_QSQRT
00242 #endif
00243
00244
00245
00246
00247
00248
00249
00250 #if defined(OS_NEXT_MACOSX)
00251
00252 #ifdef CS_SYSDEF_PROVIDE_HARDWARE_MMIO
00253
00254
00255 #include <unistd.h>
00256 #include <sys/mman.h>
00257 #include <sys/types.h>
00258 #include <sys/stat.h>
00259 #include <fcntl.h>
00260
00261
00262 #define CS_HAS_MEMORY_MAPPED_IO 1
00263
00264
00265 struct mmioInfo
00266 {
00268 int hMappedFile;
00269
00271 unsigned char *data;
00272
00274 unsigned int file_size;
00275 };
00276
00277
00278 inline
00279 bool
00280 MemoryMapFile(mmioInfo *platform, char *filename)
00281 {
00282 struct stat statInfo;
00283
00284
00285 if (
00286 (platform->hMappedFile = open(filename, O_RDONLY)) == -1 ||
00287 (fstat(platform->hMappedFile, &statInfo )) == -1 ||
00288 (int)(platform->data = (unsigned char *)mmap(0, statInfo.st_size, PROT_READ, 0, platform->hMappedFile, 0)) == -1
00289 )
00290 {
00291 return false;
00292 }
00293 else
00294 {
00295 platform->file_size=statInfo.st_size;
00296 return true;
00297 }
00298 }
00299
00300 inline
00301 void
00302 UnMemoryMapFile(mmioInfo *platform)
00303 {
00304 if (platform->data != NULL)
00305 munmap(platform->data, platform->file_size);
00306
00307 if (platform->hMappedFile != -1)
00308 close(platform->hMappedFile);
00309 }
00310
00311 #endif // memory-mapped I/O
00312
00313
00314 #endif // OS_NEXT_MACOSX
00315
00316
00317 #endif // __NeXT_csosdefs_h