--- uae/src/include/sysdeps.h 2018/04/24 16:38:39 1.1 +++ uae/src/include/sysdeps.h 2018/04/24 16:40:20 1.1.1.3 @@ -2,9 +2,14 @@ * UAE - The Un*x Amiga Emulator * * Try to include the right system headers and get other system-specific - * stuff right. + * stuff right & other collected kludges. * - * Copyright 1996 Bernd Schmidt + * If you think about modifying this, think twice. Some systems rely on + * the exact order of the #include statements. That's also the reason + * why everything gets included unconditionally regardless of whether + * it's actually needed by the .c file. + * + * Copyright 1996, 1997 Bernd Schmidt */ #include @@ -92,6 +97,10 @@ # endif #endif +#ifdef HAVE_GETOPT_H +#include +#endif + #include #include @@ -99,14 +108,6 @@ #define BROKEN_OS_PROBABLY_AIX #endif -#ifdef HAVE_LINUX_JOYSTICK_H -#if BROKEN_JOYSTICK_H == 1 -#include "joystick.h" -#else -#include -#endif -#endif - #ifdef __NeXT__ #define S_IRUSR S_IREAD #define S_IWUSR S_IWRITE @@ -119,26 +120,33 @@ struct utimbuf }; #endif -#if defined(__SASC) && defined(AMIGA) -#include -#include -#include -#include -#include -#include - -int mkdir(const char *); -int rmdir(const char *); - -#define S_ISDIR(m) (m & S_IFDIR) -#define S_IRUSR ~S_IREAD -#define S_IWUSR ~(S_IWRITE|S_IDELETE) -#define S_IXUSR ~S_IEXECUTE - -typedef unsigned short mode_t; +#if defined(__GNUC__) && defined(AMIGA) +/* gcc on the amiga need that __attribute((regparm)) must */ +/* be defined in function prototypes as well as in */ +/* function definitions ! */ +#define REGPARAM2 REGPARAM +#else /* not(GCC & AMIGA) */ +#define REGPARAM2 +#endif +/* sam: some definitions so that SAS/C can compile UAE */ +#if defined(__SASC) && defined(AMIGA) +#define REGPARAM2 +#define REGPARAM +#define S_IRUSR S_IREAD +#define S_IWUSR S_IWRITE +#define S_IXUSR S_IEXECUTE +#define S_ISDIR(val) (S_IFDIR & val) +#define mkdir(x,y) mkdir(x) +#define truncate(x,y) 0 +#define creat(x,y) open("T:creat",O_CREAT|O_TEMP|O_RDWR) /* sam: for zfile.c */ #define strcasecmp stricmp -#define chip rhubarb +#define utime(file,time) 0 +struct utimbuf +{ + time_t actime; + time_t modtime; +}; #endif #ifdef __DOS__ @@ -149,36 +157,216 @@ typedef unsigned short mode_t; #define O_BINARY 0 #endif +/* Acorn specific stuff */ +#ifdef ACORN + +#define S_IRUSR S_IREAD +#define S_IWUSR S_IWRITE +#define S_IXUSR S_IEXEC + +#define strcasecmp stricmp + +#endif + +#ifndef L_tmpnam +#define L_tmpnam 128 /* ought to be safe */ +#endif + /* If char has more then 8 bits, good night. */ -typedef unsigned char UBYTE; -typedef signed char BYTE; -typedef struct {UBYTE RGB[3];} RGB; +typedef unsigned char uae_u8; +typedef signed char uae_s8; + +typedef struct { uae_u8 RGB[3]; } RGB; #if SIZEOF_SHORT == 2 -typedef unsigned short UWORD; -typedef short WORD; +typedef unsigned short uae_u16; +typedef short uae_s16; #elif SIZEOF_INT == 2 -typedef unsigned int UWORD; -typedef int WORD; +typedef unsigned int uae_u16; +typedef int uae_s16; #else #error No 2 byte type, you lose. #endif #if SIZEOF_INT == 4 -typedef unsigned int ULONG; -typedef int LONG; +typedef unsigned int uae_u32; +typedef int uae_s32; #elif SIZEOF_LONG == 4 -typedef unsigned long ULONG; -typedef long LONG; +typedef unsigned long uae_u32; +typedef long uae_s32; #else #error No 4 byte type, you lose. #endif -typedef ULONG CPTR; -#undef INT_64BIT +typedef uae_u32 uaecptr; + +#undef uae_s64 +#undef uae_u64 #if SIZEOF_LONG_LONG == 8 -#define INT_64BIT long long +#define uae_s64 long long +#define uae_u64 long long +#define VAL64(a) (a ## LL) +#define UVAL64(a) (a ## uLL) +#elif SIZEOF___INT64 == 8 +#define uae_s64 __int64 +#define uae_u64 unsigned __int64 +#define VAL64(a) (a) +#define UVAL64(a) (a) #elif SIZEOF_LONG == 8 -#define INT_64BIT long +#define uae_s64 long; +#define uae_u64 unsigned long; +#define VAL64(a) (a ## l) +#define UVAL64(a) (a ## ul) +#endif + +#ifdef HAVE_STRDUP +#define my_strdup strdup +#else +extern char *my_strdup (const char*s); +#endif + +#ifndef HAVE_GETOPT +extern char *optarg; +extern int getopt (int, char * const *, const char *); +#endif + +extern void *xmalloc(size_t); + +/* We can only rely on GNU C getting enums right. Mickeysoft VSC++ is known + * to have problems, and it's likely that other compilers choke too. */ +#ifdef __GNUC__ +#define ENUMDECL typedef enum +#define ENUMNAME(name) name +#else +#define ENUMDECL enum +#define ENUMNAME(name) ; typedef int name #endif + +/* + * Porters to weird systems, look! This is the preferred way to get + * filesys.c (and other stuff) running on your system. Define the + * appropriate macros and implement wrappers in a machine-specific file. + * + * I guess the Mac port could use this (Ernesto?) + */ + +#undef DONT_HAVE_POSIX +#undef DONT_HAVE_REAL_POSIX /* define if open+delete doesn't do what it should */ +#undef DONT_HAVE_STDIO +#undef DONT_HAVE_MALLOC + +#ifdef _WIN32 +#define DONT_HAVE_POSIX +/* Eeek, Mathias, does Windows _really_ not have ANSI stdio? I've accepted + * that Macs are awfully broken, but is Windows really as bad? */ +#define DONT_HAVE_STDIO +#define DONT_HAVE_MALLOC +#endif + +#ifdef DONT_HAVE_POSIX + +#define access posixemu_access +extern int posixemu_access(char *,int); +#define open posixemu_open +extern int posixemu_open(char *,int,int); +#define close posixemu_close +extern void posixemu_close(int); +#define read posixemu_read +extern int posixemu_read(int, char *, int); +#define write posixemu_write +extern int posixemu_write(int, char *, int); +#undef lseek +#define lseek posixemu_seek +extern int posixemu_seek(int, int, int); +#define stat(a,b) posixemu_stat(a,b) +extern int posixemu_stat(char *, STAT *); +#define mkdir posixemu_mkdir +extern int mkdir(char *, int); +#define rmdir posixemu_rmdir +extern int posixemu_rmdir(char *); +#define unlink posixemu_unlink +extern int posixemu_unlink(char *); +#define rename posixemu_rename +extern int posixemu_rename(char *, char *); +#define chmod posixemu_chmod +extern int posixemu_chmod(char *, int); +#define tmpnam posixemu_tmpnam +extern void posixemu_tmpnam(char *); +#define utime posixemu_utime +extern void posixemu_utime(const char *, struct utimbuf *); +/* This isn't the best place for this, but it fits reasonably well. The logic + * is that you probably don't have POSIX errnos if you don't have the above + * functions. */ +extern long dos_errno(void); + +#endif + +#ifdef DONT_HAVE_REAL_POSIX + +extern FILE *uae_fopen_del (const char *name, const char *mode); +extern int uae_open_del (const char *name, int flags, int mode); + +#else + +static __inline__ FILE *uae_fopen_del (const char *name, const char *mode) +{ + FILE *fd; + fd = fopen (name, mode); + if (fd) { + unlink (name); + } + return fd; +} + +static __inline__ int uae_open_del (const char *name, int flags, int mode) +{ + int fd; + fd = open (name, mode, flags); + if (fd >= 0) { + unlink (name); + } + return fd; +} + +#endif + +#ifdef DONT_HAVE_STDIO + +/* Mathias: what about fopen? */ +extern int stdioemu_fseek(FILE *,int,int); +#define fseek(a,b,c) stdioemu_fseek(a,b,c) +extern int stdioemu_fread(char *,int,int, FILE *); +#define fread(a,b,c,d) stdioemu_fread(a,b,c,d) +extern int stdioemu_fwrite(char *,int,int, FILE *); +#define fwrite(a,b,c,d) stdioemu_fwrite(a,b,c,d) +extern int stdioemu_ftell(FILE *); +#define ftell(a) stdioemu_ftell(a) +extern int stdioemu_fclose(FILE *); +#define fclose(a) stdioemu_fclose(a) + +#endif + +#ifdef DONT_HAVE_MALLOC + +#define malloc(a) mallocemu_malloc(a) +extern void *mallocemu_malloc(int size); +#define free(a) mallocemu_free(a) +extern void mallocemu_free(void *ptr); + +#endif + +#ifdef X86_ASSEMBLY +#define ASM_SYM_FOR_FUNC(a) __asm__(a) +#else +#define ASM_SYM_FOR_FUNC(a) +#endif + +#if defined USE_COMPILER +#undef NO_PREFETCH_BUFFER +#undef NO_EXCEPTION_3 +#define NO_EXCEPTION_3 +#define NO_PREFETCH_BUFFER +#endif + +#include "target.h"