Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2000-09-08 06:56:55 +0400
committerChristopher Faylor <me@cgf.cx>2000-09-08 06:56:55 +0400
commitf0338f545d769143f542338b4d61f771b5a87f93 (patch)
treeb9d5b53c28100c35e10c0232c0e54ce474d6cc7c
parent42b6d9648fdd3f78806ac0556338f8fb13707821 (diff)
Break out more header info into separate files. Use appropriate header files
throughout. * shared.h: Remove. * cygwin_version.h: New file. * delqueue.h: New file. * environ.h: New file. * host_dependent.h: New file. * perprocess.h: New file. * registry.h: New file. * security.h: New file.
-rw-r--r--winsup/cygwin/ChangeLog13
-rw-r--r--winsup/cygwin/assert.cc1
-rw-r--r--winsup/cygwin/child_info.h2
-rw-r--r--winsup/cygwin/cygwin_version.h31
-rw-r--r--winsup/cygwin/dcrt0.cc10
-rw-r--r--winsup/cygwin/debug.cc2
-rw-r--r--winsup/cygwin/delqueue.cc1
-rw-r--r--winsup/cygwin/delqueue.h30
-rw-r--r--winsup/cygwin/dir.cc1
-rw-r--r--winsup/cygwin/dlfcn.cc5
-rw-r--r--winsup/cygwin/dll_init.cc4
-rw-r--r--winsup/cygwin/dtable.cc1
-rw-r--r--winsup/cygwin/dtable.h6
-rw-r--r--winsup/cygwin/environ.cc4
-rw-r--r--winsup/cygwin/environ.h40
-rw-r--r--winsup/cygwin/exceptions.cc3
-rw-r--r--winsup/cygwin/exec.cc4
-rw-r--r--winsup/cygwin/external.cc3
-rw-r--r--winsup/cygwin/fhandler.cc6
-rw-r--r--winsup/cygwin/fhandler.h1
-rw-r--r--winsup/cygwin/fhandler_console.cc3
-rw-r--r--winsup/cygwin/fhandler_serial.cc1
-rw-r--r--winsup/cygwin/fhandler_tty.cc1
-rw-r--r--winsup/cygwin/fork.cc5
-rw-r--r--winsup/cygwin/heap.cc1
-rw-r--r--winsup/cygwin/heap.h2
-rw-r--r--winsup/cygwin/host_dependent.h30
-rw-r--r--winsup/cygwin/init.cc1
-rw-r--r--winsup/cygwin/malloc_wrapper.cc1
-rwxr-xr-xwinsup/cygwin/mkvers.sh2
-rw-r--r--winsup/cygwin/mmap.cc1
-rw-r--r--winsup/cygwin/net.cc3
-rw-r--r--winsup/cygwin/ntea.cc3
-rw-r--r--winsup/cygwin/path.cc5
-rw-r--r--winsup/cygwin/path.h2
-rw-r--r--winsup/cygwin/perprocess.h20
-rw-r--r--winsup/cygwin/perthread.h4
-rw-r--r--winsup/cygwin/pinfo.cc4
-rw-r--r--winsup/cygwin/pinfo.h24
-rw-r--r--winsup/cygwin/pipe.cc1
-rw-r--r--winsup/cygwin/poll.cc1
-rw-r--r--winsup/cygwin/registry.cc4
-rw-r--r--winsup/cygwin/registry.h43
-rw-r--r--winsup/cygwin/security.cc1
-rw-r--r--winsup/cygwin/security.h40
-rw-r--r--winsup/cygwin/shared.cc4
-rw-r--r--winsup/cygwin/shared.h109
-rw-r--r--winsup/cygwin/shared_info.h30
-rw-r--r--winsup/cygwin/signal.cc1
-rw-r--r--winsup/cygwin/sigproc.cc3
-rw-r--r--winsup/cygwin/sigproc.h5
-rw-r--r--winsup/cygwin/spawn.cc5
-rw-r--r--winsup/cygwin/strace.cc5
-rw-r--r--winsup/cygwin/sync.cc1
-rw-r--r--winsup/cygwin/syscalls.cc5
-rw-r--r--winsup/cygwin/termios.cc3
-rw-r--r--winsup/cygwin/thread.cc2
-rw-r--r--winsup/cygwin/times.cc1
-rw-r--r--winsup/cygwin/tty.cc3
-rw-r--r--winsup/cygwin/uinfo.cc2
-rw-r--r--winsup/cygwin/uname.cc1
-rw-r--r--winsup/cygwin/window.cc3
-rw-r--r--winsup/cygwin/winsup.h142
63 files changed, 422 insertions, 274 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index dacf7aae6..9154876dd 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,16 @@
+Thu Sep 7 22:45:16 2000 Christopher Faylor <cgf@cygnus.com>
+
+ Break out more header info into separate files. Use appropriate
+ header files throughout.
+ * shared.h: Remove.
+ * cygwin_version.h: New file.
+ * delqueue.h: New file.
+ * environ.h: New file.
+ * host_dependent.h: New file.
+ * perprocess.h: New file.
+ * registry.h: New file.
+ * security.h: New file.
+
Thu Sep 7 12:14:43 2000 Christopher Faylor <cgf@cygnus.com>
Split out tty and shared_info stuff into their own headers and use
diff --git a/winsup/cygwin/assert.cc b/winsup/cygwin/assert.cc
index 5e1c0b88b..68a5934ee 100644
--- a/winsup/cygwin/assert.cc
+++ b/winsup/cygwin/assert.cc
@@ -9,6 +9,7 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include "winsup.h"
+#include "security.h"
#include <wingdi.h>
#include <winuser.h>
diff --git a/winsup/cygwin/child_info.h b/winsup/cygwin/child_info.h
index 29e44af02..8e76ca399 100644
--- a/winsup/cygwin/child_info.h
+++ b/winsup/cygwin/child_info.h
@@ -8,6 +8,8 @@ This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
+#include <setjmp.h>
+
enum
{
PROC_MAGIC = 0xaf08f000,
diff --git a/winsup/cygwin/cygwin_version.h b/winsup/cygwin/cygwin_version.h
new file mode 100644
index 000000000..e6d775842
--- /dev/null
+++ b/winsup/cygwin/cygwin_version.h
@@ -0,0 +1,31 @@
+/* cygwin_version.h: shared info for cygwin
+
+ Copyright 2000 Cygnus Solutions.
+
+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. */
+
+#include <cygwin/version.h>
+
+extern "C" {
+/* This is for programs that want to access the shared data. */
+class shared_info *cygwin_getshared (void);
+
+struct cygwin_version_info
+{
+ unsigned short api_major;
+ unsigned short api_minor;
+ unsigned short dll_major;
+ unsigned short dll_minor;
+ unsigned short shared_data;
+ unsigned short mount_registry;
+ const char *dll_build_date;
+ char shared_id[sizeof (CYGWIN_VERSION_DLL_IDENTIFIER) + 64];
+};
+
+extern cygwin_version_info cygwin_version;
+extern const char *cygwin_version_strings;
+}
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 4121d89f9..cc48d7389 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -13,23 +13,27 @@ details. */
#include <stdlib.h>
#include "glob.h"
#include "exceptions.h"
-#include "dll_init.h"
#include "autoload.h"
#include <ctype.h>
#include "sync.h"
#include "sigproc.h"
-#include "perthread.h"
#include "pinfo.h"
#include "cygheap.h"
#include "heap.h"
#include "cygerrno.h"
#include "fhandler.h"
#include "child_info.h"
+#define NEED_VFORK
+#include "perthread.h"
#include "path.h"
#include "dtable.h"
#include "thread.h"
-#include "tty.h"
#include "shared_info.h"
+#include "cygwin_version.h"
+#include "perprocess.h"
+#include "dll_init.h"
+#include "host_dependent.h"
+#include "security.h"
#define MAX_AT_FILE_LEVEL 10
diff --git a/winsup/cygwin/debug.cc b/winsup/cygwin/debug.cc
index e635c6918..f89b21a5f 100644
--- a/winsup/cygwin/debug.cc
+++ b/winsup/cygwin/debug.cc
@@ -12,6 +12,8 @@ details. */
#include "sigproc.h"
#include "pinfo.h"
#include "perthread.h"
+#include "perprocess.h"
+#include "security.h"
#undef CloseHandle
diff --git a/winsup/cygwin/delqueue.cc b/winsup/cygwin/delqueue.cc
index a08b24aef..3073d02cb 100644
--- a/winsup/cygwin/delqueue.cc
+++ b/winsup/cygwin/delqueue.cc
@@ -9,6 +9,7 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include "winsup.h"
+#include "shared_info.h"
/* FIXME: this delqueue module is very flawed and should be rewritten.
First, having an array of a fixed size for keeping track of the
diff --git a/winsup/cygwin/delqueue.h b/winsup/cygwin/delqueue.h
new file mode 100644
index 000000000..f306e7f74
--- /dev/null
+++ b/winsup/cygwin/delqueue.h
@@ -0,0 +1,30 @@
+/* delqueue.h: shared info for cygwin
+
+ Copyright 2000 Cygnus Solutions.
+
+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. */
+
+/* First pass at a file deletion queue structure.
+
+ We can't keep this list in the per-process info, since
+ one process may open a file, and outlive a process which
+ wanted to unlink the file - and the data would go away.
+*/
+
+#define MAX_DELQUEUES_PENDING 100
+
+class delqueue_list
+{
+ char name[MAX_DELQUEUES_PENDING][MAX_PATH];
+ char inuse[MAX_DELQUEUES_PENDING];
+ int empty;
+
+public:
+ void init ();
+ void queue_file (const char *dosname);
+ void process_queue ();
+};
diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc
index 350fbce8d..d73eeac9f 100644
--- a/winsup/cygwin/dir.cc
+++ b/winsup/cygwin/dir.cc
@@ -23,6 +23,7 @@ details. */
#include "cygerrno.h"
#include "fhandler.h"
#include "path.h"
+#include "security.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 4484154ee..a85351323 100644
--- a/winsup/cygwin/dlfcn.cc
+++ b/winsup/cygwin/dlfcn.cc
@@ -13,11 +13,12 @@ details. */
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
-#include "dlfcn.h"
-#include "dll_init.h"
#include "fhandler.h"
#include "path.h"
#include "thread.h"
+#include "perprocess.h"
+#include "dlfcn.h"
+#include "dll_init.h"
#define _dl_error _reent_winsup()->_dl_error
#define _dl_buffer _reent_winsup()->_dl_buffer
diff --git a/winsup/cygwin/dll_init.cc b/winsup/cygwin/dll_init.cc
index 7e94fa9f6..6a713faff 100644
--- a/winsup/cygwin/dll_init.cc
+++ b/winsup/cygwin/dll_init.cc
@@ -9,8 +9,10 @@ details. */
#include "winsup.h"
#include <stdlib.h>
#include "exceptions.h"
-#include "dll_init.h"
#include "cygerrno.h"
+#include "perprocess.h"
+#include "dll_init.h"
+#include "environ.h"
extern void __stdcall check_sanity_and_sync (per_process *);
diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc
index affac33d5..9e7b3c5d5 100644
--- a/winsup/cygwin/dtable.cc
+++ b/winsup/cygwin/dtable.cc
@@ -18,6 +18,7 @@ details. */
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
+#include <sys/cygwin.h>
#include <winsock.h>
#include "sync.h"
diff --git a/winsup/cygwin/dtable.h b/winsup/cygwin/dtable.h
index db57c6b8c..85963fc2d 100644
--- a/winsup/cygwin/dtable.h
+++ b/winsup/cygwin/dtable.h
@@ -8,6 +8,9 @@ This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
+/* Initial and increment values for cygwin's fd table */
+#define NOFILE_INCR 32
+
class dtable
{
fhandler_base **fds;
@@ -41,3 +44,6 @@ public:
void dtable_init (void);
void stdio_init (void);
extern dtable fdtab;
+
+extern "C" int getfdtabsize ();
+extern "C" void setfdtabsize (int);
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index 2cc8080f7..9c7b72ce0 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -13,6 +13,8 @@ details. */
#include <stddef.h>
#include <ctype.h>
#include <fcntl.h>
+#include <sys/cygwin.h>
+#include <cygwin/version.h>
#include "sync.h"
#include "sigproc.h"
#include "pinfo.h"
@@ -20,6 +22,8 @@ details. */
#include "path.h"
#include "cygerrno.h"
#include "cygheap.h"
+#include "registry.h"
+#include "environ.h"
extern BOOL allow_glob;
extern BOOL allow_ntea;
diff --git a/winsup/cygwin/environ.h b/winsup/cygwin/environ.h
new file mode 100644
index 000000000..e5967eb20
--- /dev/null
+++ b/winsup/cygwin/environ.h
@@ -0,0 +1,40 @@
+/* environ.h: Declarations for environ manipulation
+
+ 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. */
+
+/* Initialize the environment */
+void environ_init (char **);
+
+/* The structure below is used to control conversion to/from posix-style
+ * file specs. Currently, only PATH and HOME are converted, but PATH
+ * needs to use a "convert path list" function while HOME needs a simple
+ * "convert to posix/win32". For the simple case, where a calculated length
+ * is required, just return MAX_PATH. *FIXME*
+ */
+struct win_env
+ {
+ const char *name;
+ size_t namelen;
+ char *posix;
+ char *native;
+ int (*toposix) (const char *, char *);
+ int (*towin32) (const char *, char *);
+ int (*posix_len) (const char *);
+ int (*win32_len) (const char *);
+ void add_cache (const char *in_posix, const char *in_native = NULL);
+ const char * get_native () {return native ? native + namelen : NULL;}
+ };
+
+win_env * __stdcall getwinenv (const char *name, const char *posix = NULL);
+
+void __stdcall update_envptrs ();
+char * __stdcall winenv (const char * const *, int);
+extern char **__cygwin_environ, ***main_environ;
+extern "C" char __stdcall **cur_environ ();
+int __stdcall envsize (const char * const *, int debug_print = 0);
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index 8b133cc8c..16b845038 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -20,8 +20,9 @@ details. */
#include "cygerrno.h"
#include "thread.h"
#include "perthread.h"
-#include "tty.h"
#include "shared_info.h"
+#include "perprocess.h"
+#include "security.h"
char debugger_command[2 * MAX_PATH + 20];
diff --git a/winsup/cygwin/exec.cc b/winsup/cygwin/exec.cc
index 76a98074d..6438d16e2 100644
--- a/winsup/cygwin/exec.cc
+++ b/winsup/cygwin/exec.cc
@@ -15,6 +15,10 @@ details. */
#include <process.h>
#include "fhandler.h"
#include "path.h"
+#include "sync.h"
+#include "sigproc.h"
+#include "pinfo.h"
+#include "environ.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 64a3acf02..74b106959 100644
--- a/winsup/cygwin/external.cc
+++ b/winsup/cygwin/external.cc
@@ -16,8 +16,9 @@ details. */
#include "sigproc.h"
#include "pinfo.h"
#include <exceptions.h>
-#include "tty.h"
#include "shared_info.h"
+#include "cygwin_version.h"
+#include "perprocess.h"
static external_pinfo *
fillout_pinfo (pid_t pid, int winpid)
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index e5a903c37..7307e882c 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -15,11 +15,15 @@ details. */
#include <stdlib.h>
#include "cygheap.h"
#include <string.h>
+#include <sys/cygwin.h>
+#include <signal.h>
#include "cygerrno.h"
#include "fhandler.h"
#include "path.h"
-#include "tty.h"
#include "shared_info.h"
+#include "host_dependent.h"
+#include "perprocess.h"
+#include "security.h"
static NO_COPY const int CHUNK_SIZE = 1024; /* Used for crlf conversions */
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index b25665873..df9153e9d 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -842,5 +842,6 @@ public:
uid_t __stdcall get_file_owner (int, const char *);
gid_t __stdcall get_file_group (int, const char *);
+int __stdcall set_console_state_for_spawn ();
#endif /* _FHANDLER_H_ */
diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index ff70bb4b0..dc76df492 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -19,13 +19,14 @@ details. */
#include <winuser.h>
#include <wincon.h>
#include <ctype.h>
+#include <sys/cygwin.h>
#include "cygerrno.h"
#include "fhandler.h"
#include "sync.h"
#include "sigproc.h"
#include "pinfo.h"
-#include "tty.h"
#include "shared_info.h"
+#include "security.h"
/*
* Scroll the screen context.
diff --git a/winsup/cygwin/fhandler_serial.cc b/winsup/cygwin/fhandler_serial.cc
index 1f31cd61e..c1e472bdf 100644
--- a/winsup/cygwin/fhandler_serial.cc
+++ b/winsup/cygwin/fhandler_serial.cc
@@ -18,6 +18,7 @@ details. */
#include "sync.h"
#include "sigproc.h"
#include "pinfo.h"
+#include "security.h"
#include <sys/termios.h>
/**********************************************************************/
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index c78f2bad6..996118281 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -23,7 +23,6 @@ details. */
#include "sigproc.h"
#include "pinfo.h"
#include "cygheap.h"
-#include "tty.h"
#include "shared_info.h"
/* Tty master stuff */
diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc
index 6be5e3a25..02b784a6a 100644
--- a/winsup/cygwin/fork.cc
+++ b/winsup/cygwin/fork.cc
@@ -15,7 +15,6 @@ details. */
#include <fcntl.h>
#include <stdarg.h>
#include <errno.h>
-#include "dll_init.h"
#include "fhandler.h"
#include "dtable.h"
#include "cygerrno.h"
@@ -24,7 +23,11 @@ details. */
#include "pinfo.h"
#include "cygheap.h"
#include "child_info.h"
+#define NEED_VFORK
#include "perthread.h"
+#include "perprocess.h"
+#include "dll_init.h"
+#include "security.h"
DWORD NO_COPY chunksize = 0;
/* Timeout to wait for child to start, parent to init child, etc. */
diff --git a/winsup/cygwin/heap.cc b/winsup/cygwin/heap.cc
index 1ad80a2a5..dc2e6e977 100644
--- a/winsup/cygwin/heap.cc
+++ b/winsup/cygwin/heap.cc
@@ -15,7 +15,6 @@ details. */
#include "sigproc.h"
#include "pinfo.h"
#include "heap.h"
-#include "tty.h"
#include "shared_info.h"
#define assert(x)
diff --git a/winsup/cygwin/heap.h b/winsup/cygwin/heap.h
index 080b415de..110e03763 100644
--- a/winsup/cygwin/heap.h
+++ b/winsup/cygwin/heap.h
@@ -8,6 +8,8 @@ This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
+#include "perprocess.h"
+
/* Heap management. */
void heap_init (void);
void malloc_init (void);
diff --git a/winsup/cygwin/host_dependent.h b/winsup/cygwin/host_dependent.h
new file mode 100644
index 000000000..94e1546ca
--- /dev/null
+++ b/winsup/cygwin/host_dependent.h
@@ -0,0 +1,30 @@
+/* host_dependent.h: host dependent Cygwin header file.
+
+ 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. */
+
+/* Portions of the cygwin DLL require special constants whose values
+ are dependent on the host system. Rather than dynamically
+ determine those values whenever they are required, initialize these
+ values once at process start-up. */
+
+class host_dependent_constants
+{
+ public:
+ void init (void);
+
+ /* Used by fhandler_disk_file::lock which needs a platform-specific
+ upper word value for locking entire files. */
+ DWORD win32_upper;
+
+ /* fhandler_base::open requires host dependent file sharing
+ attributes. */
+ int shared;
+};
+
+extern host_dependent_constants host_dependent;
diff --git a/winsup/cygwin/init.cc b/winsup/cygwin/init.cc
index f0c5a1cff..1f169e9ca 100644
--- a/winsup/cygwin/init.cc
+++ b/winsup/cygwin/init.cc
@@ -11,6 +11,7 @@ details. */
#include "winsup.h"
#include <stdlib.h>
#include "thread.h"
+#include "perprocess.h"
extern HMODULE cygwin_hmodule;
diff --git a/winsup/cygwin/malloc_wrapper.cc b/winsup/cygwin/malloc_wrapper.cc
index 2e10cddc5..ad117eb8f 100644
--- a/winsup/cygwin/malloc_wrapper.cc
+++ b/winsup/cygwin/malloc_wrapper.cc
@@ -17,6 +17,7 @@ details. */
#include "cygheap.h"
#include "heap.h"
#include "sync.h"
+#include "perprocess.h"
/* we provide these stubs to call into a user's
provided malloc if there is one - otherwise
diff --git a/winsup/cygwin/mkvers.sh b/winsup/cygwin/mkvers.sh
index d111c2ca9..47cfb27d9 100755
--- a/winsup/cygwin/mkvers.sh
+++ b/winsup/cygwin/mkvers.sh
@@ -62,7 +62,7 @@ set -$- ''
# Output the initial part of version.cc
#
cat <<EOF 1>&9
-#include <winsup.h>
+#include "cygwin_version.h"
#define strval(x) #x
#define str(x) strval(x)
diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc
index 158b538c0..cb86a8493 100644
--- a/winsup/cygwin/mmap.cc
+++ b/winsup/cygwin/mmap.cc
@@ -20,6 +20,7 @@ details. */
#include "sync.h"
#include "sigproc.h"
#include "pinfo.h"
+#include "security.h"
/*
* Simple class used to keep a record of all current
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index 4f1a8a0be..f140bdc83 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -31,6 +31,7 @@ details. */
#include "sync.h"
#include "sigproc.h"
#include "pinfo.h"
+#include "registry.h"
/* We only want to initialize WinSock in a child process if socket
handles are inheritted. This global allows us to know whether this
@@ -76,7 +77,6 @@ extern "C"
unsigned long int
htonl (unsigned long int x)
{
- MARK ();
return ((((x & 0x000000ffU) << 24) |
((x & 0x0000ff00U) << 8) |
((x & 0x00ff0000U) >> 8) |
@@ -96,7 +96,6 @@ extern "C"
unsigned short
htons (unsigned short x)
{
- MARK ();
return ((((x & 0x000000ffU) << 8) |
((x & 0x0000ff00U) >> 8)));
}
diff --git a/winsup/cygwin/ntea.cc b/winsup/cygwin/ntea.cc
index cf0a1595e..2c9df4ce6 100644
--- a/winsup/cygwin/ntea.cc
+++ b/winsup/cygwin/ntea.cc
@@ -10,9 +10,10 @@ This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
-#include <winsup.h>
+#include "winsup.h"
#include <stdio.h>
#include <stdlib.h>
+#include "security.h"
/* Default to not using NTEA information */
BOOL allow_ntea = FALSE;
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 307ab62e1..a6025b0ba 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -57,6 +57,8 @@ details. */
#include <errno.h>
#include <ctype.h>
#include <winioctl.h>
+#include <sys/cygwin.h>
+#include <cygwin/version.h>
#include "cygerrno.h"
#include "fhandler.h"
#include "path.h"
@@ -65,8 +67,9 @@ details. */
#include "sigproc.h"
#include "pinfo.h"
#include "cygheap.h"
-#include "tty.h"
#include "shared_info.h"
+#include "registry.h"
+#include "security.h"
static int normalize_win32_path (const char *src, char *dst);
static void slashify (const char *src, char *dst, int trailing_slash_p);
diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h
index 9143b415b..01c965752 100644
--- a/winsup/cygwin/path.h
+++ b/winsup/cygwin/path.h
@@ -1,6 +1,6 @@
/* path.h: path data structures
- Copyright 1996, 1997, 1998, 2000 Cygnus Solutions.
+ Copyright 1996, 1997, 1998, 2000 Red Hat, Inc.
This file is part of Cygwin.
diff --git a/winsup/cygwin/perprocess.h b/winsup/cygwin/perprocess.h
new file mode 100644
index 000000000..a649ece74
--- /dev/null
+++ b/winsup/cygwin/perprocess.h
@@ -0,0 +1,20 @@
+/* per_process.h: main Cygwin header file.
+
+ 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. */
+
+#include <sys/cygwin.h>
+
+/* Pointer into application's static data */
+extern "C" per_process __cygwin_user_data;
+#define user_data (&__cygwin_user_data)
+
+/* We use the following to test that sizeof hasn't changed. When adding
+ or deleting members, insert fillers or use the reserved entries.
+ Do not change this value. */
+#define SIZEOF_PER_PROCESS (42 * 4)
diff --git a/winsup/cygwin/perthread.h b/winsup/cygwin/perthread.h
index 7d009e1f0..f4c82c0ec 100644
--- a/winsup/cygwin/perthread.h
+++ b/winsup/cygwin/perthread.h
@@ -68,6 +68,7 @@ public:
size_t size () {return sizeof (waitq);}
};
+#ifdef NEED_VFORK
struct vfork_save
{
int pid;
@@ -85,6 +86,8 @@ public:
vfork_save *create () {return (vfork_save *) this->per_thread::create ();}
size_t size () {return sizeof (vfork_save);}
};
+extern per_thread_vfork vfork_storage;
+#endif
extern "C" {
struct signal_dispatch
@@ -107,7 +110,6 @@ struct per_thread_signal_dispatch : public per_thread
};
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 37a280899..f7c233da6 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -20,6 +20,10 @@ details. */
#include "sync.h"
#include "sigproc.h"
#include "pinfo.h"
+#include "cygwin_version.h"
+#include "perprocess.h"
+#include "environ.h"
+#include "security.h"
static char NO_COPY pinfo_dummy[sizeof(pinfo)] = {0};
diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h
index 891fd4228..13eaa1de8 100644
--- a/winsup/cygwin/pinfo.h
+++ b/winsup/cygwin/pinfo.h
@@ -1,4 +1,12 @@
-/******** Process Table ********/
+/* pinfo.h: process table info
+
+ Copyright 2000 Cygnus Solutions.
+
+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. */
/* Signal constants (have to define them here, unfortunately) */
@@ -13,6 +21,7 @@ enum
#define PSIZE 1024
class ThreadItem;
+#include <sys/resource.h>
class _pinfo
{
@@ -166,3 +175,16 @@ cygwin_pid (pid_t pid)
void __stdcall pinfo_init (char **);
void __stdcall set_myself (pid_t pid, HANDLE h = NULL);
extern pinfo myself;
+
+#define _P_VFORK 0
+extern "C" int _spawnve (HANDLE hToken, int mode, const char *path,
+ const char *const *argv, const char *const *envp);
+
+extern void __stdcall exec_fixup_after_fork ();
+
+/* For mmaps across fork(). */
+int __stdcall recreate_mmaps_after_fork (void *);
+void __stdcall set_child_mmap_ptr (_pinfo *);
+
+void __stdcall fill_rusage (struct rusage *, HANDLE);
+void __stdcall add_rusage (struct rusage *, struct rusage *);
diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc
index 3a103e1ca..2de499112 100644
--- a/winsup/cygwin/pipe.cc
+++ b/winsup/cygwin/pipe.cc
@@ -16,6 +16,7 @@ details. */
#include "fhandler.h"
#include "dtable.h"
#include "thread.h"
+#include "security.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 91cdc2aed..d55b2af32 100644
--- a/winsup/cygwin/poll.cc
+++ b/winsup/cygwin/poll.cc
@@ -9,6 +9,7 @@
details. */
#include "winsup.h"
+#include <sys/time.h>
#include <sys/poll.h>
#include <errno.h>
#include "fhandler.h"
diff --git a/winsup/cygwin/registry.cc b/winsup/cygwin/registry.cc
index 82acc6981..70a96f62f 100644
--- a/winsup/cygwin/registry.cc
+++ b/winsup/cygwin/registry.cc
@@ -9,8 +9,10 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include "winsup.h"
-#include "tty.h"
#include "shared_info.h"
+#include "registry.h"
+#include "security.h"
+#include <cygwin/version.h>
char cygnus_class[] = "cygnus";
diff --git a/winsup/cygwin/registry.h b/winsup/cygwin/registry.h
new file mode 100644
index 000000000..7e21245b9
--- /dev/null
+++ b/winsup/cygwin/registry.h
@@ -0,0 +1,43 @@
+/* registry.h: shared info for cygwin
+
+ Copyright 2000 Cygnus Solutions.
+
+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 reg_key
+{
+private:
+
+ HKEY key;
+ LONG key_is_invalid;
+
+public:
+
+ reg_key (HKEY toplev, REGSAM access, ...);
+ reg_key (REGSAM access, ...);
+ reg_key (REGSAM access = KEY_ALL_ACCESS);
+
+ void *operator new (size_t, void *p) {return p;}
+ void build_reg (HKEY key, REGSAM access, va_list av);
+
+ int error () {return key == (HKEY) INVALID_HANDLE_VALUE;}
+
+ int kill (const char *child);
+ int killvalue (const char *name);
+
+ HKEY get_key ();
+ int get_int (const char *,int def);
+ int get_string (const char *, char *buf, size_t len, const char *def);
+ int set_string (const char *,const char *);
+ int set_int (const char *, int val);
+
+ ~reg_key ();
+};
+
+/* Evaluates path to the directory of the local user registry hive */
+char *__stdcall get_registry_hive_path (const PSID psid, char *path);
+void __stdcall load_registry_hive (PSID psid);
diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc
index 843385968..3a40af574 100644
--- a/winsup/cygwin/security.cc
+++ b/winsup/cygwin/security.cc
@@ -29,6 +29,7 @@ details. */
#include "sync.h"
#include "sigproc.h"
#include "pinfo.h"
+#include "security.h"
extern BOOL allow_ntea;
BOOL allow_ntsec = FALSE;
diff --git a/winsup/cygwin/security.h b/winsup/cygwin/security.h
new file mode 100644
index 000000000..b6397fe10
--- /dev/null
+++ b/winsup/cygwin/security.h
@@ -0,0 +1,40 @@
+/* security.h: security declarations
+
+ 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. */
+
+/* File manipulation */
+int __stdcall set_process_privileges ();
+int __stdcall get_file_attribute (int, const char *, int *,
+ uid_t * = NULL, gid_t * = NULL);
+int __stdcall set_file_attribute (int, const char *, int);
+int __stdcall set_file_attribute (int, const char *, uid_t, gid_t, int, const char *);
+extern BOOL allow_ntsec;
+
+/* `lookup_name' should be called instead of LookupAccountName.
+ * logsrv may be NULL, in this case only the local system is used for lookup.
+ * The buffer for ret_sid (40 Bytes) has to be allocated by the caller! */
+BOOL __stdcall lookup_name (const char *, const char *, PSID);
+char *__stdcall convert_sid_to_string_sid (PSID, char *);
+PSID __stdcall convert_string_sid_to_sid (PSID, const char *);
+BOOL __stdcall get_pw_sid (PSID, struct passwd *);
+
+/* Retrieve a security descriptor that allows all access */
+SECURITY_DESCRIPTOR *__stdcall get_null_sd (void);
+
+int __stdcall get_id_from_sid (PSID, BOOL);
+extern inline int get_uid_from_sid (PSID psid) { return get_id_from_sid (psid, FALSE);}
+extern inline int get_gid_from_sid (PSID psid) { return get_id_from_sid (psid, TRUE); }
+
+/* Various types of security attributes for use in Create* functions. */
+extern SECURITY_ATTRIBUTES sec_none, sec_none_nih, sec_all, sec_all_nih;
+extern SECURITY_ATTRIBUTES *__stdcall sec_user (PVOID sa_buf, PSID sid2 = NULL, BOOL inherit = TRUE);
+extern SECURITY_ATTRIBUTES *__stdcall sec_user_nih (PVOID sa_buf, PSID sid2 = NULL);
+
+int __stdcall NTReadEA (const char *file, const char *attrname, char *buf, int len);
+BOOL __stdcall NTWriteEA (const char *file, const char *attrname, char *buf, int len);
diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc
index aab2b1a9e..ee68c9b4a 100644
--- a/winsup/cygwin/shared.cc
+++ b/winsup/cygwin/shared.cc
@@ -17,8 +17,10 @@ details. */
#include "sync.h"
#include "sigproc.h"
#include "pinfo.h"
-#include "tty.h"
#include "shared_info.h"
+#include "registry.h"
+#include "cygwin_version.h"
+#include "security.h"
#define SHAREDVER (unsigned)(cygwin_version.api_major << 16 | \
cygwin_version.api_minor)
diff --git a/winsup/cygwin/shared.h b/winsup/cygwin/shared.h
deleted file mode 100644
index bd88ca772..000000000
--- a/winsup/cygwin/shared.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/* shared.h: shared info for cygwin
-
- Copyright 1998, 1999, 2000 Cygnus Solutions.
-
-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. */
-
-/******** Functions declarations for use in methods below ********/
-
-/* Printf type functions */
-extern "C" void __api_fatal (const char *, ...) __attribute__ ((noreturn));
-extern "C" int __small_sprintf (char *dst, const char *fmt, ...);
-extern "C" int __small_vsprintf (char *dst, const char *fmt, va_list ap);
-
-/******** Deletion Queue Class ********/
-
-/* First pass at a file deletion queue structure.
-
- We can't keep this list in the per-process info, since
- one process may open a file, and outlive a process which
- wanted to unlink the file - and the data would go away.
-
- Perhaps the FILE_FLAG_DELETE_ON_CLOSE would be ok,
- but brief experimentation didn't get too far.
-*/
-
-#define MAX_DELQUEUES_PENDING 100
-
-class delqueue_list
-{
- char name[MAX_DELQUEUES_PENDING][MAX_PATH];
- char inuse[MAX_DELQUEUES_PENDING];
- int empty;
-
-public:
- void init ();
- void queue_file (const char *dosname);
- void process_queue ();
-};
-
-/* non-NULL if this process is a child of a cygwin process */
-extern HANDLE parent_alive;
-
-/******** Registry Access ********/
-
-class reg_key
-{
-private:
-
- HKEY key;
- LONG key_is_invalid;
-
-public:
-
- reg_key (HKEY toplev, REGSAM access, ...);
- reg_key (REGSAM access, ...);
- reg_key (REGSAM access = KEY_ALL_ACCESS);
-
- void *operator new (size_t, void *p) {return p;}
- void build_reg (HKEY key, REGSAM access, va_list av);
-
- int error () {return key == (HKEY) INVALID_HANDLE_VALUE;}
-
- int kill (const char *child);
- int killvalue (const char *name);
-
- HKEY get_key ();
- int get_int (const char *,int def);
- int get_string (const char *, char *buf, size_t len, const char *def);
- int set_string (const char *,const char *);
- int set_int (const char *, int val);
-
- ~reg_key ();
-};
-
-/* Evaluates path to the directory of the local user registry hive */
-char *__stdcall get_registry_hive_path (const PSID psid, char *path);
-void __stdcall load_registry_hive (PSID psid);
-
-
-/* Various types of security attributes for use in Create* functions. */
-extern SECURITY_ATTRIBUTES sec_none, sec_none_nih, sec_all, sec_all_nih;
-extern SECURITY_ATTRIBUTES *__stdcall sec_user (PVOID sa_buf, PSID sid2 = NULL, BOOL inherit = TRUE);
-extern SECURITY_ATTRIBUTES *__stdcall sec_user_nih (PVOID sa_buf, PSID sid2 = NULL);
-
-extern int __stdcall set_console_state_for_spawn ();
-
-extern "C" {
-/* This is for programs that want to access the shared data. */
-class shared_info *cygwin_getshared (void);
-
-struct cygwin_version_info
-{
- unsigned short api_major;
- unsigned short api_minor;
- unsigned short dll_major;
- unsigned short dll_minor;
- unsigned short shared_data;
- unsigned short mount_registry;
- const char *dll_build_date;
- char shared_id[sizeof (CYGWIN_VERSION_DLL_IDENTIFIER) + 64];
-};
-}
-
-extern cygwin_version_info cygwin_version;
-extern const char *cygwin_version_strings;
diff --git a/winsup/cygwin/shared_info.h b/winsup/cygwin/shared_info.h
index 52c055989..6434da255 100644
--- a/winsup/cygwin/shared_info.h
+++ b/winsup/cygwin/shared_info.h
@@ -1,6 +1,6 @@
-/* shared_sec.h: shared info for cygwin
+/* shared_info.h: shared info for cygwin
- Copyright 1998, 1999, 2000 Cygnus Solutions.
+ Copyright 2000 Cygnus Solutions.
This file is part of Cygwin.
@@ -8,6 +8,8 @@ This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
+#include "tty.h"
+
/* Mount table entry */
class mount_item
@@ -38,6 +40,7 @@ public:
scheme should be satisfactory for a long while yet. */
#define MAX_MOUNTS 30
+class reg_key;
class mount_info
{
int posix_sorted[MAX_MOUNTS];
@@ -100,6 +103,29 @@ private:
void read_cygdrive_info_from_registry ();
};
+/******** Close-on-delete queue ********/
+
+/* First pass at a file deletion queue structure.
+
+ We can't keep this list in the per-process info, since
+ one process may open a file, and outlive a process which
+ wanted to unlink the file - and the data would go away.
+*/
+
+#define MAX_DELQUEUES_PENDING 100
+
+class delqueue_list
+{
+ char name[MAX_DELQUEUES_PENDING][MAX_PATH];
+ char inuse[MAX_DELQUEUES_PENDING];
+ int empty;
+
+public:
+ void init ();
+ void queue_file (const char *dosname);
+ void process_queue ();
+};
+
/******** Shared Info ********/
/* Data accessible to all tasks */
diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc
index 38a1aba52..f04adfd89 100644
--- a/winsup/cygwin/signal.cc
+++ b/winsup/cygwin/signal.cc
@@ -14,6 +14,7 @@ details. */
#include "winsup.h"
#include <errno.h>
#include "cygerrno.h"
+#include <sys/cygwin.h>
#include "sync.h"
#include "sigproc.h"
#include "pinfo.h"
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index 87b29c361..46342ba50 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -16,6 +16,7 @@ details. */
#include <sys/wait.h>
#include <errno.h>
#include <stdlib.h>
+#include <sys/cygwin.h>
#include "cygerrno.h"
#include "sync.h"
#include "sigproc.h"
@@ -24,8 +25,8 @@ details. */
#include "child_info.h"
#include "perthread.h"
#include <assert.h>
-#include "tty.h"
#include "shared_info.h"
+#include "security.h"
/*
* Convenience defines
diff --git a/winsup/cygwin/sigproc.h b/winsup/cygwin/sigproc.h
index 3cce46ee9..c8634022a 100644
--- a/winsup/cygwin/sigproc.h
+++ b/winsup/cygwin/sigproc.h
@@ -8,6 +8,8 @@ This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
+#include <signal.h>
+
#define EXIT_SIGNAL 0x010000
#define EXIT_REPARENTING 0x020000
#define EXIT_NOCLOSEALL 0x040000
@@ -82,6 +84,9 @@ public:
extern sigthread mainthread;
extern HANDLE signal_arrived;
+/* non-NULL if this process is a child of a cygwin process */
+extern HANDLE parent_alive;
+
BOOL __stdcall my_parent_is_alive ();
extern "C" int __stdcall sig_dispatch_pending (int force = FALSE) __asm__ ("sig_dispatch_pending");
extern "C" void __stdcall set_process_mask (sigset_t newmask);
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index a6dc10fa9..c7813a3c3 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -20,6 +20,7 @@ details. */
#include <winuser.h>
#include <ctype.h>
#include "cygerrno.h"
+#include <sys/cygwin.h>
#include "fhandler.h"
#include "path.h"
#include "dtable.h"
@@ -28,7 +29,11 @@ details. */
#include "cygheap.h"
#include "child_info.h"
#include "pinfo.h"
+#define NEED_VFORK
#include "perthread.h"
+#include "registry.h"
+#include "environ.h"
+#include "security.h"
#define LINE_BUF_CHUNK (MAX_PATH * 2)
diff --git a/winsup/cygwin/strace.cc b/winsup/cygwin/strace.cc
index 5cba5d027..60d81e05b 100644
--- a/winsup/cygwin/strace.cc
+++ b/winsup/cygwin/strace.cc
@@ -201,11 +201,6 @@ strace::prntf (unsigned category, const char *func, const char *fmt, ...)
SetLastError (err);
}
-void __stdcall
-mark (const char *, int)
-{
-}
-
static const struct tab
{
int v;
diff --git a/winsup/cygwin/sync.cc b/winsup/cygwin/sync.cc
index 9f44ff264..dededa5ed 100644
--- a/winsup/cygwin/sync.cc
+++ b/winsup/cygwin/sync.cc
@@ -21,6 +21,7 @@ details. */
#include <errno.h>
#include <stdlib.h>
#include "sync.h"
+#include "security.h"
muto NO_COPY muto_start;
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index dd24f9787..40dd69429 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -23,6 +23,8 @@ details. */
#include <limits.h>
#include <winnls.h>
#include <lmcons.h> /* for UNLEN */
+#include <cygwin/version.h>
+#include <sys/cygwin.h>
#include "cygerrno.h"
#include "fhandler.h"
#include "path.h"
@@ -32,8 +34,9 @@ details. */
#include "sigproc.h"
#include "pinfo.h"
#include <unistd.h>
-#include "tty.h"
#include "shared_info.h"
+#include "perprocess.h"
+#include "security.h"
extern BOOL allow_ntsec;
diff --git a/winsup/cygwin/termios.cc b/winsup/cygwin/termios.cc
index 07fa998da..c72a49414 100644
--- a/winsup/cygwin/termios.cc
+++ b/winsup/cygwin/termios.cc
@@ -13,9 +13,12 @@ details. */
#include "winsup.h"
#include <errno.h>
+#include <signal.h>
#include "cygerrno.h"
#include "fhandler.h"
#include "dtable.h"
+#include <cygwin/version.h>
+#include "perprocess.h"
#include <sys/termios.h>
/* tcsendbreak: POSIX 7.2.2.1 */
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index 49e52232e..fb1a3d67c 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -24,6 +24,8 @@ details. */
#include "sync.h"
#include "sigproc.h"
#include "pinfo.h"
+#include "perprocess.h"
+#include "security.h"
extern int threadsafe;
diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc
index 8b257cae7..b8e715deb 100644
--- a/winsup/cygwin/times.cc
+++ b/winsup/cygwin/times.cc
@@ -23,6 +23,7 @@ details. */
#include "sync.h"
#include "sigproc.h"
#include "pinfo.h"
+#include "security.h"
#define FACTOR (0x19db1ded53e8000LL)
#define NSPERSEC 10000000LL
diff --git a/winsup/cygwin/tty.cc b/winsup/cygwin/tty.cc
index 4dbe72c1a..f0be2a534 100644
--- a/winsup/cygwin/tty.cc
+++ b/winsup/cygwin/tty.cc
@@ -14,14 +14,15 @@ details. */
#include <utmp.h>
#include <wingdi.h>
#include <winuser.h>
+#include <sys/cygwin.h>
#include "cygerrno.h"
#include "fhandler.h"
#include "dtable.h"
#include "sync.h"
#include "sigproc.h"
#include "pinfo.h"
-#include "tty.h"
#include "shared_info.h"
+#include "security.h"
extern fhandler_tty_master *tty_master;
diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc
index a0f9ae82d..7057fd11e 100644
--- a/winsup/cygwin/uinfo.cc
+++ b/winsup/cygwin/uinfo.cc
@@ -22,6 +22,8 @@ details. */
#include "sync.h"
#include "sigproc.h"
#include "pinfo.h"
+#include "registry.h"
+#include "security.h"
char *
internal_getlogin (_pinfo *pi)
diff --git a/winsup/cygwin/uname.cc b/winsup/cygwin/uname.cc
index 0db7c3949..a8712ca08 100644
--- a/winsup/cygwin/uname.cc
+++ b/winsup/cygwin/uname.cc
@@ -13,6 +13,7 @@ details. */
#include "winsup.h"
#include <stdio.h>
#include <sys/utsname.h>
+#include "cygwin_version.h"
/* uname: POSIX 4.4.1.1 */
extern "C" int
diff --git a/winsup/cygwin/window.cc b/winsup/cygwin/window.cc
index 4373acc24..db5fbe10f 100644
--- a/winsup/cygwin/window.cc
+++ b/winsup/cygwin/window.cc
@@ -14,10 +14,13 @@ details. */
#include <sys/time.h>
#include <stdlib.h>
#include <errno.h>
+#include <signal.h>
#include <limits.h>
#include <wingdi.h>
#include <winuser.h>
#include "cygerrno.h"
+#include "perprocess.h"
+#include "security.h"
static NO_COPY UINT timer_active = 0;
static NO_COPY struct itimerval itv;
diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h
index a07c2471a..4f1bbc871 100644
--- a/winsup/cygwin/winsup.h
+++ b/winsup/cygwin/winsup.h
@@ -31,10 +31,6 @@ details. */
#include <sys/types.h>
#include <sys/strace.h>
-#include <sys/resource.h>
-#include <setjmp.h>
-#include <signal.h>
-#include <string.h>
#undef strchr
#define strchr cygwin_strchr
@@ -89,8 +85,6 @@ extern int dynamically_loaded;
#define sys_mbstowcs(tgt,src,len) \
MultiByteToWideChar(CP_ACP,0,(src),-1,(tgt),(len))
-#include <cygwin/version.h>
-
#define TITLESIZE 1024
#define MAX_USER_NAME 20
#define DEFAULT_UID 500
@@ -109,45 +103,7 @@ extern int dynamically_loaded;
#define __CONDSETF(n, what, x, prefix) \
((n) ? __SETF (what, x, prefix) : __CLEARF (what, x, prefix))
-#include "shared.h"
-
-extern HANDLE hMainThread;
-extern HANDLE hMainProc;
-
#include "debug.h"
-#include <sys/cygwin.h>
-
-/********************** Application Interface **************************/
-
-extern "C" per_process __cygwin_user_data; /* Pointer into application's static data */
-#define user_data (&__cygwin_user_data)
-
-/* We use the following to test that sizeof hasn't changed. When adding
- or deleting members, insert fillers or use the reserved entries.
- Do not change this value. */
-#define SIZEOF_PER_PROCESS (42 * 4)
-
-/******************* Host-dependent constants **********************/
-/* Portions of the cygwin DLL require special constants whose values
- are dependent on the host system. Rather than dynamically
- determine those values whenever they are required, initialize these
- values once at process start-up. */
-
-class host_dependent_constants
-{
- public:
- void init (void);
-
- /* Used by fhandler_disk_file::lock which needs a platform-specific
- upper word value for locking entire files. */
- DWORD win32_upper;
-
- /* fhandler_base::open requires host dependent file sharing
- attributes. */
- int shared;
-};
-
-extern host_dependent_constants host_dependent;
/* Events/mutexes */
extern HANDLE title_mutex;
@@ -167,12 +123,6 @@ extern HANDLE title_mutex;
#define SIGTOMASK(sig) (1<<((sig) - signal_shift_subtract))
extern unsigned int signal_shift_subtract;
-#ifdef NOSTRACE
-#define MARK() 0
-#else
-#define MARK() mark (__FILE__,__LINE__)
-#endif
-
#ifdef NEW_MACRO_VARARGS
# define api_fatal(...) __api_fatal ("%P: *** " __VA_ARGS__)
#else
@@ -188,12 +138,13 @@ extern unsigned int signal_shift_subtract;
/******************** Initialization/Termination **********************/
+class per_process;
/* cygwin .dll initialization */
void dll_crt0 (per_process *);
extern "C" void __stdcall _dll_crt0 ();
/* dynamically loaded dll initialization */
-extern "C" int dll_dllcrt0 (HMODULE, per_process*);
+extern "C" int dll_dllcrt0 (HMODULE, per_process *);
/* dynamically loaded dll initialization for non-cygwin apps */
extern "C" int dll_noncygwin_dllcrt0 (HMODULE, per_process *);
@@ -201,9 +152,6 @@ extern "C" int dll_noncygwin_dllcrt0 (HMODULE, per_process *);
/* exit the program */
extern "C" void __stdcall do_exit (int) __attribute__ ((noreturn));
-/* Initialize the environment */
-void environ_init (char **);
-
/* UID/GID */
void uinfo_init (void);
@@ -231,42 +179,15 @@ extern int cygwin_finished_initializing;
/**************************** Miscellaneous ******************************/
-/* File manipulation */
-int __stdcall set_process_privileges ();
-int __stdcall get_file_attribute (int, const char *, int *,
- uid_t * = NULL, gid_t * = NULL);
-int __stdcall set_file_attribute (int, const char *, int);
-int __stdcall set_file_attribute (int, const char *, uid_t, gid_t, int, const char *);
void __stdcall set_std_handle (int);
int __stdcall writable_directory (const char *file);
int __stdcall stat_dev (DWORD, int, unsigned long, struct stat *);
extern BOOL allow_ntsec;
-/* `lookup_name' should be called instead of LookupAccountName.
- * logsrv may be NULL, in this case only the local system is used for lookup.
- * The buffer for ret_sid (40 Bytes) has to be allocated by the caller! */
-BOOL __stdcall lookup_name (const char *, const char *, PSID);
-char *__stdcall convert_sid_to_string_sid (PSID, char *);
-PSID __stdcall convert_string_sid_to_sid (PSID, const char *);
-BOOL __stdcall get_pw_sid (PSID, struct passwd *);
-
unsigned long __stdcall hash_path_name (unsigned long hash, const char *name);
void __stdcall nofinalslash (const char *src, char *dst);
extern "C" char *__stdcall rootdir (char *full_path);
-void __stdcall mark (const char *, int);
-
-#define _P_VFORK 0
-extern "C" int _spawnve (HANDLE hToken, int mode, const char *path,
- const char *const *argv, const char *const *envp);
-
-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 *);
-
/* String manipulation */
char *__stdcall strccpy (char *s1, const char **s2, char c);
int __stdcall strcasematch (const char *s1, const char *s2);
@@ -277,24 +198,16 @@ char *__stdcall strcasestr (const char *searchee, const char *lookfor);
void __stdcall totimeval (struct timeval *dst, FILETIME * src, int sub, int flag);
long __stdcall to_time_t (FILETIME * ptr);
-/* Retrieve a security descriptor that allows all access */
-SECURITY_DESCRIPTOR *__stdcall get_null_sd (void);
-
-int __stdcall get_id_from_sid (PSID, BOOL);
-extern inline int get_uid_from_sid (PSID psid) { return get_id_from_sid (psid, FALSE);}
-extern inline int get_gid_from_sid (PSID psid) { return get_id_from_sid (psid, TRUE); }
-
-int __stdcall NTReadEA (const char *file, const char *attrname, char *buf, int len);
-BOOL __stdcall NTWriteEA (const char *file, const char *attrname, char *buf, int len);
-
void __stdcall set_console_title (char *);
void set_console_handler ();
-void __stdcall fill_rusage (struct rusage *, HANDLE);
-void __stdcall add_rusage (struct rusage *, struct rusage *);
-
void set_winsock_errno ();
+/* Printf type functions */
+extern "C" void __api_fatal (const char *, ...) __attribute__ ((noreturn));
+extern "C" int __small_sprintf (char *dst, const char *fmt, ...);
+extern "C" int __small_vsprintf (char *dst, const char *fmt, va_list ap);
+
/**************************** Exports ******************************/
extern "C" {
@@ -306,9 +219,6 @@ int kill_pgrp (pid_t, int);
int _kill (int, int);
int _raise (int sig);
-int getfdtabsize ();
-void setfdtabsize (int);
-
extern DWORD binmode;
extern char _data_start__, _data_end__, _bss_start__, _bss_end__;
extern void (*__CTOR_LIST__) (void);
@@ -328,11 +238,6 @@ extern void (*__DTOR_LIST__) (void);
issue and is neither of the Unixy ones [so we can punt on which
one is the right one to use]. */
-/* Initial and increment values for cygwin's fd table */
-#define NOFILE_INCR 32
-
-#include <sys/reent.h>
-
#define STD_RBITS (S_IRUSR | S_IRGRP | S_IROTH)
#define STD_WBITS (S_IWUSR)
#define STD_XBITS (S_IXUSR | S_IXGRP | S_IXOTH)
@@ -340,38 +245,11 @@ extern void (*__DTOR_LIST__) (void);
#define O_NOSYMLINK 0x080000
#define O_DIROPEN 0x100000
-/*************************** Environment ******************************/
-
-/* The structure below is used to control conversion to/from posix-style
- * file specs. Currently, only PATH and HOME are converted, but PATH
- * needs to use a "convert path list" function while HOME needs a simple
- * "convert to posix/win32". For the simple case, where a calculated length
- * is required, just return MAX_PATH. *FIXME*
- */
-struct win_env
- {
- const char *name;
- size_t namelen;
- char *posix;
- char *native;
- int (*toposix) (const char *, char *);
- int (*towin32) (const char *, char *);
- int (*posix_len) (const char *);
- int (*win32_len) (const char *);
- void add_cache (const char *in_posix, const char *in_native = NULL);
- const char * get_native () {return native ? native + namelen : NULL;}
- };
-
-win_env * __stdcall getwinenv (const char *name, const char *posix = NULL);
-
-void __stdcall update_envptrs ();
-char * __stdcall winenv (const char * const *, int);
-extern char **__cygwin_environ, ***main_environ;
-extern "C" char __stdcall **cur_environ ();
-int __stdcall envsize (const char * const *, int debug_print = 0);
-
/* The title on program start. */
extern char *old_title;
extern BOOL display_title;
+extern HANDLE hMainThread;
+extern HANDLE hMainProc;
+
#endif /* defined __cplusplus */