2 * Operating system dependent routines.
4 * Most of the stuff in here is based on Unix, but an attempt
5 * has been made to make things work on other operating systems.
6 * This will sometimes result in a loss of functionality, unless
7 * someone rewrites code specifically for the new operating system.
9 * The makefile provides defines to decide whether various
10 * Unix features are present.
19 * BSD setjmp() saves (and longjmp() restores) the signal mask.
20 * This costs a system call or two per setjmp(), so if possible we clear the
21 * signal mask with sigsetmask(), and use _setjmp()/_longjmp() instead.
22 * On other systems, setjmp() doesn't affect the signal mask and so
23 * _setjmp() does not exist; we just use setjmp().
25 #if HAS__SETJMP && SIGSETMASK
26 #define SET_JUMP _setjmp
27 #define LONG_JUMP _longjmp
29 #define SET_JUMP setjmp
30 #define LONG_JUMP longjmp
33 extern char *getenv();
37 static jmp_buf read_label;
40 * Like read() system call, but is deliberately interruptible.
41 * A call to intread() from a signal handler will interrupt
42 * any pending iread().
52 if (SET_JUMP(read_label))
55 * We jumped here from intread.
66 n = read(fd, buf, len);
74 * Interrupt a pending iread().
79 LONG_JUMP(read_label, 1);
94 * errno_message: Return an error message based on the value of "errno".
99 extern char *sys_errlist[];
104 errno_message(filename)
111 if (errno < sys_nerr)
112 p = sys_errlist[errno];
115 sprintf(msg, "Error %d", errno);
118 m = (char *) ecalloc(strlen(filename) + strlen(p) + 3, sizeof(char));
119 sprintf(m, "%s: %s", filename, p);
126 errno_message(filename)
130 static char msg[] = ": cannot open";
132 m = (char *) ecalloc(strlen(filename) + sizeof(msg), sizeof(char));