|
|
1.1 root 1: /* 1.1.1.2 ! root 2: * UAE - The Un*x Amiga Emulator - CPU core 1.1 root 3: * 4: * Try to include the right system headers and get other system-specific 5: * stuff right & other collected kludges. 6: * 7: * If you think about modifying this, think twice. Some systems rely on 8: * the exact order of the #include statements. That's also the reason 9: * why everything gets included unconditionally regardless of whether 10: * it's actually needed by the .c file. 11: * 12: * Copyright 1996, 1997 Bernd Schmidt 1.1.1.2 ! root 13: * ! 14: * Adaptation to Hatari by Thomas Huth ! 15: * 1.1 root 16: */ 17: 18: #ifndef UAESYSDEPS 19: #define UAESYSDEPS 20: 21: 22: /* FIXME: We should use a test instead: */ 23: /* The number of bytes in a short. */ 24: #define SIZEOF_SHORT 2 25: /* The number of bytes in a int. */ 26: #define SIZEOF_INT 4 27: /* The number of bytes in a long. */ 28: #define SIZEOF_LONG 4 29: 30: #include <stdio.h> 31: #include <stdlib.h> 32: #include <errno.h> 33: #include <assert.h> 34: #include <limits.h> 35: 36: #ifndef __STDC__ 37: #error "Your compiler is not ANSI. Get a real one." 38: #endif 39: 40: #include <stdarg.h> 41: 42: #ifdef HAVE_SYS_TYPES_H 43: #include <sys/types.h> 44: #endif 45: 46: #ifdef HAVE_VALUES_H 47: #include <values.h> 48: #endif 49: 50: #ifdef HAVE_STRINGS_H 51: #include <strings.h> 52: #endif 53: #ifdef HAVE_STRING_H 54: #include <string.h> 55: #endif 56: 57: #ifdef HAVE_UNISTD_H 58: #include <unistd.h> 59: #endif 60: #ifdef HAVE_FCNTL_H 61: #include <fcntl.h> 62: #endif 63: 64: #ifdef HAVE_UTIME_H 65: #include <utime.h> 66: #endif 67: 68: #ifdef HAVE_SYS_STAT_H 69: #include <sys/stat.h> 70: #endif 71: 72: #if TIME_WITH_SYS_TIME 73: # include <sys/time.h> 74: # include <time.h> 75: #else 76: # if HAVE_SYS_TIME_H 77: # include <sys/time.h> 78: # else 79: # include <time.h> 80: # endif 81: #endif 82: 83: #if HAVE_DIRENT_H 84: # include <dirent.h> 85: #else 86: # define dirent direct 87: # if HAVE_SYS_NDIR_H 88: # include <sys/ndir.h> 89: # endif 90: # if HAVE_SYS_DIR_H 91: # include <sys/dir.h> 92: # endif 93: # if HAVE_NDIR_H 94: # include <ndir.h> 95: # endif 96: #endif 97: 98: #ifdef HAVE_SYS_UTIME_H 99: # include <sys/utime.h> 100: #endif 101: 102: #include <errno.h> 103: #include <assert.h> 104: 105: #if EEXIST == ENOTEMPTY 106: #define BROKEN_OS_PROBABLY_AIX 107: #endif 108: 109: #ifdef __NeXT__ 110: #define S_IRUSR S_IREAD 111: #define S_IWUSR S_IWRITE 112: #define S_IXUSR S_IEXEC 113: #define S_ISDIR(val) (S_IFDIR & val) 114: struct utimbuf 115: { 116: time_t actime; 117: time_t modtime; 118: }; 119: #endif 120: 121: #if defined(__GNUC__) && defined(AMIGA) 122: /* gcc on the amiga need that __attribute((regparm)) must */ 123: /* be defined in function prototypes as well as in */ 124: /* function definitions ! */ 125: #define REGPARAM2 REGPARAM 126: #else /* not(GCC & AMIGA) */ 127: #define REGPARAM2 128: #endif 129: 130: /* sam: some definitions so that SAS/C can compile UAE */ 131: #if defined(__SASC) && defined(AMIGA) 132: #define REGPARAM2 133: #define REGPARAM 134: #define S_IRUSR S_IREAD 135: #define S_IWUSR S_IWRITE 136: #define S_IXUSR S_IEXECUTE 137: #define S_ISDIR(val) (S_IFDIR & val) 138: #define mkdir(x,y) mkdir(x) 139: #define truncate(x,y) 0 140: #define creat(x,y) open("T:creat",O_CREAT|O_TEMP|O_RDWR) /* sam: for zfile.c */ 141: #define strcasecmp stricmp 142: #define utime(file,time) 0 143: struct utimbuf 144: { 145: time_t actime; 146: time_t modtime; 147: }; 148: #endif 149: 150: #if defined(WARPUP) 151: #include "devices/timer.h" 152: #include "osdep/posixemu.h" 153: #define REGPARAM 154: #define REGPARAM2 155: #define RETSIGTYPE 156: #define USE_ZFILE 157: #define strcasecmp stricmp 158: #define memcpy q_memcpy 159: #define memset q_memset 160: #define strdup my_strdup 161: #define random rand 162: #define creat(x,y) open("T:creat",O_CREAT|O_RDWR|O_TRUNC,777) 163: extern void* q_memset(void*,int,size_t); 164: extern void* q_memcpy(void*,const void*,size_t); 165: #endif 166: 167: #ifdef __DOS__ 168: #include <pc.h> 169: #include <io.h> 170: #endif 171: 172: /* Acorn specific stuff */ 173: #ifdef ACORN 174: 175: #define S_IRUSR S_IREAD 176: #define S_IWUSR S_IWRITE 177: #define S_IXUSR S_IEXEC 178: 179: #define strcasecmp stricmp 180: 181: #endif 182: 183: #ifndef L_tmpnam 184: #define L_tmpnam 128 /* ought to be safe */ 185: #endif 186: 187: /* If char has more then 8 bits, good night. */ 188: typedef unsigned char uae_u8; 189: typedef signed char uae_s8; 190: 191: typedef struct { uae_u8 RGB[3]; } RGB; 192: 193: #if SIZEOF_SHORT == 2 194: typedef unsigned short uae_u16; 195: typedef short uae_s16; 196: #elif SIZEOF_INT == 2 197: typedef unsigned int uae_u16; 198: typedef int uae_s16; 199: #else 200: #error No 2 byte type, you lose. 201: #endif 202: 203: #if SIZEOF_INT == 4 204: typedef unsigned int uae_u32; 205: typedef int uae_s32; 206: #elif SIZEOF_LONG == 4 207: typedef unsigned long uae_u32; 208: typedef long uae_s32; 209: #else 210: #error No 4 byte type, you lose. 211: #endif 212: 213: typedef uae_u32 uaecptr; 214: 215: #undef uae_s64 216: #undef uae_u64 217: 218: #if SIZEOF_LONG_LONG == 8 219: #define uae_s64 long long 220: #define uae_u64 long long 221: #define VAL64(a) (a ## LL) 222: #define UVAL64(a) (a ## uLL) 223: #elif SIZEOF___INT64 == 8 224: #define uae_s64 __int64 225: #define uae_u64 unsigned __int64 226: #define VAL64(a) (a) 227: #define UVAL64(a) (a) 228: #elif SIZEOF_LONG == 8 229: #define uae_s64 long; 230: #define uae_u64 unsigned long; 231: #define VAL64(a) (a ## l) 232: #define UVAL64(a) (a ## ul) 233: #endif 234: 235: #ifdef HAVE_STRDUP 236: #define my_strdup strdup 237: #else 238: extern char *my_strdup (const char*s); 239: #endif 240: 241: extern void *xmalloc(size_t); 242: 243: /* We can only rely on GNU C getting enums right. Mickeysoft VSC++ is known 244: * to have problems, and it's likely that other compilers choke too. */ 245: #ifdef __GNUC__ 246: #define ENUMDECL typedef enum 247: #define ENUMNAME(name) name 248: #else 249: #define ENUMDECL enum 250: #define ENUMNAME(name) ; typedef int name 251: #endif 252: 253: /* 254: * Porters to weird systems, look! This is the preferred way to get 255: * filesys.c (and other stuff) running on your system. Define the 256: * appropriate macros and implement wrappers in a machine-specific file. 257: * 258: * I guess the Mac port could use this (Ernesto?) 259: */ 260: 261: #undef DONT_HAVE_POSIX 262: #undef DONT_HAVE_REAL_POSIX /* define if open+delete doesn't do what it should */ 263: #undef DONT_HAVE_STDIO 264: #undef DONT_HAVE_MALLOC 265: 266: #if defined(WARPUP) 267: #define DONT_HAVE_POSIX 268: #endif 269: 270: #if defined _WIN32 271: 272: #if defined __WATCOMC__ 273: 274: #define O_NDELAY 0 275: #include <direct.h> 276: #define dirent direct 277: #define mkdir(a,b) mkdir(a) 278: #define strcasecmp stricmp 279: 280: #elif defined __MINGW32__ 281: 282: #define O_NDELAY 0 283: #define mkdir(a,b) mkdir(a) 284: 285: #endif 286: 287: #endif /* _WIN32 */ 288: 289: #ifdef DONT_HAVE_POSIX 290: 291: #define access posixemu_access 292: extern int posixemu_access (const char *, int); 293: #define open posixemu_open 294: extern int posixemu_open (const char *, int, int); 295: #define close posixemu_close 296: extern void posixemu_close (int); 297: #define read posixemu_read 298: extern int posixemu_read (int, char *, int); 299: #define write posixemu_write 300: extern int posixemu_write (int, const char *, int); 301: #undef lseek 302: #define lseek posixemu_seek 303: extern int posixemu_seek (int, int, int); 304: #define stat(a,b) posixemu_stat ((a), (b)) 305: extern int posixemu_stat (const char *, STAT *); 306: #define mkdir posixemu_mkdir 307: extern int mkdir (const char *, int); 308: #define rmdir posixemu_rmdir 309: extern int posixemu_rmdir (const char *); 310: #define unlink posixemu_unlink 311: extern int posixemu_unlink (const char *); 312: #define truncate posixemu_truncate 313: extern int posixemu_truncate (const char *, long int); 314: #define rename posixemu_rename 315: extern int posixemu_rename (const char *, const char *); 316: #define chmod posixemu_chmod 317: extern int posixemu_chmod (const char *, int); 318: #define tmpnam posixemu_tmpnam 319: extern void posixemu_tmpnam (char *); 320: #define utime posixemu_utime 321: extern int posixemu_utime (const char *, struct utimbuf *); 322: #define opendir posixemu_opendir 323: extern DIR * posixemu_opendir (const char *); 324: #define readdir posixemu_readdir 325: extern struct dirent* readdir (DIR *); 326: #define closedir posixemu_closedir 327: extern void closedir (DIR *); 328: 329: /* This isn't the best place for this, but it fits reasonably well. The logic 330: * is that you probably don't have POSIX errnos if you don't have the above 331: * functions. */ 332: extern long dos_errno (void); 333: 334: #endif 335: 336: #ifdef DONT_HAVE_STDIO 337: 338: extern FILE *stdioemu_fopen (const char *, const char *); 339: #define fopen(a,b) stdioemu_fopen(a, b) 340: extern int stdioemu_fseek (FILE *, int, int); 341: #define fseek(a,b,c) stdioemu_fseek(a, b, c) 342: extern int stdioemu_fread (char *, int, int, FILE *); 343: #define fread(a,b,c,d) stdioemu_fread(a, b, c, d) 344: extern int stdioemu_fwrite (const char *, int, int, FILE *); 345: #define fwrite(a,b,c,d) stdioemu_fwrite(a, b, c, d) 346: extern int stdioemu_ftell (FILE *); 347: #define ftell(a) stdioemu_ftell(a) 348: extern int stdioemu_fclose (FILE *); 349: #define fclose(a) stdioemu_fclose(a) 350: 351: #endif 352: 353: #ifdef DONT_HAVE_MALLOC 354: 355: #define malloc(a) mallocemu_malloc(a) 356: extern void *mallocemu_malloc (int size); 357: #define free(a) mallocemu_free(a) 358: extern void mallocemu_free (void *ptr); 359: 360: #endif 361: 362: 363: #if defined USE_COMPILER 364: #undef NO_PREFETCH_BUFFER 365: #undef NO_EXCEPTION_3 366: #define NO_EXCEPTION_3 367: #define NO_PREFETCH_BUFFER 368: #endif 369: 370: /*#include "target.h"*/ 371: 372: #ifndef O_BINARY 373: #define O_BINARY 0 374: #endif 375: 376: #ifndef STATIC_INLINE 377: #define STATIC_INLINE static __inline__ 378: #endif 379: 380: /* 381: * You can specify numbers from 0 to 5 here. It is possible that higher 382: * numbers will make the CPU emulation slightly faster, but if the setting 383: * is too high, you will run out of memory while compiling. 384: * Best to leave this as it is. 385: */ 386: #define CPU_EMU_SIZE 0 387: 388: #ifndef REGPARAM 389: # define REGPARAM 390: #endif 391: #ifndef REGPARAM2 392: # define REGPARAM2 393: #endif 394: 395: #endif /* ifndef UAESYSDEPS */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.