]>
git.zerfleddert.de Git - micropolis/blob - src/tcl/tclunix.h
a4c5cabfd8a5b52b27bd43082d64203fdf024f18
4 * This file reads in UNIX-related header files and sets up
5 * UNIX-related macros for Tcl's UNIX core. It should be the
6 * only file that contains #ifdefs to handle different flavors
7 * of UNIX. This file sets up the union of all UNIX-related
8 * things needed by any of the Tcl core files. This file
9 * depends on configuration #defines in tclConfig.h
11 * The material in this file was originally contributed by
12 * Karl Lehenbauer, Mark Diekhans and Peter da Silva.
14 * Copyright 1991 Regents of the University of California
15 * Permission to use, copy, modify, and distribute this
16 * software and its documentation for any purpose and without
17 * fee is hereby granted, provided that this copyright
18 * notice appears in all copies. The University of California
19 * makes no representations about the suitability of this
20 * software for any purpose. It is provided "as is" without
21 * express or implied warranty.
23 * $Header: /user6/ouster/tcl/RCS/tclUnix.h,v 1.26 92/08/03 08:27:43 ouster Exp $ SPRITE (Berkeley)
30 * The following #defines are used to distinguish between different
31 * UNIX systems. These #defines are normally set by the "config" script
32 * based on information it gets by looking in the include and library
33 * areas. The defaults below are for BSD-based systems like SunOS
36 * TCL_GETTOD - 1 means there exists a library procedure
37 * "gettimeofday" (e.g. BSD systems). 0 means
38 * have to use "times" instead.
39 * TCL_GETWD - 1 means there exists a library procedure
40 * "getwd" (e.g. BSD systems). 0 means
41 * have to use "getcwd" instead.
42 * TCL_SYS_ERRLIST - 1 means that the array sys_errlist is
43 * defined as part of the C library.
44 * TCL_SYS_TIME_H - 1 means there exists an include file
45 * <sys/time.h> (e.g. BSD derivatives).
46 * TCL_SYS_WAIT_H - 1 means there exists an include file
47 * <sys/wait.h> that defines constants related
48 * to the results of "wait".
49 * TCL_UNION_WAIT - 1 means that the "wait" system call returns
50 * a structure of type "union wait" (e.g. BSD
51 * systems). 0 means "wait" returns an int
52 * (e.g. System V and POSIX).
53 * TCL_PID_T - 1 means that <sys/types> defines the type
54 * pid_t. 0 means that it doesn't.
55 * TCL_UID_T - 1 means that <sys/types> defines the type
56 * uid_t. 0 means that it doesn't.
61 #define TCL_SYS_ERRLIST 1
62 #define TCL_SYS_TIME_H 1
63 #define TCL_SYS_WAIT_H 1
64 #define TCL_UNION_WAIT 0
83 #include <sys/param.h>
84 #include <sys/types.h>
89 # include <sys/time.h>
94 # include <sys/wait.h>
98 * Not all systems declare the errno variable in errno.h. so this
99 * file does it explicitly. The list of system error messages also
100 * isn't generally declared in a header file anywhere.
106 //extern char *sys_errlist[];
110 * The type of the status returned by wait varies from UNIX system
111 * to UNIX system. The macro below defines it:
115 # define WAIT_STATUS_TYPE union wait
117 # define WAIT_STATUS_TYPE int
121 * Supply definitions for macros to query wait status, if not already
122 * defined in header files above.
126 # define WIFEXITED(stat) (((*((int *) &(stat))) & 0xff) == 0)
130 # define WEXITSTATUS(stat) (((*((int *) &(stat))) >> 8) & 0xff)
134 # define WIFSIGNALED(stat) (((*((int *) &(stat)))) && ((*((int *) &(stat))) == ((*((int *) &(stat))) & 0x00ff)))
138 # define WTERMSIG(stat) ((*((int *) &(stat))) & 0x7f)
142 # define WIFSTOPPED(stat) (((*((int *) &(stat))) & 0xff) == 0177)
146 # define WSTOPSIG(stat) (((*((int *) &(stat))) >> 8) & 0xff)
150 * Supply macros for seek offsets, if they're not already provided by
167 * The stuff below is needed by the "time" command. If this
168 * system has no gettimeofday call, then must use times and the
169 * CLK_TCK #define (from sys/param.h) to compute elapsed time.
170 * Unfortunately, some systems only have HZ and no CLK_TCK, and
171 * some might not even have HZ.
175 # include <sys/times.h>
176 # include <sys/param.h>
187 * Define access mode constants if they aren't already defined.
204 * On systems without symbolic links (i.e. S_IFLNK isn't defined)
205 * define "lstat" to use "stat" instead.
213 * Define macros to query file type bits, if they're not already
219 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
221 # define S_ISREG(m) 0
226 # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
228 # define S_ISDIR(m) 0
233 # define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
235 # define S_ISCHR(m) 0
240 # define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
242 # define S_ISBLK(m) 0
247 # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
249 # define S_ISFIFO(m) 0
254 # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
256 # define S_ISLNK(m) 0
261 # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
263 # define S_ISSOCK(m) 0
268 * Make sure that MAXPATHLEN is defined.
273 # define MAXPATHLEN PATH_MAX
275 # define MAXPATHLEN 2048
280 * Define pid_t and uid_t if they're not already defined.
291 * Variables provided by the C library:
294 extern char **environ
;
297 * Library procedures used by Tcl but not declared in a header file:
302 extern int access
_ANSI_ARGS_((CONST
char *path
, int mode
));
303 extern int chdir
_ANSI_ARGS_((CONST
char *path
));
304 extern int close
_ANSI_ARGS_((int fd
));
305 extern int dup2
_ANSI_ARGS_((int src
, int dst
));
306 extern int execvp
_ANSI_ARGS_((CONST
char *name
, char **argv
));
307 extern void _exit
_ANSI_ARGS_((int status
));
308 extern pid_t fork
_ANSI_ARGS_((void));
309 extern uid_t geteuid
_ANSI_ARGS_((void));
310 extern pid_t getpid
_ANSI_ARGS_((void));
311 extern char * getcwd
_ANSI_ARGS_((char *buffer
, int size
));
312 extern char * getwd
_ANSI_ARGS_((char *buffer
));
313 extern int kill
_ANSI_ARGS_((pid_t pid
, int sig
));
314 extern long lseek
_ANSI_ARGS_((int fd
, int offset
, int whence
));
315 extern char * mktemp
_ANSI_ARGS_((char *template));
316 extern int open
_ANSI_ARGS_((CONST
char *path
, int flags
, ...));
317 extern int pipe
_ANSI_ARGS_((int *fdPtr
));
318 extern int read
_ANSI_ARGS_((int fd
, char *buf
, int numBytes
));
319 extern int readlink
_ANSI_ARGS_((CONST
char *path
, char *buf
, int size
));
320 extern int unlink
_ANSI_ARGS_((CONST
char *path
));
321 extern int write
_ANSI_ARGS_((int fd
, char *buf
, int numBytes
));
325 #endif /* _TCLUNIX */