* exceptions.cc (set_signal_mask): Redefine to not pass by address. Report

calculated mask in debugging output.
* sigproc.h (set_signal_mask): Reflect above change in declaration.
* path.cc (mount_item::build_win32): Take path apart before feeding it to
fnmunge.  Throughout, change use of _reent_winsup()-> to _my_tls.locals.
instead.  Throughout, remove obsolete MT_SAFE/_CYG_THREAD_FAILSAFE
considerations.  Througout, add cygtls.h include.
* Makefile.in (DLL_OFILES): Add cygtls.o.  Add some more objects to the
-fomit-frame-pointer list.
* acconfig.h: Remove obsolete settings.
* config.h.in: Ditto.
* bsdlib.cc: Add cygtls.h include.
* configure.in: Remove --enable-extra-threadsafe-checking.
* configure: Regenerate.
* cygtls.h (_local_storage): New struct renamed from _winsup_t (sic).
(_threadinfo:local_clib): Add new field.
(_threadinfo::locals): Ditto.
(_threadinfo::init_thread): Accept second _reent * argument.
(_threadinfo::call): Define as regparm.
(CYGTLS_PADSIZE): Remove unnecessary slop.
(_getreent): Define as a macro.
* thread.h: Remove _CYG_THREAD_FAILSAFE and MT_SAFE stuff.
(_winsup_t): Move to cygtls.h.
(ResourceLocks::ResourceLocks): Eliminate empty constructor.
(MTinterface::reents): Eliminate.
(MTinterface::thread_self_key): Eliminate.
(MTinterface::MTinterface): Eliminate.
* dcrt0.cc: Include stdio.h for _impure_ptr initialization.
(do_global_ctors): Remove run_ctors_p (sic) considerations.  Don't call atexit
here.
(__main): Initialize destructors for user here.
(dll_crt0_1): Accept a dummy argument.  Don't call init_thread here.  Don't set
_impure_ptr here.  Call do_global_ctors after more things have been
initialized.
(_dll_crt0): Define zeros buffer as max of needed size of CYGTLS_PADSIZE so
that it can be used for two purposes while minimizing stack usage.  Initialize
_impure_ptr specifically, for speed.  Call dll_crt0_1 with buffer argument.
(cygwin_dll_init): Call dll_crt0_1 with dummy argument.
* dtable.cc (dtable::find_unused_handle): Remove call to AssertResourceOwner.
* exceptions.cc: Move _threadinfo stuff to new file.
* cygtls.cc: New file.
* gentls_offsets: Accommodate increasing complexity of cygtls.h.
* hires.h (hires_base::~hires_base): Remove.
* init.cc (dll_entry): Remove setting of reents.
* thread.cc: Remove syslog.h include.
(__getreent): Simplify to use _my_tls.
(_reent_winsup): Delete.
(AssertResourceOwner): Delete.
(MTinterface::Init): Remove setting of _clib and _winsup, with all that
entails.
(MTinterface::fixup_after_fork): Ditto.
(pthread::thread_init_wrapper): Ditto.  Also remove call to
set_tls_self_pointer.
(pthread::set_tls_self_pointer): Eliminate.
(pthread::get_tls_self_pointer): Just return _my_tls.tid;
(__reent_t::init_clib): Eliminate.
* tlsoffsets.h: Regenerate.
This commit is contained in:
Christopher Faylor 2003-12-23 16:26:31 +00:00
parent 1fb9256d7e
commit 29d52c8a27
35 changed files with 513 additions and 744 deletions

View File

@ -1,4 +1,74 @@
2003-12-17 Christopher Faylor <cgf@redhat.com>
2003-12-23 Christopher Faylor <cgf@redhat.com>
* exceptions.cc (set_signal_mask): Redefine to not pass by address.
Report calculated mask in debugging output.
* sigproc.h (set_signal_mask): Reflect above change in declaration.
2003-12-22 Christopher Faylor <cgf@redhat.com>
* path.cc (mount_item::build_win32): Take path apart before feeding it
to fnmunge.
2003-12-21 Christopher Faylor <cgf@redhat.com>
Throughout, change use of _reent_winsup()-> to _my_tls.locals.
instead.
Throughout, remove obsolete MT_SAFE/_CYG_THREAD_FAILSAFE considerations.
Througout, add cygtls.h include.
* Makefile.in (DLL_OFILES): Add cygtls.o. Add some more objects to the
-fomit-frame-pointer list.
* acconfig.h: Remove obsolete settings.
* config.h.in: Ditto.
* bsdlib.cc: Add cygtls.h include.
* configure.in: Remove --enable-extra-threadsafe-checking.
* configure: Regenerate.
* cygtls.h (_local_storage): New struct renamed from _winsup_t (sic).
(_threadinfo:local_clib): Add new field.
(_threadinfo::locals): Ditto.
(_threadinfo::init_thread): Accept second _reent * argument.
(_threadinfo::call): Define as regparm.
(CYGTLS_PADSIZE): Remove unnecessary slop.
(_getreent): Define as a macro.
* thread.h: Remove _CYG_THREAD_FAILSAFE and MT_SAFE stuff.
(_winsup_t): Move to cygtls.h.
(ResourceLocks::ResourceLocks): Eliminate empty constructor.
(MTinterface::reents): Eliminate.
(MTinterface::thread_self_key): Eliminate.
(MTinterface::MTinterface): Eliminate.
* dcrt0.cc: Include stdio.h for _impure_ptr initialization.
(do_global_ctors): Remove run_ctors_p (sic) considerations. Don't call
atexit here.
(__main): Initialize destructors for user here.
(dll_crt0_1): Accept a dummy argument. Don't call init_thread here.
Don't set _impure_ptr here. Call do_global_ctors after more things
have been initialized.
(_dll_crt0): Define zeros buffer as max of needed size of
CYGTLS_PADSIZE so that it can be used for two purposes while minimizing
stack usage. Initialize _impure_ptr specifically, for speed. Call
dll_crt0_1 with buffer argument.
(cygwin_dll_init): Call dll_crt0_1 with dummy argument.
* dtable.cc (dtable::find_unused_handle): Remove call to
AssertResourceOwner.
* exceptions.cc: Move _threadinfo stuff to new file.
* cygtls.cc: New file.
* gentls_offsets: Accommodate increasing complexity of cygtls.h.
* hires.h (hires_base::~hires_base): Remove.
* init.cc (dll_entry): Remove setting of reents.
* thread.cc: Remove syslog.h include.
(__getreent): Simplify to use _my_tls.
(_reent_winsup): Delete.
(AssertResourceOwner): Delete.
(MTinterface::Init): Remove setting of _clib and _winsup, with all that
entails.
(MTinterface::fixup_after_fork): Ditto.
(pthread::thread_init_wrapper): Ditto. Also remove call to
set_tls_self_pointer.
(pthread::set_tls_self_pointer): Eliminate.
(pthread::get_tls_self_pointer): Just return _my_tls.tid;
(__reent_t::init_clib): Eliminate.
* tlsoffsets.h: Regenerate.
2003-12-17 Christopher Faylor <cgf@redhat.com>
* sigproc.cc (proc_subproc): Simplify code to just remove all zombies
if SIGCHLD == SIG_IGN.

View File

@ -118,9 +118,9 @@ DLL_IMPORTS:=$(w32api_lib)/libkernel32.a
MT_SAFE_OBJECTS:=
# Please maintain this list in sorted order, with maximum files per 80 col line
#
DLL_OFILES:=assert.o autoload.o bsdlib.o cxx.o cygheap.o cygthread.o dcrt0.o \
debug.o delqueue.o devices.o dir.o dlfcn.o dll_init.o dtable.o environ.o \
errno.o exceptions.o exec.o external.o fcntl.o fhandler.o \
DLL_OFILES:=assert.o autoload.o bsdlib.o cxx.o cygheap.o cygthread.o cygtls.o \
dcrt0.o debug.o delqueue.o devices.o dir.o dlfcn.o dll_init.o dtable.o \
environ.o errno.o exceptions.o exec.o external.o fcntl.o fhandler.o \
fhandler_clipboard.o fhandler_console.o fhandler_disk_file.o \
fhandler_dsp.o fhandler_fifo.o fhandler_floppy.o fhandler_mem.o \
fhandler_nodevice.o fhandler_proc.o fhandler_process.o \
@ -219,12 +219,11 @@ TARGET_LIBS:=$(LIB_NAME) $(CYGWIN_START) $(GMON_START) $(LIBGMON_A) $(SUBLIBS) $
ifneq "${filter -O%,$(CFLAGS)}" ""
cygheap_CFLAGS:=-fomit-frame-pointer
devices_CFLAGS:=-fomit-frame-pointer -Os
malloc_CFLAGS:=-fomit-frame-pointer
malloc_wrapper_CFLAGS:=-fomit-frame-pointer
shared_CFLAGS:=-fomit-frame-pointer
cygthread_CFLAGS:=-fomit-frame-pointer
miscfuncs_CFLAGS:=-fomit-frame-pointer
cygtls_CFLAGS:=-fomit-frame-pointer
devices_CFLAGS:=-fomit-frame-pointer -Os
dir_CFLAGS:=-fomit-frame-pointer
fcntl_CFLAGS:=-fomit-frame-pointer
fhandler_CFLAGS:=-fomit-frame-pointer
fhandler_clipboard_CFLAGS:=-fomit-frame-pointer
fhandler_console_CFLAGS:=-fomit-frame-pointer
@ -239,16 +238,22 @@ fhandler_raw_CFLAGS:=-fomit-frame-pointer
fhandler_registry_CFLAGS:=-fomit-frame-pointer
fhandler_serial_CFLAGS:=-fomit-frame-pointer
fhandler_socket_CFLAGS:=-fomit-frame-pointer
fhandler_syslog_CFLAGS:=-fomit-frame-pointer
fhandler_tape_CFLAGS:=-fomit-frame-pointer
fhandler_termios_CFLAGS:=-fomit-frame-pointer
fhandler_tty_CFLAGS:=-fomit-frame-pointer
fhandler_virtual_CFLAGS:=-fomit-frame-pointer
fhandler_windows_CFLAGS:=-fomit-frame-pointer
fhandler_zero_CFLAGS:=-fomit-frame-pointer
malloc_CFLAGS:=-fomit-frame-pointer
malloc_wrapper_CFLAGS:=-fomit-frame-pointer
miscfuncs_CFLAGS:=-fomit-frame-pointer
regcomp_CFLAGS=-fomit-frame-pointer
regerror_CFLAGS=-fomit-frame-pointer
regexec_CFLAGS=-fomit-frame-pointer
regfree_CFLAGS=-fomit-frame-pointer
shared_CFLAGS:=-fomit-frame-pointer
smallprint_CFLAGS:=-fomit-frame-pointer
endif
.PHONY: all force dll_ofiles install all_target install_target all_host install_host \

View File

@ -1,18 +1,12 @@
/* Define if DEBUGGING support is requested. */
#undef DEBUGGING
/* Define if building "extra" thread-safe Cygwin DLL. */
#undef _CYG_THREAD_FAILSAFE
/* Define if GCC supports builtin memset. */
#undef HAVE_BUILTIN_MEMSET
/* Define if MALLOC_DEBUGGING support is requested. */
#undef MALLOC_DEBUG
/* Define if building thread-safe Cygwin DLL. */
#undef _MT_SAFE
/* Define if using new vfork functionality. */
#undef NEWVFORK

View File

@ -1,33 +1,7 @@
/* config.h.in. Generated automatically from configure.in by autoheader. */
/* Define if using alloca.c. */
#undef C_ALLOCA
/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
This function is required for alloca.c support on those systems. */
#undef CRAY_STACKSEG_END
/* Define if you have alloca, as a function or macro. */
#undef HAVE_ALLOCA
/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
#undef HAVE_ALLOCA_H
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown
*/
#undef STACK_DIRECTION
/* config.h.in. Generated from configure.in by autoheader. */
/* Define if DEBUGGING support is requested. */
#undef DEBUGGING
/* Define if building "extra" thread-safe Cygwin DLL. */
#undef _CYG_THREAD_FAILSAFE
/* Define if GCC supports builtin memset. */
#undef HAVE_BUILTIN_MEMSET
@ -39,3 +13,41 @@
/* Define if using cygserver */
#undef USE_SERVER
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
systems. This function is required for `alloca.c' support on those systems.
*/
#undef CRAY_STACKSEG_END
/* Define to 1 if using `alloca.c'. */
#undef C_ALLOCA
/* Define to 1 if you have `alloca', as a function or macro. */
#undef HAVE_ALLOCA
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
*/
#undef HAVE_ALLOCA_H
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */
#undef STACK_DIRECTION

View File

@ -11,8 +11,6 @@
ac_help=
ac_default_prefix=/usr/local
# Any additions from configure.in:
ac_help="$ac_help
--enable-extra-threadsafe-checking Build a cygwin DLL which is thread safe with extra consistency checking"
ac_help="$ac_help
--enable-debugging Build a cygwin DLL which has more consistency checking for debugging"
ac_help="$ac_help
@ -566,7 +564,7 @@ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
echo "configure:570: checking for a BSD compatible install" >&5
echo "configure:568: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@ -652,7 +650,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
fi
echo $ac_n "checking host system type""... $ac_c" 1>&6
echo "configure:656: checking host system type" >&5
echo "configure:654: checking host system type" >&5
host_alias=$host
case "$host_alias" in
@ -673,7 +671,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
echo "$ac_t""$host" 1>&6
echo $ac_n "checking target system type""... $ac_c" 1>&6
echo "configure:677: checking target system type" >&5
echo "configure:675: checking target system type" >&5
target_alias=$target
case "$target_alias" in
@ -691,7 +689,7 @@ target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
echo "$ac_t""$target" 1>&6
echo $ac_n "checking build system type""... $ac_c" 1>&6
echo "configure:695: checking build system type" >&5
echo "configure:693: checking build system type" >&5
build_alias=$build
case "$build_alias" in
@ -723,7 +721,7 @@ fi
# Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
set dummy ${ac_tool_prefix}gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:727: checking for $ac_word" >&5
echo "configure:725: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -755,7 +753,7 @@ if test -n "$ac_tool_prefix"; then
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:759: checking for $ac_word" >&5
echo "configure:757: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -791,7 +789,7 @@ if test -z "$CC"; then
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:795: checking for $ac_word" >&5
echo "configure:793: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -840,7 +838,7 @@ fi
fi
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
echo "configure:844: checking whether we are using GNU C" >&5
echo "configure:842: checking whether we are using GNU C" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -849,7 +847,7 @@ else
yes;
#endif
EOF
if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:853: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:851: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
@ -864,7 +862,7 @@ if test $ac_cv_prog_gcc = yes; then
ac_save_CFLAGS="$CFLAGS"
CFLAGS=
echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
echo "configure:868: checking whether ${CC-cc} accepts -g" >&5
echo "configure:866: checking whether ${CC-cc} accepts -g" >&5
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -894,7 +892,7 @@ fi
# Extract the first word of "${ac_tool_prefix}g++", so it can be a program name with args.
set dummy ${ac_tool_prefix}g++; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:898: checking for $ac_word" >&5
echo "configure:896: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -926,7 +924,7 @@ if test -n "$ac_tool_prefix"; then
# Extract the first word of "g++", so it can be a program name with args.
set dummy g++; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:930: checking for $ac_word" >&5
echo "configure:928: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -962,7 +960,7 @@ if test -z "$CXX"; then
# Extract the first word of "c++", so it can be a program name with args.
set dummy c++; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:966: checking for $ac_word" >&5
echo "configure:964: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1018,7 +1016,7 @@ EOF
# Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
set dummy ${ac_tool_prefix}ar; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:1022: checking for $ac_word" >&5
echo "configure:1020: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1050,7 +1048,7 @@ if test -n "$ac_tool_prefix"; then
# Extract the first word of "ar", so it can be a program name with args.
set dummy ar; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:1054: checking for $ac_word" >&5
echo "configure:1052: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1085,7 +1083,7 @@ fi
# Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args.
set dummy ${ac_tool_prefix}as; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:1089: checking for $ac_word" >&5
echo "configure:1087: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1117,7 +1115,7 @@ if test -n "$ac_tool_prefix"; then
# Extract the first word of "as", so it can be a program name with args.
set dummy as; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:1121: checking for $ac_word" >&5
echo "configure:1119: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1152,7 +1150,7 @@ fi
# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
set dummy ${ac_tool_prefix}ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:1156: checking for $ac_word" >&5
echo "configure:1154: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1184,7 +1182,7 @@ if test -n "$ac_tool_prefix"; then
# Extract the first word of "ranlib", so it can be a program name with args.
set dummy ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:1188: checking for $ac_word" >&5
echo "configure:1186: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1219,7 +1217,7 @@ fi
# Extract the first word of "${ac_tool_prefix}ld", so it can be a program name with args.
set dummy ${ac_tool_prefix}ld; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:1223: checking for $ac_word" >&5
echo "configure:1221: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_LD'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1251,7 +1249,7 @@ if test -n "$ac_tool_prefix"; then
# Extract the first word of "ld", so it can be a program name with args.
set dummy ld; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:1255: checking for $ac_word" >&5
echo "configure:1253: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_LD'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1286,7 +1284,7 @@ fi
# Extract the first word of "${ac_tool_prefix}nm", so it can be a program name with args.
set dummy ${ac_tool_prefix}nm; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:1290: checking for $ac_word" >&5
echo "configure:1288: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_NM'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1318,7 +1316,7 @@ if test -n "$ac_tool_prefix"; then
# Extract the first word of "nm", so it can be a program name with args.
set dummy nm; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:1322: checking for $ac_word" >&5
echo "configure:1320: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_NM'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1353,7 +1351,7 @@ fi
# Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.
set dummy ${ac_tool_prefix}dlltool; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:1357: checking for $ac_word" >&5
echo "configure:1355: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1385,7 +1383,7 @@ if test -n "$ac_tool_prefix"; then
# Extract the first word of "dlltool", so it can be a program name with args.
set dummy dlltool; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:1389: checking for $ac_word" >&5
echo "configure:1387: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1420,7 +1418,7 @@ fi
# Extract the first word of "${ac_tool_prefix}windres", so it can be a program name with args.
set dummy ${ac_tool_prefix}windres; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:1424: checking for $ac_word" >&5
echo "configure:1422: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_WINDRES'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1452,7 +1450,7 @@ if test -n "$ac_tool_prefix"; then
# Extract the first word of "windres", so it can be a program name with args.
set dummy windres; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:1456: checking for $ac_word" >&5
echo "configure:1454: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_WINDRES'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1486,7 +1484,7 @@ fi
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
echo "configure:1490: checking how to run the C preprocessor" >&5
echo "configure:1488: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@ -1501,13 +1499,13 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
#line 1505 "configure"
#line 1503 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1511: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1509: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@ -1518,13 +1516,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
#line 1522 "configure"
#line 1520 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1528: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1526: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@ -1535,13 +1533,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -nologo -E"
cat > conftest.$ac_ext <<EOF
#line 1539 "configure"
#line 1537 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1545: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1543: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@ -1568,19 +1566,19 @@ echo "$ac_t""$CPP" 1>&6
# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
# for constant arguments. Useless!
echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6
echo "configure:1572: checking for working alloca.h" >&5
echo "configure:1570: checking for working alloca.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1577 "configure"
#line 1575 "configure"
#include "confdefs.h"
#include <alloca.h>
int main() {
char *p = alloca(2 * sizeof(int));
; return 0; }
EOF
if { (eval echo configure:1584: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1582: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_header_alloca_h=yes
else
@ -1601,12 +1599,12 @@ EOF
fi
echo $ac_n "checking for alloca""... $ac_c" 1>&6
echo "configure:1605: checking for alloca" >&5
echo "configure:1603: checking for alloca" >&5
if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1610 "configure"
#line 1608 "configure"
#include "confdefs.h"
#ifdef __GNUC__
@ -1634,7 +1632,7 @@ int main() {
char *p = (char *) alloca(1);
; return 0; }
EOF
if { (eval echo configure:1638: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1636: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_func_alloca_works=yes
else
@ -1666,12 +1664,12 @@ EOF
echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
echo "configure:1670: checking whether alloca needs Cray hooks" >&5
echo "configure:1668: checking whether alloca needs Cray hooks" >&5
if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1675 "configure"
#line 1673 "configure"
#include "confdefs.h"
#if defined(CRAY) && ! defined(CRAY2)
webecray
@ -1696,12 +1694,12 @@ echo "$ac_t""$ac_cv_os_cray" 1>&6
if test $ac_cv_os_cray = yes; then
for ac_func in _getb67 GETB67 getb67; do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:1700: checking for $ac_func" >&5
echo "configure:1698: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1705 "configure"
#line 1703 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@ -1724,7 +1722,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:1728: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1726: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@ -1751,7 +1749,7 @@ done
fi
echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
echo "configure:1755: checking stack direction for C alloca" >&5
echo "configure:1753: checking stack direction for C alloca" >&5
if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1759,7 +1757,7 @@ else
ac_cv_c_stack_direction=0
else
cat > conftest.$ac_ext <<EOF
#line 1763 "configure"
#line 1761 "configure"
#include "confdefs.h"
find_stack_direction ()
{
@ -1778,7 +1776,7 @@ main ()
exit (find_stack_direction() < 0);
}
EOF
if { (eval echo configure:1782: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
if { (eval echo configure:1780: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_c_stack_direction=1
else
@ -1800,7 +1798,7 @@ EOF
fi
echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
echo "configure:1804: checking whether ${MAKE-make} sets \${MAKE}" >&5
echo "configure:1802: checking whether ${MAKE-make} sets \${MAKE}" >&5
set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@ -1837,7 +1835,7 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes
cross_compiling=$ac_cv_prog_cxx_cross
cat > conftest.$ac_ext <<EOF
#line 1841 "configure"
#line 1839 "configure"
#include "confdefs.h"
#include <string.h>
@ -1850,7 +1848,7 @@ int main() {
; return 0; }
EOF
if { (eval echo configure:1854: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:1852: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
use_builtin_memset=yes
else
@ -1874,25 +1872,6 @@ ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$a
cross_compiling=$ac_cv_prog_cc_cross
# Check whether --enable-extra-threadsafe-checking or --disable-extra-threadsafe-checking was given.
if test "${enable_extra_threadsafe_checking+set}" = set; then
enableval="$enable_extra_threadsafe_checking"
case "${enableval}" in
yes)
mt_safe_val=1
MT_SAFE=yes
cat >> confdefs.h <<\EOF
#define _CYG_THREAD_FAILSAFE 1
EOF
;;
no)
;;
esac
fi
# Check whether --enable-debugging or --disable-debugging was given.
if test "${enable_debugging+set}" = set; then
enableval="$enable_debugging"

View File

@ -117,20 +117,6 @@ if test $use_builtin_memset = "yes"; then
fi
AC_LANG_RESTORE
AC_ARG_ENABLE(extra-threadsafe-checking,
[ --enable-extra-threadsafe-checking Build a cygwin DLL which is thread safe with extra consistency checking],
[case "${enableval}" in
yes)
mt_safe_val=1
MT_SAFE=yes
AC_DEFINE(_CYG_THREAD_FAILSAFE)
;;
no)
dnl Don't do anything here to avoid overriding --enable-threadsafe.
;;
esac
])
AC_ARG_ENABLE(debugging,
[ --enable-debugging Build a cygwin DLL which has more consistency checking for debugging],
[case "${enableval}" in

View File

@ -9,16 +9,83 @@ details. */
#ifndef _CYGTLS_H
#define _CYGTLS_H
#include <cygwin/signal.h>
#include <signal.h>
#include <pwd.h>
#include <grp.h>
#include <sys/time.h>
#define _NOMNTENT_FUNCS
#include <mntent.h>
#undef _NOMNTENT_FUNCS
#define CYGTLS_INITIALIZED 0x43227
#define CYGTLS_EXCEPTION (0x43227 + true)
#ifndef CYG_MAX_PATH
# define CYG_MAX_PATH 260
#endif
#ifndef UNLEN
# define UNLEN 256
#endif
#pragma pack(push,4)
struct _local_storage
{
/*
Needed for the group functions
*/
struct __group16 grp;
char *namearray[2];
int grp_pos;
/* console.cc */
unsigned rarg;
/* dlfcn.cc */
int dl_error;
char dl_buffer[256];
/* passwd.cc */
struct passwd res;
char pass[_PASSWORD_LEN];
int pw_pos;
/* path.cc */
struct mntent mntbuf;
int iteration;
unsigned available_drives;
char mnt_type[80];
char mnt_opts[80];
char mnt_fsname[CYG_MAX_PATH];
char mnt_dir[CYG_MAX_PATH];
/* strerror */
char strerror_buf[20];
/* sysloc.cc */
char *process_ident;
int process_logopt;
int process_facility;
int process_logmask;
/* times.cc */
char timezone_buf[20];
struct tm _localtime_buf;
/* uinfo.cc */
char username[UNLEN + 1];
/* net.cc */
char *ntoa_buf;
struct protoent *protoent_buf;
struct servent *servent_buf;
struct hostent *hostent_buf;
};
/* Please keep this file simple. Changes to the below structure may require
acompanying changes to the very simple parser in the perl script
'gentls_offsets' (<<-- start parsing here). */
#pragma pack(push,4)
typedef __uint32_t __stack_t;
struct _threadinfo
{
@ -35,6 +102,8 @@ struct _threadinfo
siginfo_t *sigwait_info;
siginfo_t infodata;
struct pthread *tid;
struct _reent local_clib;
struct _local_storage locals;
struct _threadinfo *prev, *next;
__stack_t stack[8];
int sig;
@ -43,9 +112,9 @@ struct _threadinfo
/*gentls_offsets*/
static CRITICAL_SECTION protect_linked_list;
static void init ();
void init_thread (void *);
static void call (DWORD (*) (void *, void *), void *);
void call2 (DWORD (*) (void *, void *), void *, void *);
void init_thread (void *) __attribute__ ((regparm (2)));
static void call (DWORD (*) (void *, void *), void *) __attribute__ ((regparm (3)));
static void call2 (DWORD (*) (void *, void *), void *, void *) __attribute__ ((regparm (3)));
static struct _threadinfo *find_tls (int sig);
void remove ();
void push (__stack_t, bool = false);
@ -67,5 +136,7 @@ extern char *_tlstop __asm__ ("%fs:8");
#define _my_tls (((_threadinfo *) _tlsbase)[-1])
extern _threadinfo *_main_tls;
#define CYGTLS_PADSIZE (sizeof (_threadinfo) + 64)
#define __getreent() (&_my_tls.local_clib)
#define CYGTLS_PADSIZE (sizeof (_threadinfo))
#endif /*_CYGTLS_H*/

View File

@ -24,7 +24,6 @@ opterr DATA
optind DATA
optopt DATA
optreset DATA
reent_data DATA
_alloca NOSIGFE
dll_entry@12 NOSIGFE
__assert SIGFE

View File

@ -10,6 +10,7 @@ details. */
#include "winsup.h"
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "glob.h"
#include "exceptions.h"
@ -89,7 +90,6 @@ extern "C"
char ***main_environ;
/* __progname used in getopt error message */
char *__progname;
struct _reent reent_data = _REENT_INIT(reent_data);
struct per_process __cygwin_user_data =
{/* initial_sp */ 0, /* magic_biscuit */ 0,
/* dll_major */ CYGWIN_VERSION_DLL_MAJOR,
@ -110,7 +110,7 @@ extern "C"
/* api_minor */ CYGWIN_VERSION_API_MINOR,
/* unused2 */ {0, 0, 0, 0, 0},
/* resourcelocks */ &_reslock, /* threadinterface */ &_mtinterf,
/* impure_ptr */ &reent_data,
/* impure_ptr */ NULL,
};
bool ignore_case_with_glob;
int __declspec (dllexport) _check_for_executable = true;
@ -136,25 +136,18 @@ do_global_dtors (void)
static void __stdcall
do_global_ctors (void (**in_pfunc)(), int force)
{
if (!force)
{
if (user_data->forkee || user_data->run_ctors_p)
return; // inherit constructed stuff from parent pid
user_data->run_ctors_p = 1;
}
if (!force && user_data->forkee)
return; // inherit constructed stuff from parent pid
/* Run ctors backwards, so skip the first entry and find how many
there are, then run them. */
void (**pfunc)() = in_pfunc;
void (**pfunc) () = in_pfunc;
while (*++pfunc)
;
while (--pfunc > in_pfunc)
(*pfunc) ();
if (user_data->magic_biscuit == SIZEOF_PER_PROCESS)
atexit (do_global_dtors);
}
/*
@ -530,12 +523,8 @@ alloc_stack (child_info_fork *ci)
opposed to being link-time loaded by Cygwin apps) from a non
cygwin app via LoadLibrary. */
static void
dll_crt0_1 ()
dll_crt0_1 (char *)
{
char padding[CYGTLS_PADSIZE];
_main_tls = &_my_tls;
_main_tls->init_thread (padding);
/* According to onno@stack.urc.tue.nl, the exception handler record must
be on the stack. */
/* FIXME: Verify forked children get their exception handler set up ok. */
@ -557,8 +546,6 @@ dll_crt0_1 ()
fork copy code doesn't copy the data in libccrt0.cc (that's why we
pass in the per_process struct into the .dll from libccrt0). */
_impure_ptr = &reent_data;
user_data->resourcelocks->Init ();
user_data->threadinterface->Init ();
@ -771,15 +758,16 @@ dll_crt0_1 ()
/* Disable case-insensitive globbing */
ignore_case_with_glob = false;
/* Flush signals and ensure that signal thread is up and running. Can't
do this for noncygwin case since the signal thread is blocked due to
LoadLibrary serialization. */
wait_for_sigthread ();
set_errno (0);
MALLOC_CHECK;
cygbench (__progname);
/* Flush signals and ensure that signal thread is up and running. Can't
do this for noncygwin case since the signal thread is blocked due to
LoadLibrary serialization. */
wait_for_sigthread ();
if (user_data->main)
exit (user_data->main (__argc, __argv, *user_data->envptr));
}
@ -830,6 +818,21 @@ initial_env ()
_cygwin_testing = 1;
}
struct _reent *
initialize_main_tls (char *padding)
{
if (!_main_tls)
{
_threadinfo::init ();
_main_tls = &_my_tls;
_main_tls->init_thread (padding);
_main_tls->local_clib._stdin = &_main_tls->local_clib.__sf[0];
_main_tls->local_clib._stdout = &_main_tls->local_clib.__sf[1];
_main_tls->local_clib._stderr = &_main_tls->local_clib.__sf[2];
}
return &_main_tls->local_clib;
}
/* Wrap the real one, otherwise gdb gets confused about
two symbols with the same name, but different addresses.
@ -840,7 +843,7 @@ extern "C" void __stdcall
_dll_crt0 ()
{
initial_env ();
char zeros[sizeof (fork_info->zero)] = {0};
char zeros[max (CYGTLS_PADSIZE, sizeof (child_proc_info->zero))] = {0};
static NO_COPY STARTUPINFO si;
main_environ = user_data->envptr;
@ -859,7 +862,8 @@ _dll_crt0 ()
GetStartupInfo (&si);
child_proc_info = (child_info *) si.lpReserved2;
if (si.cbReserved2 < EXEC_MAGIC_SIZE || !child_proc_info
|| memcmp (child_proc_info->zero, zeros, sizeof (zeros)) != 0)
|| memcmp (child_proc_info->zero, zeros,
sizeof (child_proc_info->zero)) != 0)
child_proc_info = NULL;
else
{
@ -901,19 +905,20 @@ _dll_crt0 ()
break;
}
}
_threadinfo::init ();
dll_crt0_1 ();
user_data->impure_ptr = _impure_ptr = initialize_main_tls (zeros);
dll_crt0_1 (zeros);
}
void
dll_crt0 (per_process *uptr)
{
char padding[CYGTLS_PADSIZE];
/* Set the local copy of the pointer into the user space. */
if (uptr && uptr != user_data)
{
memcpy (user_data, uptr, per_process_overwrite);
*(user_data->impure_ptr_ptr) = &reent_data;
*(user_data->impure_ptr_ptr) = initialize_main_tls (padding);
}
_dll_crt0 ();
}
@ -937,13 +942,14 @@ cygwin_dll_init ()
user_data->envptr = &envp;
user_data->fmode_ptr = &_fmode;
dll_crt0_1 ();
dll_crt0_1 (NULL);
}
extern "C" void
__main (void)
{
do_global_ctors (user_data->ctors, false);
atexit (do_global_dtors);
}
exit_states NO_COPY exit_state;

View File

@ -21,15 +21,13 @@ details. */
#include "dlfcn.h"
#include "dll_init.h"
#include "cygerrno.h"
#define _dl_error _reent_winsup ()->_dl_error
#define _dl_buffer _reent_winsup ()->_dl_buffer
#include "cygtls.h"
static void __stdcall
set_dl_error (const char *str)
{
__small_sprintf (_dl_buffer, "%s: %E", str);
_dl_error = 1;
__small_sprintf (_my_tls.locals.dl_buffer, "%s: %E", str);
_my_tls.locals.dl_error = 1;
}
/* Look for an executable file given the name and the environment
@ -145,12 +143,12 @@ char *
dlerror ()
{
char *res;
if (!_dl_error)
if (!_my_tls.locals.dl_error)
res = NULL;
else
{
_dl_error = 0;
res = _dl_buffer;
_my_tls.locals.dl_error = 0;
res = _my_tls.locals.dl_buffer;
}
return res;
}

View File

@ -200,7 +200,6 @@ dtable::delete_archetype (fhandler_base *fh)
int
dtable::find_unused_handle (int start)
{
AssertResourceOwner (LOCK_FD_LIST, READ_LOCK);
do
{
for (size_t i = start; i < size; i++)

View File

@ -15,6 +15,7 @@ details. */
#include <stdio.h>
#include "cygerrno.h"
#include "thread.h"
#include "cygtls.h"
#undef _sys_nerr
#undef sys_nerr
#undef _sys_errlist
@ -681,13 +682,8 @@ strerror (int errnum)
error = "Value too large for defined data type";
break;
default:
#ifdef _MT_SAFE
char *buf= _reent_winsup ()->_strerror_buf;
#else
static NO_COPY char buf[20];
#endif
__small_sprintf (buf, "error %d", errnum);
error = buf;
__small_sprintf (_my_tls.locals.strerror_buf, "error %d", errnum);
error = _my_tls.locals.strerror_buf;
break;
}

View File

@ -36,11 +36,6 @@ static int handle_exceptions (EXCEPTION_RECORD *, void *, CONTEXT *, void *);
extern void sigdelayed ();
};
_threadinfo NO_COPY dummy_thread;
_threadinfo NO_COPY *_last_thread = &dummy_thread;
CRITICAL_SECTION NO_COPY _threadinfo::protect_linked_list;
extern DWORD sigtid;
extern HANDLE hExeced;
@ -129,101 +124,6 @@ init_exceptions (exception_list *el)
init_exception_handler (el);
}
void
_threadinfo::set_state (bool is_exception)
{
initialized = CYGTLS_INITIALIZED + is_exception;
}
void
_threadinfo::reset_exception ()
{
if (initialized == CYGTLS_EXCEPTION)
{
#ifdef DEBUGGING
debug_printf ("resetting stack after an exception stack %p, stackptr %p", stack, stackptr);
#endif
set_state (false);
stackptr--;
}
}
void
_threadinfo::call (DWORD (*func) (void *, void *), void *arg)
{
char buf[CYGTLS_PADSIZE];
_my_tls.call2 (func, arg, buf);
}
void
_threadinfo::call2 (DWORD (*func) (void *, void *), void *arg, void *buf)
{
init_thread (buf);
ExitThread (func (arg, buf));
}
void
_threadinfo::init ()
{
InitializeCriticalSection (&protect_linked_list);
}
void
_threadinfo::init_thread (void *x)
{
if (x)
{
memset (this, 0, sizeof (*this));
stackptr = stack;
}
EnterCriticalSection (&protect_linked_list);
prev = _last_thread;
_last_thread->next = this;
_last_thread = this;
LeaveCriticalSection (&protect_linked_list);
set_state (false);
errno_addr = &errno;
}
void
_threadinfo::remove ()
{
EnterCriticalSection (&protect_linked_list);
if (prev)
{
prev->next = next;
if (next)
next->prev = prev;
if (this == _last_thread)
_last_thread = prev;
prev = next = NULL;
}
LeaveCriticalSection (&protect_linked_list);
}
void
_threadinfo::push (__stack_t addr, bool exception)
{
*stackptr++ = (__stack_t) addr;
set_state (exception);
}
__stack_t
_threadinfo::pop ()
{
#ifdef DEBUGGING
assert (stackptr > stack);
#endif
__stack_t res = *--stackptr;
#ifdef DEBUGGING
*stackptr = 0;
debug_printf ("popped %p, stack %p, stackptr %p", res, stack, stackptr);
#endif
return res;
}
extern "C" void
error_start_init (const char *buf)
{
@ -663,9 +563,9 @@ handle_sigsuspend (sigset_t tempmask)
sig_dispatch_pending ();
sigset_t oldmask = myself->getsigmask (); // Remember for restoration
set_signal_mask (tempmask & ~SIG_NONMASKABLE);// Let signals we're
set_signal_mask (tempmask &= ~SIG_NONMASKABLE, oldmask);// Let signals we're
// interested in through.
sigproc_printf ("old mask %x, new mask %x", oldmask, tempmask);
sigproc_printf ("oldmask %p, newmask %p", oldmask, tempmask);
pthread_testcancel ();
pthread::cancelable_wait (signal_arrived, INFINITE);
@ -974,20 +874,24 @@ set_process_mask (sigset_t newmask)
/* Set the signal mask for this process.
Note that some signals are unmaskable, as in UNIX. */
extern "C" void __stdcall
set_signal_mask (sigset_t newmask, sigset_t& oldmask)
set_signal_mask (sigset_t newmask, sigset_t oldmask)
{
mask_sync->acquire (INFINITE);
newmask &= ~SIG_NONMASKABLE;
sigproc_printf ("old mask %p, new mask %p", oldmask, newmask);
sigset_t mask_bits = oldmask & ~newmask;
sigproc_printf ("oldmask %p, newmask %p, mask_bits %p", oldmask, newmask,
mask_bits);
myself->setsigmask (newmask); // Set a new mask
mask_sync->release ();
if (oldmask & ~newmask)
if (mask_bits)
sig_dispatch_pending ();
else
sigproc_printf ("not calling sig_dispatch_pending");
return;
}
extern _threadinfo *_last_thread;
_threadinfo *
_threadinfo::find_tls (int sig)
{

View File

@ -27,6 +27,7 @@ details. */
#include "heap.h"
#include "cygthread.h"
#include "pwdgrp.h"
#include "cygtls.h"
static external_pinfo *
fillout_pinfo (pid_t pid, int winpid)

View File

@ -263,7 +263,8 @@ fork_child (HANDLE& hParent, dll *&first_dll, bool& load_dlls)
if (fork_info->stacksize)
{
_main_tls = &_my_tls;
_my_tls.init_thread (NULL);
_main_tls->init_thread (NULL);
// memcpy (&_main_tls->local_clib, _impure_ptr, sizeof (*_main_tls->local_lib));
}
set_file_api_mode (current_codepage);
@ -553,13 +554,22 @@ fork_parent (HANDLE& hParent, dll *&first_dll,
MALLOC_CHECK;
void *impure_beg;
void *impure_end;
if (&_my_tls == _main_tls)
impure_beg = impure_end = NULL;
else
{
impure_beg = _impure_ptr;
impure_end = _impure_ptr + 1;
}
rc = fork_copy (pi, "user/cygwin data",
user_data->data_start, user_data->data_end,
user_data->bss_start, user_data->bss_end,
cygheap->user_heap.base, cygheap->user_heap.ptr,
stack_here, ch.stackbottom,
dll_data_start, dll_data_end,
dll_bss_start, dll_bss_end, NULL);
dll_bss_start, dll_bss_end, impure_beg, impure_end, NULL);
__malloc_unlock ();
MALLOC_CHECK;

View File

@ -6,7 +6,11 @@ my $struct = '';
my @fields = ();
my $def = '';
my $tls = join('', <TLS>);
$tls =~ s/\A.*?gentls_offsets[^\n]*\n//os;
$tls =~ s/\n[^\n]*gentls_offsets[^\n]*\n(.+)\Z/$1/os;
my $pre = $`;
substr($tls, 0, length($pre)) = '';
$pre =~ s/\n#ifndef _[^\n]+\n/\n/os;
$pre .= "\n//*/";
$tls =~ s%/\*\s*gentls_offsets.*?/\*\s*gentls_offsets\s*\*/%%ogs;
foreach ($tls =~ /^.*\n/mg) {
$def .= $_ if $struct;
@ -32,11 +36,13 @@ foreach ($tls =~ /^.*\n/mg) {
close TLS;
open(TMP, '>', "/tmp/$$.cc") or die "$0: couldn't open temporary index file \"/tmp/$$.c\" - $!\n";
print TMP <<EOF;
#define __INSIDE_CYGWIN__
#define __attribute__(X)
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
typedef void *HANDLE;
$pre
$def
int
main(int argc, char **argv)

View File

@ -24,9 +24,7 @@ details. */
#include "cygerrno.h"
#include "cygheap.h"
#include "pwdgrp.h"
/* Position in the group cache */
#define grp_pos _reent_winsup ()->_grp_pos
#include "cygtls.h"
static __group32 *group_buf;
static pwdgrp gr (group_buf);
@ -208,16 +206,16 @@ getgrnam (const char *name)
extern "C" void
endgrent ()
{
grp_pos = 0;
_my_tls.locals.grp_pos = 0;
}
extern "C" struct __group32 *
getgrent32 ()
{
if (grp_pos == 0)
if (_my_tls.locals.grp_pos == 0)
gr.refresh (true);
if (grp_pos < gr.curr_lines)
return group_buf + grp_pos++;
if (_my_tls.locals.grp_pos < gr.curr_lines)
return group_buf + _my_tls.locals.grp_pos++;
return NULL;
}
@ -233,7 +231,7 @@ getgrent ()
extern "C" void
setgrent ()
{
grp_pos = 0;
_my_tls.locals.grp_pos = 0;
}
/* Internal function. ONLY USE THIS INTERNALLY, NEVER `getgrent'!!! */

View File

@ -27,7 +27,6 @@ class hires_base
int inited;
public:
virtual LONGLONG usecs (bool justdelta) {return 0LL;}
virtual ~hires_base () {}
};
class hires_us : hires_base

View File

@ -232,12 +232,13 @@ details. */
105: Export sigwait.
106: Export flock.
107: Export fcntl64.
108: Remove unused (hopefully) reent_data export.
*/
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
#define CYGWIN_VERSION_API_MAJOR 0
#define CYGWIN_VERSION_API_MINOR 107
#define CYGWIN_VERSION_API_MINOR 108
/* There is also a compatibity version number associated with the
shared memory regions. It is incremented when incompatible

View File

@ -51,14 +51,13 @@ dll_entry (HANDLE h, DWORD reason, void *static_load)
switch (reason)
{
case DLL_PROCESS_ATTACH:
_my_tls.stackptr = _my_tls.stack;
dynamically_loaded = (static_load == NULL);
__cygwin_user_data.impure_ptr = &_my_tls.local_clib;
_my_tls.stackptr = _my_tls.stack;
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
if (MT_INTERFACE->reent_key.set (&MT_INTERFACE->reents))
api_fatal ("thread initialization failed");
munge_threadfunc (h);
break;
}

View File

@ -40,6 +40,8 @@
#include <sys/ioctl.h>
#include <fcntl.h>
#include "cygerrno.h"
#include "thread.h"
#include "cygtls.h"
extern "C" int
daemon (int nochdir, int noclose)

View File

@ -36,6 +36,7 @@ details. */
#include "pinfo.h"
#include "registry.h"
#include "wsock_event.h"
#include "cygtls.h"
extern "C"
{
@ -175,22 +176,16 @@ dump_protoent (struct protoent *p)
extern "C" char *
cygwin_inet_ntoa (struct in_addr in)
{
#ifdef _MT_SAFE
#define ntoa_buf _reent_winsup ()->_ntoa_buf
#else
static char *ntoa_buf = NULL;
#endif
char *res = inet_ntoa (in);
if (ntoa_buf)
if (_my_tls.locals.ntoa_buf)
{
free (ntoa_buf);
ntoa_buf = NULL;
free (_my_tls.locals.ntoa_buf);
_my_tls.locals.ntoa_buf = NULL;
}
if (res)
ntoa_buf = strdup (res);
return ntoa_buf;
_my_tls.locals.ntoa_buf = strdup (res);
return _my_tls.locals.ntoa_buf;
}
/* exported as inet_addr: BSD 4.3 */
@ -587,38 +582,34 @@ dup_ent (void *old, void *src0, struct_type type)
return dst;
}
#ifdef _MT_SAFE
#define protoent_buf _reent_winsup ()->_protoent_buf
#else
static struct protoent *protoent_buf = NULL;
#endif
/* exported as getprotobyname: standards? */
extern "C" struct protoent *
cygwin_getprotobyname (const char *p)
{
if (check_null_str_errno (p))
return NULL;
protoent_buf = (protoent *) dup_ent (protoent_buf, getprotobyname (p),
is_protoent);
if (!protoent_buf)
_my_tls.locals.protoent_buf =
(protoent *) dup_ent (_my_tls.locals.protoent_buf, getprotobyname (p),
is_protoent);
if (!_my_tls.locals.protoent_buf)
set_winsock_errno ();
dump_protoent (protoent_buf);
return protoent_buf;
dump_protoent (_my_tls.locals.protoent_buf);
return _my_tls.locals.protoent_buf;
}
/* exported as getprotobynumber: standards? */
extern "C" struct protoent *
cygwin_getprotobynumber (int number)
{
protoent_buf = (protoent *) dup_ent (protoent_buf, getprotobynumber (number),
is_protoent);
if (!protoent_buf)
_my_tls.locals.protoent_buf =
(protoent *) dup_ent (_my_tls.locals.protoent_buf,
getprotobynumber (number), is_protoent);
if (!_my_tls.locals.protoent_buf)
set_winsock_errno ();
dump_protoent (protoent_buf);
return protoent_buf;
dump_protoent (_my_tls.locals.protoent_buf);
return _my_tls.locals.protoent_buf;
}
bool
@ -936,12 +927,6 @@ cygwin_connect (int fd, const struct sockaddr *name, int namelen)
return res;
}
#ifdef _MT_SAFE
#define servent_buf _reent_winsup ()->_servent_buf
#else
static struct servent *servent_buf = NULL;
#endif
/* exported as getservbyname: standards? */
extern "C" struct servent *
cygwin_getservbyname (const char *name, const char *proto)
@ -951,13 +936,13 @@ cygwin_getservbyname (const char *name, const char *proto)
|| (proto != NULL && check_null_str_errno (proto)))
return NULL;
servent_buf = (servent *) dup_ent (servent_buf, getservbyname (name, proto),
_my_tls.locals.servent_buf = (servent *) dup_ent (_my_tls.locals.servent_buf, getservbyname (name, proto),
is_servent);
if (!servent_buf)
if (!_my_tls.locals.servent_buf)
set_winsock_errno ();
syscall_printf ("%x = getservbyname (%s, %s)", servent_buf, name, proto);
return servent_buf;
syscall_printf ("%x = getservbyname (%s, %s)", _my_tls.locals.servent_buf, name, proto);
return _my_tls.locals.servent_buf;
}
/* exported as getservbyport: standards? */
@ -968,13 +953,13 @@ cygwin_getservbyport (int port, const char *proto)
if (proto != NULL && check_null_str_errno (proto))
return NULL;
servent_buf = (servent *) dup_ent (servent_buf, getservbyport (port, proto),
_my_tls.locals.servent_buf = (servent *) dup_ent (_my_tls.locals.servent_buf, getservbyport (port, proto),
is_servent);
if (!servent_buf)
if (!_my_tls.locals.servent_buf)
set_winsock_errno ();
syscall_printf ("%x = getservbyport (%d, %s)", servent_buf, port, proto);
return servent_buf;
syscall_printf ("%x = getservbyport (%d, %s)", _my_tls.locals.servent_buf, port, proto);
return _my_tls.locals.servent_buf;
}
extern "C" int
@ -999,12 +984,6 @@ cygwin_gethostname (char *name, size_t len)
return 0;
}
#ifdef _MT_SAFE
#define hostent_buf _reent_winsup ()->_hostent_buf
#else
static struct hostent *hostent_buf = NULL;
#endif
/* exported as gethostbyname: standards? */
extern "C" struct hostent *
cygwin_gethostbyname (const char *name)
@ -1036,19 +1015,19 @@ cygwin_gethostbyname (const char *name)
return &tmp;
}
hostent_buf = (hostent *) dup_ent (hostent_buf, gethostbyname (name),
_my_tls.locals.hostent_buf = (hostent *) dup_ent (_my_tls.locals.hostent_buf, gethostbyname (name),
is_hostent);
if (!hostent_buf)
if (!_my_tls.locals.hostent_buf)
{
set_winsock_errno ();
set_host_errno ();
}
else
{
debug_printf ("h_name %s", hostent_buf->h_name);
debug_printf ("h_name %s", _my_tls.locals.hostent_buf->h_name);
h_errno = 0;
}
return hostent_buf;
return _my_tls.locals.hostent_buf;
}
/* exported as gethostbyaddr: standards? */
@ -1059,20 +1038,20 @@ cygwin_gethostbyaddr (const char *addr, int len, int type)
if (__check_invalid_read_ptr_errno (addr, len))
return NULL;
hostent_buf = (hostent *) dup_ent (hostent_buf,
_my_tls.locals.hostent_buf = (hostent *) dup_ent (_my_tls.locals.hostent_buf,
gethostbyaddr (addr, len, type),
is_hostent);
if (!hostent_buf)
if (!_my_tls.locals.hostent_buf)
{
set_winsock_errno ();
set_host_errno ();
}
else
{
debug_printf ("h_name %s", hostent_buf->h_name);
debug_printf ("h_name %s", _my_tls.locals.hostent_buf->h_name);
h_errno = 0;
}
return hostent_buf;
return _my_tls.locals.hostent_buf;
}
/* exported as accept: standards? */

View File

@ -26,12 +26,8 @@ details. */
on the first call that needs information from it. */
passwd *passwd_buf;
/* FIXME: This really should use a constructor, but they are slow */
static pwdgrp pr (passwd_buf);
/* Position in the passwd cache */
#define pw_pos _reent_winsup ()->_pw_pos
/* Parse /etc/passwd line into passwd structure. */
bool
pwdgrp::parse_passwd ()
@ -254,10 +250,10 @@ getpwnam_r (const char *nam, struct passwd *pwd, char *buffer, size_t bufsize, s
extern "C" struct passwd *
getpwent (void)
{
if (pw_pos == 0)
if (_my_tls.locals.pw_pos == 0)
pr.refresh (true);
if (pw_pos < pr.curr_lines)
return passwd_buf + pw_pos++;
if (_my_tls.locals.pw_pos < pr.curr_lines)
return passwd_buf + _my_tls.locals.pw_pos++;
return NULL;
}
@ -271,13 +267,13 @@ getpwduid (__uid16_t)
extern "C" void
setpwent (void)
{
pw_pos = 0;
_my_tls.locals.pw_pos = 0;
}
extern "C" void
endpwent (void)
{
pw_pos = 0;
_my_tls.locals.pw_pos = 0;
}
extern "C" int
@ -289,7 +285,7 @@ setpassent ()
extern "C" char *
getpass (const char * prompt)
{
char *pass=_reent_winsup ()->_pass;
char *pass = _my_tls.locals.pass;
struct termios ti, newti;
cygheap_fdget fhstdin (0);

View File

@ -72,16 +72,9 @@ details. */
#include "cygheap.h"
#include "shared_info.h"
#include "registry.h"
#include "cygtls.h"
#include <assert.h>
#ifdef _MT_SAFE
#define iteration _reent_winsup ()->_iteration
#define available_drives _reent_winsup ()->available_drives
#else
static int iteration;
static DWORD available_drives;
#endif
static int normalize_win32_path (const char *src, char *dst);
static void slashify (const char *src, char *dst, int trailing_slash_p);
static void backslashify (const char *src, char *dst, int trailing_slash_p);
@ -1235,7 +1228,7 @@ void
mount_item::fnmunge (char *dst, const char *src)
{
int name_type;
if (!(flags & MOUNT_ENC) || !(name_type = special_name (src)))
if (!(name_type = special_name (src)))
strcpy (dst, src);
else
{
@ -1286,7 +1279,25 @@ mount_item::build_win32 (char *dst, const char *src, unsigned *outflags, unsigne
/* nothing */;
else if ((!(flags & MOUNT_ENC) && isdrive (dst) && !dst[2]) || *p)
dst[n++] = '\\';
fnmunge (dst + n, p);
if (!*p || !(flags & MOUNT_ENC))
strcpy (dst + n, p);
else
while (*p)
{
char slash = 0;
char *s = strchr (p + 1, '/');
if (s)
{
slash = *s;
*s = '\0';
}
fnmunge (dst += n, p);
if (!s)
break;
n = strlen (dst);
*s = slash;
p = s;
}
}
/* conv_to_win32_path: Ensure src_path is a pure Win32 path and store
@ -2234,18 +2245,14 @@ mount_info::del_item (const char *path, unsigned flags, int reg_p)
static mntent *
fillout_mntent (const char *native_path, const char *posix_path, unsigned flags)
{
#ifdef _MT_SAFE
struct mntent &ret=_reent_winsup ()->mntbuf;
#else
static NO_COPY struct mntent ret;
#endif
struct mntent& ret=_my_tls.locals.mntbuf;
/* Remove drivenum from list if we see a x: style path */
if (strlen (native_path) == 2 && native_path[1] == ':')
{
int drivenum = cyg_tolower (native_path[0]) - 'a';
if (drivenum >= 0 && drivenum <= 31)
available_drives &= ~(1 << drivenum);
_my_tls.locals.available_drives &= ~(1 << drivenum);
}
/* Pass back pointers to mount_table strings reserved for use by
@ -2253,40 +2260,39 @@ fillout_mntent (const char *native_path, const char *posix_path, unsigned flags)
table because the mount table might change, causing weird effects
from the getmntent user's point of view. */
strcpy (_reent_winsup ()->mnt_fsname, native_path);
ret.mnt_fsname = _reent_winsup ()->mnt_fsname;
strcpy (_reent_winsup ()->mnt_dir, posix_path);
ret.mnt_dir = _reent_winsup ()->mnt_dir;
strcpy (_my_tls.locals.mnt_fsname, native_path);
ret.mnt_fsname = _my_tls.locals.mnt_fsname;
strcpy (_my_tls.locals.mnt_dir, posix_path);
ret.mnt_dir = _my_tls.locals.mnt_dir;
if (!(flags & MOUNT_SYSTEM)) /* user mount */
strcpy (_reent_winsup ()->mnt_type, (char *) "user");
strcpy (_my_tls.locals.mnt_type, (char *) "user");
else /* system mount */
strcpy (_reent_winsup ()->mnt_type, (char *) "system");
strcpy (_my_tls.locals.mnt_type, (char *) "system");
ret.mnt_type = _reent_winsup ()->mnt_type;
ret.mnt_type = _my_tls.locals.mnt_type;
/* mnt_opts is a string that details mount params such as
binary or textmode, or exec. We don't print
`silent' here; it's a magic internal thing. */
if (!(flags & MOUNT_BINARY))
strcpy (_reent_winsup ()->mnt_opts, (char *) "textmode");
strcpy (_my_tls.locals.mnt_opts, (char *) "textmode");
else
strcpy (_reent_winsup ()->mnt_opts, (char *) "binmode");
strcpy (_my_tls.locals.mnt_opts, (char *) "binmode");
if (flags & MOUNT_CYGWIN_EXEC)
strcat (_reent_winsup ()->mnt_opts, (char *) ",cygexec");
strcat (_my_tls.locals.mnt_opts, (char *) ",cygexec");
else if (flags & MOUNT_EXEC)
strcat (_reent_winsup ()->mnt_opts, (char *) ",exec");
strcat (_my_tls.locals.mnt_opts, (char *) ",exec");
else if (flags & MOUNT_NOTEXEC)
strcat (_reent_winsup ()->mnt_opts, (char *) ",noexec");
strcat (_my_tls.locals.mnt_opts, (char *) ",noexec");
if (flags & MOUNT_ENC)
strcat (_reent_winsup ()->mnt_opts, ",managed");
strcat (_my_tls.locals.mnt_opts, ",managed");
if ((flags & MOUNT_CYGDRIVE)) /* cygdrive */
strcat (_reent_winsup ()->mnt_opts, (char *) ",noumount");
ret.mnt_opts = _reent_winsup ()->mnt_opts;
strcat (_my_tls.locals.mnt_opts, (char *) ",noumount");
ret.mnt_opts = _my_tls.locals.mnt_opts;
ret.mnt_freq = 1;
ret.mnt_passno = 1;
@ -2307,16 +2313,16 @@ cygdrive_getmntent ()
DWORD mask = 1, drive = 'a';
struct mntent *ret = NULL;
while (available_drives)
while (_my_tls.locals.available_drives)
{
for (/* nothing */; drive <= 'z'; mask <<= 1, drive++)
if (available_drives & mask)
if (_my_tls.locals.available_drives & mask)
break;
__small_sprintf (native_path, "%c:\\", drive);
if (GetFileAttributes (native_path) == INVALID_FILE_ATTRIBUTES)
{
available_drives &= ~mask;
_my_tls.locals.available_drives &= ~mask;
continue;
}
native_path[2] = '\0';
@ -2425,15 +2431,15 @@ cygwin_umount (const char *path, unsigned flags)
extern "C" FILE *
setmntent (const char *filep, const char *)
{
iteration = 0;
available_drives = GetLogicalDrives ();
_my_tls.locals.iteration = 0;
_my_tls.locals.available_drives = GetLogicalDrives ();
return (FILE *) filep;
}
extern "C" struct mntent *
getmntent (FILE *)
{
return mount_table->getmntent (iteration++);
return mount_table->getmntent (_my_tls.locals.iteration++);
}
extern "C" int

View File

@ -257,6 +257,7 @@ pinfo::set_acl()
void
_pinfo::set_ctty (tty_min *tc, int flags, fhandler_tty_slave *arch)
{
debug_printf ("ctty %d", ctty);
if ((ctty < 0 || ctty == tc->ntty) && !(flags & O_NOCTTY))
{
ctty = tc->ntty;

View File

@ -22,6 +22,7 @@ extern struct __group32 *internal_getgrent (int);
int internal_getgroups (int, __gid32_t *, cygpsid * = NULL);
#include "sync.h"
#include "cygtls.h"
class pwdgrp
{
unsigned pwdgrp_buf_elem_size;

View File

@ -588,8 +588,17 @@ int __stdcall
sig_dispatch_pending ()
{
if (exit_state || GetCurrentThreadId () == sigtid || !sigqueue.start.next)
return 0;
{
#ifdef DEBUGGING
sigproc_printf ("exit_state %d, GetCurrentThreadId () %p, sigtid %p, sigqueue.start.next %p",
exit_state, GetCurrentThreadId (), sigtid, sigqueue.start.next);
#endif
return 0;
}
#ifdef DEBUGGING
sigproc_printf ("flushing");
#endif
(void) sig_send (myself, __SIGFLUSH);
return call_signal_handler_now ();
}
@ -1155,8 +1164,15 @@ wait_sig (VOID *self)
sig_clear (-pack.sig);
else
{
if (sig_handle (pack.sig, *pack.mask, pack.pid, pack.tls) <= 0)
sigqueue.add (pack.sig, pack.pid, pack.tls);// FIXME: Shouldn't add this in !sh condition
int sigres = sig_handle (pack.sig, *pack.mask, pack.pid, pack.tls);
if (sigres <= 0)
{
#ifdef DEBUGGING
if (!sigres)
system_printf ("Failed to arm signal %d from pid %d");
#endif
sigqueue.add (pack.sig, pack.pid, pack.tls);// FIXME: Shouldn't add this in !sh condition
}
if (pack.sig == SIGCHLD)
proc_subproc (PROC_CLEARWAIT, 0);
}

View File

@ -54,7 +54,7 @@ extern HANDLE sigCONT;
bool __stdcall my_parent_is_alive ();
int __stdcall sig_dispatch_pending ();
#ifdef _PINFO_H
extern "C" void __stdcall set_signal_mask (sigset_t newmask, sigset_t& = myself->getsigmask ());
extern "C" void __stdcall set_signal_mask (sigset_t newmask, sigset_t = myself->getsigmask ());
#endif
int __stdcall handle_sigprocmask (int sig, const sigset_t *set,
sigset_t *oldset, sigset_t& opmask)

View File

@ -319,7 +319,9 @@ setsid (void)
/* assuming that fork was successful */
}
if (myself->pgid != myself->pid)
if (myself->pgid == myself->pid)
syscall_printf ("hmm. pgid %d pid %d", myself->pgid, myself->pid);
else
{
if (myself->ctty >= 0 && fhandler_console::open_fhs <= 0)
{

View File

@ -21,6 +21,7 @@ details. */
#include "cygerrno.h"
#include "cygheap.h"
#include "thread.h"
#include "cygtls.h"
/* FIXME: These should probably be in the registry. */
/* FIXME: The Win95 path should be whatever slash is */
@ -38,50 +39,31 @@ get_win95_event_log_path ()
return WIN95_EVENT_LOG_PATH;
}
/* FIXME: For MT safe code these will need to be replaced */
#ifdef _MT_SAFE
#define process_ident _reent_winsup ()->_process_ident
#define process_logopt _reent_winsup ()->_process_logopt
#define process_facility _reent_winsup ()->_process_facility
/* Default priority logmask */
#define process_logmask _reent_winsup ()->_process_logmask
#else
static char *process_ident = 0;
static int process_logopt = 0;
static int process_facility = 0;
/* Default priority logmask */
static int process_logmask = LOG_UPTO (LOG_DEBUG);
#endif
/*
* openlog: save the passed args. Don't open the
* system log (NT) or log file (95) yet.
*/
/* openlog: save the passed args. Don't open the
system log (NT) or log file (95) yet. */
extern "C" void
openlog (const char *ident, int logopt, int facility)
{
debug_printf ("openlog called with (%s, %d, %d)",
ident ? ident : "<NULL>", logopt, facility);
if (process_ident != NULL)
if (_my_tls.locals.process_ident != NULL)
{
free (process_ident);
process_ident = 0;
free (_my_tls.locals.process_ident);
_my_tls.locals.process_ident = 0;
}
if (ident)
{
process_ident = (char *) malloc (strlen (ident) + 1);
if (process_ident == NULL)
_my_tls.locals.process_ident = (char *) malloc (strlen (ident) + 1);
if (_my_tls.locals.process_ident == NULL)
{
debug_printf ("failed to allocate memory for process_ident");
debug_printf ("failed to allocate memory for _my_tls.locals.process_ident");
return;
}
strcpy (process_ident, ident);
strcpy (_my_tls.locals.process_ident, ident);
}
process_logopt = logopt;
process_facility = facility;
_my_tls.locals.process_logopt = logopt;
_my_tls.locals.process_facility = facility;
}
/* setlogmask: set the log priority mask and return previous mask.
@ -90,16 +72,16 @@ int
setlogmask (int maskpri)
{
if (maskpri == 0)
return process_logmask;
return _my_tls.locals.process_logmask;
int old_mask = process_logmask;
process_logmask = maskpri & LOG_PRIMASK;
int old_mask = _my_tls.locals.process_logmask;
_my_tls.locals.process_logmask = maskpri & LOG_PRIMASK;
return old_mask;
}
/* Private class used to handle formatting of syslog message */
/* It is named pass_handler because it does a two-pass handling of log
/* Private class used to handle formatting of syslog message
It is named pass_handler because it does a two-pass handling of log
strings. The first pass counts the length of the string, and the second
one builds the string. */
@ -211,10 +193,10 @@ vsyslog (int priority, const char *message, va_list ap)
{
debug_printf ("%x %s", priority, message);
/* If the priority fails the current mask, reject */
if (((priority & LOG_PRIMASK) & process_logmask) == 0)
if (((priority & LOG_PRIMASK) & _my_tls.locals.process_logmask) == 0)
{
debug_printf ("failing message %x due to priority mask %x",
priority, process_logmask);
priority, _my_tls.locals.process_logmask);
return;
}
@ -290,12 +272,12 @@ vsyslog (int priority, const char *message, va_list ap)
pass.set_message ((char *) alloca (n));
/* Deal with ident_string */
if (process_ident != NULL)
if (_my_tls.locals.process_ident != NULL)
{
if (pass.print ("%s : ", process_ident) == -1)
if (pass.print ("%s : ", _my_tls.locals.process_ident) == -1)
return;
}
if (process_logopt & LOG_PID)
if (_my_tls.locals.process_logopt & LOG_PID)
{
if (pass.print ("PID %u : ", getpid ()) == -1)
return;
@ -353,8 +335,8 @@ vsyslog (int priority, const char *message, va_list ap)
if (wincap.has_eventlog ())
{
/* For NT, open the event log and send the message */
HANDLE hEventSrc = RegisterEventSourceA (NULL, (process_ident != NULL) ?
process_ident : CYGWIN_LOG_NAME);
HANDLE hEventSrc = RegisterEventSourceA (NULL, (_my_tls.locals.process_ident != NULL) ?
_my_tls.locals.process_ident : CYGWIN_LOG_NAME);
if (hEventSrc == NULL)
{
debug_printf ("RegisterEventSourceA failed with %E");

View File

@ -34,7 +34,6 @@ details. */
#include "cygerrno.h"
#include <assert.h>
#include <stdlib.h>
#include <syslog.h>
#include "pinfo.h"
#include "sigproc.h"
#include "perprocess.h"
@ -48,112 +47,36 @@ details. */
extern int threadsafe;
#undef __getreent
extern "C" struct _reent *
__getreent ()
{
struct __reent_t *_r =
(struct __reent_t *) MT_INTERFACE->reent_key.get ();
if (_r == 0)
{
#ifdef _CYG_THREAD_FAILSAFE
system_printf ("local thread storage not inited");
#endif
/* Return _impure_ptr as long as MTinterface is not initialized */
return _impure_ptr;
}
return _r->_clib;
}
struct _winsup_t *
_reent_winsup ()
{
struct __reent_t *_r =
(struct __reent_t *) MT_INTERFACE->reent_key.get ();
if (_r == 0)
{
#ifdef _CYG_THREAD_FAILSAFE
system_printf ("local thread storage not inited");
#endif
return NULL;
}
return _r->_winsup;
return &_my_tls.local_clib;
}
inline LPCRITICAL_SECTION
ResourceLocks::Lock (int _resid)
{
#ifdef _CYG_THREAD_FAILSAFE
if (!inited)
system_printf ("lock called before initialization");
thread_printf
("Get Resource lock %d ==> %p for %p , real : %d , threadid %d ", _resid,
&lock, user_data, myself->pid, GetCurrentThreadId ());
#endif
return &lock;
}
void
SetResourceLock (int _res_id, int _mode, const char *_function)
{
#ifdef _CYG_THREAD_FAILSAFE
thread_printf ("Set resource lock %d mode %d for %s start",
_res_id, _mode, _function);
#endif
EnterCriticalSection (user_data->resourcelocks->Lock (_res_id));
#ifdef _CYG_THREAD_FAILSAFE
user_data->resourcelocks->owner = GetCurrentThreadId ();
user_data->resourcelocks->count++;
#endif
}
void
ReleaseResourceLock (int _res_id, int _mode, const char *_function)
{
#ifdef _CYG_THREAD_FAILSAFE
thread_printf ("Release resource lock %d mode %d for %s done", _res_id,
_mode, _function);
AssertResourceOwner (_res_id, _mode);
user_data->resourcelocks->count--;
if (user_data->resourcelocks->count == 0)
user_data->resourcelocks->owner = 0;
#endif
LeaveCriticalSection (user_data->resourcelocks->Lock (_res_id));
}
#ifdef _CYG_THREAD_FAILSAFE
void
AssertResourceOwner (int _res_id, int _mode)
{
thread_printf
("Assert Resource lock %d ==> for %p , real : %d , threadid %d count %d owner %d",
_res_id, user_data, myself->pid, GetCurrentThreadId (),
user_data->resourcelocks->count, user_data->resourcelocks->owner);
if (user_data && (user_data->resourcelocks->owner != GetCurrentThreadId ()))
system_printf ("assertion failed, not the resource owner");
}
#endif
void
ResourceLocks::Init ()
{
InitializeCriticalSection (&lock);
inited = true;
#ifdef _CYG_THREAD_FAILSAFE
owner = 0;
count = 0;
#endif
thread_printf ("lock %p inited by %p , %d", &lock, user_data, myself->pid);
}
@ -171,11 +94,6 @@ ResourceLocks::Delete ()
void
MTinterface::Init ()
{
reents._clib = _impure_ptr;
reents._winsup = &winsup_reent;
winsup_reent._process_logmask = LOG_UPTO (LOG_DEBUG);
reent_key.set (&reents);
pthread_mutex::init_mutex ();
pthread_cond::init_mutex ();
pthread_rwlock::init_mutex ();
@ -193,14 +111,6 @@ MTinterface::fixup_after_fork (void)
{
pthread_key::fixup_after_fork ();
/* As long as the signal handling not multithreaded
switch reents storage back to _impure_ptr for the mainthread
to support fork from threads other than the mainthread */
reents._clib = _impure_ptr;
reents._winsup = &winsup_reent;
winsup_reent._process_logmask = LOG_UPTO (LOG_DEBUG);
reent_key.set (&reents);
threadcount = 0;
pthread::init_mainthread ();
@ -232,7 +142,6 @@ pthread::init_mainthread ()
GetCurrentProcess (), &thread->win32_obj_id,
0, FALSE, DUPLICATE_SAME_ACCESS))
api_fatal ("failed to create mainthread handle");
thread->set_tls_self_pointer ();
if (!thread->create_cancel_event ())
api_fatal ("couldn't create cancel event for main thread");
thread->postcreate ();
@ -247,20 +156,12 @@ pthread::self ()
return pthread_null::get_null_pthread ();
}
void
pthread::set_tls_self_pointer ()
{
MT_INTERFACE->thread_self_key.set (this);
}
pthread *
pthread::get_tls_self_pointer ()
{
return (pthread *) MT_INTERFACE->thread_self_key.get ();
return _my_tls.tid;
}
List<pthread> pthread::threads;
/* member methods */
@ -1876,18 +1777,6 @@ verifyable_object_isvalid (void const * objectptr, long magic)
return verifyable_object_isvalid (objectptr, magic, NULL);
}
inline void
__reent_t::init_clib (struct _reent& var)
{
var = ((struct _reent) _REENT_INIT (var));
var._stdin = _GLOBAL_REENT->_stdin;
var._stdout = _GLOBAL_REENT->_stdout;
var._stderr = _GLOBAL_REENT->_stderr;
var.__sdidinit = _GLOBAL_REENT->__sdidinit;
var.__cleanup = _GLOBAL_REENT->__cleanup;
_clib = &var;
};
DWORD WINAPI
pthread::thread_init_wrapper (void *arg)
{
@ -1897,32 +1786,14 @@ pthread::thread_init_wrapper (void *arg)
exception_list cygwin_except_entry;
init_exceptions (&cygwin_except_entry); /* Initialize SIGSEGV handling, etc. */
thread->set_tls_self_pointer ();
struct __reent_t local_reent;
struct _winsup_t local_winsup;
struct _reent local_clib;
memset (&local_winsup, 0, sizeof (struct _winsup_t));
local_reent.init_clib (local_clib);
local_reent._winsup = &local_winsup;
local_winsup._process_logmask = LOG_UPTO (LOG_DEBUG);
MT_INTERFACE->reent_key.set (&local_reent);
thread->mutex.lock ();
// if thread is detached force cleanup on exit
if (thread->attr.joinable == PTHREAD_CREATE_DETACHED && thread->joiner == NULL)
thread->joiner = thread;
thread->mutex.unlock ();
#ifdef _CYG_THREAD_FAILSAFE
if (_REENT == _impure_ptr)
system_printf ("local storage for thread isn't setup correctly");
#endif
thread_printf ("started thread %p %p %p %p %p %p", arg, &local_clib,
thread_printf ("started thread %p %p %p %p %p %p", arg, &_my_tls.local_clib,
_impure_ptr, thread, thread->function, thread->arg);
// call the user's thread
@ -2394,7 +2265,7 @@ pthread_getschedparam (pthread_t thread, int *policy,
return 0;
}
/* Thread SpecificData */
/* Thread Specific Data */
extern "C" int
pthread_key_create (pthread_key_t *key, void (*destructor) (void *))
{

View File

@ -22,106 +22,16 @@ details. */
#define WRITE_LOCK 1
#define READ_LOCK 2
extern "C"
{
#if defined (_CYG_THREAD_FAILSAFE) && defined (_MT_SAFE)
void AssertResourceOwner (int, int);
#else
#define AssertResourceOwner(i,ii)
#endif
}
#ifndef _MT_SAFE
#define SetResourceLock(i,n,c)
#define ReleaseResourceLock(i,n,c)
#else
#include <pthread.h>
#include <limits.h>
#include <errno.h>
#include <signal.h>
#include <pwd.h>
#include <grp.h>
#include <security.h>
#define _NOMNTENT_FUNCS
#include <mntent.h>
#include <errno.h>
extern "C"
{
struct _winsup_t
{
/*
Needed for the group functions
*/
struct __group16 _grp;
char *_namearray[2];
int _grp_pos;
/* console.cc */
unsigned _rarg;
/* dlfcn.cc */
int _dl_error;
char _dl_buffer[256];
/* passwd.cc */
struct passwd _res;
char _pass[_PASSWORD_LEN];
int _pw_pos;
/* path.cc */
struct mntent mntbuf;
int _iteration;
DWORD available_drives;
char mnt_type[80];
char mnt_opts[80];
char mnt_fsname[CYG_MAX_PATH];
char mnt_dir[CYG_MAX_PATH];
/* strerror */
char _strerror_buf[20];
/* sysloc.cc */
char *_process_ident;
int _process_logopt;
int _process_facility;
int _process_logmask;
/* times.cc */
char timezone_buf[20];
struct tm _localtime_buf;
/* uinfo.cc */
char _username[UNLEN + 1];
/* net.cc */
char *_ntoa_buf;
struct protoent *_protoent_buf;
struct servent *_servent_buf;
struct hostent *_hostent_buf;
};
struct __reent_t
{
struct _reent *_clib;
struct _winsup_t *_winsup;
void init_clib (_reent&);
};
_winsup_t *_reent_winsup ();
void SetResourceLock (int, int, const char *) __attribute__ ((regparm (3)));
void ReleaseResourceLock (int, int, const char *)
__attribute__ ((regparm (3)));
#ifdef _CYG_THREAD_FAILSAFE
void AssertResourceOwner (int, int);
#else
#define AssertResourceOwner(i,ii)
#endif
}
class fast_mutex
@ -173,16 +83,9 @@ class pinfo;
class ResourceLocks
{
public:
ResourceLocks ()
{
}
LPCRITICAL_SECTION Lock (int);
void Init ();
void Delete ();
#ifdef _CYG_THREAD_FAILSAFE
DWORD owner;
DWORD count;
#endif
private:
CRITICAL_SECTION lock;
bool inited;
@ -770,36 +673,22 @@ struct MTinterface
int concurrency;
long int threadcount;
// Used for main thread data, and sigproc thread
struct __reent_t reents;
struct _winsup_t winsup_reent;
callback *pthread_prepare;
callback *pthread_child;
callback *pthread_parent;
pthread_key reent_key;
pthread_key thread_self_key;
void Init ();
void fixup_before_fork (void);
void fixup_after_fork (void);
#if 1 // avoid initialization since zero is implied and
// only use of this class is static
MTinterface () : reent_key (NULL), thread_self_key (NULL) {}
#else
#if 0 // avoid initialization since zero is implied and
MTinterface () :
concurrency (0), threadcount (0),
pthread_prepare (NULL), pthread_child (NULL), pthread_parent (NULL),
reent_key (NULL), thread_self_key (NULL)
pthread_prepare (NULL), pthread_child (NULL), pthread_parent (NULL)
{
}
#endif
};
#define MT_INTERFACE user_data->threadinterface
#endif // MT_SAFE
#endif // _CYGNUS_THREADS_

View File

@ -21,6 +21,7 @@ details. */
#include "fhandler.h"
#include "pinfo.h"
#include "hires.h"
#include "cygtls.h"
#define FACTOR (0x19db1ded53e8000LL)
#define NSPERSEC 10000000LL
@ -118,11 +119,7 @@ settimeofday (const struct timeval *tv, const struct timezone *tz)
extern "C" char *
timezone ()
{
#ifdef _MT_SAFE
char *b=_reent_winsup ()->timezone_buf;
#else
static NO_COPY char b[20] = {0};
#endif
char *b = _my_tls.locals.timezone_buf;
tzset ();
__small_sprintf (b,"GMT%+d:%02d", (int) (-_timezone / 3600), (int) (abs (_timezone / 60) % 60));
@ -332,11 +329,7 @@ corelocaltime (const time_t * tim_p)
int y;
int yleap;
_CONST int *ip;
#ifdef _MT_SAFE
struct tm &localtime_buf=_reent_winsup ()->_localtime_buf;
#else
static NO_COPY struct tm localtime_buf = {0};
#endif
struct tm &localtime_buf=_my_tls.locals.localtime_buf;
time_t tim = *tim_p;
struct tm *res = &localtime_buf;

View File

@ -1,18 +1,20 @@
//;# autogenerated: Do not edit.
//; $tls::func = -620;
//; $tls::saved_errno = -616;
//; $tls::sa_flags = -612;
//; $tls::oldmask = -608;
//; $tls::newmask = -604;
//; $tls::event = -600;
//; $tls::errno_addr = -596;
//; $tls::initialized = -592;
//; $tls::sigmask = -588;
//; $tls::sigwait_mask = -584;
//; $tls::sigwait_info = -580;
//; $tls::infodata = -576;
//; $tls::tid = -52;
//; $tls::func = -3084;
//; $tls::saved_errno = -3080;
//; $tls::sa_flags = -3076;
//; $tls::oldmask = -3072;
//; $tls::newmask = -3068;
//; $tls::event = -3064;
//; $tls::errno_addr = -3060;
//; $tls::initialized = -3056;
//; $tls::sigmask = -3052;
//; $tls::sigwait_mask = -3048;
//; $tls::sigwait_info = -3044;
//; $tls::infodata = -3040;
//; $tls::tid = -2516;
//; $tls::local_clib = -2512;
//; $tls::locals = -1584;
//; $tls::prev = -48;
//; $tls::next = -44;
//; $tls::stack = -40;
@ -20,19 +22,21 @@
//; $tls::stackptr = -4;
//; __DATA__
#define tls_func (-620)
#define tls_saved_errno (-616)
#define tls_sa_flags (-612)
#define tls_oldmask (-608)
#define tls_newmask (-604)
#define tls_event (-600)
#define tls_errno_addr (-596)
#define tls_initialized (-592)
#define tls_sigmask (-588)
#define tls_sigwait_mask (-584)
#define tls_sigwait_info (-580)
#define tls_infodata (-576)
#define tls_tid (-52)
#define tls_func (-3084)
#define tls_saved_errno (-3080)
#define tls_sa_flags (-3076)
#define tls_oldmask (-3072)
#define tls_newmask (-3068)
#define tls_event (-3064)
#define tls_errno_addr (-3060)
#define tls_initialized (-3056)
#define tls_sigmask (-3052)
#define tls_sigwait_mask (-3048)
#define tls_sigwait_info (-3044)
#define tls_infodata (-3040)
#define tls_tid (-2516)
#define tls_local_clib (-2512)
#define tls_locals (-1584)
#define tls_prev (-48)
#define tls_next (-44)
#define tls_stack (-40)

View File

@ -180,13 +180,7 @@ uinfo_init ()
extern "C" char *
getlogin (void)
{
#ifdef _MT_SAFE
char *this_username=_reent_winsup ()->_username;
#else
static char this_username[UNLEN + 1] NO_COPY;
#endif
return strcpy (this_username, cygheap->user.name ());
return strcpy (_my_tls.locals.username, cygheap->user.name ());
}
extern "C" __uid32_t