Debian Codegraph @

sysdep.h

raw
1 /**************************************************************************
2 * This program is Copyright (C) 1986-2002 by Jonathan Payne. JOVE is *
3 * provided by Jonathan and Jovehacks without charge and without *
4 * warranty. You may copy, modify, and/or distribute JOVE, provided that *
5 * this notice is included in all the source files and documentation. *
6 **************************************************************************/
7
8 /*
9 * System Feature Selection: describe OS and C system to JOVE. See sysdep.txt
10 * for a better description of what the different #define feature symbols
11 * mean. If you add new ones, please keep the syntax of the first #ifdef, so
12 * that "grep System: sysdep.h" catches the first line of all symbols.
13 * See old/sysdep.h for historical symbols for untested systems that once
14 * worked.
15 */
16
17 /* The modern *BSD family all have slightly different quirks */
18 #ifdef NetBSD
19 /* System: modern NetBSD, sigh, TIOCREMOTE does not work, see iproc.c comment */
20 # define XBSD 1
21 # define NO_TIOCREMOTE 1
22 # define PNAME_SYSCTL_OID {CTL_KERN,KERN_PROC_ARGS,-1,KERN_PROC_PATHNAME}
23 #endif
24
25 #if defined(FreeBSD) || defined(DragonFly)
26 /* System: modern FreeBSD, needs HAVE_LIBUTIL_H */
27 # define XBSD 1
28 # define HAVE_LIBUTIL_H 1
29 # define SPELL "aspell list < %s | sort -u"
30 # define PNAME_SYSCTL_OID {CTL_KERN,KERN_PROC,KERN_PROC_PATHNAME,-1}
31 #endif
32
33 #if defined(OpenBSD) || defined(Darwin) || defined (XBSD)
34 /* System: modern OpenBSD, Darwin Mac OSX */
35 # define BSDPOSIX 1
36 # define USE_OPENPTY 1
37 #endif
38
39 #if defined(SunOS)
40 /* System: SunOS 5.1 aka Solaris 2.1 onwards, including Illumos/Joyent/OpenSolaris/OpenIndiana */
41 # define SYSVR4 1
42 # define PNAME_GETEXECNAME 1
43 #endif
44
45 #if defined(XLINUX)
46 /*
47 * System: Some Linux e.g. Debian 9 and earlier. Very old Linux (e.g. before
48 * RedHat6) used BSD-compatible pty handling so BSDPOSIX is better for
49 * those. Middle-aged Linux (e.g. upto Debian 9) seemed to work better with
50 * SYSVR4 and _XOPEN_SOURCE defined. Modern Linux (e.g. Debian 10 on) works
51 * better with GLIBCPTY, since they have openpty in libutil, and pty.h.
52 */
53 # define SYSVR4 1
54 # ifndef _XOPEN_SOURCE
55 # define _XOPEN_SOURCE 500
56 # endif
57 # define SPELL "aspell list < %s | sort -u"
58 # define PNAME_PROC_SELF 1
59 #endif
60
61 #if defined(CYGWIN) || defined(CYGWIN32)
62 /* System: Cygwin POSIX-like environment on Windows (see README.cyg) */
63 # define FILENAME_CASEINSENSITIVE 1
64 # define GLIBCPTY 1
65 # define O_TRUNC_BROKEN 1 /* see fp.c */
66 # define SPELL "aspell list < %s | sort -u"
67 # define JTC 1 /* no real point using curses for Cygwin, surely?! */
68 #endif
69
70 #if defined(Linux) || defined(GNU) || defined(GLIBCPTY)
71 /*
72 * modern glibc e.g. Linux, Cygwin) provides openpty and pty.h
73 * so this is also Linux alternative. Also GNU Debian Hurd.
74 */
75 # define USE_OPENPTY 1 /* older Cygwin may not have openpty? */
76 # define HAVE_PTY_H 1
77 # define BSDPOSIX 1
78 # define PNAME_PROC_SELF 1
79 #endif
80
81 #ifdef MINGW /* System: MinGW cross-compilation for Windows WIN32 (see README.win) */
82 # define WIN32 1
83 # define NO_MKSTEMP 1 /* MKSTEMP on Windows unlinks the filename, which Jove uses for filters */
84 #endif
85
86 #ifdef OWCDOS /* System: Open Watcom C 1.9 for x86 running MSDOS (see README.dos) */
87 # define IBMPCDOS 1
88 #endif
89
90 #ifdef _MSC_VER /* System: Microsoft C for the IBM-PC under MSDOS or WIN32 (see README.dos or README.win) */
91 /* 4.16.0.38 tested under VC++ 5.0 / VS 97 */
92 /* 4.16.0.62 tested under Visual C++ 6.0 SP5 */
93 /* 4.17.x.x tested under Visual Studio 2019 Community Edition */
94 /* 5.x tested under Visual Studio 2022 Build Tools MSVC 14.43.34808 */
95 # if defined(_WIN32) && !defined(WIN32)
96 # define WIN32 _WIN32
97 # endif
98 # ifndef WIN32 /* ! WIN32 => MSDOS, worked pre-MSVC 7.x */
99 # define IBMPCDOS 1
100 # endif
101 # define NO_MKSTEMP 1
102 # define _POSIX_ 1 /* suppresses MS's min and max in VC++ 5.0 */
103 # define jmode_t int /* no mode_t on WIN32 */
104 #endif
105
106 /**************************************************************************/
107 /* Some very common collectons of capabilities, used by many defs above */
108
109 #ifdef BSDPOSIX /* System: Posix system with BSD flavouring for ptys */
110 /* System: SunOS4.1.3, DEC Ultrix 4.2 -- BSDPOSIX */
111 /* System: DEC OSF/1 V1.3 -- BSDPOSIX + NO_TIOCREMOTE + NO_TIOCSIGNAL */
112 # define USE_SELECT 1
113 # if !defined(PIPEPROCS) && !defined(NO_IPROCS) /* useful to test PIPEPROCS even on pty platforms */
114 # define PTYPROCS 1
115 # define BSD_PTYS 1 /* beware security flaw! */
116 # endif
117 # define POSIX_PROCS 1
118 # define POSIX_SIGS 1
119 # define JOB_CONTROL 1
120 # define BSD_SETPGRP 1
121 # define USE_KILLPG 1
122 # define USE_GETPWNAM 1
123 # define USE_GETHOSTNAME 1
124 # define USE_FSYNC 1
125 # define HAS_SYMLINKS 1
126 # ifndef ISO_8859_1 /* fudge for __convex__ (see above) */
127 # define USE_CTYPE 1
128 # endif
129 #endif
130
131 #ifdef SYSVR4 /* System: System V, Release 4 and derivatives */
132 /* System: Consensys V4 -- use SYSVR4 and GRANTPT_BUG */
133 /* System: DEC OSF/1 V2.0 or later -- use SYSVR4 */
134 /* System: DEC OSF R1.3MK -- use SYSVR4 */
135 /* System: Digital UNIX V4.0 and later -- use SYSVR4 and GRANTPT_BUG */
136 /* System: Solaris 2.0, SunOS 5.0 -- use SYSVR4 and GRANTPT_BUG */
137 /* System: Solaris 2.x onwards, SunOS 5.x, OpenIndiana/Illumos/Joyent -- use SYSVR4 */
138 /* Note: some versions of System V Release 4 have a bug in that affects
139 * interactive processes. Examples include Consensys V4 and SunOS 5.0
140 * also known as Solaris 5.0. See the description of GRANTPT_BUG in
141 * sysdep.txt. It turns out that this bug is documented as a feature
142 * in "The Single UNIX Specification", Version 2!
143 */
144 # define USE_SELECT 1
145 # if !defined(PIPEPROCS) && !defined(NO_IPROCS) /* useful to test PIPEPROCS even on pty platforms */
146 # define PTYPROCS 1
147 # define SVR4_PTYS 1
148 # endif
149 # define POSIX_PROCS 1
150 # define POSIX_SIGS 1
151 # define JOB_CONTROL 1
152 # define USE_UNAME 1
153 # define USE_GETPWNAM 1
154 # define USE_FSYNC 1
155 # define HAS_SYMLINKS 1
156 # define USE_CTYPE 1
157 #endif
158
159 /**************** Common Characteristics ****************/
160
161 #ifdef IBMPCDOS /* Common characteristics for IBM-PC MS-DOS systems. */
162 # ifndef MSDOS
163 # define MSDOS 1
164 # endif
165 # define PCNONASCII 0xFF /* prefix for peculiar IBM PC key codes */
166 # define NO_JSTDOUT 1 /* don't use jstdout */
167 # define CODEPAGE437 1 /* Code Page 437 English display characters */
168 # define PCSCRATTR 1 /* exploit IBMPC screen attributes */
169 # define HIGHLIGHTING 1 /* highlighting is used for mark and scrollbar */
170 # define MALLOC_CACHE 1 /* DGROUP gets full otherwise */
171 # define JSMALL 1 /* less than 64K lines fit in memory anyway */
172 # define FAR_LINES 1 /* to squeeze larger files, use far line pointers */
173 # if defined(M_I86SM) || defined(__SMALL__) || defined(M_I86CM) || defined(__COMPACT__)
174 /* try small or compact memory model: currently 20K over the 64K code+data limit, so not really viable */
175 # define BAREBONES 1
176 # endif
177 # if defined(M_I86LM) || defined(__LARGE__) /* large memory model */
178 # define LG_JBUFSIZ 11 /* so JBUFSIZ (and max line len) 2048 chars */
179 # define NBUF 30 /* NBUF*JBUFSIZ must be less than 64K. Is this true even if MALLOC_CACHE is set? */
180 # endif
181 #endif
182
183 #ifdef MSDOS /* Common characteristics for MS-DOS systems. */
184 # define MSDOS_PROCS 1 /* spawn et al */
185 # define FILENAME_CASEINSENSITIVE 1
186 # define USE_CRLF 1
187 # define DIRECTORY_ADD_SLASH 1
188 # define MSFILESYSTEM 1
189 #endif
190
191 #ifdef WIN32 /* Common characteristics for WIN32 systems. */
192 # define WINRESIZE 1
193 # define PCNONASCII ((unsigned char)0xFF) /* prefix for peculiar IBM PC key codes */
194 # define NO_JSTDOUT 1 /* don't use jstdout */
195 # define CODEPAGE437 1 /* Code Page 437 English display characters */
196 # define PCSCRATTR 1 /* exploit IBMPC screen attributes */
197 # define HIGHLIGHTING 1 /* highlighting is used for mark and scrollbar */
198 # define MSDOS_PROCS 1 /* spawn et al */
199 # define FILENAME_CASEINSENSITIVE 1
200 # define USE_CRLF 1
201 # define DIRECTORY_ADD_SLASH 1
202 # define MSFILESYSTEM 1
203 # ifdef _WIN64 /* the only 64bit arch where unsigned long != unsigned long long */
204 # define DADDR unsigned long long
205 # endif
206 #endif
207
208 /* The operating system (MSDOS, WIN32) must be defined by this point. */
209 #if !(defined(MSDOS) || defined(WIN32))
210 # define UNIX 1 /* default to UNIX */
211 #endif
212
213 #ifdef UNIX /* Common characteristics for UNIX systems. */
214 /* Our defaults tend to be conservative and lean towards pure SYSV */
215 # define USE_INO 1
216 # define TERMCAP 1
217 # define NCURSES_BUG 1 /* almost certainly safe anyway */
218 # define WINRESIZE 1
219 # define MOUSE 1
220 # define MALLOC_CACHE 1
221 # if !(defined(NO_IPROCS) || defined(PIPEPROCS) || defined(PTYPROCS))
222 # define PIPEPROCS 1 /* use pipes */
223 # endif
224 /* At the moment, the PTY code mandates having select(). One day, this might
225 * change.
226 */
227 # if defined(PTYPROCS) && !defined(USE_SELECT)
228 sysdep.h: Sorry, PTYPROCS requires the select() system call. You must
229 either define USE_SELECT or undefine PTYPROCS.
230 # endif
231 # if defined(SIGCLD) && !defined(SIGCHLD)
232 # define SIGCHLD SIGCLD
233 # endif
234 # ifndef USE_EXIT
235 # define EXIT _exit /* so linker does not drag in all of stdio for static linking */
236 # endif
237 #endif /* UNIX */
238
239 #ifndef EXIT
240 # define EXIT exit
241 #endif
242
243 /* lint suppression macros; GCC requires use of extensions! Clang mimics. */
244 #if !defined(GCC_LINT) && (defined(__GNUC__) || defined(__clang__))
245 # define GCC_LINT
246 #endif
247
248 #ifdef GCC_LINT
249 # define UNUSED(x) x __attribute__ ((unused))
250 # define NEVER_RETURNS __attribute__ ((noreturn))
251 #else /* !GCC_LINT */
252 # define UNUSED(x) x
253 # define NEVER_RETURNS
254 #endif /* !GCC_LINT */
255
256 /*************************************************************************
257 *
258 * The things below here aren't meant to be tuned, but are included here
259 * because they're dependent on the things defined earlier in the file.
260 */
261
262 /* jmode_t: the type for file modes
263 * Really old systems might use "int" or perhaps "unsigned".
264 */
265 #ifndef jmode_t
266 # define jmode_t mode_t
267 #endif
268
269 #ifndef SIGRESTYPE /* default to void, correct for most modern systems */
270 # define SIGRESTYPE void
271 # define SIGRESVALUE /*void!*/
272 #endif
273
274 #ifndef EOL
275 # define EOL '\n' /* end-of-line character for files */
276 #endif
277
278 #ifdef JSMALL
279 /*
280 * On small memory/no-VM machines, save as much data space
281 * as we can. Going to hit either Out of lines, Tmp file
282 * too large, or Out of memory (for open files) at some
283 * point, alas.
284 */
285 # ifndef DADDR
286 # define DADDR unsigned short
287 # endif
288 # define LG_FILESIZE 7 /* log2 maximum path length (including '\0'): currently, 2+1+64+3+1+3+1 == 80 ought to be OK */
289 # define MAXCOLS 132 /* maximum number of columns */
290 # define MAXTTYBUF 512 /* maximum size of output terminal buffer */
291 # ifndef LG_JBUFSIZ
292 # define LG_JBUFSIZ 9 /* temp file block size, also maximum line length. 512 bytes is the traditional UNIX block size */
293 # endif
294 # ifndef NBUF
295 # define NBUF 3 /* number of temp file blocks to cache in memory, NBUF*JBUFSIZ is big part of JOVE memory footprint */
296 # endif
297
298 #else
299 /*
300 * On most modern machines (VM, or lots of memory), use
301 * slightly more generous buffer sizes to improve speed
302 * and/or convenience.
303 */
304 # ifndef DADDR
305 # define DADDR unsigned long
306 # endif
307 # define LG_FILESIZE 9 /* log2 maximum path length (including '\0') */
308 # define MAXCOLS 1024 /* maximum number of columns */
309 # define MAXTTYBUF 4096 /* maximum size of output terminal buffer */
310 # ifndef LG_JBUFSIZ
311 # define LG_JBUFSIZ 15 /* temp file block size, also maximum line length, 32K seems better for modern VM machines */
312 # endif
313 # ifndef NBUF
314 # define NBUF 64 /* number of temp file blocks to cache in memory, NBUF*JBUFSIZ is big part of JOVE memory footprint */
315 # endif
316
317 #endif /* !JSMALL */
318
319 /* DADDR must be >= sizeof(void *), wish everyone had stdint and intptr_t */
320 typedef DADDR daddr; /* index of line contents in tmp file, see temp.h and disp.h. */
321 #define JBUFSIZ (1 << LG_JBUFSIZ)
322 #define FILESIZE (1 << LG_FILESIZE)