~ubuntu-branches/ubuntu/karmic/e-uae/karmic

« back to all changes in this revision

Viewing changes to src/include/sysdeps.h

  • Committer: Bazaar Package Importer
  • Author(s): Stephan Suerken
  • Date: 2008-07-05 14:02:02 UTC
  • Revision ID: james.westby@ubuntu.com-20080705140202-u5aagnhtg31pmjc3
Tags: upstream-0.8.29-WIP4
ImportĀ upstreamĀ versionĀ 0.8.29-WIP4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
  */
 
14
 
 
15
#if defined __AMIGA__ || defined __amiga__
 
16
#include <devices/timer.h>
 
17
#endif
 
18
 
 
19
#include <stdio.h>
 
20
#include <stdlib.h>
 
21
#include <errno.h>
 
22
#include <assert.h>
 
23
#include <limits.h>
 
24
 
 
25
#ifndef __STDC__
 
26
#ifndef _MSC_VER
 
27
#error "Your compiler is not ANSI. Get a real one."
 
28
#endif
 
29
#endif
 
30
 
 
31
#include <stdarg.h>
 
32
 
 
33
#ifdef HAVE_SYS_TYPES_H
 
34
#include <sys/types.h>
 
35
#endif
 
36
 
 
37
#ifdef HAVE_VALUES_H
 
38
#include <values.h>
 
39
#endif
 
40
 
 
41
#include "uae_string.h"
 
42
 
 
43
#ifdef HAVE_UNISTD_H
 
44
#include <unistd.h>
 
45
#endif
 
46
#ifdef HAVE_FCNTL_H
 
47
#include <fcntl.h>
 
48
#endif
 
49
 
 
50
#ifdef HAVE_UTIME_H
 
51
#include <utime.h>
 
52
#endif
 
53
 
 
54
#ifdef HAVE_SYS_STAT_H
 
55
#include <sys/stat.h>
 
56
#endif
 
57
 
 
58
#if TIME_WITH_SYS_TIME
 
59
# include <sys/time.h>
 
60
# include <time.h>
 
61
#else
 
62
# if HAVE_SYS_TIME_H
 
63
#  include <sys/time.h>
 
64
# else
 
65
#  include <time.h>
 
66
# endif
 
67
#endif
 
68
 
 
69
#if HAVE_DIRENT_H
 
70
# include <dirent.h>
 
71
#else
 
72
# define dirent direct
 
73
# if HAVE_SYS_NDIR_H
 
74
#  include <sys/ndir.h>
 
75
# endif
 
76
# if HAVE_SYS_DIR_H
 
77
#  include <sys/dir.h>
 
78
# endif
 
79
# if HAVE_NDIR_H
 
80
#  include <ndir.h>
 
81
# endif
 
82
#endif
 
83
 
 
84
#ifdef HAVE_SYS_UTIME_H
 
85
# include <sys/utime.h>
 
86
#endif
 
87
 
 
88
#include <errno.h>
 
89
#include <assert.h>
 
90
 
 
91
#if EEXIST == ENOTEMPTY
 
92
#define BROKEN_OS_PROBABLY_AIX
 
93
#endif
 
94
 
 
95
#ifdef __NeXT__
 
96
#define S_IRUSR S_IREAD
 
97
#define S_IWUSR S_IWRITE
 
98
#define S_IXUSR S_IEXEC
 
99
#define S_ISDIR(val) (S_IFDIR & val)
 
100
struct utimbuf
 
101
{
 
102
    time_t actime;
 
103
    time_t modtime;
 
104
};
 
105
#endif
 
106
 
 
107
#include "uae_types.h"
 
108
 
 
109
#include "uae_malloc.h"
 
110
 
 
111
#include "writelog.h"
 
112
 
 
113
#ifdef __GNUC__
 
114
/* While we're here, make abort more useful.  */
 
115
#ifndef __MORPHOS__
 
116
/* This fails to compile on Morphos - not sure why yet */
 
117
#define abort() \
 
118
  do { \
 
119
    write_log ("Internal error; file %s, line %d\n", __FILE__, __LINE__); \
 
120
    exit (0); \
 
121
} while (0)
 
122
#else
 
123
#define abort() exit(0)
 
124
#endif
 
125
#endif
 
126
 
 
127
/*
 
128
 * Porters to weird systems, look! This is the preferred way to get
 
129
 * filesys.c (and other stuff) running on your system. Define the
 
130
 * appropriate macros and implement wrappers in a machine-specific file.
 
131
 *
 
132
 * I guess the Mac port could use this (Ernesto?)
 
133
 */
 
134
 
 
135
#undef DONT_HAVE_POSIX
 
136
#undef DONT_HAVE_REAL_POSIX /* define if open+delete doesn't do what it should */
 
137
#undef DONT_HAVE_STDIO
 
138
#undef DONT_HAVE_MALLOC
 
139
 
 
140
#if defined _WIN32
 
141
 
 
142
#if defined __WATCOMC__
 
143
 
 
144
#define O_NDELAY 0
 
145
#include <direct.h>
 
146
#define dirent direct
 
147
#define mkdir(a,b) mkdir(a)
 
148
 
 
149
#elif defined __MINGW32__
 
150
 
 
151
#define FILEFLAG_DIR     0x1
 
152
#define FILEFLAG_ARCHIVE 0x2
 
153
#define FILEFLAG_WRITE   0x4
 
154
#define FILEFLAG_READ    0x8
 
155
#define FILEFLAG_EXECUTE 0x10
 
156
#define FILEFLAG_SCRIPT  0x20
 
157
#define FILEFLAG_PURE    0x40
 
158
 
 
159
#define O_NDELAY 0
 
160
#define mkdir(a,b) mkdir(a)
 
161
 
 
162
#elif defined _MSC_VER
 
163
 
 
164
#ifdef HAVE_GETTIMEOFDAY
 
165
#include <winsock.h> // for 'struct timeval' definition
 
166
extern void gettimeofday( struct timeval *tv, void *blah );
 
167
#endif
 
168
 
 
169
#define O_NDELAY 0
 
170
 
 
171
#define FILEFLAG_DIR     0x1
 
172
#define FILEFLAG_ARCHIVE 0x2
 
173
#define FILEFLAG_WRITE   0x4
 
174
#define FILEFLAG_READ    0x8
 
175
#define FILEFLAG_EXECUTE 0x10
 
176
#define FILEFLAG_SCRIPT  0x20
 
177
#define FILEFLAG_PURE    0x40
 
178
 
 
179
 
 
180
#include <io.h>
 
181
#define O_BINARY _O_BINARY
 
182
#define O_WRONLY _O_WRONLY
 
183
#define O_RDONLY _O_RDONLY
 
184
#define O_RDWR   _O_RDWR
 
185
#define O_CREAT  _O_CREAT
 
186
#define O_TRUNC  _O_TRUNC
 
187
#define W_OK 0x2
 
188
#define R_OK 0x4
 
189
#define STAT struct stat
 
190
#define DIR struct DIR
 
191
struct direct
 
192
{
 
193
    char d_name[1];
 
194
};
 
195
#include <sys/utime.h>
 
196
#define utimbuf _utimbuf
 
197
#define USE_ZFILE
 
198
 
 
199
#undef S_ISDIR
 
200
#undef S_IWUSR
 
201
#undef S_IRUSR
 
202
#undef S_IXUSR
 
203
#define S_ISDIR(a) (a&FILEFLAG_DIR)
 
204
#define S_ISARC(a) (a&FILEFLAG_ARCHIVE)
 
205
#define S_IWUSR FILEFLAG_WRITE
 
206
#define S_IRUSR FILEFLAG_READ
 
207
#define S_IXUSR FILEFLAG_EXECUTE
 
208
 
 
209
/* These are prototypes for functions from the Win32 posixemu file */
 
210
extern void get_time(time_t t, long* days, long* mins, long* ticks);
 
211
extern time_t put_time (long days, long mins, long ticks);
 
212
extern DWORD getattr(const char *name, LPFILETIME lpft, size_t *size);
 
213
 
 
214
/* #define DONT_HAVE_POSIX - don't need all of Mathias' posixemu_functions, just a subset (below) */
 
215
#define chmod(a,b) posixemu_chmod ((a), (b))
 
216
extern int posixemu_chmod (const char *, int);
 
217
#define stat(a,b) posixemu_stat ((a), (b))
 
218
extern int posixemu_stat (const char *, struct stat *);
 
219
#define mkdir(x,y) mkdir(x)
 
220
#define truncate posixemu_truncate
 
221
extern int posixemu_truncate (const char *, long int);
 
222
#define utime posixemu_utime
 
223
extern int posixemu_utime (const char *, struct utimbuf *);
 
224
#define opendir posixemu_opendir
 
225
extern DIR * posixemu_opendir (const char *);
 
226
#define readdir posixemu_readdir
 
227
extern struct dirent* posixemu_readdir (DIR *);
 
228
#define closedir posixemu_closedir
 
229
extern void posixemu_closedir (DIR *);
 
230
 
 
231
#endif
 
232
 
 
233
#endif /* _WIN32 */
 
234
 
 
235
#ifdef DONT_HAVE_POSIX
 
236
 
 
237
#define access posixemu_access
 
238
extern int posixemu_access (const char *, int);
 
239
#define open posixemu_open
 
240
extern int posixemu_open (const char *, int, int);
 
241
#define close posixemu_close
 
242
extern void posixemu_close (int);
 
243
#define read posixemu_read
 
244
extern int posixemu_read (int, char *, int);
 
245
#define write posixemu_write
 
246
extern int posixemu_write (int, const char *, int);
 
247
#undef lseek
 
248
#define lseek posixemu_seek
 
249
extern int posixemu_seek (int, int, int);
 
250
#define stat(a,b) posixemu_stat ((a), (b))
 
251
extern int posixemu_stat (const char *, STAT *);
 
252
#define mkdir posixemu_mkdir
 
253
extern int mkdir (const char *, int);
 
254
#define rmdir posixemu_rmdir
 
255
extern int posixemu_rmdir (const char *);
 
256
#define unlink posixemu_unlink
 
257
extern int posixemu_unlink (const char *);
 
258
#define truncate posixemu_truncate
 
259
extern int posixemu_truncate (const char *, long int);
 
260
#define rename posixemu_rename
 
261
extern int posixemu_rename (const char *, const char *);
 
262
#define chmod posixemu_chmod
 
263
extern int posixemu_chmod (const char *, int);
 
264
#define tmpnam posixemu_tmpnam
 
265
extern void posixemu_tmpnam (char *);
 
266
#define utime posixemu_utime
 
267
extern int posixemu_utime (const char *, struct utimbuf *);
 
268
#define opendir posixemu_opendir
 
269
extern DIR * posixemu_opendir (const char *);
 
270
#define readdir posixemu_readdir
 
271
extern struct dirent* readdir (DIR *);
 
272
#define closedir posixemu_closedir
 
273
extern void closedir (DIR *);
 
274
 
 
275
/* This isn't the best place for this, but it fits reasonably well. The logic
 
276
 * is that you probably don't have POSIX errnos if you don't have the above
 
277
 * functions. */
 
278
extern long dos_errno (void);
 
279
 
 
280
#endif
 
281
 
 
282
#ifdef DONT_HAVE_STDIO
 
283
 
 
284
extern FILE *stdioemu_fopen (const char *, const char *);
 
285
#define fopen(a,b) stdioemu_fopen(a, b)
 
286
extern int stdioemu_fseek (FILE *, int, int);
 
287
#define fseek(a,b,c) stdioemu_fseek(a, b, c)
 
288
extern int stdioemu_fread (char *, int, int, FILE *);
 
289
#define fread(a,b,c,d) stdioemu_fread(a, b, c, d)
 
290
extern int stdioemu_fwrite (const char *, int, int, FILE *);
 
291
#define fwrite(a,b,c,d) stdioemu_fwrite(a, b, c, d)
 
292
extern int stdioemu_ftell (FILE *);
 
293
#define ftell(a) stdioemu_ftell(a)
 
294
extern int stdioemu_fclose (FILE *);
 
295
#define fclose(a) stdioemu_fclose(a)
 
296
 
 
297
#endif
 
298
 
 
299
#ifdef DONT_HAVE_MALLOC
 
300
 
 
301
#define malloc(a) mallocemu_malloc(a)
 
302
extern void *mallocemu_malloc (int size);
 
303
#define free(a) mallocemu_free(a)
 
304
extern void mallocemu_free (void *ptr);
 
305
 
 
306
#endif
 
307
 
 
308
#ifdef X86_ASSEMBLY
 
309
#define ASM_SYM_FOR_FUNC(a) __asm__(a)
 
310
#else
 
311
#define ASM_SYM_FOR_FUNC(a)
 
312
#endif
 
313
 
 
314
#include "target.h"
 
315
#include "machdep/machdep.h"
 
316
#include "gfxdep/gfx.h"
 
317
 
 
318
extern void console_out (const char *, ...);
 
319
extern void console_flush (void);
 
320
extern int  console_get (char *, int);
 
321
extern void f_out (void *, const char *, ...);
 
322
extern void gui_message (const char *,...);
 
323
extern int gui_message_multibutton (int flags, const char *format,...);
 
324
#define write_log_err write_log
 
325
 
 
326
#ifndef O_BINARY
 
327
#define O_BINARY 0
 
328
#endif
 
329
 
 
330
#ifndef MAX_PATH
 
331
# define MAX_PATH         512
 
332
#endif
 
333
#ifndef MAX_DPATH
 
334
# define MAX_DPATH        512
 
335
#endif