Minimal changes to get m6502 to compile (won't work)
[Apout.git] / defines.h
1 /* defines.h    - Definitions of things needed in all C files
2  *
3  * $Revision: 2.75 $
4  * $Date: 2008/05/19 13:42:39 $
5  */
6
7 #include <sys/types.h>
8 #include <sys/param.h>
9 #include <sys/stat.h>
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <string.h>
13 #include <ctype.h>
14 #include <signal.h>
15 #include <errno.h>
16
17 /* Defines for ifdef'd code -- define them in the Makefile */
18
19 /* #define DEBUG                        adds in debugging code */
20 /* #define ZERO_MEMORY                  zeros all of process memory before
21                                         it starts to run */
22 /* #define NATIVES                      allows native binaries and PDP-11
23                                         binaries in the filespace */
24 /* #define EMU211                       add 2.11BSD emulation */
25 /* #define EMUV1                        add 1st Edition emulation */
26 /* #define INLINE inline                inlines some functions (needs gcc) */
27
28
29 /* Optimisation defines */
30 #ifndef INLINE
31 #define INLINE
32 #endif
33
34 /* Special defines to enable/disable certain
35  * functionality. These are added as required
36  * to port to new platforms. Please send in new
37  * defines, please!
38  */
39
40 #if defined(__FreeBSD__) && __FreeBSD__ < 3
41 #define NO_GETPGID
42 #endif
43
44 #ifdef __FreeBSD__
45 #define Reboot(x) reboot(x)
46 #endif
47
48 #ifdef __linux__
49 #define NO_CHFLAGS
50 #define NO_STFLAGS
51 #define NO_GETPGID
52 #define NEED_MAP_FCNTL
53 #define SIGEMT 0
54 #ifndef SIGSYS
55 #define SIGSYS 0
56 #endif
57 #define OXTABS XTABS
58 #define VDSUSP VSUSP            /* I don't think these are equivalent */
59 #define O_SHLOCK 0
60 #define O_EXLOCK 0
61 #endif
62
63 #if defined(__NetBSD__) || defined(__OpenBSD__)
64 #define Reboot(x) reboot(x,NULL)
65 #endif
66
67 #ifndef Reboot
68 #define Reboot(x) exit(0)
69 #endif
70
71 #if !defined(__FreeBSD__) && !defined(__NetBSD__) && \
72     !defined(__OpenBSD__) && !defined(__linux__) && !defined(__APPLE__)
73 #define NEED_INT_N
74 #endif
75
76 /* Type definitions for PDP data types. You may need to
77  * define NEED_INT_N if your system  doesn't provide the
78  * types defined below. If you do this, the best way is
79  * to add some #if .. #define .. #endif lines above,
80  * rather then modifying the ones below. If you make
81  * changes to the #if's above, then I would  be very
82  * happy to include them.
83  *
84  * Warren Toomey: wkt@tuhs.org
85  */
86
87 #ifdef NEED_INT_N
88 typedef char int8_t;
89 typedef short int16_t;
90 typedef long int32_t;
91 typedef unsigned char u_int8_t;
92 typedef unsigned short u_int16_t;
93 typedef unsigned long u_int32_t;
94 #endif
95
96 /* Macro defines for debug output, makes
97  * the code look somewhat cleaner
98  */
99
100 #ifdef DEBUG
101 #define TrapDebug(x) if (trap_debug) (void)fprintf x
102 #define InstDebug(x) if (inst_debug) (void)fprintf x
103 #define JsrDebug(x)  if (jsr_debug)  (void)fprintf x
104 #define FpDebug(x)   if (fp_debug)   (void)fprintf x
105 #else
106 #define TrapDebug(x)
107 #define InstDebug(x)
108 #define JsrDebug(x)
109 #define FpDebug(x)
110 #endif
111
112 /* Defines for -DSTREAM_BUFFERING */
113 #define NFILE   40              /* Number of file pointers we can buffer */
114 #define ValidFD(x) ((x>=0) && (x<NFILE))
115 /* Used for opening on directories */
116 #define TMP_PLATE       "/tmp/apout_tmp_dir.XXXXXX"
117
118
119 /* Set up prototype macro for
120  * both K&R and ANSI C platforms
121  */
122 #ifdef __STDC__
123 #define P(s) s
124 #else
125 #define P(s) ()
126 #endif
127
128 #define MAX_ARGS        200     /* Max cmd-line args per process */
129 #define PDP_MEM_SIZE    65536   /* Size of inst-space and data-space */
130 extern u_int8_t *ispace, *dspace;
131
132 /* The following array holds the FILE pointers
133  * that correspond to open file descriptors.
134  * Only fds which are not ttys have
135  * FILE * pointers
136  */
137 extern FILE *stream[NFILE];
138 extern char *streammode[NFILE];
139
140 extern int sig_arrived;         /* Indicates if a signal has arrived */
141 extern int Argc, Envc;          /* Arguments passed to new process */
142 extern char *Argv[MAX_ARGS], *Envp[MAX_ARGS];
143 extern int Binary;              /* Type of binary this a.out is. One of: */
144 #define IS_UNKNOWN      0
145 #define IS_V1           1
146 #define IS_V2           2
147 #define IS_V3           3
148 #define IS_V4           4
149 #define IS_V5           5
150 #define IS_V6           6
151 #define IS_V7           7
152 #define IS_A68          68
153 #define IS_29BSD        29
154 #define IS_211BSD       211
155
156 /* 2.11BSD overlay stuff */
157 extern u_int32_t ov_changes;    /* Number of overlay changes */
158 extern u_int8_t current_ov;     /* Current overlay number */
159
160 #ifdef DEBUG
161 /* Debugging flags */
162 extern int inst_debug,          /* Print a line before each instruction */
163        trap_debug,                      /* Print details of each trap */
164        jsr_debug,                       /* Print out each jsr */
165        fp_debug;                        /* Print out each floating-point instruction */
166 extern FILE *dbg_file;          /* Debugging output file */
167 extern char *progname;          /* The program's name - used in debugging */
168 #endif
169
170 /* We keep a list of signals that are pending */
171 struct our_siglist {
172     int sig;                    /* Number of the signal */
173     struct our_siglist *next;
174 };
175 extern struct our_siglist *Sighead;     /* Head of the list */
176 extern struct our_siglist *Sigtail;     /* Tail of the list */
177
178
179
180 /* Function prototypes */
181
182 /* aout.c */
183 int load_a_out P((const char *file, const char *origpath, int want_env))
184 /*@globals errno,stdout,stderr; @ */ ;
185 #ifdef EMU211
186 void do_bsd_overlay P((void));
187 #endif
188
189 /* main.c */
190 int main P((int argc, char **argv));
191 void usage P((void));
192 char *xlate_filename P((char *name));
193 void set_apout_root P((char *dirname));
194
195 /* magic.c */
196 int special_magic P((u_int16_t * cptr));
197
198 /* v6trap.c */
199 void v6trap P((void));
200
201 /* v7trap.c */
202 void v7trap P((void));
203
204 /* v1trap.c */
205 void v1trap P((void));
206
207 /* bsdtrap.c */
208 #if 1 //def EMU211
209 void bsdtrap P((void)) /*@globals errno,stdout,stderr; @ */ ;
210
211 /* bsd_ioctl.h */
212 int trap_ioctl P((void));
213
214 /* bsd_signal.c */
215 void set_bsdsig_dfl P((void));
216 int do_sigaction P((int sig, int a, int oa));
217 void sigcatcher P((int sig));
218 #endif
219
220 #undef P
221
222 #ifdef CPU_PDP11
223 #include "pdp11/cpu.h"
224 #endif
225 #ifdef CPU_Z180
226 #include "z180/cpu.h"
227 #endif