aboutsummaryrefslogtreecommitdiff
path: root/include/mpw/mpw.h
blob: 58702e725ff835bd5aa2c57543775e9810e674ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/* Mac MPW host-specific definitions. */

#ifndef	__INCLUDE_MPW_H
#define __INCLUDE_MPW_H

#ifndef MPW
#define MPW
#endif

/* MPW C is basically ANSI, but doesn't actually enable __STDC__,
   nor does it allow __STDC__ to be #defined. */

#ifndef ALMOST_STDC
#define ALMOST_STDC
#endif

#include <stdio.h>
#include <ctype.h>
#include <errno.h>

#define HAVE_TIME_T_IN_TIME_H 1

#define HAVE_STDLIB_H 1

#define HAVE_ERRNO_H 1

#define HAVE_STDDEF_H 1

#define HAVE_STRING_H 1

#define HAVE_STDARG_H 1

#define HAVE_VPRINTF 1

#ifdef USE_MW_HEADERS

#include <unix.h>

#else

#include <fcntl.h>
#include <ioctl.h>
#include <sys/stat.h>

#define HAVE_FCNTL_H 1

#ifndef	O_ACCMODE
#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
#endif

#ifndef fileno
#define fileno(fp) ((fp)->_file)
#endif

/* stdio.h does not define this if __STDC__, so define here. */

#ifdef __STDC__
FILE *fdopen(int fildes, const char *mode);
#endif

#endif /* USE_MW_HEADERS */

/* Add ersatz definitions, for systems that lack them.  */

#ifndef EIO
#define EIO 96
#endif
#ifndef ENOENT
#define ENOENT 97
#endif
#ifndef EACCES
#define EACCES 98
#endif
#ifndef ENOSYS
#define ENOSYS 99
#endif

#ifndef R_OK
#define R_OK 4
#define W_OK 2
#define X_OK 1
#endif

/* Binary files have different characteristics; for instance, no cr/nl
   translation. */

#define USE_BINARY_FOPEN

#include <spin.h>

#ifdef MPW_C
#undef  __PTR_TO_INT
#define __PTR_TO_INT(P) ((int)(P))
#undef __INT_TO_PTR
#define __INT_TO_PTR(P) ((char *)(P))
#endif /* MPW_C */

#define NO_FCNTL

int fstat ();

FILE *mpw_fopen ();
int mpw_fseek ();
int mpw_fread ();
int mpw_fwrite ();
int mpw_access ();
int mpw_open ();
int mpw_creat ();
void mpw_abort (void);

/* Map these standard functions to improved versions in libiberty. */

#define fopen mpw_fopen
#define fseek mpw_fseek
#define fread mpw_fread
#define fwrite mpw_fwrite
#define open mpw_open
#define access mpw_access
#define creat mpw_creat
#define abort mpw_abort

#define POSIX_UTIME

#define LOSING_TOTALLY

/* Define this so that files will be closed before being unlinked. */

#define CLOSE_BEFORE_UNLINK

#endif /* __INCLUDE_MPW_H */