Annotation of uae/src/include/sysdeps.h, revision 1.1.1.3

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.