diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 722a572b5..83736c28e 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +Sat Aug 12 01:33:12 2000 Christopher Faylor + + * winsup.h: Split out dtable definitions into separate header file. + * dtable.h: New file. + * sigproc.h: Eliminate pinfo.h usage here. Use it in source files that + need it. + Sat Aug 12 01:08:11 2000 Christopher Faylor * Makefile.in: Use dtable.o rather than hinfo.o. diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index aa00a3ace..e14447ab5 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -16,6 +16,8 @@ details. */ #include "dll_init.h" #include "autoload.h" #include +#include "dtable.h" +#include "pinfo.h" #define MAX_AT_FILE_LEVEL 10 @@ -730,7 +732,7 @@ dll_crt0_1 () } /* Allocate fdtab */ - fdtab_init (); + dtable_init (); /* Initialize uid, gid. */ uinfo_init (); diff --git a/winsup/cygwin/debug.cc b/winsup/cygwin/debug.cc index 23cd83cba..e83b13af5 100644 --- a/winsup/cygwin/debug.cc +++ b/winsup/cygwin/debug.cc @@ -10,6 +10,7 @@ details. */ #include "winsup.h" #include "exceptions.h" #include "perthread.h" +#include "pinfo.h" static muto NO_COPY *threadname_lock = NULL; #define lock_threadname() \ diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc index f9cb83baf..07d0e34ca 100644 --- a/winsup/cygwin/dir.cc +++ b/winsup/cygwin/dir.cc @@ -13,6 +13,7 @@ details. */ #include #include #include +#include "pinfo.h" #define _COMPILING_NEWLIB #include "dirent.h" diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index 45c06804d..716770ae8 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -20,12 +20,14 @@ details. */ #include #include +#include "dtable.h" +#include "pinfo.h" dtable fdtab; /* Set aside space for the table of fds */ void -fdtab_init (void) +dtable_init (void) { if (!fdtab.size) fdtab.extend(NOFILE_INCR); diff --git a/winsup/cygwin/dtable.h b/winsup/cygwin/dtable.h new file mode 100644 index 000000000..64ffc496f --- /dev/null +++ b/winsup/cygwin/dtable.h @@ -0,0 +1,44 @@ +/* dtable.h: fd table definition. + + Copyright 2000 Red Hat, Inc. + +This file is part of Cygwin. + +This software is a copyrighted work licensed under the terms of the +Cygwin license. Please consult the file "CYGWIN_LICENSE" for +details. */ + +class dtable +{ + fhandler_base **fds; + fhandler_base **fds_on_hold; + int first_fd_for_open; +public: + size_t size; + dtable () {first_fd_for_open = 3;} + int vfork_child_dup (); + void vfork_parent_restore (); + fhandler_base *dup_worker (fhandler_base *oldfh); + int extend (int howmuch); + void fixup_after_fork (HANDLE); + fhandler_base *build_fhandler (int fd, DWORD dev, const char *name, + int unit = -1); + fhandler_base *build_fhandler (int fd, const char *name, HANDLE h); + int not_open (int n); + int find_unused_handle (int start); + int find_unused_handle () { return find_unused_handle (first_fd_for_open);} + void release (int fd); + void init_std_file_from_handle (int fd, HANDLE handle, DWORD access, const char *name); + int dup2 (int oldfd, int newfd); + int linearize_fd_array (unsigned char *buf, int buflen); + LPBYTE de_linearize_fd_array (LPBYTE buf); + fhandler_base *operator [](int fd) { return fds[fd]; } + select_record *select_read (int fd, select_record *s); + select_record *select_write (int fd, select_record *s); + select_record *select_except (int fd, select_record *s); + operator fhandler_base **() {return fds;} +}; + +void dtable_init (void); +void stdio_init (void); +extern dtable fdtab; diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index c081b7025..dfb53a82c 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -13,6 +13,7 @@ details. */ #include #include #include +#include "pinfo.h" extern BOOL allow_glob; extern BOOL allow_ntea; diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 7452e94fa..52e333cdf 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -15,6 +15,7 @@ details. */ #include "exceptions.h" #include +#include "pinfo.h" char debugger_command[2 * MAX_PATH + 20]; diff --git a/winsup/cygwin/external.cc b/winsup/cygwin/external.cc index f31d34938..0d0801110 100644 --- a/winsup/cygwin/external.cc +++ b/winsup/cygwin/external.cc @@ -11,6 +11,7 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for details. */ #include "winsup.h" +#include "pinfo.h" static external_pinfo * fillout_pinfo (pid_t pid, int winpid) diff --git a/winsup/cygwin/fcntl.cc b/winsup/cygwin/fcntl.cc index 793e432e7..6f64bd941 100644 --- a/winsup/cygwin/fcntl.cc +++ b/winsup/cygwin/fcntl.cc @@ -13,6 +13,7 @@ details. */ #include #include #include +#include "dtable.h" extern "C" int diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index 564e4e29b..7388dda06 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -22,6 +22,7 @@ details. */ #include #include #include +#include "pinfo.h" /* * Scroll the screen context. diff --git a/winsup/cygwin/fhandler_serial.cc b/winsup/cygwin/fhandler_serial.cc index 6ceb71e31..80f090426 100644 --- a/winsup/cygwin/fhandler_serial.cc +++ b/winsup/cygwin/fhandler_serial.cc @@ -13,6 +13,7 @@ details. */ #include #include #include +#include "pinfo.h" /**********************************************************************/ /* fhandler_serial */ diff --git a/winsup/cygwin/fhandler_termios.cc b/winsup/cygwin/fhandler_termios.cc index 410a936ce..3e3b5b66e 100644 --- a/winsup/cygwin/fhandler_termios.cc +++ b/winsup/cygwin/fhandler_termios.cc @@ -14,6 +14,7 @@ details. */ #include #include #include +#include "pinfo.h" /* Common functions shared by tty/console */ diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 6491ed994..2c807013a 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -16,6 +16,8 @@ details. */ #include #include #include +#include "pinfo.h" +#include "dtable.h" /* Tty master stuff */ diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index 1f0a007e9..6181b2442 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -16,6 +16,8 @@ details. */ #include #include #include "dll_init.h" +#include "dtable.h" +#include "pinfo.h" DWORD NO_COPY chunksize = 0; /* Timeout to wait for child to start, parent to init child, etc. */ diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc index f7f86de96..8e1171ac4 100644 --- a/winsup/cygwin/grp.cc +++ b/winsup/cygwin/grp.cc @@ -15,6 +15,7 @@ details. */ #include #include #include +#include "pinfo.h" /* Read /etc/group only once for better performance. This is done on the first call that needs information from it. */ diff --git a/winsup/cygwin/heap.cc b/winsup/cygwin/heap.cc index b3dc488d4..53bace4af 100644 --- a/winsup/cygwin/heap.cc +++ b/winsup/cygwin/heap.cc @@ -10,6 +10,7 @@ details. */ #include "winsup.h" #include +#include "pinfo.h" #define brksize ((char *) user_data->heaptop - (char *) user_data->heapbase) #define brk (user_data->heapptr) diff --git a/winsup/cygwin/ioctl.cc b/winsup/cygwin/ioctl.cc index 51022ee55..e232ae3d3 100644 --- a/winsup/cygwin/ioctl.cc +++ b/winsup/cygwin/ioctl.cc @@ -14,6 +14,7 @@ details. */ #include "winsup.h" #include #include +#include "dtable.h" extern "C" int diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc index 400b5759f..bef6b4bb7 100644 --- a/winsup/cygwin/mmap.cc +++ b/winsup/cygwin/mmap.cc @@ -13,7 +13,8 @@ details. */ #include #include #include - +#include "dtable.h" +#include "pinfo.h" /* * Simple class used to keep a record of all current diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index 00d988f05..e0b5a0854 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -23,6 +23,8 @@ details. */ #include #include "autoload.h" #include +#include "dtable.h" +#include "pinfo.h" /* We only want to initialize WinSock in a child process if socket handles are inheritted. This global allows us to know whether this diff --git a/winsup/cygwin/passwd.cc b/winsup/cygwin/passwd.cc index 6dd01295d..d5f8b1551 100644 --- a/winsup/cygwin/passwd.cc +++ b/winsup/cygwin/passwd.cc @@ -13,6 +13,8 @@ details. */ #include #include #include +#include "dtable.h" +#include "pinfo.h" /* Read /etc/passwd only once for better performance. This is done on the first call that needs information from it. */ diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index fe1c3852c..8ab7316ca 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -81,6 +81,7 @@ details. */ #include #include #include +#include "pinfo.h" static int normalize_win32_path (const char *cwd, const char *src, char *dst); static char *getcwd_inner (char *buf, size_t ulen, int posix_p, int with_chroot); diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index 02d3cf6d7..49ef4991a 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -13,6 +13,8 @@ details. */ #include #include #include +#include "dtable.h" +#include "pinfo.h" static char NO_COPY pinfo_dummy[sizeof(pinfo)] = {0}; diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc index 951e9f431..c001c55cd 100644 --- a/winsup/cygwin/pipe.cc +++ b/winsup/cygwin/pipe.cc @@ -12,6 +12,7 @@ details. */ #include #include #include +#include "dtable.h" static int make_pipe (int fildes[2], unsigned int psize, int mode) diff --git a/winsup/cygwin/poll.cc b/winsup/cygwin/poll.cc index 6804619cb..2121d28c2 100644 --- a/winsup/cygwin/poll.cc +++ b/winsup/cygwin/poll.cc @@ -11,6 +11,7 @@ #include #include #include "winsup.h" +#include "dtable.h" extern "C" int diff --git a/winsup/cygwin/resource.cc b/winsup/cygwin/resource.cc index a456f24b8..330e147e3 100644 --- a/winsup/cygwin/resource.cc +++ b/winsup/cygwin/resource.cc @@ -14,6 +14,7 @@ details. */ #include "winsup.h" #include +#include "pinfo.h" /* add timeval values */ static void diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc index 09c732dc4..98bf59c47 100644 --- a/winsup/cygwin/security.cc +++ b/winsup/cygwin/security.cc @@ -22,6 +22,8 @@ details. */ #include #include #include +#include "dtable.h" +#include "pinfo.h" extern BOOL allow_ntea; BOOL allow_ntsec = FALSE; diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc index 3b23b397d..8c630ee7a 100644 --- a/winsup/cygwin/select.cc +++ b/winsup/cygwin/select.cc @@ -33,6 +33,7 @@ details. */ #include #include #include "select.h" +#include "dtable.h" /* * All these defines below should be in sys/types.h diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc index ff8dd3dfa..e44c7256d 100644 --- a/winsup/cygwin/shared.cc +++ b/winsup/cygwin/shared.cc @@ -14,6 +14,7 @@ details. */ #include #include #include +#include "pinfo.h" #define SHAREDVER (unsigned)(cygwin_version.api_major << 16 | \ cygwin_version.api_minor) diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc index 332034fd3..5695b4db4 100644 --- a/winsup/cygwin/signal.cc +++ b/winsup/cygwin/signal.cc @@ -13,6 +13,7 @@ details. */ #include "winsup.h" #include +#include "pinfo.h" extern "C" _sig_func_ptr diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index aba39d6ac..1bd9bcda4 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -16,6 +16,7 @@ details. */ #include #include #include +#include "pinfo.h" extern BOOL allow_ntsec; diff --git a/winsup/cygwin/sigproc.h b/winsup/cygwin/sigproc.h index f7b36a843..683e1d99d 100644 --- a/winsup/cygwin/sigproc.h +++ b/winsup/cygwin/sigproc.h @@ -94,8 +94,7 @@ int __stdcall handle_sigsuspend (sigset_t); int __stdcall proc_subproc (DWORD, DWORD); -#include "pinfo.h" - +class _pinfo; void __stdcall proc_terminate (); void __stdcall sigproc_init (); void __stdcall subproc_init (); diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index af5ac6ce0..6ac71e1b7 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -19,7 +19,9 @@ details. */ #include #include #include -#include "paths.h" +#include +#include "dtable.h" +#include "pinfo.h" extern BOOL allow_ntsec; diff --git a/winsup/cygwin/strace.cc b/winsup/cygwin/strace.cc index 047089764..457cd2200 100644 --- a/winsup/cygwin/strace.cc +++ b/winsup/cygwin/strace.cc @@ -14,6 +14,7 @@ details. */ #include #include #include +#include "pinfo.h" #define PROTECT(x) x[sizeof(x)-1] = 0 #define CHECK(x) if (x[sizeof(x)-1] != 0) { small_printf("array bound exceeded %d\n", __LINE__); ExitProcess(1); } diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 2fa0643b4..4acec27bf 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -24,6 +24,8 @@ details. */ #include #include #include /* for UNLEN */ +#include "dtable.h" +#include "pinfo.h" extern BOOL allow_ntsec; diff --git a/winsup/cygwin/sysconf.cc b/winsup/cygwin/sysconf.cc index 75bf69f61..05131d9a1 100644 --- a/winsup/cygwin/sysconf.cc +++ b/winsup/cygwin/sysconf.cc @@ -13,6 +13,7 @@ details. */ #include #include #include +#include "dtable.h" /* sysconf: POSIX 4.8.1.1 */ /* Allows a portable app to determine quantities of resources or diff --git a/winsup/cygwin/syslog.cc b/winsup/cygwin/syslog.cc index 50ef80b2c..b0c4789de 100644 --- a/winsup/cygwin/syslog.cc +++ b/winsup/cygwin/syslog.cc @@ -14,6 +14,7 @@ details. */ #include #include #include +#include "dtable.h" /* FIXME: These should probably be in the registry. */ /* FIXME: The Win95 path should be whatever slash is */ diff --git a/winsup/cygwin/termios.cc b/winsup/cygwin/termios.cc index 4b8a99648..6a5736b10 100644 --- a/winsup/cygwin/termios.cc +++ b/winsup/cygwin/termios.cc @@ -13,6 +13,7 @@ details. */ #include "winsup.h" #include +#include "dtable.h" /* tcsendbreak: POSIX 7.2.2.1 */ extern "C" diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc index 2335d6062..6f40a6800 100644 --- a/winsup/cygwin/thread.cc +++ b/winsup/cygwin/thread.cc @@ -18,9 +18,9 @@ details. */ #include "winsup.h" #include #include - #include #include +#include "pinfo.h" extern int threadsafe; diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc index 28763e180..fa8cdb512 100644 --- a/winsup/cygwin/times.cc +++ b/winsup/cygwin/times.cc @@ -16,7 +16,7 @@ details. */ #include #include #include - +#include "pinfo.h" #define FACTOR (0x19db1ded53ea710LL) #define NSPERSEC 10000000LL diff --git a/winsup/cygwin/tty.cc b/winsup/cygwin/tty.cc index fa55b2684..1aa182cc9 100644 --- a/winsup/cygwin/tty.cc +++ b/winsup/cygwin/tty.cc @@ -14,6 +14,8 @@ details. */ #include #include #include +#include "dtable.h" +#include "pinfo.h" extern fhandler_tty_master *tty_master; diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc index d752d69ea..a9cb2270a 100644 --- a/winsup/cygwin/uinfo.cc +++ b/winsup/cygwin/uinfo.cc @@ -18,6 +18,7 @@ details. */ #include #include #include +#include "pinfo.h" char * internal_getlogin (_pinfo *pi) diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h index f3794f521..3c9e51981 100644 --- a/winsup/cygwin/winsup.h +++ b/winsup/cygwin/winsup.h @@ -113,7 +113,6 @@ extern int dynamically_loaded; extern HANDLE hMainThread; extern HANDLE hMainProc; -/* Now that pinfo has been defined, include... */ #include "debug.h" #include "sync.h" #include "sigproc.h" @@ -131,36 +130,6 @@ extern "C" per_process __cygwin_user_data; /* Pointer into application's static Do not change this value. */ #define SIZEOF_PER_PROCESS (42 * 4) -class dtable -{ - fhandler_base **fds; - fhandler_base **fds_on_hold; - int first_fd_for_open; -public: - size_t size; - dtable () {first_fd_for_open = 3;} - int vfork_child_dup (); - void vfork_parent_restore (); - fhandler_base *dup_worker (fhandler_base *oldfh); - int extend (int howmuch); - void fixup_after_fork (HANDLE parent); - fhandler_base *build_fhandler (int fd, DWORD dev, const char *name, - int unit = -1); - fhandler_base *build_fhandler (int fd, const char *name, HANDLE h); - int not_open (int n); - int find_unused_handle (int start); - int find_unused_handle () { return find_unused_handle (first_fd_for_open);} - void release (int fd); - void init_std_file_from_handle (int fd, HANDLE handle, DWORD access, const char *name); - int dup2 (int oldfd, int newfd); - int linearize_fd_array (unsigned char *buf, int buflen); - LPBYTE de_linearize_fd_array (LPBYTE buf); - fhandler_base *operator [](int fd) { return fds[fd]; } - select_record *select_read (int fd, select_record *s); - select_record *select_write (int fd, select_record *s); - select_record *select_except (int fd, select_record *s); -}; - /******************* Host-dependent constants **********************/ /* Portions of the cygwin DLL require special constants whose values are dependent on the host system. Rather than dynamically @@ -320,11 +289,6 @@ void environ_init (int); void heap_init (void); void malloc_init (void); -/* fd table */ -void fdtab_init (void); -void stdio_init (void); -extern dtable fdtab; - /* UID/GID */ void uinfo_init (void);