|
|
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.1.5 root 135: #if defined(WARPUP)
136: #include "devices/timer.h"
137: #include "osdep/posixemu.h"
138: #define REGPARAM
139: #define REGPARAM2
140: #define RETSIGTYPE
141: #define USE_ZFILE
142: #define strcasecmp stricmp
143: #define memcpy q_memcpy
144: #define memset q_memset
145: #define strdup my_strdup
146: #define random rand
1.1.1.6 root 147: #define creat(x,y) open("T:creat",O_CREAT|O_RDWR|O_TRUNC,777)
1.1.1.5 root 148: extern void* q_memset(void*,int,size_t);
149: extern void* q_memcpy(void*,const void*,size_t);
150: #endif
151:
1.1 root 152: #ifdef __DOS__
153: #include <pc.h>
154: #include <io.h>
155: #endif
156:
1.1.1.3 root 157: /* Acorn specific stuff */
158: #ifdef ACORN
159:
160: #define S_IRUSR S_IREAD
161: #define S_IWUSR S_IWRITE
162: #define S_IXUSR S_IEXEC
163:
164: #define strcasecmp stricmp
165:
166: #endif
167:
168: #ifndef L_tmpnam
169: #define L_tmpnam 128 /* ought to be safe */
170: #endif
171:
1.1 root 172: /* If char has more then 8 bits, good night. */
1.1.1.3 root 173: typedef unsigned char uae_u8;
174: typedef signed char uae_s8;
175:
176: typedef struct { uae_u8 RGB[3]; } RGB;
1.1 root 177:
178: #if SIZEOF_SHORT == 2
1.1.1.3 root 179: typedef unsigned short uae_u16;
180: typedef short uae_s16;
1.1 root 181: #elif SIZEOF_INT == 2
1.1.1.3 root 182: typedef unsigned int uae_u16;
183: typedef int uae_s16;
1.1 root 184: #else
185: #error No 2 byte type, you lose.
186: #endif
187:
188: #if SIZEOF_INT == 4
1.1.1.3 root 189: typedef unsigned int uae_u32;
190: typedef int uae_s32;
1.1 root 191: #elif SIZEOF_LONG == 4
1.1.1.3 root 192: typedef unsigned long uae_u32;
193: typedef long uae_s32;
1.1 root 194: #else
195: #error No 4 byte type, you lose.
196: #endif
197:
1.1.1.3 root 198: typedef uae_u32 uaecptr;
199:
200: #undef uae_s64
201: #undef uae_u64
1.1 root 202:
203: #if SIZEOF_LONG_LONG == 8
1.1.1.3 root 204: #define uae_s64 long long
1.1.1.7 ! root 205: #define uae_u64 unsigned long long
1.1.1.3 root 206: #define VAL64(a) (a ## LL)
207: #define UVAL64(a) (a ## uLL)
208: #elif SIZEOF___INT64 == 8
209: #define uae_s64 __int64
210: #define uae_u64 unsigned __int64
211: #define VAL64(a) (a)
212: #define UVAL64(a) (a)
1.1 root 213: #elif SIZEOF_LONG == 8
1.1.1.3 root 214: #define uae_s64 long;
215: #define uae_u64 unsigned long;
216: #define VAL64(a) (a ## l)
217: #define UVAL64(a) (a ## ul)
1.1 root 218: #endif
1.1.1.3 root 219:
220: #ifdef HAVE_STRDUP
221: #define my_strdup strdup
222: #else
223: extern char *my_strdup (const char*s);
1.1.1.2 root 224: #endif
1.1.1.3 root 225:
226: extern void *xmalloc(size_t);
1.1.1.7 ! root 227: extern void *xcalloc(size_t, size_t);
1.1.1.3 root 228:
229: /* We can only rely on GNU C getting enums right. Mickeysoft VSC++ is known
230: * to have problems, and it's likely that other compilers choke too. */
231: #ifdef __GNUC__
232: #define ENUMDECL typedef enum
233: #define ENUMNAME(name) name
234: #else
235: #define ENUMDECL enum
236: #define ENUMNAME(name) ; typedef int name
237: #endif
238:
239: /*
240: * Porters to weird systems, look! This is the preferred way to get
241: * filesys.c (and other stuff) running on your system. Define the
242: * appropriate macros and implement wrappers in a machine-specific file.
243: *
244: * I guess the Mac port could use this (Ernesto?)
245: */
246:
247: #undef DONT_HAVE_POSIX
248: #undef DONT_HAVE_REAL_POSIX /* define if open+delete doesn't do what it should */
249: #undef DONT_HAVE_STDIO
250: #undef DONT_HAVE_MALLOC
251:
1.1.1.5 root 252: #if defined(WARPUP)
253: #define DONT_HAVE_POSIX
254: #endif
255:
1.1.1.4 root 256: #if defined _WIN32
257:
258: #if defined __WATCOMC__
259:
260: #define O_NDELAY 0
261: #include <direct.h>
262: #define dirent direct
263: #define mkdir(a,b) mkdir(a)
264: #define strcasecmp stricmp
265:
266: #elif defined __MINGW32__
267:
268: #define O_NDELAY 0
269: #define mkdir(a,b) mkdir(a)
270:
1.1.1.3 root 271: #endif
272:
1.1.1.4 root 273: #endif /* _WIN32 */
274:
1.1.1.3 root 275: #ifdef DONT_HAVE_POSIX
276:
277: #define access posixemu_access
1.1.1.4 root 278: extern int posixemu_access (const char *, int);
1.1.1.3 root 279: #define open posixemu_open
1.1.1.4 root 280: extern int posixemu_open (const char *, int, int);
1.1.1.3 root 281: #define close posixemu_close
1.1.1.4 root 282: extern void posixemu_close (int);
1.1.1.3 root 283: #define read posixemu_read
1.1.1.4 root 284: extern int posixemu_read (int, char *, int);
1.1.1.3 root 285: #define write posixemu_write
1.1.1.4 root 286: extern int posixemu_write (int, const char *, int);
1.1.1.3 root 287: #undef lseek
288: #define lseek posixemu_seek
1.1.1.4 root 289: extern int posixemu_seek (int, int, int);
290: #define stat(a,b) posixemu_stat ((a), (b))
291: extern int posixemu_stat (const char *, STAT *);
1.1.1.3 root 292: #define mkdir posixemu_mkdir
1.1.1.4 root 293: extern int mkdir (const char *, int);
1.1.1.3 root 294: #define rmdir posixemu_rmdir
1.1.1.4 root 295: extern int posixemu_rmdir (const char *);
1.1.1.3 root 296: #define unlink posixemu_unlink
1.1.1.4 root 297: extern int posixemu_unlink (const char *);
298: #define truncate posixemu_truncate
299: extern int posixemu_truncate (const char *, long int);
1.1.1.3 root 300: #define rename posixemu_rename
1.1.1.4 root 301: extern int posixemu_rename (const char *, const char *);
1.1.1.3 root 302: #define chmod posixemu_chmod
1.1.1.4 root 303: extern int posixemu_chmod (const char *, int);
1.1.1.3 root 304: #define tmpnam posixemu_tmpnam
1.1.1.4 root 305: extern void posixemu_tmpnam (char *);
1.1.1.3 root 306: #define utime posixemu_utime
1.1.1.4 root 307: extern int posixemu_utime (const char *, struct utimbuf *);
308: #define opendir posixemu_opendir
309: extern DIR * posixemu_opendir (const char *);
310: #define readdir posixemu_readdir
311: extern struct dirent* readdir (DIR *);
312: #define closedir posixemu_closedir
313: extern void closedir (DIR *);
314:
1.1.1.3 root 315: /* This isn't the best place for this, but it fits reasonably well. The logic
316: * is that you probably don't have POSIX errnos if you don't have the above
317: * functions. */
1.1.1.4 root 318: extern long dos_errno (void);
1.1.1.3 root 319:
320: #endif
321:
322: #ifdef DONT_HAVE_STDIO
323:
1.1.1.4 root 324: extern FILE *stdioemu_fopen (const char *, const char *);
325: #define fopen(a,b) stdioemu_fopen(a, b)
326: extern int stdioemu_fseek (FILE *, int, int);
327: #define fseek(a,b,c) stdioemu_fseek(a, b, c)
328: extern int stdioemu_fread (char *, int, int, FILE *);
329: #define fread(a,b,c,d) stdioemu_fread(a, b, c, d)
330: extern int stdioemu_fwrite (const char *, int, int, FILE *);
331: #define fwrite(a,b,c,d) stdioemu_fwrite(a, b, c, d)
332: extern int stdioemu_ftell (FILE *);
1.1.1.3 root 333: #define ftell(a) stdioemu_ftell(a)
1.1.1.4 root 334: extern int stdioemu_fclose (FILE *);
1.1.1.3 root 335: #define fclose(a) stdioemu_fclose(a)
336:
337: #endif
338:
339: #ifdef DONT_HAVE_MALLOC
340:
341: #define malloc(a) mallocemu_malloc(a)
1.1.1.4 root 342: extern void *mallocemu_malloc (int size);
1.1.1.3 root 343: #define free(a) mallocemu_free(a)
1.1.1.4 root 344: extern void mallocemu_free (void *ptr);
1.1.1.3 root 345:
346: #endif
347:
348: #ifdef X86_ASSEMBLY
349: #define ASM_SYM_FOR_FUNC(a) __asm__(a)
350: #else
351: #define ASM_SYM_FOR_FUNC(a)
352: #endif
353:
354: #if defined USE_COMPILER
355: #undef NO_PREFETCH_BUFFER
356: #undef NO_EXCEPTION_3
357: #define NO_EXCEPTION_3
358: #define NO_PREFETCH_BUFFER
359: #endif
360:
361: #include "target.h"
1.1.1.4 root 362:
363: #ifndef O_BINARY
364: #define O_BINARY 0
365: #endif
1.1.1.5 root 366:
367: #ifndef STATIC_INLINE
368: #define STATIC_INLINE static __inline__
369: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.