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