home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / Emulatoren / UAE061.LZH / uae-0.6.1 / include / sysdeps.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-28  |  6.6 KB  |  311 lines

  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.
  6.   *
  7.   * Copyright 1996 Bernd Schmidt
  8.   */
  9.  
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <errno.h>
  13. #include <assert.h>
  14.  
  15. #ifdef HAVE_SYS_TYPES_H
  16. #include <sys/types.h>
  17. #endif
  18.  
  19. #ifdef HAVE_VALUES_H
  20. #include <values.h>
  21. #endif
  22.  
  23. #ifdef HAVE_STRINGS_H
  24. #include <strings.h>
  25. #endif
  26. #ifdef HAVE_STRING_H
  27. #include <string.h>
  28. #endif
  29.  
  30. #ifdef HAVE_UNISTD_H
  31. #include <unistd.h>
  32. #endif
  33. #ifdef HAVE_FCNTL_H
  34. #include <fcntl.h>
  35. #endif
  36.  
  37. #ifdef HAVE_UTIME_H
  38. #include <utime.h>
  39. #endif
  40.  
  41. #ifdef HAVE_SYS_PARAM_H
  42. #include <sys/param.h>
  43. #endif
  44.  
  45. #ifdef HAVE_SYS_VFS_H
  46. #include <sys/vfs.h>
  47. #endif
  48.  
  49. #ifdef HAVE_SYS_STAT_H
  50. #include <sys/stat.h>
  51. #endif
  52.  
  53. #ifdef HAVE_SYS_MOUNT_H
  54. #include <sys/mount.h>
  55. #endif
  56.  
  57. #ifdef HAVE_SYS_STATFS_H
  58. #include <sys/statfs.h>
  59. #endif
  60.  
  61. #ifdef HAVE_SYS_STATVFS_H
  62. #include <sys/statvfs.h>
  63. #endif
  64.  
  65. #if TIME_WITH_SYS_TIME
  66. # include <sys/time.h>
  67. # include <time.h>
  68. #else
  69. # if HAVE_SYS_TIME_H
  70. #  include <sys/time.h>
  71. # else
  72. #  include <time.h>
  73. # endif
  74. #endif
  75.  
  76. #if HAVE_DIRENT_H
  77. # include <dirent.h>
  78. #else
  79. # define dirent direct
  80. # if HAVE_SYS_NDIR_H
  81. #  include <sys/ndir.h>
  82. # endif
  83. # if HAVE_SYS_DIR_H
  84. #  include <sys/dir.h>
  85. # endif
  86. # if HAVE_NDIR_H
  87. #  include <ndir.h>
  88. # endif
  89. #endif
  90.  
  91. #include <errno.h>
  92. #include <assert.h>
  93.  
  94. #ifdef HAVE_LINUX_JOYSTICK_H
  95. #if BROKEN_JOYSTICK_H == 1
  96. #include "joystick.h"
  97. #else
  98. #include <linux/joystick.h>
  99. #endif
  100. #endif
  101.  
  102. #ifdef __NeXT__
  103. #define S_IRUSR S_IREAD
  104. #define S_IWUSR S_IWRITE
  105. #define S_IXUSR S_IEXEC
  106. #define S_ISDIR(val) (S_IFDIR & val)
  107. struct utimbuf
  108. {
  109.     time_t actime;
  110.     time_t modtime;
  111. };
  112. #endif
  113.  
  114. #if defined(__SASC) && defined(AMIGA)
  115. #include <sys/types.h>
  116. #include <sys/stat.h>
  117. #include <dirent.h>
  118. #include <stdio.h>
  119. #include <fcntl.h>
  120. #include <time.h>
  121.  
  122. int mkdir(const char *);
  123. int rmdir(const char *);
  124.  
  125. #define S_ISDIR(m)    (m & S_IFDIR)
  126. #define S_IRUSR        ~S_IREAD
  127. #define S_IWUSR        ~(S_IWRITE|S_IDELETE)
  128. #define S_IXUSR        ~S_IEXECUTE
  129.  
  130. typedef unsigned short        mode_t;
  131.  
  132. #define strcasecmp stricmp
  133. #define chip rhubarb
  134. #endif
  135.  
  136. #if defined(__GNUC__) && defined(AMIGA)
  137. /* 
  138.  * sam: GCC has a bad feature ("bug" would a better word) for uae in 
  139.  * libamiga.a: bltsize, bltcon0, ... are defined as absolute adress
  140.  * in memory, causing real customchip registers being modified when
  141.  * UAE is running. (I hate this feature... It makes  me lost lots of 
  142.  * time looking for a bug on my side =:-( ).
  143.  *
  144.  * This cures the problem (I hope, since I don't exactly know which 
  145.  * variables need to be redefined for UAE):
  146.  */
  147. #define bltsize my_bltsize
  148. #define bltcon0 my_bltcon0
  149. #define bltcon1 my_bltcon1
  150. #define bltapt  my_bltapt
  151. #define bltbpt  my_bltbpt
  152. #define bltcpt  my_bltcpt
  153. #define bltdpt  my_bltdpt
  154. #define adkcon  my_adkcon
  155. /*
  156.  * Those are here is case of doubt (they are all absolute adress
  157.  * in libamiga.a, defining CUSTOM_NEED_TO_BE_REALLY_SURE will prevent
  158.  * uae from using any absolute variable.
  159.  */
  160. #ifdef AMIGALIB_NEED_TO_BE_REALLY_SURE 
  161. #define bootrom my_bootrom
  162. #define cartridge my_cartridge
  163. #define romend my_romend
  164. #define romstart my_romstart
  165. #define adkcon my_adkcon
  166. #define adkconr my_adkconr
  167. #define aud my_aud
  168. #define bltadat my_bltadat
  169. #define bltafwm my_bltafwm
  170. #define bltalwm my_bltalwm
  171. #define bltamod my_bltamod
  172. #define bltapt my_bltapt
  173. #define bltbdat my_bltbdat
  174. #define bltbmod my_bltbmod
  175. #define bltbpt my_bltbpt
  176. #define bltcdat my_bltcdat
  177. #define bltcmod my_bltcmod
  178. #define bltcon0 my_bltcon0
  179. #define bltcon1 my_bltcon1
  180. #define bltcpt my_bltcpt
  181. #define bltddat my_bltddat
  182. #define bltdmod my_bltdmod
  183. #define bltdpt my_bltdpt
  184. #define bltsize my_bltsize
  185. #define bpl1mod my_bpl1mod
  186. #define bpl2mod my_bpl2mod
  187. #define bplcon0 my_bplcon0
  188. #define bplcon1 my_bplcon1
  189. #define bplcon2 my_bplcon2
  190. #define bpldat my_bpldat
  191. #define bplpt my_bplpt
  192. #define clxcon my_clxcon
  193. #define clxdat my_clxdat
  194. /* Oh look ! libamiga.a does not allow you to define a shared
  195.    variable caled color.... This is quite annoying :-/ */
  196. #define color my_color
  197. #define cop1lc my_cop1lc
  198. #define cop2lc my_cop2lc
  199. #define copcon my_copcon
  200. #define copins my_copins
  201. #define copjmp1 my_copjmp1
  202. #define copjmp2 my_copjmp2
  203. #define custom my_custom
  204. #define ddfstop my_ddfstop
  205. #define ddfstrt my_ddfstrt
  206. #define diwstop my_diwstop
  207. #define diwstrt my_diwstrt
  208. #define dmacon my_dmacon
  209. #define dmaconr my_dmaconr
  210. #define dskbytr my_dskbytr
  211. #define dskdat my_dskdat
  212. #define dskdatr my_dskdatr
  213. #define dsklen my_dsklen
  214. #define dskpt my_dskpt
  215. #define intena my_intena
  216. #define intenar my_intenar
  217. #define intreq my_intreq
  218. #define intreqr my_intreqr
  219. #define joy0dat my_joy0dat
  220. #define joy1dat my_joy1dat
  221. #define joytest my_joytest
  222. #define pot0dat my_pot0dat
  223. #define pot1dat my_pot1dat
  224. #define potgo my_potgo
  225. #define potinp my_potinp
  226. #define refptr my_refptr
  227. #define serdat my_serdat
  228. #define serdatr my_serdatr
  229. #define serper my_serper
  230. #define spr my_spr
  231. #define sprpt my_sprpt
  232. #define vhposr my_vhposr
  233. #define vhposw my_vhposw
  234. #define vposr my_vposr
  235. #define vposw my_vposw
  236. #define ciaa my_ciaa
  237. #define ciaacra my_ciaacra
  238. #define ciaacrb my_ciaacrb
  239. #define ciaad<dra my_ciaaddra
  240. #define ciaaddrb my_ciaaddrb
  241. #define ciaaicr my_ciaaicr
  242. #define ciaapra my_ciaapra
  243. #define ciaaprb my_ciaaprb
  244. #define ciaasdr my_ciaasdr
  245. #define ciaatahi my_ciaatahi
  246. #define ciaatalo my_ciaatalo
  247. #define ciaatbhi my_ciaatbhi
  248. #define ciaatblo my_ciaatblo
  249. #define ciaatodhi my_ciaatodhi
  250. #define ciaatodlow my_ciaatodlow
  251. #define ciaatodmid my_ciaatodmid
  252. #define ciab my_ciab
  253. #define ciabcra my_ciabcra
  254. #define ciabcrb my_ciabcrb
  255. #define ciabddra my_ciabddra
  256. #define ciabddrb my_ciabddrb
  257. #define ciabicr my_ciabicr
  258. #define ciabpra my_ciabpra
  259. #define ciabprb my_ciabprb
  260. #define ciabsdr my_ciabsdr
  261. #define ciabtahi my_ciabtahi
  262. #define ciabtalo my_ciabtalo
  263. #define ciabtbhi my_ciabtbhi
  264. #define ciabtblo my_ciabtblo
  265. #define ciabtodhi my_ciabtodhi
  266. #define ciabtodlow my_ciabtodlow
  267. #define ciabtodmid my_ciabtodmid
  268. #endif /* AMIGALIB_NEED_TO_BE_REALLY_SURE */
  269. #endif
  270.  
  271. #ifdef __DOS__
  272. #include <pc.h>
  273. #include <io.h>
  274. #else
  275. #undef O_BINARY
  276. #define O_BINARY 0
  277. #endif
  278.  
  279. #ifndef EXEC_TYPES_H /* sam: to prevent re-definition in awin.c ! */
  280. /* If char has more then 8 bits, good night. */
  281. typedef unsigned char UBYTE;
  282. typedef signed char BYTE;
  283.  
  284. #if SIZEOF_SHORT == 2
  285. typedef unsigned short UWORD;
  286. typedef short WORD;
  287. #elif SIZEOF_INT == 2
  288. typedef unsigned int UWORD;
  289. typedef int WORD;
  290. #else
  291. #error No 2 byte type, you lose.
  292. #endif
  293.  
  294. #if SIZEOF_INT == 4
  295. typedef unsigned int ULONG;
  296. typedef int LONG;
  297. #elif SIZEOF_LONG == 4
  298. typedef unsigned long ULONG;
  299. typedef long LONG;
  300. #else
  301. #error No 4 byte type, you lose.
  302. #endif
  303. typedef ULONG CPTR;
  304.  
  305. #if SIZEOF_LONG_LONG == 8
  306. #define INT_64bit long long
  307. #elif SIZEOF_LONG == 8
  308. #define INT_64bit long
  309. #endif
  310. #endif
  311.