Annotation of hatari/src/cpu/sysdeps.h, revision 1.1.1.6

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
                      5:   * stuff right & other collected kludges.
                      6:   *
                      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
                     13:   */
1.1.1.4   root       14: #ifndef UAE_SYSDEPS_H
                     15: #define UAE_SYSDEPS_H
                     16: 
                     17: #ifdef HAVE_CONFIG_H
                     18: #include "config.h"
                     19: #endif
                     20: #include "sysconfig.h"
                     21: 
                     22: #ifdef WINUAE_FOR_HATARI
                     23: #include "compat.h"
                     24: #endif
                     25: 
                     26: #ifndef UAE
                     27: #define UAE
                     28: #endif
1.1       root       29: 
1.1.1.4   root       30: #ifdef __cplusplus
                     31: #include <string>
                     32: using namespace std;
                     33: #else
                     34: #include <string.h>
                     35: #include <ctype.h>
                     36: #endif
1.1       root       37: #include <stdio.h>
                     38: #include <stdlib.h>
                     39: #include <errno.h>
                     40: #include <assert.h>
                     41: #include <limits.h>
1.1.1.4   root       42: 
                     43: #ifndef UAE
                     44: #define UAE
                     45: #endif
                     46: 
                     47: #if defined(__x86_64__) || defined(_M_AMD64)
                     48: #define CPU_x86_64 1
                     49: #define CPU_64_BIT 1
                     50: #elif defined(__i386__) || defined(_M_IX86)
                     51: #define CPU_i386 1
1.1.1.5   root       52: #elif defined(__arm__) || defined(_M_ARM) || defined(__aarch64__)
1.1.1.4   root       53: #define CPU_arm 1
                     54: #elif defined(__powerpc__) || defined(_M_PPC) || defined(__ppc__) || defined(__ppc64__)
                     55: #define CPU_powerpc 1
1.1.1.5   root       56: #elif defined(__mips__) || defined(mips) || defined(__mips64)
                     57: #define CPU_mips 1
                     58: #elif defined(JIT)
1.1.1.4   root       59: #error unrecognized CPU type
                     60: #endif
                     61: 
                     62: #ifdef _WIN32
                     63: /* Parameters are passed in ECX, EDX for both x86 and x86-64 (RCX, RDX).
                     64:  * For x86-64, __fastcall is the default, so it isn't really required. */
                     65: #define JITCALL __fastcall
                     66: #elif defined(CPU_x86_64)
                     67: /* Parameters are passed in RDI, RSI by default (System V AMD64 ABI). */
                     68: #define JITCALL
                     69: #elif defined(HAVE_FUNC_ATTRIBUTE_REGPARM)
                     70: /* Parameters are passed in EAX, EDX on x86 with regparm(2). */
                     71: #define JITCALL __attribute__((regparm(2)))
                     72: /* This was originally regparm(3), but as far as I can see only two register
                     73:  * params are supported by the JIT code. It probably just worked anyway
                     74:  * if all functions used max two arguments. */
                     75: #elif !defined(JIT)
                     76: #define JITCALL
                     77: #endif
                     78: #define REGPARAM
                     79: #define REGPARAM2 JITCALL
                     80: #define REGPARAM3 JITCALL
                     81: 
                     82: #ifdef WINUAE_FOR_HATARI
                     83: #include "uae/types.h"
                     84: #else
                     85: #include <tchar.h>
                     86: #endif
1.1       root       87: 
                     88: #ifndef __STDC__
                     89: #ifndef _MSC_VER
                     90: #error "Your compiler is not ANSI. Get a real one."
                     91: #endif
                     92: #endif
                     93: 
                     94: #include <stdarg.h>
                     95: 
                     96: #ifdef HAVE_SYS_TYPES_H
                     97: #include <sys/types.h>
                     98: #endif
                     99: 
                    100: #ifdef HAVE_VALUES_H
                    101: #include <values.h>
                    102: #endif
                    103: 
                    104: #ifdef HAVE_STRINGS_H
                    105: #include <strings.h>
                    106: #endif
                    107: #ifdef HAVE_STRING_H
                    108: #include <string.h>
                    109: #endif
                    110: 
                    111: #ifdef HAVE_UNISTD_H
                    112: #include <unistd.h>
                    113: #endif
                    114: 
                    115: #ifdef HAVE_UTIME_H
                    116: #include <utime.h>
                    117: #endif
                    118: 
                    119: #ifdef HAVE_SYS_STAT_H
                    120: #include <sys/stat.h>
                    121: #endif
                    122: 
                    123: #if TIME_WITH_SYS_TIME
                    124: # include <sys/time.h>
                    125: # include <time.h>
                    126: #else
                    127: # if HAVE_SYS_TIME_H
                    128: #  include <sys/time.h>
                    129: # else
                    130: #  include <time.h>
                    131: # endif
                    132: #endif
                    133: 
                    134: #if HAVE_DIRENT_H
                    135: # include <dirent.h>
                    136: #else
                    137: # define dirent direct
                    138: # if HAVE_SYS_NDIR_H
                    139: #  include <sys/ndir.h>
                    140: # endif
                    141: # if HAVE_SYS_DIR_H
                    142: #  include <sys/dir.h>
                    143: # endif
                    144: # if HAVE_NDIR_H
                    145: #  include <ndir.h>
                    146: # endif
                    147: #endif
                    148: 
                    149: #ifdef HAVE_SYS_UTIME_H
                    150: # include <sys/utime.h>
                    151: #endif
                    152: 
                    153: #include <errno.h>
                    154: #include <assert.h>
                    155: 
                    156: #ifdef __NeXT__
                    157: #define S_IRUSR S_IREAD
                    158: #define S_IWUSR S_IWRITE
                    159: #define S_IXUSR S_IEXEC
                    160: #define S_ISDIR(val) (S_IFDIR & val)
                    161: struct utimbuf
                    162: {
                    163:     time_t actime;
                    164:     time_t modtime;
                    165: };
                    166: #endif
                    167: 
1.1.1.5   root      168: #ifdef WINUAE_FOR_HATARI  /* Types are provided by uae/types.h already */
                    169: 
                    170: #if SIZEOF_LONG_LONG == 8
                    171: #define VAL64(a) (a ## LL)
                    172: #define UVAL64(a) (a ## uLL)
                    173: #elif SIZEOF___INT64 == 8
                    174: #define VAL64(a) (a)
                    175: #define UVAL64(a) (a)
                    176: #elif SIZEOF_LONG == 8
                    177: #define VAL64(a) (a ## l)
                    178: #define UVAL64(a) (a ## ul)
1.1       root      179: #endif
                    180: 
1.1.1.5   root      181: #define uae_s64 uae_s64
                    182: #define uae_u64 uae_u64
                    183: 
                    184: #else  /* WINUAE_FOR_HATARI */
                    185: 
1.1       root      186: /* If char has more then 8 bits, good night. */
                    187: typedef unsigned char uae_u8;
                    188: typedef signed char uae_s8;
                    189: typedef char uae_char;
                    190: 
                    191: typedef struct { uae_u8 RGB[3]; } RGB;
                    192: 
                    193: #if SIZEOF_SHORT == 2
                    194: typedef unsigned short uae_u16;
                    195: typedef short uae_s16;
                    196: #elif SIZEOF_INT == 2
                    197: typedef unsigned int uae_u16;
                    198: typedef int uae_s16;
                    199: #else
                    200: #error No 2 byte type, you lose.
                    201: #endif
                    202: 
                    203: #if SIZEOF_INT == 4
                    204: typedef unsigned int uae_u32;
                    205: typedef int uae_s32;
                    206: #elif SIZEOF_LONG == 4
                    207: typedef unsigned long uae_u32;
                    208: typedef long uae_s32;
                    209: #else
                    210: #error No 4 byte type, you lose.
                    211: #endif
                    212: 
                    213: typedef uae_u32 uaecptr;
                    214: 
                    215: #undef uae_s64
                    216: #undef uae_u64
                    217: 
                    218: #if SIZEOF_LONG_LONG == 8
                    219: #define uae_s64 long long
                    220: #define uae_u64 unsigned long long
                    221: #define VAL64(a) (a ## LL)
                    222: #define UVAL64(a) (a ## uLL)
                    223: #elif SIZEOF___INT64 == 8
                    224: #define uae_s64 __int64
                    225: #define uae_u64 unsigned __int64
                    226: #define VAL64(a) (a)
                    227: #define UVAL64(a) (a)
                    228: #elif SIZEOF_LONG == 8
                    229: #define uae_s64 long;
                    230: #define uae_u64 unsigned long;
                    231: #define VAL64(a) (a ## l)
                    232: #define UVAL64(a) (a ## ul)
                    233: #endif
                    234: 
1.1.1.5   root      235: #endif /* WINUAE_FOR_HATARI */
                    236: 
1.1.1.6 ! root      237: uae_atomic atomic_and(volatile uae_atomic *p, uae_u32 v);
        !           238: uae_atomic atomic_or(volatile uae_atomic *p, uae_u32 v);
1.1.1.4   root      239: uae_atomic atomic_inc(volatile uae_atomic *p);
                    240: uae_atomic atomic_dec(volatile uae_atomic *p);
                    241: uae_u32 atomic_bit_test_and_reset(volatile uae_atomic *p, uae_u32 v);
                    242: 
1.1       root      243: #ifdef HAVE_STRDUP
                    244: #define my_strdup _tcsdup
                    245: #else
                    246: extern TCHAR *my_strdup (const TCHAR*s);
                    247: #endif
                    248: extern TCHAR *my_strdup_ansi (const char*);
1.1.1.4   root      249: extern void my_trim (TCHAR*);
                    250: extern TCHAR *my_strdup_trim (const TCHAR*);
1.1       root      251: extern TCHAR *au (const char*);
                    252: extern char *ua (const TCHAR*);
                    253: extern TCHAR *aucp (const char *s, unsigned int cp);
                    254: extern char *uacp (const TCHAR *s, unsigned int cp);
                    255: extern TCHAR *au_fs (const char*);
                    256: extern char *ua_fs (const TCHAR*, int);
                    257: extern char *ua_copy (char *dst, int maxlen, const TCHAR *src);
                    258: extern TCHAR *au_copy (TCHAR *dst, int maxlen, const char *src);
                    259: extern char *ua_fs_copy (char *dst, int maxlen, const TCHAR *src, int defchar);
                    260: extern TCHAR *au_fs_copy (TCHAR *dst, int maxlen, const char *src);
                    261: extern char *uutf8 (const TCHAR *s);
                    262: extern TCHAR *utf8u (const char *s);
                    263: extern void unicode_init (void);
                    264: extern void to_lower (TCHAR *s, int len);
                    265: extern void to_upper (TCHAR *s, int len);
1.1.1.4   root      266: 
1.1       root      267: /* We can only rely on GNU C getting enums right. Mickeysoft VSC++ is known
                    268:  * to have problems, and it's likely that other compilers choke too. */
                    269: #ifdef __GNUC__
                    270: #define ENUMDECL typedef enum
                    271: #define ENUMNAME(name) name
                    272: 
                    273: /* While we're here, make abort more useful.  */
1.1.1.4   root      274: #define abort() \
1.1       root      275:   do { \
1.1.1.6 ! root      276:     fprintf (stderr, "FATAL: Internal error; file %s, line %d\n", __FILE__, __LINE__); \
1.1       root      277:     (abort) (); \
                    278: } while (0)
1.1.1.4   root      279: #else
1.1       root      280: #define ENUMDECL enum
                    281: #define ENUMNAME(name) ; typedef int name
                    282: #endif
                    283: 
                    284: /*
                    285:  * Porters to weird systems, look! This is the preferred way to get
                    286:  * filesys.c (and other stuff) running on your system. Define the
                    287:  * appropriate macros and implement wrappers in a machine-specific file.
                    288:  *
                    289:  * I guess the Mac port could use this (Ernesto?)
                    290:  */
                    291: 
                    292: #undef DONT_HAVE_POSIX
                    293: #undef DONT_HAVE_REAL_POSIX /* define if open+delete doesn't do what it should */
                    294: #undef DONT_HAVE_STDIO
                    295: #undef DONT_HAVE_MALLOC
                    296: 
                    297: #if defined(WARPUP)
                    298: #define DONT_HAVE_POSIX
                    299: #endif
                    300: 
1.1.1.4   root      301: #if !defined(FSUAE) && defined _WIN32
1.1       root      302: 
1.1.1.4   root      303: //#ifdef FSUAE
                    304: //#error _WIN32 should not be defined here
                    305: //#endif
1.1       root      306: #if defined __WATCOMC__
                    307: 
                    308: #define O_NDELAY 0
                    309: #include <direct.h>
                    310: #define dirent direct
                    311: #define mkdir(a,b) mkdir(a)
                    312: #define strcasecmp stricmp
                    313: 
                    314: #elif defined __MINGW32__
                    315: 
1.1.1.4   root      316: #include <winsock.h>
                    317: 
1.1       root      318: #define O_NDELAY 0
1.1.1.4   root      319: 
                    320: #define FILEFLAG_DIR     0x1
                    321: #define FILEFLAG_ARCHIVE 0x2
                    322: #define FILEFLAG_WRITE   0x4
                    323: #define FILEFLAG_READ    0x8
                    324: #define FILEFLAG_EXECUTE 0x10
                    325: #define FILEFLAG_SCRIPT  0x20
                    326: #define FILEFLAG_PURE    0x40
                    327: 
1.1       root      328: #define mkdir(a,b) mkdir(a)
                    329: 
                    330: #elif defined _MSC_VER
                    331: 
                    332: #ifdef HAVE_GETTIMEOFDAY
                    333: #include <winsock.h> // for 'struct timeval' definition
                    334: extern void gettimeofday( struct timeval *tv, void *blah );
                    335: #endif
                    336: 
                    337: #define O_NDELAY 0
                    338: 
                    339: #define FILEFLAG_DIR     0x1
                    340: #define FILEFLAG_ARCHIVE 0x2
                    341: #define FILEFLAG_WRITE   0x4
                    342: #define FILEFLAG_READ    0x8
                    343: #define FILEFLAG_EXECUTE 0x10
                    344: #define FILEFLAG_SCRIPT  0x20
                    345: #define FILEFLAG_PURE    0x40
                    346: 
                    347: #include <io.h>
                    348: #define O_BINARY _O_BINARY
                    349: #define O_WRONLY _O_WRONLY
                    350: #define O_RDONLY _O_RDONLY
                    351: #define O_RDWR   _O_RDWR
                    352: #define O_CREAT  _O_CREAT
                    353: #define O_TRUNC  _O_TRUNC
                    354: #define strcasecmp _tcsicmp 
                    355: #define strncasecmp _tcsncicmp 
                    356: #define W_OK 0x2
                    357: #define R_OK 0x4
                    358: #define STAT struct stat
                    359: #define DIR struct DIR
                    360: struct direct
                    361: {
                    362:     TCHAR d_name[1];
                    363: };
                    364: #include <sys/utime.h>
                    365: #define utimbuf __utimbuf64
                    366: #define USE_ZFILE
                    367: 
                    368: #undef S_ISDIR
                    369: #undef S_IWUSR
                    370: #undef S_IRUSR
                    371: #undef S_IXUSR
                    372: #define S_ISDIR(a) (a&FILEFLAG_DIR)
                    373: #define S_ISARC(a) (a&FILEFLAG_ARCHIVE)
                    374: #define S_IWUSR FILEFLAG_WRITE
                    375: #define S_IRUSR FILEFLAG_READ
                    376: #define S_IXUSR FILEFLAG_EXECUTE
                    377: 
                    378: #endif
                    379: 
                    380: #endif /* _WIN32 */
                    381: 
                    382: #ifdef DONT_HAVE_POSIX
                    383: 
                    384: #define access posixemu_access
                    385: extern int posixemu_access (const TCHAR *, int);
                    386: #define open posixemu_open
                    387: extern int posixemu_open (const TCHAR *, int, int);
                    388: #define close posixemu_close
                    389: extern void posixemu_close (int);
                    390: #define read posixemu_read
                    391: extern int posixemu_read (int, TCHAR *, int);
                    392: #define write posixemu_write
                    393: extern int posixemu_write (int, const TCHAR *, int);
                    394: #undef lseek
                    395: #define lseek posixemu_seek
                    396: extern int posixemu_seek (int, int, int);
                    397: #define stat(a,b) posixemu_stat ((a), (b))
                    398: extern int posixemu_stat (const TCHAR *, STAT *);
                    399: #define mkdir posixemu_mkdir
                    400: extern int mkdir (const TCHAR *, int);
                    401: #define rmdir posixemu_rmdir
                    402: extern int posixemu_rmdir (const TCHAR *);
                    403: #define unlink posixemu_unlink
                    404: extern int posixemu_unlink (const TCHAR *);
                    405: #define truncate posixemu_truncate
                    406: extern int posixemu_truncate (const TCHAR *, long int);
                    407: #define rename posixemu_rename
                    408: extern int posixemu_rename (const TCHAR *, const TCHAR *);
                    409: #define chmod posixemu_chmod
                    410: extern int posixemu_chmod (const TCHAR *, int);
                    411: #define tmpnam posixemu_tmpnam
                    412: extern void posixemu_tmpnam (TCHAR *);
                    413: #define utime posixemu_utime
                    414: extern int posixemu_utime (const TCHAR *, struct utimbuf *);
                    415: #define opendir posixemu_opendir
                    416: extern DIR * posixemu_opendir (const TCHAR *);
                    417: #define readdir posixemu_readdir
                    418: extern struct dirent* readdir (DIR *);
                    419: #define closedir posixemu_closedir
                    420: extern void closedir (DIR *);
                    421: 
                    422: /* This isn't the best place for this, but it fits reasonably well. The logic
                    423:  * is that you probably don't have POSIX errnos if you don't have the above
                    424:  * functions. */
                    425: extern long dos_errno (void);
                    426: 
                    427: #endif
                    428: 
                    429: #ifdef DONT_HAVE_STDIO
                    430: 
                    431: extern FILE *stdioemu_fopen (const TCHAR *, const TCHAR *);
                    432: #define fopen(a,b) stdioemu_fopen(a, b)
                    433: extern int stdioemu_fseek (FILE *, int, int);
                    434: #define fseek(a,b,c) stdioemu_fseek(a, b, c)
                    435: extern int stdioemu_fread (TCHAR *, int, int, FILE *);
                    436: #define fread(a,b,c,d) stdioemu_fread(a, b, c, d)
                    437: extern int stdioemu_fwrite (const TCHAR *, int, int, FILE *);
                    438: #define fwrite(a,b,c,d) stdioemu_fwrite(a, b, c, d)
                    439: extern int stdioemu_ftell (FILE *);
                    440: #define ftell(a) stdioemu_ftell(a)
                    441: extern int stdioemu_fclose (FILE *);
                    442: #define fclose(a) stdioemu_fclose(a)
                    443: 
                    444: #endif
                    445: 
                    446: #ifdef DONT_HAVE_MALLOC
                    447: 
                    448: #define malloc(a) mallocemu_malloc(a)
                    449: extern void *mallocemu_malloc (int size);
                    450: #define free(a) mallocemu_free(a)
                    451: extern void mallocemu_free (void *ptr);
                    452: 
                    453: #endif
                    454: 
                    455: #ifdef X86_ASSEMBLY
                    456: #define ASM_SYM_FOR_FUNC(a) __asm__(a)
                    457: #else
                    458: #define ASM_SYM_FOR_FUNC(a)
                    459: #endif
                    460: 
                    461: //#include "target.h"
                    462: 
                    463: #ifdef UAE_CONSOLE
                    464: #undef write_log
                    465: #define write_log write_log_standard
                    466: #endif
                    467: 
1.1.1.6 ! root      468: #ifdef WINUAE_FOR_HATARI
        !           469: #define write_log(...) Log_Printf(LOG_DEBUG, __VA_ARGS__)
        !           470: #elif __GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 6
1.1.1.5   root      471: extern void write_log(const TCHAR *, ...);
                    472: extern void write_logx(const TCHAR *, ...);
                    473: extern void write_log(const char *, ...) __attribute__ ((format (printf, 1, 2)));
                    474: #else
                    475: extern void write_log(const TCHAR *, ...);
                    476: extern void write_logx(const TCHAR *, ...);
                    477: extern void write_log(const char *, ...);
1.1       root      478: #endif
                    479: extern void write_dlog (const TCHAR *, ...);
1.1.1.3   root      480: extern int read_log(void);
1.1       root      481: 
                    482: extern void flush_log (void);
1.1.1.4   root      483: extern TCHAR *setconsolemode (TCHAR *buffer, int maxlen);
1.1       root      484: extern void close_console (void);
                    485: extern void reopen_console (void);
1.1.1.4   root      486: extern void activate_console (void);
1.1.1.3   root      487: //extern void console_out (const TCHAR *);
                    488: //extern void console_out_f (const TCHAR *, ...);
1.1       root      489: extern void console_flush (void);
                    490: extern int console_get (TCHAR *, int);
1.1.1.4   root      491: extern bool console_isch (void);
1.1       root      492: extern TCHAR console_getch (void);
1.1.1.5   root      493: extern void f_out (void *, const TCHAR *, ...);
1.1       root      494: extern TCHAR* buf_out (TCHAR *buffer, int *bufsize, const TCHAR *format, ...);
1.1.1.3   root      495: //extern void gui_message (const TCHAR *,...);
1.1       root      496: extern int gui_message_multibutton (int flags, const TCHAR *format,...);
                    497: #define write_log_err write_log
                    498: extern void logging_init (void);
1.1.1.4   root      499: extern FILE *log_open (const TCHAR *name, int append, int bootlog, TCHAR*);
1.1       root      500: extern void log_close (FILE *f);
1.1.1.6 ! root      501: extern TCHAR *write_log_get_ts(void);
1.1       root      502: 
1.1.1.6 ! root      503: extern bool use_long_double;
1.1       root      504: 
                    505: #ifndef O_BINARY
                    506: #define O_BINARY 0
                    507: #endif
                    508: 
                    509: #ifndef STATIC_INLINE
1.1.1.6 ! root      510: #if __GNUC__ - 1 > 2 || (__GNUC__ - 1 == 2 && __GNUC_MINOR__ - 1 >= 0)
1.1       root      511: #define STATIC_INLINE static __inline__ __attribute__ ((always_inline))
                    512: #define NOINLINE __attribute__ ((noinline))
                    513: #define NORETURN __attribute__ ((noreturn))
                    514: #elif _MSC_VER
                    515: #define STATIC_INLINE static __forceinline
                    516: #define NOINLINE __declspec(noinline)
                    517: #define NORETURN __declspec(noreturn)
                    518: #else
                    519: #define STATIC_INLINE static __inline__
                    520: #define NOINLINE
                    521: #define NORETURN
                    522: #endif
                    523: #endif
                    524: /* Every Amiga hardware clock cycle takes this many "virtual" cycles.  This
                    525:    used to be hardcoded as 1, but using higher values allows us to time some
                    526:    stuff more precisely.
1.1.1.3   root      527:    512 is the official value from now on - it can't change, unless we want
                    528:    _another_ config option "finegrain2_m68k_speed".
                    529: 
1.1       root      530:    We define this value here rather than in events.h so that gencpu.c sees
                    531:    it.  */
1.1.1.3   root      532: #define CYCLE_UNIT 512
                    533: 
                    534: /* This one is used by cfgfile.c.  We could reduce the CYCLE_UNIT back to 1,
                    535:    I'm not 100% sure this code is bug free yet.  */
                    536: #define OFFICIAL_CYCLE_UNIT 512
1.1       root      537: 
                    538: /*
                    539:  * You can specify numbers from 0 to 5 here. It is possible that higher
                    540:  * numbers will make the CPU emulation slightly faster, but if the setting
                    541:  * is too high, you will run out of memory while compiling.
                    542:  * Best to leave this as it is.
                    543:  */
                    544: #define CPU_EMU_SIZE 0
                    545: 
                    546: /*
                    547:  * Byte-swapping functions
                    548:  */
                    549: 
                    550: /* Try to use system bswap_16/bswap_32 functions. */
                    551: #if defined HAVE_BSWAP_16 && defined HAVE_BSWAP_32
                    552: # include <byteswap.h>
                    553: #  ifdef HAVE_BYTESWAP_H
                    554: #  include <byteswap.h>
                    555: # endif
                    556: #else
                    557: /* Else, if using SDL, try SDL's endian functions. */
                    558: # ifdef USE_SDL
                    559: #  include <SDL_endian.h>
1.1.1.5   root      560: #  ifndef bswap_16
                    561: #    define bswap_16(x) SDL_Swap16(x)
                    562: #  endif
                    563: #  ifndef bswap_32
                    564: #    define bswap_32(x) SDL_Swap32(x)
                    565: #  endif
1.1       root      566: # else
                    567: /* Otherwise, we'll roll our own. */
1.1.1.5   root      568: #  ifndef bswap_16
                    569: #    define bswap_16(x) (((x) >> 8) | (((x) & 0xFF) << 8))
                    570: #  endif
                    571: #  ifndef bswap_32
                    572: #    define bswap_32(x) (((x) << 24) | (((x) << 8) & 0x00FF0000) | (((x) >> 8) & 0x0000FF00) | ((x) >> 24))
                    573: #  endif
1.1       root      574: # endif
                    575: #endif
                    576: 
                    577: #ifndef __cplusplus
                    578: 
                    579: #define xmalloc(T, N) malloc(sizeof (T) * (N))
                    580: #define xcalloc(T, N) calloc(sizeof (T), N)
                    581: #define xfree(T) free(T)
                    582: #define xrealloc(T, TP, N) realloc(TP, sizeof (T) * (N))
                    583: 
                    584: #if 0
                    585: extern void *xmalloc (size_t);
                    586: extern void *xcalloc (size_t, size_t);
                    587: extern void xfree (const void*);
                    588: #endif
                    589: 
                    590: #else
                    591: 
                    592: #define xmalloc(T, N) static_cast<T*>(malloc (sizeof (T) * (N)))
                    593: #define xcalloc(T, N) static_cast<T*>(calloc (sizeof (T), N))
                    594: #define xrealloc(T, TP, N) static_cast<T*>(realloc (TP, sizeof (T) * (N)))
                    595: #define xfree(T) free(T)
                    596: 
                    597: #endif
1.1.1.4   root      598: 
                    599: #define DBLEQU(f, i) (abs ((f) - (i)) < 0.000001)
                    600: 
                    601: #ifdef HAVE_VAR_ATTRIBUTE_UNUSED
                    602: #define NOWARN_UNUSED(x) __attribute__((unused)) x
                    603: #else
                    604: #define NOWARN_UNUSED(x) x
                    605: #endif
                    606: 
                    607: #endif /* UAE_SYSDEPS_H */

unix.superglobalmegacorp.com

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