|
|
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
! 147: #define creat(x,y) open("T:creat",O_CREAT|O_RDWR,777)
! 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
205: #define uae_u64 long long
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);
227:
228: /* We can only rely on GNU C getting enums right. Mickeysoft VSC++ is known
229: * to have problems, and it's likely that other compilers choke too. */
230: #ifdef __GNUC__
231: #define ENUMDECL typedef enum
232: #define ENUMNAME(name) name
233: #else
234: #define ENUMDECL enum
235: #define ENUMNAME(name) ; typedef int name
236: #endif
237:
238: /*
239: * Porters to weird systems, look! This is the preferred way to get
240: * filesys.c (and other stuff) running on your system. Define the
241: * appropriate macros and implement wrappers in a machine-specific file.
242: *
243: * I guess the Mac port could use this (Ernesto?)
244: */
245:
246: #undef DONT_HAVE_POSIX
247: #undef DONT_HAVE_REAL_POSIX /* define if open+delete doesn't do what it should */
248: #undef DONT_HAVE_STDIO
249: #undef DONT_HAVE_MALLOC
250:
1.1.1.5 ! root 251: #if defined(WARPUP)
! 252: #define DONT_HAVE_POSIX
! 253: #endif
! 254:
1.1.1.4 root 255: #if defined _WIN32
256:
257: #if defined __WATCOMC__
258:
259: #define O_NDELAY 0
260: #include <direct.h>
261: #define dirent direct
262: #define mkdir(a,b) mkdir(a)
263: #define strcasecmp stricmp
264:
265: #elif defined __MINGW32__
266:
267: #define O_NDELAY 0
268: #define mkdir(a,b) mkdir(a)
269:
1.1.1.3 root 270: #endif
271:
1.1.1.4 root 272: #endif /* _WIN32 */
273:
1.1.1.3 root 274: #ifdef DONT_HAVE_POSIX
275:
276: #define access posixemu_access
1.1.1.4 root 277: extern int posixemu_access (const char *, int);
1.1.1.3 root 278: #define open posixemu_open
1.1.1.4 root 279: extern int posixemu_open (const char *, int, int);
1.1.1.3 root 280: #define close posixemu_close
1.1.1.4 root 281: extern void posixemu_close (int);
1.1.1.3 root 282: #define read posixemu_read
1.1.1.4 root 283: extern int posixemu_read (int, char *, int);
1.1.1.3 root 284: #define write posixemu_write
1.1.1.4 root 285: extern int posixemu_write (int, const char *, int);
1.1.1.3 root 286: #undef lseek
287: #define lseek posixemu_seek
1.1.1.4 root 288: extern int posixemu_seek (int, int, int);
289: #define stat(a,b) posixemu_stat ((a), (b))
290: extern int posixemu_stat (const char *, STAT *);
1.1.1.3 root 291: #define mkdir posixemu_mkdir
1.1.1.4 root 292: extern int mkdir (const char *, int);
1.1.1.3 root 293: #define rmdir posixemu_rmdir
1.1.1.4 root 294: extern int posixemu_rmdir (const char *);
1.1.1.3 root 295: #define unlink posixemu_unlink
1.1.1.4 root 296: extern int posixemu_unlink (const char *);
297: #define truncate posixemu_truncate
298: extern int posixemu_truncate (const char *, long int);
1.1.1.3 root 299: #define rename posixemu_rename
1.1.1.4 root 300: extern int posixemu_rename (const char *, const char *);
1.1.1.3 root 301: #define chmod posixemu_chmod
1.1.1.4 root 302: extern int posixemu_chmod (const char *, int);
1.1.1.3 root 303: #define tmpnam posixemu_tmpnam
1.1.1.4 root 304: extern void posixemu_tmpnam (char *);
1.1.1.3 root 305: #define utime posixemu_utime
1.1.1.4 root 306: extern int posixemu_utime (const char *, struct utimbuf *);
307: #define opendir posixemu_opendir
308: extern DIR * posixemu_opendir (const char *);
309: #define readdir posixemu_readdir
310: extern struct dirent* readdir (DIR *);
311: #define closedir posixemu_closedir
312: extern void closedir (DIR *);
313:
1.1.1.3 root 314: /* This isn't the best place for this, but it fits reasonably well. The logic
315: * is that you probably don't have POSIX errnos if you don't have the above
316: * functions. */
1.1.1.4 root 317: extern long dos_errno (void);
1.1.1.3 root 318:
319: #endif
320:
321: #ifdef DONT_HAVE_STDIO
322:
1.1.1.4 root 323: extern FILE *stdioemu_fopen (const char *, const char *);
324: #define fopen(a,b) stdioemu_fopen(a, b)
325: extern int stdioemu_fseek (FILE *, int, int);
326: #define fseek(a,b,c) stdioemu_fseek(a, b, c)
327: extern int stdioemu_fread (char *, int, int, FILE *);
328: #define fread(a,b,c,d) stdioemu_fread(a, b, c, d)
329: extern int stdioemu_fwrite (const char *, int, int, FILE *);
330: #define fwrite(a,b,c,d) stdioemu_fwrite(a, b, c, d)
331: extern int stdioemu_ftell (FILE *);
1.1.1.3 root 332: #define ftell(a) stdioemu_ftell(a)
1.1.1.4 root 333: extern int stdioemu_fclose (FILE *);
1.1.1.3 root 334: #define fclose(a) stdioemu_fclose(a)
335:
336: #endif
337:
338: #ifdef DONT_HAVE_MALLOC
339:
340: #define malloc(a) mallocemu_malloc(a)
1.1.1.4 root 341: extern void *mallocemu_malloc (int size);
1.1.1.3 root 342: #define free(a) mallocemu_free(a)
1.1.1.4 root 343: extern void mallocemu_free (void *ptr);
1.1.1.3 root 344:
345: #endif
346:
347: #ifdef X86_ASSEMBLY
348: #define ASM_SYM_FOR_FUNC(a) __asm__(a)
349: #else
350: #define ASM_SYM_FOR_FUNC(a)
351: #endif
352:
353: #if defined USE_COMPILER
354: #undef NO_PREFETCH_BUFFER
355: #undef NO_EXCEPTION_3
356: #define NO_EXCEPTION_3
357: #define NO_PREFETCH_BUFFER
358: #endif
359:
360: #include "target.h"
1.1.1.4 root 361:
362: #ifndef O_BINARY
363: #define O_BINARY 0
364: #endif
1.1.1.5 ! root 365:
! 366: #ifndef STATIC_INLINE
! 367: #define STATIC_INLINE static __inline__
! 368: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.