? cygserver_sem.cc
? cygserver_sem.h
? cygstrptime.patch
? daemonstate.patch
? daemonstate2.patch
? daemonstate3.patch
? gmon.din
? exportipc.patch
? t
? getsem.patch
? how-cygwin-options-work.txt
? key_t.patch
? localworkingstuff.patch
? merge.log
? new
? sem.cc
? perthread.cc
? profiling.diff
? t.t
? how-profiling-works.txt
? run_dtors.patch
? include/sys/sem.h
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/Makefile.in,v
retrieving revision 1.87
diff -u -p -r1.87 Makefile.in
--- Makefile.in	18 May 2002 06:10:16 -0000	1.87
+++ Makefile.in	26 May 2002 13:25:41 -0000
@@ -47,13 +47,15 @@ INSTALL_PROGRAM:=@INSTALL_PROGRAM@
 MT_SAFE:=@MT_SAFE@
 DEFS:=@DEFS@
 
-CC:=@CC@
+CC:=@CC@ -pg -Dregparm\(x\)=unused
+CCNOPROF:=@CC@
 # FIXME: Which is it, CC or CC_FOR_TARGET?
 CC_FOR_TARGET:=$(CC)
 CFLAGS:=@CFLAGS@
 CFLAGS+=-MMD -fbuiltin
-CXX:=@CXX@
+CXX:=@CXX@ -pg -Dregparm\(x\)=unused
 CXXFLAGS:=@CXXFLAGS@
+CXXNOPROF:=@CXX@
 
 # For linking mount, etc. crt0.o isn't accessable in a fresh build.
 EXE_LDFLAGS:=@EXE_LDFLAGS@
@@ -92,11 +94,14 @@ RUNTESTFLAGS =
 # native rebuilding issues (we don't want the build tools to see a partially
 # built cygwin.dll and attempt to use it instead of the old one).
 
+
 DLL_NAME:=cygwin1.dll
 LIB_NAME:=libcygwin.a
 DEF_FILE:=cygwin.def
 DLL_ENTRY:=@DLL_ENTRY@
 
+GMONDLL_NAME:=cyggmon.dll
+GMONDEF_FILE:=gmon.def
 LIBGMON_A:=libgmon.a
 GMON_START:=gcrt0.o
 
@@ -111,6 +116,9 @@ LIBCOS:=${sort ${addsuffix .o,${basename
 
 EXTRA_DLL_OFILES:=${addsuffix .o,${basename ${notdir ${wildcard $(CONFIG_DIR)/*.c}}}}
 
+# Profile cygwin1.dll
+EXTRA_DLL_OFILES+= $(LIBGMON_A)
+
 EXTRA_OFILES=$(bupdir1)/libiberty/random.o $(bupdir1)/libiberty/strsignal.o
 
 MALLOC_OFILES=@MALLOC_OFILES@
@@ -128,15 +136,31 @@ DLL_OFILES:=assert.o autoload.o cygheap.
 	fhandler_tape.o fhandler_termios.o fhandler_tty.o fhandler_virtual.o \
 	fhandler_windows.o fhandler_zero.o fnmatch.o fork.o glob.o grp.o \
 	heap.o init.o ioctl.o ipc.o localtime.o malloc.o miscfuncs.o mmap.o \
-	net.o ntea.o passwd.o path.o pinfo.o pipe.o poll.o pthread.o regcomp.o \
+	net.o ntea.o passwd.o path.o \
+	perthread.o \
+	pinfo.o pipe.o poll.o pthread.o regcomp.o \
 	regerror.o regexec.o regfree.o registry.o resource.o scandir.o sched.o \
-	sec_acl.o sec_helper.o security.o select.o shared.o shm.o shortcut.o \
+	sec_acl.o sec_helper.o sem.o security.o select.o shared.o shm.o \
+	shortcut.o \
 	signal.o sigproc.o smallprint.o spawn.o strace.o strsep.o sync.o \
 	syscalls.o sysconf.o syslog.o termios.o thread.o times.o tty.o uinfo.o \
 	uname.o v8_regexp.o v8_regerror.o v8_regsub.o wait.o wincap.o window.o \
 	$(EXTRA_DLL_OFILES) $(EXTRA_OFILES) $(MALLOC_OFILES) $(MT_SAFE_OBJECTS)
 
-GMON_OFILES:=gmon.o mcount.o profil.o
+# mcount.o goes in the static lib
+GMON_OFILES:=gmon.o mcountdll.o profil.o
+
+mcount.o: mcount.c
+	$(CCNOPROF) $c -nostdinc $(ALL_CFLAGS) $(GCC_INCLUDE)  -o $(@D)/$(*F)$o $<
+
+mcountdll.o: mcount.c
+	$(CCNOPROF) $c -nostdinc $(ALL_CFLAGS) $(GCC_INCLUDE) -DGMONDECL="extern __declspec (dllexport)" -o $(@D)/$(*F)$o $<
+
+gmon.o: gmon.c
+	$(CCNOPROF) $c -nostdinc $(ALL_CFLAGS) $(GCC_INCLUDE)  -o $(@D)/$(*F)$o $<
+
+profil.o: profil.c
+	$(CCNOPROF) $c -nostdinc $(ALL_CFLAGS) $(GCC_INCLUDE)  -o $(@D)/$(*F)$o $<
 
 OBSOLETE_FUNCTIONS:=regcomp regerror regexec regfree regsub
 NEW_FUNCTIONS:=regcomp posix_regcomp \
@@ -162,7 +186,9 @@ all: all_target $(all_host)
 
 all_target: $(TARGET_LIBS) cygserver.exe
 
-all_host: new-$(LIB_NAME) cygrun.exe
+all_host: new-$(LIB_NAME) $(LIBGMON_A)
+
+#cygrun.exe
 
 force:
 
@@ -173,6 +199,7 @@ uninstall: uninstall-libs uninstall-head
 
 install-libs: $(TARGET_LIBS)
 	$(INSTALL_DATA) new-$(DLL_NAME) $(bindir)/$(DLL_NAME); \
+	$(INSTALL_DATA) new-$(GMONDLL_NAME) $(bindir)/$(GMONDLL_NAME);\
 	for i in $^; do \
 	    $(INSTALL_DATA) $$i $(tooldir)/lib/`basename $$i` ; \
 	done
@@ -209,6 +236,7 @@ install_host:
 
 uninstall-libs: $(TARGET_LIBS)
 	rm -f $(bindir)/$(DLL_NAME); \
+	rm -f $(bindir)/$(GMONDLL_NAME); \
 	for i in $^; do \
 	    rm -f $(tooldir)/lib/$$i ; \
 	done
@@ -259,6 +287,17 @@ $(LIB_NAME): rmsym newsym new-$(DLL_NAME
 	/bin/sh ${word 2,$^} ./cygdll.a "$(AS)" "$(AR)" "$(RANLIB)" $(NEW_FUNCTIONS) || exit 0
 	(echo create $(LIB_NAME); echo addmod $(LIBCOS); echo addlib cygdll.a; echo save) | $(AR) -M
 
+# Rule to build cyggmon.dll
+new-$(GMONDLL_NAME): $(GMON_OFILES) $(GMONDEF_FILE) $(LIB_NAME) Makefile
+	$(CXX) $(CXXFLAGS) -nostdlib -Wl,--out-implib,gmondll.a -shared -o $@ \
+	$(GMONDEF_FILE) $(GMON_OFILES) $(LIB_NAME) $(DLL_IMPORTS)
+
+# Rule to build libgmon.a (which needs a real mcount + the imports for
+# cyggmon.dll
+
+$(LIBGMON_A): new-$(GMONDLL_NAME) mcount.o
+	(echo create $(LIBGMON_A); echo addmod mcount.o; echo addlib gmondll.a; echo save) | $(AR) -M
+
 # Rule to make stub library used by testsuite
 # dependency set to $(LIB_NAME) to accommodate make -j2.
 # Otherwise dlltool gets confused. cgf (11-16-2000)
@@ -269,9 +308,6 @@ new-$(LIB_NAME): $(LIB_NAME)
 
 dll_ofiles: $(DLL_OFILES)
 
-$(LIBGMON_A): $(GMON_OFILES) $(GMON_START)
-	$(AR) rcv $(LIBGMON_A) $(GMON_OFILES)
-
 version.cc winver.o: winver_stamp
 	@ :
 
@@ -304,8 +340,8 @@ winver_stamp: mkvers.sh include/cygwin/v
 	touch $@
 
 cygrun.exe : cygrun.o $(LIB_NAME) $(w32api_lib)/libuser32.a \
-	     $(w32api_lib)/libshell32.a $(w32api_lib)/libkernel32.a
-	$(CC) -nodefaultlibs -o $@ $^
+	     $(w32api_lib)/libshell32.a $(w32api_lib)/libkernel32.a 
+	$(CC) -nodefaultlibs -o $@ $^ 
 
 cygserver_transport_outside.o: cygserver_transport.cc
 	$(COMPILE_CXX) -D__OUTSIDE_CYGWIN__ -o $@ $<
@@ -322,8 +358,11 @@ cygserver_client_outside.o: cygserver_cl
 cygserver_shm.o: cygserver_shm.cc
 	$(COMPILE_CXX) -D__OUTSIDE_CYGWIN__ -o $@ $<
 
-cygserver.exe: cygserver.o cygserver_shm.o cygserver_transport_outside.o cygserver_transport_pipes_outside.o cygserver_transport_sockets_outside.o cygserver_client_outside.o cygserver_process.o threaded_queue.o wincap.o version.o smallprint.o
-	$(CXX) -o $@ $^
+cygserver_sem.o: cygserver_sem.cc
+	$(COMPILE_CXX) -D__OUTSIDE_CYGWIN__ -o $@ $<
+
+cygserver.exe: cygserver.o cygserver_sem.o cygserver_shm.o cygserver_transport_outside.o cygserver_transport_pipes_outside.o cygserver_transport_sockets_outside.o cygserver_client_outside.o cygserver_process.o threaded_queue.o wincap.o version.o smallprint.o 
+	$(CXX) -o $@ $^ -limagehlp
 #ifdef VERBOSE
 #	$(CXX) $(MINGW_CXXFLAGS) -o $@ ${wordlist 1,3,$^} -B$(mingw_build)/ $(MINGW_LDFLAGS)
 #else
Index: child_info.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/child_info.h,v
retrieving revision 1.29
diff -u -p -r1.29 child_info.h
--- child_info.h	10 Feb 2002 13:50:13 -0000	1.29
+++ child_info.h	26 May 2002 13:25:42 -0000
@@ -8,6 +8,9 @@ This software is a copyrighted work lice
 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
 details. */
 
+#ifndef _CHILD_INFO_H_
+#define _CHILD_INFO_H_
+
 #include <setjmp.h>
 
 enum
@@ -109,3 +112,5 @@ public:
 void __stdcall init_child_info (DWORD, child_info *, int, HANDLE);
 
 extern child_info_fork *child_proc_info;
+
+#endif /* _CHILD_INFO_H_ */
Index: configure
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/configure,v
retrieving revision 1.12
diff -u -p -r1.12 configure
--- configure	20 Dec 2001 02:55:08 -0000	1.12
+++ configure	26 May 2002 13:25:43 -0000
@@ -2124,7 +2124,7 @@ done
 ac_given_srcdir=$srcdir
 ac_given_INSTALL="$INSTALL"
 
-trap 'rm -fr `echo "Makefile cygwin.def:cygwin.din config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+trap 'rm -fr `echo "Makefile cygwin.def:cygwin.din gmon.def:gmon.din config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
 EOF
 cat >> $CONFIG_STATUS <<EOF
 
@@ -2235,7 +2235,7 @@ EOF
 
 cat >> $CONFIG_STATUS <<EOF
 
-CONFIG_FILES=\${CONFIG_FILES-"Makefile cygwin.def:cygwin.din"}
+CONFIG_FILES=\${CONFIG_FILES-"Makefile cygwin.def:cygwin.din gmon.def:gmon.din"}
 EOF
 cat >> $CONFIG_STATUS <<\EOF
 for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
Index: configure.in
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/configure.in,v
retrieving revision 1.13
diff -u -p -r1.13 configure.in
--- configure.in	20 Dec 2001 02:55:08 -0000	1.13
+++ configure.in	26 May 2002 13:25:43 -0000
@@ -253,5 +253,5 @@ AC_SUBST(DLL_ENTRY)
 AC_SUBST(DEF_DLL_ENTRY)
 AC_SUBST(ALLOCA)
 AC_SUBST(CONFIG_DIR)
-AC_OUTPUT(Makefile cygwin.def:cygwin.din)
+AC_OUTPUT(Makefile cygwin.def:cygwin.din gmon.def:gmon.din)
 
Index: cygerrno.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/cygerrno.h,v
retrieving revision 1.7
diff -u -p -r1.7 cygerrno.h
--- cygerrno.h	22 Oct 2001 21:09:41 -0000	1.7
+++ cygerrno.h	26 May 2002 13:25:43 -0000
@@ -8,6 +8,9 @@ This software is a copyrighted work lice
 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
 details. */
 
+#ifndef _CYGERRNO_H_
+#define _CYGERRNO_H_
+
 void __stdcall seterrno_from_win_error (const char *file, int line, DWORD code) __attribute__ ((regparm(3)));
 void __stdcall seterrno (const char *, int line) __attribute__ ((regparm(2)));
 int __stdcall geterrno_from_win_error (DWORD code, int deferrno) __attribute__ ((regparm(2)));
@@ -37,3 +40,5 @@ class save_errno
 
 extern const char *__sp_fn;
 extern int __sp_ln;
+
+#endif /* _CYGERRNO_H_ */
Index: cygheap.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/cygheap.h,v
retrieving revision 1.38
diff -u -p -r1.38 cygheap.h
--- cygheap.h	8 May 2002 14:21:08 -0000	1.38
+++ cygheap.h	26 May 2002 13:25:44 -0000
@@ -8,6 +8,16 @@ This software is a copyrighted work lice
 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
 details. */
 
+#ifndef _CYGHEAP_H_
+#define _CYGHEAP_H_
+
+#include "path.h"
+#include "dtable.h"
+/* for set_errno */
+#include "cygerrno.h"
+/* for various errnumbers */
+#include <errno.h>
+
 #undef cfree
 
 enum cygheap_types
@@ -273,3 +283,5 @@ char *__stdcall cstrdup (const char *) _
 char *__stdcall cstrdup1 (const char *) __attribute__ ((regparm(1)));
 void __stdcall cygheap_init ();
 }
+
+#endif /* _CYGHEAP_H_ */
Index: cygserver.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/cygserver.cc,v
retrieving revision 1.4
diff -u -p -r1.4 cygserver.cc
--- cygserver.cc	15 Mar 2002 21:52:05 -0000	1.4
+++ cygserver.cc	26 May 2002 13:25:44 -0000
@@ -31,6 +31,7 @@
 #include "cygwin/cygserver_process.h"
 #include "cygwin/cygserver.h"
 #include "cygserver_shm.h"
+#include "cygserver_sem.h"
 
 /* for quieter operation, set to 0 */
 #define DEBUG 0
@@ -158,6 +159,8 @@ out:
 void
 client_request::serve (transport_layer_base *conn, class process_cache *cache)
 {
+  if (header.req_id == CYGSERVER_REQUEST_INVALID)
+    return;
   printf ("*****************************************\n"
 	  "A call to the base client_request class has occured\n"
 	  "This indicates a mismatch in a virtual function definition somewhere\n");
@@ -365,7 +368,9 @@ server_request::process ()
     case CYGSERVER_REQUEST_SHUTDOWN:
       req = new client_request_shutdown (); break;
     case CYGSERVER_REQUEST_SHM_GET:
-     req = new client_request_shm (); break;
+      req = new client_request_shm (); break;
+    case CYGSERVER_REQUEST_SEM:
+      req = new client_request_sem (); break; 
     default:
       req = new client_request (CYGSERVER_REQUEST_INVALID, 0);
       req->header.error_code = ENOSYS;
@@ -374,8 +379,22 @@ server_request::process ()
 
   if (req->header.cb != req_ptr->cb)
     {
-      debug_printf ("Mismatch in request buffer sizes\n");
-      goto out;
+      if (req->header.req_id == CYGSERVER_REQUEST_INVALID)
+	{
+	  // suck the connection dry
+	  char tempbuf[req_ptr->cb];
+	  bytes_read = conn->read (&tempbuf[0], req_ptr->cb);
+	  if (bytes_read != req_ptr->cb)
+	    {
+	      debug_printf ("error reading %ld / %ld from connection (%lu)\n", bytes_read,req_ptr->cb, GetLastError ());
+	      goto out;
+	    }
+	}
+      else
+	{
+          debug_printf ("Mismatch in request buffer sizes\n");
+          goto out;
+	}
     }
 
   if (req->header.cb)
Index: cygwin.din
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/cygwin.din,v
retrieving revision 1.46
diff -u -p -r1.46 cygwin.din
--- cygwin.din	13 May 2002 19:53:46 -0000	1.46
+++ cygwin.din	26 May 2002 13:25:45 -0000
@@ -1252,3 +1252,11 @@ acltotext
 _acltotext = acltotext
 aclfromtext
 _aclfromtext = aclfromtext
+ftok
+shmat
+shmctl
+shmdt
+shmget
+semctl
+semget
+semop
Index: debug.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/debug.cc,v
retrieving revision 1.31
diff -u -p -r1.31 debug.cc
--- debug.cc	22 Feb 2002 19:33:41 -0000	1.31
+++ debug.cc	26 May 2002 13:25:45 -0000
@@ -38,6 +38,8 @@ void
 threadname_init ()
 {
   new_muto (threadname_lock);
+//  static muto threadname_lock##_storage __attribute__((nocommon)) __attribute__((section(".data_cygwin_nocopy")));
+//  threadname_lock = threadname_lock##_storage (threadname_lock);
 }
 
 void __stdcall
Index: dtable.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/dtable.h,v
retrieving revision 1.17
diff -u -p -r1.17 dtable.h
--- dtable.h	24 May 2002 05:44:10 -0000	1.17
+++ dtable.h	26 May 2002 13:25:45 -0000
@@ -8,6 +8,9 @@ This software is a copyrighted work lice
 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
 details. */
 
+#ifndef _DTABLE_H_
+#define _DTABLE_H_
+
 /* Initial and increment values for cygwin's fd table */
 #define NOFILE_INCR    32
 
@@ -86,3 +89,5 @@ extern dtable fdtab;
 
 extern "C" int getfdtabsize ();
 extern "C" void setfdtabsize (int);
+
+#endif /* _DTABLE_H_ */
Index: fhandler.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler.h,v
retrieving revision 1.117
diff -u -p -r1.117 fhandler.h
--- fhandler.h	24 May 2002 05:44:10 -0000	1.117
+++ fhandler.h	26 May 2002 13:25:46 -0000
@@ -12,6 +12,7 @@ details. */
 #define _FHANDLER_H_
 
 #include <sys/ioctl.h>
+#include "security.h"
 
 enum
 {
Index: gcrt0.c
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/gcrt0.c,v
retrieving revision 1.5
diff -u -p -r1.5 gcrt0.c
--- gcrt0.c	11 Sep 2001 20:01:00 -0000	1.5
+++ gcrt0.c	26 May 2002 13:25:46 -0000
@@ -10,14 +10,37 @@ details. */
 
 #include <sys/types.h>
 #include <stdlib.h>
+#include <unistd.h>
+#include <windows.h>
+#include <imagehlp.h>
+
+#define ERR(s) write(2, s, sizeof(s))
 
 extern u_char etext asm ("etext");
 extern u_char eprol asm ("__eprol");
-extern void _mcleanup (void);
-extern void monstartup (u_long, u_long);
+extern void __declspec (dllimport) _mcleanup (void);
+extern void __declspec (dllimport) monstartup (u_long, u_long);
 
 void _monstartup (void) __attribute__((__constructor__));
 
+static ULONG lowpc=0;
+static ULONG highpc=0;
+
+/* find the low and high pc address's */
+BOOL CALLBACK EnumerateLoadedModulesProc (PSTR name, ULONG base, ULONG size, PVOID unused)
+{
+  if (lowpc == 0)
+    {
+      lowpc = base;
+      highpc = base + size;
+    }
+  else if (lowpc > base)
+    lowpc = base;
+  else if (highpc < base + size)
+    highpc = base + size;
+  return TRUE;
+}
+
 /* startup initialization for -pg support */
 
 void
@@ -32,7 +55,14 @@ _monstartup (void)
   if (called++)
     return;
 
-  monstartup ((u_long) &eprol, (u_long) &etext);
+  if (EnumerateLoadedModules (GetCurrentProcess(), EnumerateLoadedModulesProc, 0) == FALSE)
+    {
+      ERR("Enumerate Loaded Modules failed\n");
+      monstartup ((u_long) &eprol, (u_long) &etext);
+    }
+  else
+    monstartup (lowpc,highpc);
+//  monstartup ((u_long) &eprol, (u_long) &etext);
   atexit (&_mcleanup);
 }
 
Index: gmon.c
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/gmon.c,v
retrieving revision 1.5
diff -u -p -r1.5 gmon.c
--- gmon.c	24 May 2002 14:24:33 -0000	1.5
+++ gmon.c	26 May 2002 13:25:46 -0000
@@ -41,6 +41,7 @@ static char rcsid[] = "$OpenBSD: gmon.c,
 #include <unistd.h>
 #include <sys/param.h>
 #include <sys/types.h>
+#define GMONDECL extern __declspec (dllexport)
 #include <gmon.h>
 
 #include <profil.h>
@@ -62,14 +63,14 @@ void	moncontrol __P((int));
 static void *
 fake_sbrk(int size)
 {
-    void *rv = malloc(size);
+    void *rv = VirtualAlloc (0, size, MEM_COMMIT, PAGE_READWRITE);
     if (rv)
       return rv;
     else
       return (void *) -1;
 }
 
-void
+void __declspec (dllexport)
 monstartup(lowpc, highpc)
 	u_long lowpc;
 	u_long highpc;
@@ -86,8 +87,12 @@ monstartup(lowpc, highpc)
 	p->highpc = ROUNDUP(highpc, HISTFRACTION * sizeof(HISTCOUNTER));
 	p->textsize = p->highpc - p->lowpc;
 	p->kcountsize = p->textsize / HISTFRACTION;
+//	if (p->kcountsize > 50000000)
+//	  p->kcountsize = 50000000;
 	p->hashfraction = HASHFRACTION;
 	p->fromssize = p->textsize / p->hashfraction;
+//	if (p->fromssize > 50000000)
+//	  p->fromssize = 50000000;
 	p->tolimit = p->textsize * ARCDENSITY / 100;
 	if (p->tolimit < MINARCS)
 		p->tolimit = MINARCS;
@@ -98,6 +103,7 @@ monstartup(lowpc, highpc)
 	cp = fake_sbrk(p->kcountsize + p->fromssize + p->tossize);
 	if (cp == (char *)-1) {
 		ERR("monstartup: out of memory\n");
+		p->state = GMON_PROF_ERROR;
 		return;
 	}
 #ifdef notdef
@@ -135,7 +141,7 @@ monstartup(lowpc, highpc)
 	moncontrol(1);
 }
 
-void
+void __declspec (dllexport)
 _mcleanup()
 {
 	int fd;
@@ -154,7 +160,10 @@ _mcleanup()
 #endif
 
 	if (p->state == GMON_PROF_ERROR)
-		ERR("_mcleanup: tos overflow\n");
+	  {
+	    ERR("_mcleanup: tos overflow\n");
+	    return;
+	  }
 
 	hz = PROF_HZ;
 	moncontrol(0);
Index: gmon.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/gmon.h,v
retrieving revision 1.2
diff -u -p -r1.2 gmon.h
--- gmon.h	24 Jun 2001 22:26:51 -0000	1.2
+++ gmon.h	26 May 2002 13:25:46 -0000
@@ -66,7 +66,8 @@ struct gmonhdr {
 /*
  * fraction of text space to allocate for histogram counters here, 1/2
  */
-#define	HISTFRACTION	2
+#define	HISTFRACTION	20
+# 2
 
 /*
  * Fraction of text space to allocate for from hash buckets.
@@ -96,8 +97,8 @@ struct gmonhdr {
  * profiling data structures without (in practice) sacrificing
  * any granularity.
  */
-#define	HASHFRACTION	2
-
+#define	HASHFRACTION	20
+# 2
 /*
  * percent of text space to allocate for tostructs with a minimum.
  */
@@ -145,7 +146,11 @@ struct gmonparam {
 	u_long		textsize;
 	u_long		hashfraction;
 };
-extern struct gmonparam _gmonparam;
+
+#ifndef GMONDECL
+#define GMONDECL extern __declspec (dllimport)
+#endif
+GMONDECL struct gmonparam _gmonparam;
 
 /*
  * Possible states of profiling.
Index: mcount.c
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/mcount.c,v
retrieving revision 1.3
diff -u -p -r1.3 mcount.c
--- mcount.c	24 Jun 2001 22:26:51 -0000	1.3
+++ mcount.c	26 May 2002 13:25:46 -0000
@@ -76,6 +76,8 @@ _MCOUNT_DECL(frompc, selfpc)	/* _mcount;
 	 * for example:	signal catchers get called from the stack,
 	 *		not from text space.  too bad.
 	 */
+	if (frompc < p->lowpc)
+	    goto done;
 	frompc -= p->lowpc;
 	if (frompc > p->textsize)
 		goto done;
@@ -169,5 +171,10 @@ overflow:
  * Actual definition of mcount function.  Defined in <machine/profile.h>,
  * which is included by <sys/gmon.h>
  */
-MCOUNT
+// MCOUNT
 
+
+void mcount(void)
+{
+  _mcount (__builtin_return_address (1), __builtin_return_address (0));
+}
Index: path.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/path.h,v
retrieving revision 1.42
diff -u -p -r1.42 path.h
--- path.h	24 May 2002 05:44:10 -0000	1.42
+++ path.h	26 May 2002 13:25:46 -0000
@@ -8,6 +8,11 @@ This software is a copyrighted work lice
 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
 details. */
 
+#ifndef _PATH_H_
+#define _PATH_H_
+
+#include "fhandler.h"
+
 struct suffix_info
 {
   const char *name;
@@ -190,3 +195,5 @@ int pathmatch (const char *path1, const 
 int pathnmatch (const char *path1, const char *path2, int len) __attribute__ ((regparm (2)));
 
 int path_prefix_p (const char *path1, const char *path2, int len1) __attribute__ ((regparm (3)));
+
+#endif /* _PATH_H_ */
Index: perthread.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/perthread.h,v
retrieving revision 1.8
diff -u -p -r1.8 perthread.h
--- perthread.h	30 Nov 2001 06:19:58 -0000	1.8
+++ perthread.h	26 May 2002 13:25:46 -0000
@@ -10,6 +10,16 @@ This software is a copyrighted work lice
 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
 details. */
 
+#include "winsup.h"
+#include "exceptions.h"
+#include "sync.h"
+#include "sigproc.h"
+#include "pinfo.h"
+#ifdef NEED_VFORK
+#include "cygheap.h"
+#include "child_info.h"
+#endif
+
 #define PTMAGIC 0x77366377
 
 struct _reent;
@@ -41,7 +51,7 @@ public:
 class per_thread_waitq : public per_thread
 {
 public:
-  per_thread_waitq () : per_thread (0) {}
+  per_thread_waitq ();
   void *get () {return (waitq *) this->per_thread::get ();}
   void *create () {return (waitq *) this->per_thread::create ();}
   size_t size () {return sizeof (waitq);}
@@ -61,6 +71,7 @@ struct vfork_save
 class per_thread_vfork : public per_thread
 {
 public:
+  per_thread_vfork();
   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);}
@@ -86,6 +97,7 @@ struct signal_dispatch
 
 struct per_thread_signal_dispatch : public per_thread
 {
+  per_thread_signal_dispatch();
   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);}
Index: pinfo.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/pinfo.h,v
retrieving revision 1.37
diff -u -p -r1.37 pinfo.h
--- pinfo.h	18 May 2002 20:27:49 -0000	1.37
+++ pinfo.h	26 May 2002 13:25:47 -0000
@@ -8,6 +8,9 @@ This software is a copyrighted work lice
 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
 details. */
 
+#ifndef _PINFO_H_
+#define _PINFO_H_
+
 /* Signal constants (have to define them here, unfortunately) */
 
 enum
@@ -206,3 +209,5 @@ int __stdcall fixup_shms_after_fork ();
 
 void __stdcall fill_rusage (struct rusage *, HANDLE);
 void __stdcall add_rusage (struct rusage *, struct rusage *);
+
+#endif /* _PINFO_H_ */
Index: security.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/security.cc,v
retrieving revision 1.90
diff -u -p -r1.90 security.cc
--- security.cc	21 May 2002 14:50:26 -0000	1.90
+++ security.cc	26 May 2002 13:25:48 -0000
@@ -1663,3 +1663,10 @@ set_file_attribute (int use_ntsec, const
 			     myself->uid, myself->gid,
 			     attribute, cygheap->user.logsrv ());
 }
+
+cygsid::cygsid () : psid ((PSID) sbuf) {}
+cygsid::cygsid (const PSID nsid) { *this = nsid; }
+cygsid::cygsid (const char *nstrsid) { *this = nstrsid; }
+
+const PSID cygsid::operator= (const char *nsidstr)
+    { return getfromstr (nsidstr); }
Index: security.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/security.h,v
retrieving revision 1.23
diff -u -p -r1.23 security.h
--- security.h	16 May 2002 09:30:48 -0000	1.23
+++ security.h	26 May 2002 13:25:48 -0000
@@ -8,6 +8,9 @@ This software is a copyrighted work lice
 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
 details. */
 
+#ifndef _SECURITY_H_
+#define _SECURITY_H_
+
 #define DONT_INHERIT (0)
 #define INHERIT_ALL  (CONTAINER_INHERIT_ACE|OBJECT_INHERIT_ACE)
 #define INHERIT_ONLY (INHERIT_ONLY_ACE|CONTAINER_INHERIT_ACE|OBJECT_INHERIT_ACE)
@@ -47,12 +50,11 @@ public:
     { return assign (nsid); }
   inline const PSID operator= (const PSID nsid)
     { return assign (nsid); }
-  inline const PSID operator= (const char *nsidstr)
-    { return getfromstr (nsidstr); }
+  const PSID operator= (const char *nsidstr);
 
-  inline cygsid () : psid ((PSID) sbuf) {}
-  inline cygsid (const PSID nsid) { *this = nsid; }
-  inline cygsid (const char *nstrsid) { *this = nstrsid; }
+  cygsid ();
+  cygsid (const PSID nsid);
+  cygsid (const char *nstrsid);
 
   inline PSID set () { return psid = (PSID) sbuf; }
 
@@ -223,3 +225,5 @@ sec_user (char sa_buf[], PSID sid = NULL
 {
   return allow_ntsec ? __sec_user (sa_buf, sid, TRUE) : &sec_none_nih;
 }
+
+#endif /* _SECURITY_H_ */
Index: sigproc.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/sigproc.h,v
retrieving revision 1.48
diff -u -p -r1.48 sigproc.h
--- sigproc.h	13 Jan 2002 20:03:03 -0000	1.48
+++ sigproc.h	26 May 2002 13:25:48 -0000
@@ -8,6 +8,9 @@ This software is a copyrighted work lice
 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
 details. */
 
+#ifndef _SIGPROC_H_
+#define _SIGPROC_H_
+
 #include <signal.h>
 
 #define EXIT_SIGNAL	 0x010000
@@ -124,3 +127,5 @@ extern char myself_nowait_nonmain_dummy[
 
 #define myself_nowait ((_pinfo *)myself_nowait_dummy)
 #define myself_nowait_nonmain ((_pinfo *)myself_nowait_nonmain_dummy)
+
+#endif /* _SIGPROG_H_ */
Index: sync.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/sync.h,v
retrieving revision 1.20
diff -u -p -r1.20 sync.h
--- sync.h	22 Feb 2002 19:33:41 -0000	1.20
+++ sync.h	26 May 2002 13:25:49 -0000
@@ -10,6 +10,9 @@ This software is a copyrighted work lice
 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
 details. */
 
+#ifndef _SYNC_H_
+#define _SYNC_H_
+
 /* FIXME: Note that currently this class cannot be allocated via `new' since
    there are issues with malloc and fork. */
 class muto
@@ -47,3 +50,5 @@ extern muto muto_start;
   static muto __name##_storage __attribute__((nocommon)) __attribute__((section(".data_cygwin_nocopy"))); \
   __name = __name##_storage.init (#__name); \
 })
+
+#endif /* _SYNC_H_ */
Index: thread.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/thread.cc,v
retrieving revision 1.66
diff -u -p -r1.66 thread.cc
--- thread.cc	2 May 2002 11:26:22 -0000	1.66
+++ thread.cc	26 May 2002 13:25:49 -0000
@@ -48,6 +48,14 @@ details. */
 
 extern int threadsafe;
 
+/* MTinterface */
+MTinterface::MTinterface ():reent_index (0), indexallocated (0), threadcount (1)
+{
+  pthread_prepare = NULL;
+  pthread_child   = NULL;
+  pthread_parent  = NULL;
+}
+
 /*pthread_key_destructor_list class: to-be threadsafe single linked list
  *FIXME: Put me in a dedicated file, or a least a tools area !
  */
Index: thread.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/thread.h,v
retrieving revision 1.33
diff -u -p -r1.33 thread.h
--- thread.h	10 Feb 2002 13:50:13 -0000	1.33
+++ thread.h	26 May 2002 13:25:50 -0000
@@ -381,12 +381,7 @@ public:
   void Init (int);
   void fixup_after_fork (void);
 
-    MTinterface ():reent_index (0), indexallocated (0), threadcount (1)
-  {
-    pthread_prepare = NULL;
-    pthread_child   = NULL;
-    pthread_parent  = NULL;
-  }
+    MTinterface ();
 };
 
 void __pthread_atforkprepare(void);
Index: winsup.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/winsup.h,v
retrieving revision 1.89
diff -u -p -r1.89 winsup.h
--- winsup.h	2 May 2002 04:13:48 -0000	1.89
+++ winsup.h	26 May 2002 13:25:50 -0000
@@ -8,6 +8,9 @@ This software is a copyrighted work lice
 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
 details. */
 
+#ifndef _WINSUP_H_
+#define _WINSUP_H_
+
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
@@ -228,9 +231,6 @@ extern void multiple_cygwin_problem (con
 extern "C" void __malloc_lock (struct _reent *);
 extern "C" void __malloc_unlock (struct _reent *);
 
-extern "C" void __malloc_lock (struct _reent *);
-extern "C" void __malloc_unlock (struct _reent *);
-
 class path_conv;
 int __stdcall stat_worker (const char *name, struct __stat64 *buf, int nofollow,
 			   path_conv *pc = NULL) __attribute__ ((regparm (3)));
@@ -289,3 +289,4 @@ extern HMODULE cygwin_hmodule;
 extern struct WSAData wsadata;
 
 #endif /* defined __cplusplus */
+#endif /* _WINSUP_H_ */
Index: config/i386/profile.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/config/i386/profile.h,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 profile.h
--- config/i386/profile.h	17 Feb 2000 19:38:31 -0000	1.1.1.1
+++ config/i386/profile.h	26 May 2002 13:25:50 -0000
@@ -37,6 +37,7 @@
 
 #define	_MCOUNT_DECL static inline void _mcount
 
+#if 0
 #define	MCOUNT \
 void									\
 mcount()								\
@@ -55,4 +56,4 @@ mcount()								\
 	__asm("movl (%%ebp),%0;movl 4(%0),%0" : "=r" (frompcindex));	\
 	_mcount(frompcindex, selfpc);					\
 }
-
+#endif
Index: include/cygwin/cygserver.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/include/cygwin/cygserver.h,v
retrieving revision 1.3
diff -u -p -r1.3 cygserver.h
--- include/cygwin/cygserver.h	13 Mar 2002 02:34:05 -0000	1.3
+++ include/cygwin/cygserver.h	26 May 2002 13:25:50 -0000
@@ -33,6 +33,7 @@ typedef enum {
   CYGSERVER_REQUEST_ATTACH_TTY,
   CYGSERVER_REQUEST_SHUTDOWN,
   CYGSERVER_REQUEST_SHM_GET,
+  CYGSERVER_REQUEST_SEM,
   CYGSERVER_REQUEST_LAST
 } cygserver_request_code;
 
Index: include/cygwin/cygserver_transport_pipes.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/include/cygwin/cygserver_transport_pipes.h,v
retrieving revision 1.3
diff -u -p -r1.3 cygserver_transport_pipes.h
--- include/cygwin/cygserver_transport_pipes.h	13 Mar 2002 02:34:05 -0000	1.3
+++ include/cygwin/cygserver_transport_pipes.h	26 May 2002 13:25:50 -0000
@@ -29,11 +29,11 @@ class transport_layer_pipes : public tra
   private:
     /* for pipe based communications */
     void init_security ();
-    SECURITY_DESCRIPTOR sd;
-    SECURITY_ATTRIBUTES sec_none_nih, sec_all_nih;
+    transport_layer_pipes (HANDLE new_pipe);
     char pipe_name [MAX_PATH];
     HANDLE pipe;
+    SECURITY_DESCRIPTOR sd;
+    SECURITY_ATTRIBUTES sec_none_nih, sec_all_nih;
     bool inited;
-    transport_layer_pipes (HANDLE new_pipe);
 };
 #endif /* _CYGSERVER_TRANSPORT_PIPES_ */
