From 1809b65e23777b594936915264cc0bcfb78ff622 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Mon, 2 Jul 2012 02:24:25 +0000 Subject: [PATCH] * Makefile.in: Add some more optimization flags for cygwait, malloc and path. Explain why -fomit-frame-pointer doesn't work right for passwd.o and path.o. Add -static to link command line for cygwin0.dll. * fhandler_disk_file.cc (fhandler_disk_file::facl): Reorganize slightly to silence compiler warning when compiling with -fstack-check. * net.cc (inet_ntop6): Initialize structure members to silence compiler warning when compiling with -fstack-check. * pseudo-reloc.cc (_pei386_runtime_relocator): Make this a C function. Detect NULL u. * winsup.h (_pei386_runtime_relocator): Declare this as extern "C". * lib/_cygwin_crt0_common.cc (_pei386_runtime_relocator): Call with NULL argument. * signal.cc (sigaction_worker): Eliminate last argument. Let callers report their own strace info. Regparmize. (sigaction): Reflect sigaction_worker changes. (siginterrupt): Ditto. * exceptions.cc: Update copyright. --- winsup/cygwin/ChangeLog | 24 ++++++++++++++++++++++++ winsup/cygwin/Makefile.in | 15 ++++++++++++--- winsup/cygwin/exceptions.cc | 2 +- winsup/cygwin/fhandler_disk_file.cc | 2 +- winsup/cygwin/lib/_cygwin_crt0_common.cc | 3 +-- winsup/cygwin/net.cc | 2 ++ winsup/cygwin/pseudo-reloc.cc | 4 ++-- winsup/cygwin/signal.cc | 15 +++++++++------ winsup/cygwin/winsup.h | 2 +- 9 files changed, 53 insertions(+), 16 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index fde2c16d0..77e54f78b 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,27 @@ +2012-07-01 Christopher Faylor + + * Makefile.in: Add some more optimization flags for cygwait, malloc and + path. Explain why -fomit-frame-pointer doesn't work right for passwd.o + and path.o. Add -static to link command line for cygwin0.dll. + + * fhandler_disk_file.cc (fhandler_disk_file::facl): Reorganize slightly + to silence compiler warning when compiling with -fstack-check. + * net.cc (inet_ntop6): Initialize structure members to silence compiler + warning when compiling with -fstack-check. + + * pseudo-reloc.cc (_pei386_runtime_relocator): Make this a C function. + Detect NULL u. + * winsup.h (_pei386_runtime_relocator): Declare this as extern "C". + * lib/_cygwin_crt0_common.cc (_pei386_runtime_relocator): Call with + NULL argument. + + * signal.cc (sigaction_worker): Eliminate last argument. Let callers + report their own strace info. Regparmize. + (sigaction): Reflect sigaction_worker changes. + (siginterrupt): Ditto. + + * exceptions.cc: Update copyright. + 2012-07-01 Christopher Faylor * path.cc: Perform some whitespace fixups throughout. diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in index 2aedb1c7b..494314be8 100644 --- a/winsup/cygwin/Makefile.in +++ b/winsup/cygwin/Makefile.in @@ -237,6 +237,7 @@ ifneq "${filter -O%,$(CFLAGS)}" "" cygheap_CFLAGS:=-fomit-frame-pointer cygthread_CFLAGS:=-fomit-frame-pointer cygtls_CFLAGS:=-fomit-frame-pointer +cygwait_CFLAGS=-fomit-frame-pointer delqueue_CFLAGS:=-fomit-frame-pointer devices_CFLAGS:=-fomit-frame-pointer -Os dir_CFLAGS:=-fomit-frame-pointer @@ -270,11 +271,19 @@ fhandler_zero_CFLAGS:=-fomit-frame-pointer flock_CFLAGS:=-fomit-frame-pointer grp_CFLAGS:=-fomit-frame-pointer libstdcxx_wrapper_CFLAGS:=-fomit-frame-pointer -malloc_CFLAGS:=-fomit-frame-pointer +malloc_CFLAGS:=-fomit-frame-pointer -O3 malloc_wrapper_CFLAGS:=-fomit-frame-pointer miscfuncs_CFLAGS:=-fomit-frame-pointer net_CFLAGS:=-fomit-frame-pointer -passwd_CFLAGS:=-fomit-frame-pointer +# +# FIXME: Setting either of the below to -fomit-frame-pointer causes an +# optimized version of Cygwin to sometimes "jump to zero" in long-running +# shell processes when compiled with gcc 4.5.3. +# +# passwd_CFLAGS:=-fomit-frame-pointer +# path_CFLAGS=-fomit-frame-pointer +# +path_CFLAGS=-fgcse-lm -fgcse-sm -fgcse-las -fgcse-after-reload regcomp_CFLAGS=-fomit-frame-pointer regerror_CFLAGS=-fomit-frame-pointer regexec_CFLAGS=-fomit-frame-pointer @@ -394,7 +403,7 @@ maintainer-clean realclean: clean # Rule to build cygwin.dll $(TEST_DLL_NAME): $(LDSCRIPT) dllfixdbg $(DLL_OFILES) $(DLL_IMPORTS) $(LIBSERVER) $(LIBC) $(LIBM) $(API_VER) Makefile winver_stamp - $(CXX) $(CXXFLAGS) -Wl,--gc-sections $(nostdlib) -Wl,-T$(firstword $^) \ + $(CXX) $(CXXFLAGS) -Wl,--gc-sections $(nostdlib) -Wl,-T$(firstword $^) -static \ -Wl,--heap=0 -Wl,--out-implib,cygdll.a -shared -o $@ \ -e $(DLL_ENTRY) $(DEF_FILE) $(DLL_OFILES) version.o winver.o \ $(MALLOC_OBJ) $(LIBSERVER) $(LIBM) $(LIBC) \ diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 4aa48c5ef..833fa4f42 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -1,7 +1,7 @@ /* exceptions.cc Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008, 2009, 2010, 2011 Red Hat, Inc. + 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc. This file is part of Cygwin. diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 2c63b6468..8ed8a8155 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -984,7 +984,6 @@ fhandler_disk_file::facl (int cmd, int nentries, __aclent32_t *aclbufp) cant_access_acl: switch (cmd) { - struct __stat64 st; case SETACL: /* Open for writing required to be able to set ctime @@ -1000,6 +999,7 @@ cant_access_acl: set_errno (ENOSPC); else { + struct __stat64 st; if (!fstat (&st)) { aclbufp[0].a_type = USER_OBJ; diff --git a/winsup/cygwin/lib/_cygwin_crt0_common.cc b/winsup/cygwin/lib/_cygwin_crt0_common.cc index d44b7c453..a0dfb8fe4 100644 --- a/winsup/cygwin/lib/_cygwin_crt0_common.cc +++ b/winsup/cygwin/lib/_cygwin_crt0_common.cc @@ -49,7 +49,6 @@ extern "C" { char **environ; int _fmode; -void _pei386_runtime_relocator (void); extern char __RUNTIME_PSEUDO_RELOC_LIST__; extern char __RUNTIME_PSEUDO_RELOC_LIST_END__; @@ -155,7 +154,7 @@ _cygwin_crt0_common (MainFunc f, per_process *u) u->image_base = &_image_base__; /* This is actually a dummy call to force the linker to load this symbol for older apps which need it. */ - _pei386_runtime_relocator (); + _pei386_runtime_relocator (NULL); return 1; } } /* "C" */ diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index 3106a8daf..5efd8d120 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -3169,6 +3169,8 @@ inet_ntop6 (const u_char *src, char *dst, size_t size) words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3)); best.base = -1; cur.base = -1; + best.len = 0; + cur.len = 0; for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) { if (words[i] == 0) diff --git a/winsup/cygwin/pseudo-reloc.cc b/winsup/cygwin/pseudo-reloc.cc index ea10d9220..06d3356c7 100644 --- a/winsup/cygwin/pseudo-reloc.cc +++ b/winsup/cygwin/pseudo-reloc.cc @@ -328,10 +328,10 @@ do_pseudo_reloc (void * start, void * end, void * base) } #ifdef __CYGWIN__ -void +extern "C" void _pei386_runtime_relocator (per_process *u) { - if (CYGWIN_VERSION_USE_PSEUDO_RELOC_IN_DLL (u)) + if (u && CYGWIN_VERSION_USE_PSEUDO_RELOC_IN_DLL (u)) do_pseudo_reloc (u->pseudo_reloc_start, u->pseudo_reloc_end, u->image_base); } #else diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc index a62c038cd..3fac7cbb0 100644 --- a/winsup/cygwin/signal.cc +++ b/winsup/cygwin/signal.cc @@ -26,7 +26,7 @@ details. */ #define _SA_NORESTART 0x8000 -static int sigaction_worker (int, const struct sigaction *, struct sigaction *, bool, const char *) +static int sigaction_worker (int, const struct sigaction *, struct sigaction *, bool) __attribute__ ((regparm (3))); #define sigtrapped(func) ((func) != SIG_IGN && (func) != SIG_DFL) @@ -390,9 +390,9 @@ abort (void) do_exit (SIGABRT); /* signal handler didn't exit. Goodbye. */ } -static int +static int __attribute__ ((regparm (3))) sigaction_worker (int sig, const struct sigaction *newact, - struct sigaction *oldact, bool isinternal, const char *fnname) + struct sigaction *oldact, bool isinternal) { int res = -1; myfault efault; @@ -445,14 +445,15 @@ sigaction_worker (int sig, const struct sigaction *newact, } out: - syscall_printf ("%R = %s(%d, %p, %p)", res, fnname, sig, newact, oldact); return res; } extern "C" int sigaction (int sig, const struct sigaction *newact, struct sigaction *oldact) { - return sigaction_worker (sig, newact, oldact, false, "sigaction"); + int res = sigaction_worker (sig, newact, oldact, false); + syscall_printf ("%R = sigaction(%d, %p, %p)", res, sig, newact, oldact); + return res; } extern "C" int @@ -549,7 +550,9 @@ siginterrupt (int sig, int flag) act.sa_flags &= ~_SA_NORESTART; act.sa_flags |= SA_RESTART; } - return sigaction_worker (sig, &act, NULL, true, "siginterrupt"); + int res = sigaction_worker (sig, &act, NULL, true); + syscall_printf ("%R = siginterrupt(%d, %p)", sig, flag); + return res; } extern "C" int diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h index 5c3660931..dff81fc6c 100644 --- a/winsup/cygwin/winsup.h +++ b/winsup/cygwin/winsup.h @@ -162,7 +162,7 @@ void dll_dllcrt0_1 (void *); /* dynamically loaded dll initialization */ extern "C" int dll_dllcrt0 (HMODULE, per_process *); -void _pei386_runtime_relocator (per_process *); +extern "C" void _pei386_runtime_relocator (per_process *); /* dynamically loaded dll initialization for non-cygwin apps */ extern "C" int dll_noncygwin_dllcrt0 (HMODULE, per_process *);