diff options
Diffstat (limited to 'winsup/cygwin')
63 files changed, 281 insertions, 209 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 1d3217e..538d218 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +Tue Aug 22 01:08:01 2000 Christopher Faylor <cgf@cygnus.com> + + * winsup.h: Eliminate inclusion of most of the cygwin .h files. Use .h + files only in sources which require them. + * Makefile.in: Generate dependencies with -MD option. + Mon Aug 21 23:49:05 2000 Christopher Faylor <cgf@cygnus.com> * cygerrno.h: New file. Use this throughout whenever errno diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in index 9efa984..8a6575b 100644 --- a/winsup/cygwin/Makefile.in +++ b/winsup/cygwin/Makefile.in @@ -47,7 +47,7 @@ INSTALL_PROGRAM:=@INSTALL_PROGRAM@ MT_SAFE = @MT_SAFE@ DEFS = @DEFS@ -CC:=@CC@ +CC:=@CC@ -MD # FIXME: Which is it, CC or CC_FOR_TARGET? CC_FOR_TARGET:=$(CC) CFLAGS:=@CFLAGS@ @@ -282,77 +282,5 @@ WINSUP_H:=winsup.h fhandler.h path.h shared.h \ $(MT_SAFE_HEADERS) winsup.h: config.h -assert.o: $(WINSUP_H) -dcrt0.o: $(WINSUP_H) include/exceptions.h include/glob.h dll_init.h autoload.h -debug.o: $(WINSUP_H) debug.h sync.h -delqueue.o: $(WINSUP_H) -dir.o: $(WINSUP_H) -dlfcn.o: $(WINSUP_H) dll_init.h -dll_entry.o: $(WINSUP_H) include/cygwin/cygwin_dll.h -dll_init.o: $(WINSUP_H) include/exceptions.h dll_init.h -dll_main.o: -environ.o: $(WINSUP_H) -errno.o: $(WINSUP_H) -exceptions.o: $(WINSUP_H) include/exceptions.h sync.h -exec.o: $(WINSUP_H) -external.o: $(WINSUP_H) -fcntl.o: $(WINSUP_H) -fhandler.o: $(WINSUP_H) -fhandler_console.o: $(WINSUP_H) -fhandler_serial.o: $(WINSUP_H) -fhandler_termios.o: $(WINSUP_H) -fhandler_tty.o: $(WINSUP_H) -fhandler_windows.o: $(WINSUP_H) -fhandler_raw.o: $(WINSUP_H) -fhandler_floppy.o: $(WINSUP_H) -fhandler_tape.o: $(WINSUP_H) -fhandler_zero.o: $(WINSUP_H) -fhandler_random.o: $(WINSUP_H) -fork.o: $(WINSUP_H) dll_init.h -glob.o: include/glob.h -gmon.o: profil.h gmon.h -grp.o: $(WINSUP_H) -heap.o: $(WINSUP_H) -dtable.o: $(WINSUP_H) -init.o: $(WINSUP_H) -ioctl.o: $(WINSUP_H) -libccrt0.o: $(WINSUP_H) -libcmain.o: $(WINSUP_H) -localtime.o: tz_posixrules.h -malloc.o: $(WINSUP_H) sync.h -mcount.o: gmon.h -mmap.o: $(WINSUP_H) -net.o: $(WINSUP_H) autoload.h -ntea.o: -passwd.o: $(WINSUP_H) -path.o: $(WINSUP_H) -pinfo.o: $(WINSUP_H) -pipe.o: $(WINSUP_H) -poll.o: $(WINSUP_H) -profile.o: profil.h -pthread.o: $(WINSUP_H) -registry.o: $(WINSUP_H) -resource.o: $(WINSUP_H) -scandir.o: -security.o: $(WINSUP_H) -select.o: $(WINSUP_H) select.h -shared.o: $(WINSUP_H) -signal.o: $(WINSUP_H) -sigproc.o: $(WINSUP_H) sync.h -smallprint.o: $(WINSUP_H) -spawn.o: $(WINSUP_H) -strace.o: $(WINSUP_H) -strsep.o: -sync.o: $(WINSUP_H) sync.h -syscalls.o: $(WINSUP_H) -sysconf.o: $(WINSUP_H) -syslog.o: $(WINSUP_H) -termios.o: $(WINSUP_H) -test.o: $(WINSUP_H) -times.o: $(WINSUP_H) -tty.o: $(WINSUP_H) -uinfo.o: $(WINSUP_H) autoload.h -uname.o: $(WINSUP_H) -wait.o: $(WINSUP_H) -window.o: $(WINSUP_H) -thread.o: $(WINSUP_H) + +include *.d diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index f6b2bfc..fa0f4dd 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -16,9 +16,15 @@ details. */ #include "dll_init.h" #include "autoload.h" #include <ctype.h> -#include "dtable.h" +#include "sync.h" +#include "sigproc.h" +#include "perthread.h" #include "pinfo.h" #include "cygerrno.h" +#include "fhandler.h" +#include "path.h" +#include "dtable.h" +#include "thread.h" #define MAX_AT_FILE_LEVEL 10 diff --git a/winsup/cygwin/debug.cc b/winsup/cygwin/debug.cc index e83b13a..050619b 100644 --- a/winsup/cygwin/debug.cc +++ b/winsup/cygwin/debug.cc @@ -9,8 +9,10 @@ details. */ #define NO_DEBUG_DEFINES #include "winsup.h" #include "exceptions.h" -#include "perthread.h" +#include "sync.h" +#include "sigproc.h" #include "pinfo.h" +#include "perthread.h" static muto NO_COPY *threadname_lock = NULL; #define lock_threadname() \ diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc index 612d9e0..96ca52d 100644 --- a/winsup/cygwin/dir.cc +++ b/winsup/cygwin/dir.cc @@ -13,11 +13,16 @@ details. */ #include <stdlib.h> #include <sys/stat.h> #include <errno.h> -#include "pinfo.h" -#include "cygerrno.h" #define _COMPILING_NEWLIB -#include "dirent.h" +#include <dirent.h> + +#include "sync.h" +#include "sigproc.h" +#include "pinfo.h" +#include "cygerrno.h" +#include "fhandler.h" +#include "path.h" /* Cygwin internal */ /* Return whether the directory of a file is writable. Return 1 if it diff --git a/winsup/cygwin/dlfcn.cc b/winsup/cygwin/dlfcn.cc index 010281a..4484154 100644 --- a/winsup/cygwin/dlfcn.cc +++ b/winsup/cygwin/dlfcn.cc @@ -15,6 +15,9 @@ details. */ #include <ctype.h> #include "dlfcn.h" #include "dll_init.h" +#include "fhandler.h" +#include "path.h" +#include "thread.h" #define _dl_error _reent_winsup()->_dl_error #define _dl_buffer _reent_winsup()->_dl_buffer diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index c405d92..05b767f 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -20,9 +20,14 @@ details. */ #include <fcntl.h> #include <winsock.h> -#include "dtable.h" +#include "sync.h" +#include "sigproc.h" #include "pinfo.h" #include "cygerrno.h" +#include "fhandler.h" +#include "path.h" +#include "dtable.h" +#include "thread.h" dtable fdtab; diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index 7ae95b5..fc497a3 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -13,7 +13,11 @@ details. */ #include <stddef.h> #include <ctype.h> #include <fcntl.h> +#include "sync.h" +#include "sigproc.h" #include "pinfo.h" +#include "fhandler.h" +#include "path.h" #include "cygerrno.h" extern BOOL allow_glob; diff --git a/winsup/cygwin/errno.cc b/winsup/cygwin/errno.cc index 25dcf70..8e88cd5 100644 --- a/winsup/cygwin/errno.cc +++ b/winsup/cygwin/errno.cc @@ -13,6 +13,7 @@ details. */ #include <stdio.h> #include <errno.h> #include "cygerrno.h" +#include "thread.h" /* Table to map Windows error codes to Errno values. */ /* FIXME: Doing things this way is a little slow. It's trivial to change diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 39ae079..18af64d 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -10,13 +10,16 @@ details. */ #define Win32_Winsock #include "winsup.h" -#include <stdio.h> +#include <imagehlp.h> #include <errno.h> #include "exceptions.h" -#include <imagehlp.h> +#include "sync.h" +#include "sigproc.h" #include "pinfo.h" #include "cygerrno.h" +#include "thread.h" +#include "perthread.h" char debugger_command[2 * MAX_PATH + 20]; diff --git a/winsup/cygwin/exec.cc b/winsup/cygwin/exec.cc index ee40d16..e6765e8 100644 --- a/winsup/cygwin/exec.cc +++ b/winsup/cygwin/exec.cc @@ -13,6 +13,8 @@ details. */ #include <stdlib.h> #include <errno.h> #include <process.h> +#include "fhandler.h" +#include "path.h" /* This is called _execve and not execve because the real execve is defined in libc/posix/execve.c. It calls us. */ diff --git a/winsup/cygwin/external.cc b/winsup/cygwin/external.cc index 0d08011..1ecbf14 100644 --- a/winsup/cygwin/external.cc +++ b/winsup/cygwin/external.cc @@ -11,6 +11,9 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for details. */ #include "winsup.h" +#include "fhandler.h" +#include "sync.h" +#include "sigproc.h" #include "pinfo.h" static external_pinfo * diff --git a/winsup/cygwin/fcntl.cc b/winsup/cygwin/fcntl.cc index da73911..f4d1b44 100644 --- a/winsup/cygwin/fcntl.cc +++ b/winsup/cygwin/fcntl.cc @@ -13,8 +13,10 @@ details. */ #include <stdarg.h> #include <errno.h> #include <unistd.h> +#include "fhandler.h" #include "dtable.h" #include "cygerrno.h" +#include "thread.h" extern "C" int diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index 4b62095..fb6065f 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -15,6 +15,8 @@ details. */ #include <stdlib.h> #include <string.h> #include "cygerrno.h" +#include "fhandler.h" +#include "path.h" static NO_COPY const int CHUNK_SIZE = 1024; /* Used for crlf conversions */ diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index 92e695b..38580d3 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -22,8 +22,11 @@ details. */ #include <wingdi.h> #include <winuser.h> #include <ctype.h> -#include "pinfo.h" #include "cygerrno.h" +#include "fhandler.h" +#include "sync.h" +#include "sigproc.h" +#include "pinfo.h" /* * Scroll the screen context. diff --git a/winsup/cygwin/fhandler_floppy.cc b/winsup/cygwin/fhandler_floppy.cc index 44a15d8..ec48c91 100644 --- a/winsup/cygwin/fhandler_floppy.cc +++ b/winsup/cygwin/fhandler_floppy.cc @@ -14,6 +14,7 @@ details. */ #include <fcntl.h> #include <errno.h> #include <unistd.h> +#include "fhandler.h" /**********************************************************************/ /* fhandler_dev_floppy */ diff --git a/winsup/cygwin/fhandler_random.cc b/winsup/cygwin/fhandler_random.cc index 2c364b2..99d12c4 100644 --- a/winsup/cygwin/fhandler_random.cc +++ b/winsup/cygwin/fhandler_random.cc @@ -14,6 +14,7 @@ details. */ #include <errno.h> #include <limits.h> #include "cygerrno.h" +#include "fhandler.h" #define RANDOM 8 #define URANDOM 9 diff --git a/winsup/cygwin/fhandler_raw.cc b/winsup/cygwin/fhandler_raw.cc index 7a2e97b..49c2d02 100644 --- a/winsup/cygwin/fhandler_raw.cc +++ b/winsup/cygwin/fhandler_raw.cc @@ -17,6 +17,8 @@ #include <cygwin/rdevio.h> #include <sys/mtio.h> #include "cygerrno.h" +#include "fhandler.h" +#include "path.h" /* static wrapper functions to hide the effect of media changes and bus resets which occurs after a new media is inserted. This is diff --git a/winsup/cygwin/fhandler_serial.cc b/winsup/cygwin/fhandler_serial.cc index 4511486..8ea4c9f 100644 --- a/winsup/cygwin/fhandler_serial.cc +++ b/winsup/cygwin/fhandler_serial.cc @@ -13,8 +13,11 @@ details. */ #include <errno.h> #include <unistd.h> #include <stdlib.h> -#include "pinfo.h" #include "cygerrno.h" +#include "fhandler.h" +#include "sync.h" +#include "sigproc.h" +#include "pinfo.h" /**********************************************************************/ /* fhandler_serial */ diff --git a/winsup/cygwin/fhandler_tape.cc b/winsup/cygwin/fhandler_tape.cc index 03dd485..43bbf0f 100644 --- a/winsup/cygwin/fhandler_tape.cc +++ b/winsup/cygwin/fhandler_tape.cc @@ -17,6 +17,8 @@ details. */ #include <sys/mtio.h> #include "cygerrno.h" +#include "fhandler.h" +#include "path.h" /**********************************************************************/ /* fhandler_dev_tape */ diff --git a/winsup/cygwin/fhandler_termios.cc b/winsup/cygwin/fhandler_termios.cc index e154e29..49430a0 100644 --- a/winsup/cygwin/fhandler_termios.cc +++ b/winsup/cygwin/fhandler_termios.cc @@ -14,8 +14,11 @@ details. */ #include <unistd.h> #include <errno.h> #include <ctype.h> -#include "pinfo.h" #include "cygerrno.h" +#include "fhandler.h" +#include "sync.h" +#include "sigproc.h" +#include "pinfo.h" /* Common functions shared by tty/console */ diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 1b0bb39..2e291ba 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -16,9 +16,12 @@ details. */ #include <errno.h> #include <ctype.h> #include <limits.h> +#include "cygerrno.h" +#include "fhandler.h" #include "dtable.h" +#include "sync.h" +#include "sigproc.h" #include "pinfo.h" -#include "cygerrno.h" /* Tty master stuff */ diff --git a/winsup/cygwin/fhandler_windows.cc b/winsup/cygwin/fhandler_windows.cc index 5b1e285..f937d81 100644 --- a/winsup/cygwin/fhandler_windows.cc +++ b/winsup/cygwin/fhandler_windows.cc @@ -16,6 +16,7 @@ details. */ #include <wingdi.h> #include <winuser.h> #include "cygerrno.h" +#include "fhandler.h" /* The following unix-style calls are supported: diff --git a/winsup/cygwin/fhandler_zero.cc b/winsup/cygwin/fhandler_zero.cc index 9b4212c..4c74abc 100644 --- a/winsup/cygwin/fhandler_zero.cc +++ b/winsup/cygwin/fhandler_zero.cc @@ -12,6 +12,7 @@ details. */ #include "winsup.h" #include <errno.h> +#include "fhandler.h" fhandler_dev_zero::fhandler_dev_zero (const char *name) : fhandler_base (FH_ZERO, name) diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index d9bc5d9..f93d3a8 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -16,9 +16,13 @@ details. */ #include <stdarg.h> #include <errno.h> #include "dll_init.h" +#include "fhandler.h" #include "dtable.h" -#include "pinfo.h" #include "cygerrno.h" +#include "sync.h" +#include "sigproc.h" +#include "pinfo.h" +#include "perthread.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 8e1171a..85d9aa8 100644 --- a/winsup/cygwin/grp.cc +++ b/winsup/cygwin/grp.cc @@ -15,6 +15,9 @@ details. */ #include <grp.h> #include <stdio.h> #include <stdlib.h> +#include "thread.h" +#include "sync.h" +#include "sigproc.h" #include "pinfo.h" /* Read /etc/group only once for better performance. This is done diff --git a/winsup/cygwin/heap.cc b/winsup/cygwin/heap.cc index fdc4367..6c05a5d 100644 --- a/winsup/cygwin/heap.cc +++ b/winsup/cygwin/heap.cc @@ -10,8 +10,10 @@ details. */ #include "winsup.h" #include <errno.h> -#include "pinfo.h" #include "cygerrno.h" +#include "sync.h" +#include "sigproc.h" +#include "pinfo.h" #define brksize ((char *) user_data->heaptop - (char *) user_data->heapbase) #define brk (user_data->heapptr) diff --git a/winsup/cygwin/init.cc b/winsup/cygwin/init.cc index 5b6e2aa..ddf4822 100644 --- a/winsup/cygwin/init.cc +++ b/winsup/cygwin/init.cc @@ -10,6 +10,7 @@ details. */ #include "winsup.h" #include <stdlib.h> +#include "thread.h" extern HMODULE cygwin_hmodule; diff --git a/winsup/cygwin/ioctl.cc b/winsup/cygwin/ioctl.cc index 860ad6e..5e198b8 100644 --- a/winsup/cygwin/ioctl.cc +++ b/winsup/cygwin/ioctl.cc @@ -14,11 +14,11 @@ details. */ #include "winsup.h" #include <sys/ioctl.h> #include <errno.h> -#include "dtable.h" #include "cygerrno.h" +#include "fhandler.h" +#include "dtable.h" -extern "C" -int +extern "C" int ioctl (int fd, int cmd, void *buf) { if (fdtab.not_open (fd)) diff --git a/winsup/cygwin/malloc_wrapper.cc b/winsup/cygwin/malloc_wrapper.cc index 22aa207..7e17fd9 100644 --- a/winsup/cygwin/malloc_wrapper.cc +++ b/winsup/cygwin/malloc_wrapper.cc @@ -13,6 +13,7 @@ details. */ #include "winsup.h" #include <stdlib.h> +#include "sync.h" /* we provide these stubs to call into a user's provided malloc if there is one - otherwise diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc index 9afcd8c..bc2764c 100644 --- a/winsup/cygwin/mmap.cc +++ b/winsup/cygwin/mmap.cc @@ -13,9 +13,13 @@ details. */ #include <stddef.h> #include <sys/mman.h> #include <errno.h> +#include "fhandler.h" #include "dtable.h" -#include "pinfo.h" #include "cygerrno.h" +#include "thread.h" +#include "sync.h" +#include "sigproc.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 e8217b3..bcd8f8f 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -23,9 +23,14 @@ details. */ #include <fcntl.h> #include "autoload.h" #include <winsock.h> +#include "cygerrno.h" +#include "fhandler.h" +#include "path.h" #include "dtable.h" +#include "thread.h" +#include "sync.h" +#include "sigproc.h" #include "pinfo.h" -#include "cygerrno.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 8dfa330..a4ceda5 100644 --- a/winsup/cygwin/passwd.cc +++ b/winsup/cygwin/passwd.cc @@ -13,9 +13,13 @@ details. */ #include <pwd.h> #include <stdio.h> #include <errno.h> +#include "cygerrno.h" +#include "fhandler.h" #include "dtable.h" +#include "thread.h" +#include "sync.h" +#include "sigproc.h" #include "pinfo.h" -#include "cygerrno.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 94da125..8fd0424 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -81,8 +81,13 @@ details. */ #include <errno.h> #include <ctype.h> #include <winioctl.h> -#include "pinfo.h" #include "cygerrno.h" +#include "fhandler.h" +#include "path.h" +#include "thread.h" +#include "sync.h" +#include "sigproc.h" +#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/path.h b/winsup/cygwin/path.h index a2b647b..a436702 100644 --- a/winsup/cygwin/path.h +++ b/winsup/cygwin/path.h @@ -108,6 +108,9 @@ int __stdcall get_device_number (const char *name, int &unit, BOOL from_conv = F int __stdcall slash_unc_prefix_p (const char *path); int __stdcall check_null_empty_path (const char *name); +const char * __stdcall find_exec (const char *name, path_conv& buf, const char *winenv = "PATH=", + int null_if_notfound = 0, const char **known_suffix = NULL); + /* Common macros for checking for invalid path names */ #define check_null_empty_path_errno(src) \ diff --git a/winsup/cygwin/perthread.h b/winsup/cygwin/perthread.h index fa6e1df..7d009e1 100644 --- a/winsup/cygwin/perthread.h +++ b/winsup/cygwin/perthread.h @@ -35,3 +35,79 @@ set_reent (struct _reent *r) *base = PTMAGIC; base[-1] = (DWORD) r; } + +#define PER_THREAD_FORK_CLEAR ((void *)0xffffffff) +class per_thread +{ + DWORD tls; + int clear_on_fork_p; +public: + per_thread (int forkval = 1) {tls = TlsAlloc (); clear_on_fork_p = forkval;} + DWORD get_tls () {return tls;} + int clear_on_fork () {return clear_on_fork_p;} + + virtual void *get () {return TlsGetValue (get_tls ());} + virtual size_t size () {return 0;} + virtual void set (void *s = NULL); + virtual void set (int n) {TlsSetValue (get_tls (), (void *)n);} + virtual void *create () + { + void *s = new char [size ()]; + memset (s, 0, size ()); + set (s); + return s; + } +}; + +class per_thread_waitq : public per_thread +{ +public: + per_thread_waitq () : per_thread (0) {} + void *get () {return (waitq *) this->per_thread::get ();} + void *create () {return (waitq *) this->per_thread::create ();} + size_t size () {return sizeof (waitq);} +}; + +struct vfork_save +{ + int pid; + jmp_buf j; + DWORD frame[100]; + char **vfork_ebp; + char **vfork_esp; + int is_active () { return pid < 0; } +}; + +class per_thread_vfork : public per_thread +{ +public: + vfork_save *val () { return (vfork_save *) this->per_thread::get (); } + vfork_save *create () {return (vfork_save *) this->per_thread::create ();} + size_t size () {return sizeof (vfork_save);} +}; + +extern "C" { +struct signal_dispatch +{ + int arg; + void (*func) (int); + int sig; + int saved_errno; + DWORD oldmask; + DWORD retaddr; + DWORD *retaddr_on_stack; +}; +}; + +struct per_thread_signal_dispatch : public per_thread +{ + signal_dispatch *get () { return (signal_dispatch *) this->per_thread::get (); } + signal_dispatch *create () {return (signal_dispatch *) this->per_thread::create ();} + size_t size () {return sizeof (signal_dispatch);} +}; + +extern per_thread_waitq waitq_storage; +extern per_thread_vfork vfork_storage; +extern per_thread_signal_dispatch signal_dispatch_storage; + +extern per_thread *threadstuff[]; diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index 8316bd2..347015b 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -13,9 +13,13 @@ details. */ #include <time.h> #include <errno.h> #include <limits.h> +#include "fhandler.h" #include "dtable.h" -#include "pinfo.h" #include "cygerrno.h" +#include "thread.h" +#include "sync.h" +#include "sigproc.h" +#include "pinfo.h" static char NO_COPY pinfo_dummy[sizeof(pinfo)] = {0}; diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h index 87d4f3d..b8ee914 100644 --- a/winsup/cygwin/pinfo.h +++ b/winsup/cygwin/pinfo.h @@ -11,6 +11,9 @@ enum }; #define PSIZE 1024 + +class ThreadItem; + class _pinfo { public: @@ -166,3 +169,4 @@ cygwin_pid (pid_t pid) return (pid_t) (os_being_run == winNT) ? pid : -(int) pid; } void __stdcall pinfo_init (PBYTE); +extern pinfo myself; diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc index 091548a..fb354a4 100644 --- a/winsup/cygwin/pipe.cc +++ b/winsup/cygwin/pipe.cc @@ -12,8 +12,10 @@ details. */ #include <unistd.h> #include <sys/fcntl.h> #include <errno.h> -#include "dtable.h" #include "cygerrno.h" +#include "fhandler.h" +#include "dtable.h" +#include "thread.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 0ecf152..fc51be1 100644 --- a/winsup/cygwin/poll.cc +++ b/winsup/cygwin/poll.cc @@ -11,6 +11,7 @@ #include "winsup.h" #include <sys/poll.h> #include <errno.h> +#include "fhandler.h" #include "dtable.h" #include "cygerrno.h" diff --git a/winsup/cygwin/pthread.cc b/winsup/cygwin/pthread.cc index f535318..2a2287b 100644 --- a/winsup/cygwin/pthread.cc +++ b/winsup/cygwin/pthread.cc @@ -11,6 +11,7 @@ details. */ #include "winsup.h" +#include "thread.h" extern "C" { /* ThreadCreation */ diff --git a/winsup/cygwin/resource.cc b/winsup/cygwin/resource.cc index 5a3241f..9ca1917 100644 --- a/winsup/cygwin/resource.cc +++ b/winsup/cygwin/resource.cc @@ -14,8 +14,10 @@ details. */ #include "winsup.h" #include <errno.h> -#include "pinfo.h" #include "cygerrno.h" +#include "sync.h" +#include "sigproc.h" +#include "pinfo.h" /* add timeval values */ static void diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc index 6766007..a8d5780 100644 --- a/winsup/cygwin/security.cc +++ b/winsup/cygwin/security.cc @@ -22,9 +22,13 @@ details. */ #include <sys/stat.h> #include <sys/acl.h> #include <ctype.h> +#include "cygerrno.h" +#include "fhandler.h" +#include "path.h" #include "dtable.h" +#include "sync.h" +#include "sigproc.h" #include "pinfo.h" -#include "cygerrno.h" extern BOOL allow_ntea; BOOL allow_ntsec = FALSE; @@ -51,11 +55,11 @@ convert_sid_to_string_sid (PSID psid, char *sid_str) if (!psid || !sid_str) return NULL; strcpy (sid_str, "S-1-"); - sprintf(t, "%u", GetSidIdentifierAuthority (psid)->Value[5]); + __small_sprintf(t, "%u", GetSidIdentifierAuthority (psid)->Value[5]); strcat (sid_str, t); for (i = 0; i < *GetSidSubAuthorityCount (psid); ++i) { - sprintf(t, "-%lu", *GetSidSubAuthority (psid, i)); + __small_sprintf(t, "-%lu", *GetSidSubAuthority (psid, i)); strcat (sid_str, t); } return sid_str; @@ -2005,27 +2009,27 @@ acltotext (aclent_t *aclbufp, int aclcnt) switch (aclbufp[pos].a_type) { case USER_OBJ: - sprintf (buf + strlen (buf), "user::%s", + __small_sprintf (buf + strlen (buf), "user::%s", permtostr (aclbufp[pos].a_perm)); break; case USER: - sprintf (buf + strlen (buf), "user:%d:%s", + __small_sprintf (buf + strlen (buf), "user:%d:%s", aclbufp[pos].a_id, permtostr (aclbufp[pos].a_perm)); break; case GROUP_OBJ: - sprintf (buf + strlen (buf), "group::%s", + __small_sprintf (buf + strlen (buf), "group::%s", permtostr (aclbufp[pos].a_perm)); break; case GROUP: - sprintf (buf + strlen (buf), "group:%d:%s", + __small_sprintf (buf + strlen (buf), "group:%d:%s", aclbufp[pos].a_id, permtostr (aclbufp[pos].a_perm)); break; case CLASS_OBJ: - sprintf (buf + strlen (buf), "mask::%s", + __small_sprintf (buf + strlen (buf), "mask::%s", permtostr (aclbufp[pos].a_perm)); break; case OTHER_OBJ: - sprintf (buf + strlen (buf), "other::%s", + __small_sprintf (buf + strlen (buf), "other::%s", permtostr (aclbufp[pos].a_perm)); break; default: diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc index 5f427d4..99c321b 100644 --- a/winsup/cygwin/select.cc +++ b/winsup/cygwin/select.cc @@ -33,8 +33,12 @@ details. */ #include <stdio.h> #include <winsock.h> #include "select.h" -#include "dtable.h" #include "cygerrno.h" +#include "fhandler.h" +#include "dtable.h" +#include "sync.h" +#include "sigproc.h" +#include "perthread.h" /* * All these defines below should be in sys/types.h diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc index e44c725..2010d18 100644 --- a/winsup/cygwin/shared.cc +++ b/winsup/cygwin/shared.cc @@ -14,6 +14,8 @@ details. */ #include <stdlib.h> #include <grp.h> #include <pwd.h> +#include "sync.h" +#include "sigproc.h" #include "pinfo.h" #define SHAREDVER (unsigned)(cygwin_version.api_major << 16 | \ diff --git a/winsup/cygwin/shared.h b/winsup/cygwin/shared.h index 851bad4..2a8e9a6 100644 --- a/winsup/cygwin/shared.h +++ b/winsup/cygwin/shared.h @@ -86,9 +86,6 @@ void __stdcall init_child_info (DWORD, child_info *, int, HANDLE); extern child_info_fork *child_proc_info; -/* Process info for this process */ -extern pinfo myself; - /* non-NULL if this process is a child of a cygwin process */ extern HANDLE parent_alive; diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc index 94cd2cf..2927712 100644 --- a/winsup/cygwin/signal.cc +++ b/winsup/cygwin/signal.cc @@ -13,8 +13,10 @@ details. */ #include "winsup.h" #include <errno.h> -#include "pinfo.h" #include "cygerrno.h" +#include "sync.h" +#include "sigproc.h" +#include "pinfo.h" extern "C" _sig_func_ptr diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index a1d9ad3..45b6d20 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -16,8 +16,11 @@ details. */ #include <sys/wait.h> #include <errno.h> #include <stdlib.h> -#include "pinfo.h" #include "cygerrno.h" +#include "sync.h" +#include "sigproc.h" +#include "pinfo.h" +#include "perthread.h" extern BOOL allow_ntsec; diff --git a/winsup/cygwin/sigproc.h b/winsup/cygwin/sigproc.h index 683e1d9..9e1c3fb 100644 --- a/winsup/cygwin/sigproc.h +++ b/winsup/cygwin/sigproc.h @@ -32,8 +32,6 @@ typedef struct struct_waitq HANDLE thread_ev; } waitq; -class muto; - struct sigthread { DWORD id; diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index 4095727..940f8d1 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -20,9 +20,14 @@ details. */ #include <winuser.h> #include <ctype.h> #include <paths.h> +#include "cygerrno.h" +#include "fhandler.h" +#include "path.h" #include "dtable.h" +#include "sync.h" +#include "sigproc.h" #include "pinfo.h" -#include "cygerrno.h" +#include "perthread.h" extern BOOL allow_ntsec; diff --git a/winsup/cygwin/strace.cc b/winsup/cygwin/strace.cc index 457cd22..5cba5d0 100644 --- a/winsup/cygwin/strace.cc +++ b/winsup/cygwin/strace.cc @@ -14,6 +14,8 @@ details. */ #include <wingdi.h> #include <winuser.h> #include <ctype.h> +#include "sync.h" +#include "sigproc.h" #include "pinfo.h" #define PROTECT(x) x[sizeof(x)-1] = 0 diff --git a/winsup/cygwin/sync.cc b/winsup/cygwin/sync.cc index 70f7985..f5c2159 100644 --- a/winsup/cygwin/sync.cc +++ b/winsup/cygwin/sync.cc @@ -20,6 +20,7 @@ details. */ #include <sys/wait.h> #include <errno.h> #include <stdlib.h> +#include "sync.h" muto NO_COPY muto_start; diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 114b768..92a53a4 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -24,9 +24,14 @@ details. */ #include <unistd.h> #include <winnls.h> #include <lmcons.h> /* for UNLEN */ +#include "cygerrno.h" +#include "fhandler.h" +#include "path.h" #include "dtable.h" +#include "thread.h" +#include "sync.h" +#include "sigproc.h" #include "pinfo.h" -#include "cygerrno.h" extern BOOL allow_ntsec; diff --git a/winsup/cygwin/sysconf.cc b/winsup/cygwin/sysconf.cc index 25f8370..a6383dc 100644 --- a/winsup/cygwin/sysconf.cc +++ b/winsup/cygwin/sysconf.cc @@ -13,6 +13,7 @@ details. */ #include <errno.h> #include <time.h> #include <limits.h> +#include "fhandler.h" #include "dtable.h" #include "cygerrno.h" diff --git a/winsup/cygwin/syslog.cc b/winsup/cygwin/syslog.cc index 3a79269..48b0d66 100644 --- a/winsup/cygwin/syslog.cc +++ b/winsup/cygwin/syslog.cc @@ -14,8 +14,10 @@ details. */ #include <syslog.h> #include <stdarg.h> #include <unistd.h> +#include "fhandler.h" #include "dtable.h" #include "cygerrno.h" +#include "thread.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 5eb5ddb..e30bb60 100644 --- a/winsup/cygwin/termios.cc +++ b/winsup/cygwin/termios.cc @@ -13,8 +13,9 @@ details. */ #include "winsup.h" #include <errno.h> -#include "dtable.h" #include "cygerrno.h" +#include "fhandler.h" +#include "dtable.h" /* tcsendbreak: POSIX 7.2.2.1 */ extern "C" diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc index 6f40a68..da3b0da 100644 --- a/winsup/cygwin/thread.cc +++ b/winsup/cygwin/thread.cc @@ -20,6 +20,9 @@ details. */ #include <assert.h> #include <stdlib.h> #include <syslog.h> +#include "thread.h" +#include "sync.h" +#include "sigproc.h" #include "pinfo.h" extern int threadsafe; diff --git a/winsup/cygwin/thread.h b/winsup/cygwin/thread.h index e16d3ce..aed02dc 100644 --- a/winsup/cygwin/thread.h +++ b/winsup/cygwin/thread.h @@ -43,9 +43,8 @@ extern "C" #include <pthread.h> #include <pwd.h> #include <grp.h> -#include <stdio.h> +#define _NOMNTENT_FUNCS #include <mntent.h> -#include <time.h> extern "C" { diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc index bd7286d..b34d510 100644 --- a/winsup/cygwin/times.cc +++ b/winsup/cygwin/times.cc @@ -16,8 +16,13 @@ details. */ #include <stdio.h> #include <stdlib.h> #include <errno.h> -#include "pinfo.h" #include "cygerrno.h" +#include "fhandler.h" +#include "path.h" +#include "thread.h" +#include "sync.h" +#include "sigproc.h" +#include "pinfo.h" #define FACTOR (0x19db1ded53ea710LL) #define NSPERSEC 10000000LL diff --git a/winsup/cygwin/tty.cc b/winsup/cygwin/tty.cc index 015cce6..16fe39a 100644 --- a/winsup/cygwin/tty.cc +++ b/winsup/cygwin/tty.cc @@ -14,9 +14,12 @@ details. */ #include <utmp.h> #include <wingdi.h> #include <winuser.h> +#include "cygerrno.h" +#include "fhandler.h" #include "dtable.h" +#include "sync.h" +#include "sigproc.h" #include "pinfo.h" -#include "cygerrno.h" extern fhandler_tty_master *tty_master; diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc index a9cb227..fc3f8bf 100644 --- a/winsup/cygwin/uinfo.cc +++ b/winsup/cygwin/uinfo.cc @@ -18,6 +18,9 @@ details. */ #include <stdlib.h> #include <wchar.h> #include <lm.h> +#include "thread.h" +#include "sync.h" +#include "sigproc.h" #include "pinfo.h" char * diff --git a/winsup/cygwin/wait.cc b/winsup/cygwin/wait.cc index 62d4112..4ad5afd 100644 --- a/winsup/cygwin/wait.cc +++ b/winsup/cygwin/wait.cc @@ -13,6 +13,9 @@ details. */ #include <stdlib.h> #include <errno.h> #include "cygerrno.h" +#include "sync.h" +#include "sigproc.h" +#include "perthread.h" /* This is called _wait and not wait because the real wait is defined in libc/syscalls/syswait.c. It calls us. */ diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h index db30441..be151e7 100644 --- a/winsup/cygwin/winsup.h +++ b/winsup/cygwin/winsup.h @@ -107,17 +107,12 @@ extern int dynamically_loaded; #define __CONDSETF(n, what, x, prefix) \ ((n) ? __SETF (what, x, prefix) : __CLEARF (what, x, prefix)) -#include "thread.h" #include "shared.h" extern HANDLE hMainThread; extern HANDLE hMainProc; #include "debug.h" -#include "sync.h" -#include "sigproc.h" -#include "fhandler.h" -#include "path.h" #include <sys/cygwin.h> /********************** Application Interface **************************/ @@ -155,84 +150,6 @@ extern host_dependent_constants host_dependent; /* Events/mutexes */ extern HANDLE title_mutex; -/*************************** Per Thread ******************************/ - -#define PER_THREAD_FORK_CLEAR ((void *)0xffffffff) -class per_thread -{ - DWORD tls; - int clear_on_fork_p; -public: - per_thread (int forkval = 1) {tls = TlsAlloc (); clear_on_fork_p = forkval;} - DWORD get_tls () {return tls;} - int clear_on_fork () {return clear_on_fork_p;} - - virtual void *get () {return TlsGetValue (get_tls ());} - virtual size_t size () {return 0;} - virtual void set (void *s = NULL); - virtual void set (int n) {TlsSetValue (get_tls (), (void *)n);} - virtual void *create () - { - void *s = new char [size ()]; - memset (s, 0, size ()); - set (s); - return s; - } -}; - -class per_thread_waitq : public per_thread -{ -public: - per_thread_waitq () : per_thread (0) {} - void *get () {return (waitq *) this->per_thread::get ();} - void *create () {return (waitq *) this->per_thread::create ();} - size_t size () {return sizeof (waitq);} -}; - -struct vfork_save -{ - int pid; - jmp_buf j; - DWORD frame[100]; - char **vfork_ebp; - char **vfork_esp; - int is_active () { return pid < 0; } -}; - -class per_thread_vfork : public per_thread -{ -public: - vfork_save *val () { return (vfork_save *) this->per_thread::get (); } - vfork_save *create () {return (vfork_save *) this->per_thread::create ();} - size_t size () {return sizeof (vfork_save);} -}; - -extern "C" { -struct signal_dispatch -{ - int arg; - void (*func) (int); - int sig; - int saved_errno; - DWORD oldmask; - DWORD retaddr; - DWORD *retaddr_on_stack; -}; -}; - -struct per_thread_signal_dispatch : public per_thread -{ - signal_dispatch *get () { return (signal_dispatch *) this->per_thread::get (); } - signal_dispatch *create () {return (signal_dispatch *) this->per_thread::create ();} - size_t size () {return sizeof (signal_dispatch);} -}; - -extern per_thread_waitq waitq_storage; -extern per_thread_vfork vfork_storage; -extern per_thread_signal_dispatch signal_dispatch_storage; - -extern per_thread *threadstuff[]; - /**************************** Convenience ******************************/ #define NO_COPY __attribute__((section(".data_cygwin_nocopy"))) @@ -316,9 +233,6 @@ extern int cygwin_finished_initializing; /**************************** Miscellaneous ******************************/ -const char * __stdcall find_exec (const char *name, path_conv& buf, const char *winenv = "PATH=", - int null_if_notfound = 0, const char **known_suffix = NULL); - /* File manipulation */ int __stdcall set_process_privileges (); int __stdcall get_file_attribute (int, const char *, int *, @@ -349,6 +263,7 @@ extern "C" int _spawnve (HANDLE hToken, int mode, const char *path, extern void __stdcall exec_fixup_after_fork (); +class _pinfo; /* For mmaps across fork(). */ int __stdcall recreate_mmaps_after_fork (void *); void __stdcall set_child_mmap_ptr (_pinfo *); |