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

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.9   root      106: #if defined(__GNUC__)
1.1.1.2   root      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
1.1.1.8   root      234: 
                    235: /* While we're here, make abort more useful.  */
                    236: #define abort() \
                    237:   do { \
                    238:     write_log ("Internal error; file %s, line %d\n", __FILE__, __LINE__); \
                    239:     (abort) (); \
                    240: } while (0)
1.1.1.3   root      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: 
1.1.1.5   root      259: #if defined(WARPUP)
                    260: #define DONT_HAVE_POSIX
                    261: #endif
                    262: 
1.1.1.4   root      263: #if defined _WIN32
                    264: 
                    265: #if defined __WATCOMC__
                    266: 
                    267: #define O_NDELAY 0
                    268: #include <direct.h>
                    269: #define dirent direct
                    270: #define mkdir(a,b) mkdir(a)
                    271: #define strcasecmp stricmp
                    272: 
                    273: #elif defined __MINGW32__
                    274: 
                    275: #define O_NDELAY 0
                    276: #define mkdir(a,b) mkdir(a)
                    277: 
1.1.1.3   root      278: #endif
                    279: 
1.1.1.4   root      280: #endif /* _WIN32 */ 
                    281: 
1.1.1.3   root      282: #ifdef DONT_HAVE_POSIX
                    283: 
                    284: #define access posixemu_access
1.1.1.4   root      285: extern int posixemu_access (const char *, int);
1.1.1.3   root      286: #define open posixemu_open
1.1.1.4   root      287: extern int posixemu_open (const char *, int, int);
1.1.1.3   root      288: #define close posixemu_close
1.1.1.4   root      289: extern void posixemu_close (int);
1.1.1.3   root      290: #define read posixemu_read
1.1.1.4   root      291: extern int posixemu_read (int, char *, int);
1.1.1.3   root      292: #define write posixemu_write
1.1.1.4   root      293: extern int posixemu_write (int, const char *, int);
1.1.1.3   root      294: #undef lseek
                    295: #define lseek posixemu_seek
1.1.1.4   root      296: extern int posixemu_seek (int, int, int);
                    297: #define stat(a,b) posixemu_stat ((a), (b))
                    298: extern int posixemu_stat (const char *, STAT *);
1.1.1.3   root      299: #define mkdir posixemu_mkdir
1.1.1.4   root      300: extern int mkdir (const char *, int);
1.1.1.3   root      301: #define rmdir posixemu_rmdir
1.1.1.4   root      302: extern int posixemu_rmdir (const char *);
1.1.1.3   root      303: #define unlink posixemu_unlink
1.1.1.4   root      304: extern int posixemu_unlink (const char *);
                    305: #define truncate posixemu_truncate
                    306: extern int posixemu_truncate (const char *, long int);
1.1.1.3   root      307: #define rename posixemu_rename
1.1.1.4   root      308: extern int posixemu_rename (const char *, const char *);
1.1.1.3   root      309: #define chmod posixemu_chmod
1.1.1.4   root      310: extern int posixemu_chmod (const char *, int);
1.1.1.3   root      311: #define tmpnam posixemu_tmpnam
1.1.1.4   root      312: extern void posixemu_tmpnam (char *);
1.1.1.3   root      313: #define utime posixemu_utime
1.1.1.4   root      314: extern int posixemu_utime (const char *, struct utimbuf *);
                    315: #define opendir posixemu_opendir
                    316: extern DIR * posixemu_opendir (const char *);
                    317: #define readdir posixemu_readdir
                    318: extern struct dirent* readdir (DIR *);
                    319: #define closedir posixemu_closedir
                    320: extern void closedir (DIR *);
                    321: 
1.1.1.3   root      322: /* This isn't the best place for this, but it fits reasonably well. The logic
                    323:  * is that you probably don't have POSIX errnos if you don't have the above
                    324:  * functions. */
1.1.1.4   root      325: extern long dos_errno (void);
1.1.1.3   root      326: 
                    327: #endif
                    328: 
                    329: #ifdef DONT_HAVE_STDIO
                    330: 
1.1.1.4   root      331: extern FILE *stdioemu_fopen (const char *, const char *);
                    332: #define fopen(a,b) stdioemu_fopen(a, b)
                    333: extern int stdioemu_fseek (FILE *, int, int);
                    334: #define fseek(a,b,c) stdioemu_fseek(a, b, c)
                    335: extern int stdioemu_fread (char *, int, int, FILE *);
                    336: #define fread(a,b,c,d) stdioemu_fread(a, b, c, d)
                    337: extern int stdioemu_fwrite (const char *, int, int, FILE *);
                    338: #define fwrite(a,b,c,d) stdioemu_fwrite(a, b, c, d)
                    339: extern int stdioemu_ftell (FILE *);
1.1.1.3   root      340: #define ftell(a) stdioemu_ftell(a)
1.1.1.4   root      341: extern int stdioemu_fclose (FILE *);
1.1.1.3   root      342: #define fclose(a) stdioemu_fclose(a)
                    343: 
                    344: #endif
                    345: 
                    346: #ifdef DONT_HAVE_MALLOC
                    347: 
                    348: #define malloc(a) mallocemu_malloc(a)
1.1.1.4   root      349: extern void *mallocemu_malloc (int size);
1.1.1.3   root      350: #define free(a) mallocemu_free(a)
1.1.1.4   root      351: extern void mallocemu_free (void *ptr);
1.1.1.3   root      352: 
                    353: #endif
                    354: 
                    355: #ifdef X86_ASSEMBLY
                    356: #define ASM_SYM_FOR_FUNC(a) __asm__(a)
                    357: #else
                    358: #define ASM_SYM_FOR_FUNC(a)
                    359: #endif
                    360: 
                    361: #if defined USE_COMPILER
                    362: #undef NO_PREFETCH_BUFFER
                    363: #undef NO_EXCEPTION_3
                    364: #define NO_EXCEPTION_3
                    365: #define NO_PREFETCH_BUFFER
                    366: #endif
                    367: 
                    368: #include "target.h"
1.1.1.4   root      369: 
1.1.1.8   root      370: #ifdef UAE_CONSOLE
                    371: #undef write_log
                    372: #define write_log write_log_standard
                    373: #endif
                    374: 
                    375: #if __GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 6
                    376: extern void write_log (const char *, ...) __attribute__ ((format (printf, 1, 2)));
                    377: #else
                    378: extern void write_log (const char *, ...);
                    379: #endif
                    380: 
                    381: extern void console_out (const char *, ...);
                    382: extern void console_flush (void);
                    383: extern int console_get (char *, int);
                    384: 
1.1.1.4   root      385: #ifndef O_BINARY
                    386: #define O_BINARY 0
                    387: #endif
1.1.1.5   root      388: 
                    389: #ifndef STATIC_INLINE
1.1.1.9   root      390: #if __GNUC__ - 1 > 1 && __GNUC_MINOR__ - 1 >= 0
                    391: #define STATIC_INLINE static __inline__ __attribute__ ((always_inline))
1.1.1.10! root      392: #define NOINLINE __attribute__ ((noinline))
1.1.1.9   root      393: #else
1.1.1.5   root      394: #define STATIC_INLINE static __inline__
1.1.1.10! root      395: #define NOINLINE
1.1.1.5   root      396: #endif
1.1.1.9   root      397: #endif
1.1.1.8   root      398: 
                    399: /* Every Amiga hardware clock cycle takes this many "virtual" cycles.  This
                    400:    used to be hardcoded as 1, but using higher values allows us to time some
                    401:    stuff more precisely.
                    402:    512 is the official value from now on - it can't change, unless we want
                    403:    _another_ config option "finegrain2_m68k_speed".
                    404: 
                    405:    We define this value here rather than in events.h so that gencpu.c sees
                    406:    it.  */
                    407: #define CYCLE_UNIT 512
                    408: 
                    409: /* This one is used by cfgfile.c.  We could reduce the CYCLE_UNIT back to 1,
                    410:    I'm not 100% sure this code is bug free yet.  */
                    411: #define OFFICIAL_CYCLE_UNIT 512
                    412: 
                    413: /*
                    414:  * You can specify numbers from 0 to 5 here. It is possible that higher
                    415:  * numbers will make the CPU emulation slightly faster, but if the setting
                    416:  * is too high, you will run out of memory while compiling.
                    417:  * Best to leave this as it is.
                    418:  */
                    419: #define CPU_EMU_SIZE 0

unix.superglobalmegacorp.com

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