* localtime.cc (localtime_r): Call tzset.

* Makefile.in: Make version.h/cygwin.din version check a warning since it is
not foolproof.
* cygheap.h (CYGHEAPSIZE): Bump size down.
* cygtls.h (_threadinfo::stacklock): New element.
(_threadinfo::pop): Make regparm.
(_threadinfo::lock): New function.
(_threadinfo::unlock): New function.
* cygtls.cc (_threadinfo::push): Wait for a lock on the stack before performing
the operation.
(_threadinfo::pop): Move to another file.
* cygwin.din: More SIGFE changes.
* exceptions.cc (try_to_debug): Always display messages on console.
(handle_exceptions): Unwind stack only when actually about to call sig_send.
(setup_handler): Lock stack prior to performing any operations.
* gendef (_sigfe): Ditto.
(_sigbe): Ditto.
(_threadinfo::pop): Ditto.  Move here.
* gen_tlsoffsets: Generate positive offsets.
* tlsoffsets.h: Regenerate.
This commit is contained in:
Christopher Faylor 2004-02-08 19:59:27 +00:00
parent f5133f95b0
commit 6946073e78
11 changed files with 214 additions and 100 deletions

View File

@ -1,3 +1,30 @@
2004-02-08 Christopher Faylor <cgf@redhat.com>
* localtime.cc (localtime_r): Call tzset.
* Makefile.in: Make version.h/cygwin.din version check a warning since
it is not foolproof.
* cygheap.h (CYGHEAPSIZE): Bump size down.
* cygtls.h (_threadinfo::stacklock): New element.
(_threadinfo::pop): Make regparm.
(_threadinfo::lock): New function.
(_threadinfo::unlock): New function.
* cygtls.cc (_threadinfo::push): Wait for a lock on the stack before
performing the operation.
(_threadinfo::pop): Move to another file.
* cygwin.din: More SIGFE changes.
* exceptions.cc (try_to_debug): Always display messages on console.
(handle_exceptions): Unwind stack only when actually about to call
sig_send.
(setup_handler): Lock stack prior to performing any operations.
* gendef (_sigfe): Ditto.
(_sigbe): Ditto.
(_threadinfo::pop): Ditto. Move here.
* gen_tlsoffsets: Generate positive offsets.
* tlsoffsets.h: Regenerate.
2004-02-06 Corinna Vinschen <corinna@vinschen.de> 2004-02-06 Corinna Vinschen <corinna@vinschen.de>
* cygserver.h (CYGWIN_SERVER_VERSION_API): Bump. * cygserver.h (CYGWIN_SERVER_VERSION_API): Bump.

View File

@ -384,8 +384,7 @@ $(LIBGMON_A): $(GMON_OFILES) $(GMON_START)
$(AR) rcv $(LIBGMON_A) $(GMON_OFILES) $(AR) rcv $(LIBGMON_A) $(GMON_OFILES)
$(API_VER): $(srcdir)/cygwin.din $(API_VER): $(srcdir)/cygwin.din
@echo Error: Version info is older than DLL API!;\ @echo Error: Version info is older than DLL API!
false
version.cc winver.o: winver_stamp version.cc winver.o: winver_stamp
@ : @ :

View File

@ -272,7 +272,7 @@ struct init_cygheap
void close_ctty (); void close_ctty ();
}; };
#define CYGHEAPSIZE (sizeof (init_cygheap) + (20000 * sizeof (fhandler_union)) + (64 * 1024 * 1024)) #define CYGHEAPSIZE (sizeof (init_cygheap) + (20000 * sizeof (fhandler_union)) + (32 * 1024 * 1024))
extern init_cygheap *cygheap; extern init_cygheap *cygheap;
extern void *cygheap_max; extern void *cygheap_max;

View File

@ -155,24 +155,14 @@ _threadinfo::remove (DWORD wait)
void void
_threadinfo::push (__stack_t addr, bool exception) _threadinfo::push (__stack_t addr, bool exception)
{ {
if (exception)
lock (true);
*stackptr++ = (__stack_t) addr; *stackptr++ = (__stack_t) addr;
if (exception)
unlock ();
set_state (exception); 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;
}
#define BAD_IX ((size_t) -1) #define BAD_IX ((size_t) -1)
static size_t NO_COPY threadlist_ix = BAD_IX; static size_t NO_COPY threadlist_ix = BAD_IX;

View File

@ -111,6 +111,7 @@ struct _threadinfo
struct _threadinfo *prev, *next; struct _threadinfo *prev, *next;
__stack_t *stackptr; __stack_t *stackptr;
int sig; int sig;
unsigned stacklock;
__stack_t stack[TLS_STACK_SIZE]; __stack_t stack[TLS_STACK_SIZE];
unsigned padding[0]; unsigned padding[0];
@ -123,7 +124,7 @@ struct _threadinfo
static struct _threadinfo *find_tls (int sig); static struct _threadinfo *find_tls (int sig);
void remove (DWORD); void remove (DWORD);
void push (__stack_t, bool = false) __attribute__ ((regparm (3))); void push (__stack_t, bool = false) __attribute__ ((regparm (3)));
__stack_t pop (); __stack_t pop () __attribute__ ((regparm (1)));
bool isinitialized () {return initialized == CYGTLS_INITIALIZED || initialized == CYGTLS_EXCEPTION;} bool isinitialized () {return initialized == CYGTLS_INITIALIZED || initialized == CYGTLS_EXCEPTION;}
void set_state (bool); void set_state (bool);
void reset_exception (); void reset_exception ();
@ -136,6 +137,8 @@ struct _threadinfo
void set_siginfo (struct sigpacket *) __attribute__ ((regparm (3))); void set_siginfo (struct sigpacket *) __attribute__ ((regparm (3)));
void set_threadkill () {threadkill = true;} void set_threadkill () {threadkill = true;}
void reset_threadkill () {threadkill = false;} void reset_threadkill () {threadkill = false;}
int lock (int wait) __attribute__ ((regparm (2)));
void unlock () __attribute__ ((regparm (1)));
/*gentls_offsets*/ /*gentls_offsets*/
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -479,19 +479,19 @@ fdimf NOSIGFE
fdopen SIGFE fdopen SIGFE
_fdopen = fdopen SIGFE _fdopen = fdopen SIGFE
_fdopen64 = fdopen64 SIGFE _fdopen64 = fdopen64 SIGFE
feof NOSIGFE feof SIGFE
_feof = feof NOSIGFE _feof = feof SIGFE
ferror NOSIGFE ferror NOSIGFE
_ferror = ferror NOSIGFE _ferror = ferror NOSIGFE
fflush NOSIGFE fflush SIGFE
_fflush = fflush NOSIGFE _fflush = fflush SIGFE
ffs NOSIGFE ffs NOSIGFE
_ffs = ffs NOSIGFE _ffs = ffs NOSIGFE
fgetc SIGFE fgetc SIGFE
_fgetc = fgetc SIGFE _fgetc = fgetc SIGFE
fgetpos NOSIGFE fgetpos SIGFE
_fgetpos = fgetpos NOSIGFE _fgetpos = fgetpos SIGFE
_fgetpos64 = fgetpos64 NOSIGFE _fgetpos64 = fgetpos64 SIGFE
fgets SIGFE fgets SIGFE
_fgets = fgets SIGFE _fgets = fgets SIGFE
fileno NOSIGFE fileno NOSIGFE
@ -503,7 +503,6 @@ _finitef = finitef NOSIGFE
fiprintf SIGFE fiprintf SIGFE
_fiprintf = fiprintf SIGFE _fiprintf = fiprintf SIGFE
flock SIGFE flock SIGFE
flock SIGFE
floor NOSIGFE floor NOSIGFE
_floor = floor NOSIGFE _floor = floor NOSIGFE
floorf NOSIGFE floorf NOSIGFE
@ -559,11 +558,11 @@ fstatfs SIGFE
_fstatfs = fstatfs SIGFE _fstatfs = fstatfs SIGFE
fsync SIGFE fsync SIGFE
_fsync = fsync SIGFE _fsync = fsync SIGFE
ftell NOSIGFE ftell SIGFE
_ftell = ftell NOSIGFE _ftell = ftell SIGFE
ftello NOSIGFE ftello SIGFE
_ftello = ftello NOSIGFE _ftello = ftello SIGFE
_ftello64 = ftello64 NOSIGFE _ftello64 = ftello64 SIGFE
ftime SIGFE ftime SIGFE
_ftime = ftime SIGFE _ftime = ftime SIGFE
ftok SIGFE ftok SIGFE

View File

@ -361,7 +361,7 @@ try_to_debug (bool waitloop)
} }
} }
small_printf ("*** starting debugger for pid %u\n", console_printf ("*** starting debugger for pid %u\n",
cygwin_pid (GetCurrentProcessId ())); cygwin_pid (GetCurrentProcessId ()));
BOOL dbg; BOOL dbg;
dbg = CreateProcess (NULL, dbg = CreateProcess (NULL,
@ -380,17 +380,18 @@ try_to_debug (bool waitloop)
else else
{ {
if (!waitloop) if (!waitloop)
return 1; return dbg;
SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_IDLE); SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_IDLE);
while (!being_debugged ()) while (!being_debugged ())
Sleep (0); Sleep (0);
Sleep (2000); Sleep (2000);
small_printf ("*** continuing pid %u from debugger call\n",
cygwin_pid (GetCurrentProcessId ()));
} }
console_printf ("*** continuing pid %u from debugger call (%d)\n",
cygwin_pid (GetCurrentProcessId ()), dbg);
SetThreadPriority (GetCurrentThread (), prio); SetThreadPriority (GetCurrentThread (), prio);
return 0; return dbg;
} }
/* Main exception handler. */ /* Main exception handler. */
@ -416,10 +417,6 @@ handle_exceptions (EXCEPTION_RECORD *e0, void *frame, CONTEXT *in0, void *)
EXCEPTION_RECORD e = *e0; EXCEPTION_RECORD e = *e0;
CONTEXT in = *in0; CONTEXT in = *in0;
extern DWORD ret_here[];
RtlUnwind (frame, ret_here, e0, 0);
__asm__ volatile (".equ _ret_here,.");
siginfo_t si; siginfo_t si;
/* Coerce win32 value to posix value. */ /* Coerce win32 value to posix value. */
switch (e.ExceptionCode) switch (e.ExceptionCode)
@ -557,6 +554,10 @@ handle_exceptions (EXCEPTION_RECORD *e0, void *frame, CONTEXT *in0, void *)
signal_exit (0x80 | si.si_signo); // Flag signal + core dump signal_exit (0x80 | si.si_signo); // Flag signal + core dump
} }
extern DWORD ret_here[];
RtlUnwind (frame, ret_here, e0, 0);
__asm__ volatile (".equ _ret_here,.");
si.si_addr = ebp; si.si_addr = ebp;
si.si_code = SI_KERNEL; si.si_code = SI_KERNEL;
si.si_errno = si.si_pid = si.si_uid = 0; si.si_errno = si.si_pid = si.si_uid = 0;
@ -766,12 +767,15 @@ setup_handler (int sig, void *handler, struct sigaction& siga, _threadinfo *tls)
__stack_t *retaddr_on_stack = tls->stackptr - 1; __stack_t *retaddr_on_stack = tls->stackptr - 1;
if (retaddr_on_stack >= tls->stack) if (retaddr_on_stack >= tls->stack)
{ {
if (!tls->lock (false))
continue;
__stack_t retaddr = InterlockedExchange ((LONG *) retaddr_on_stack, 0); __stack_t retaddr = InterlockedExchange ((LONG *) retaddr_on_stack, 0);
if (!retaddr) if (!retaddr)
continue; continue;
tls->reset_exception (); tls->reset_exception ();
tls->interrupt_setup (sig, handler, siga, retaddr); tls->interrupt_setup (sig, handler, siga, retaddr);
sigproc_printf ("interrupted known cygwin routine"); sigproc_printf ("interrupted known cygwin routine");
tls->unlock ();
interrupted = true; interrupted = true;
break; break;
} }

View File

@ -88,40 +88,79 @@ EOF
if (!$main::first++) { if (!$main::first++) {
$res = <<EOF . longjmp () . $res; $res = <<EOF . longjmp () . $res;
.text .text
.global __sigbe
.global _sigreturn
.global _sigdelayed
.stabs "_sigfe:F(0,1)",36,0,0,__sigbe .stabs "_sigfe:F(0,1)",36,0,0,__sigbe
__sigfe: __sigfe:
pushl %edx pushl %edx
movl %fs:4,%eax movl %fs:4,%edx
movl \$4,%edx 1: movl \$1,%eax
xadd %edx,$tls::stackptr(%eax) lock cmpxchg %eax,$tls::stacklock(%edx)
leal __sigbe,%eax jne 2f
xchg %eax,8(%esp) xorl %eax,%eax
movl %eax,(%edx) call _low_priority_sleep
jmp 1b
2: movl \$4,%eax
xadd %eax,$tls::stackptr(%edx)
decl $tls::stacklock(%edx)
leal __sigbe,%edx
xchg %edx,8(%esp)
movl %edx,(%eax)
popl %edx popl %edx
ret ret
.global __sigbe
.stabs "_sigbe:F(0,1)",36,0,0,__sigbe .stabs "_sigbe:F(0,1)",36,0,0,__sigbe
__sigbe: __sigbe:
pushl %eax
pushl %edx pushl %edx
movl \$-4,%edx pushl %eax
1: movl %fs:4,%eax movl %fs:4,%edx
xadd %edx,$tls::stackptr(%eax) 1: movl \$1,%eax
lock cmpxchg %eax,$tls::stacklock(%edx)
jne 2f
xorl %eax,%eax xorl %eax,%eax
lock xchg %eax,-4(%edx)
testl %eax,%eax
jnz 2f
call _low_priority_sleep call _low_priority_sleep
xorl %edx,%edx
jmp 1b jmp 1b
2: xchg %eax,4(%esp) 2: movl \$-4,%eax
popl %edx xadd %eax,$tls::stackptr(%edx)
xchg %edx,-4(%eax)
xchg %edx,4(%esp)
popl %eax
ret ret
.global __ZN11_threadinfo3popEv
__ZN11_threadinfo3popEv:
1: pushl %ebx
movl %eax,%edx
movl \$-4,%ebx
xadd %ebx,$tls::pstackptr(%edx)
xorl %eax,%eax
xchg %eax,-4(%ebx)
decl $tls::pstacklock(%edx)
popl %ebx
ret
.global __ZN11_threadinfo4lockEi
__ZN11_threadinfo4lockEi:
pushl %ebx
movl %eax,%ebx
1: movl \$1,%eax
lock cmpxchg %eax,$tls::pstacklock(%ebx)
jne 2f
cmpl %edx,%edx
jz 2f
xorl %eax,%eax
call _low_priority_sleep
jmp 1b
2: xorl \$1,%eax
popl %ebx
ret
.global __ZN11_threadinfo6unlockEv
__ZN11_threadinfo6unlockEv:
decl $tls::pstacklock(%eax)
ret
.global _sigreturn
.stabs "sigreturn:F(0,1)",36,0,0,_sigreturn .stabs "sigreturn:F(0,1)",36,0,0,_sigreturn
_sigreturn: _sigreturn:
addl \$4,%esp # Remove argument addl \$4,%esp # Remove argument
@ -147,6 +186,7 @@ _sigreturn:
popl %ebp popl %ebp
jmp __sigbe jmp __sigbe
.global _sigdelayed
.stabs "sigdelayed:F(0,1)",36,0,0,_sigdelayed .stabs "sigdelayed:F(0,1)",36,0,0,_sigdelayed
_sigdelayed: _sigdelayed:
pushl %ebp pushl %ebp

View File

@ -50,14 +50,17 @@ main(int argc, char **argv)
$struct foo[1]; $struct foo[1];
# define foo_end ((char *) (foo + 1)) # define foo_end ((char *) (foo + 1))
# define offset(f) (((char *) &(foo->f)) - foo_end) # define offset(f) (((char *) &(foo->f)) - foo_end)
# define poffset(f) (((char *) &(foo->f)) - ((char *) foo))
EOF EOF
print TMP 'puts ("//;# autogenerated: Do not edit.\n");', "\n\n"; print TMP 'puts ("//;# autogenerated: Do not edit.\n");', "\n\n";
for my $f (@fields) { for my $f (@fields) {
print TMP ' printf ("//; $tls::', $f, ' = %d;\n", ', "offset($f));\n"; print TMP ' printf ("//; $tls::', $f, ' = %d;\n", ', "offset($f));\n";
print TMP ' printf ("//; $tls::p', $f, ' = %d;\n", ', "poffset($f));\n";
} }
print TMP ' puts ("//; __DATA__\n");', "\n"; print TMP ' puts ("//; __DATA__\n");', "\n";
for my $f (@fields) { for my $f (@fields) {
print TMP ' printf ("#define tls_', $f, ' (%d)\n", ', "offset($f));\n"; print TMP ' printf ("#define tls_', $f, ' (%d)\n", ', "offset($f));\n";
print TMP ' printf ("#define tls_p', $f, ' (%d)\n", ', "poffset($f));\n";
} }
print TMP <<EOF; print TMP <<EOF;

View File

@ -1565,6 +1565,7 @@ localtime(const time_t *timep)
extern "C" struct tm * extern "C" struct tm *
localtime_r(const time_t *timep, struct tm *tm) localtime_r(const time_t *timep, struct tm *tm)
{ {
tzset();
localsub(timep, 0L, tm); localsub(timep, 0L, tm);
return tm; return tm;
} }

View File

@ -1,48 +1,96 @@
//;# autogenerated: Do not edit. //;# autogenerated: Do not edit.
//; $tls::func = -3736; //; $tls::func = -3740;
//; $tls::saved_errno = -3732; //; $tls::pfunc = 0;
//; $tls::sa_flags = -3728; //; $tls::saved_errno = -3736;
//; $tls::oldmask = -3724; //; $tls::psaved_errno = 4;
//; $tls::newmask = -3720; //; $tls::sa_flags = -3732;
//; $tls::event = -3716; //; $tls::psa_flags = 8;
//; $tls::errno_addr = -3712; //; $tls::oldmask = -3728;
//; $tls::initialized = -3708; //; $tls::poldmask = 12;
//; $tls::sigmask = -3704; //; $tls::newmask = -3724;
//; $tls::sigwait_mask = -3700; //; $tls::pnewmask = 16;
//; $tls::sigwait_info = -3696; //; $tls::event = -3720;
//; $tls::threadkill = -3692; //; $tls::pevent = 20;
//; $tls::infodata = -3688; //; $tls::errno_addr = -3716;
//; $tls::tid = -3540; //; $tls::perrno_addr = 24;
//; $tls::local_clib = -3536; //; $tls::initialized = -3712;
//; $tls::locals = -2608; //; $tls::pinitialized = 28;
//; $tls::prev = -1040; //; $tls::sigmask = -3708;
//; $tls::next = -1036; //; $tls::psigmask = 32;
//; $tls::stackptr = -1032; //; $tls::sigwait_mask = -3704;
//; $tls::sig = -1028; //; $tls::psigwait_mask = 36;
//; $tls::sigwait_info = -3700;
//; $tls::psigwait_info = 40;
//; $tls::threadkill = -3696;
//; $tls::pthreadkill = 44;
//; $tls::infodata = -3692;
//; $tls::pinfodata = 48;
//; $tls::tid = -3544;
//; $tls::ptid = 196;
//; $tls::local_clib = -3540;
//; $tls::plocal_clib = 200;
//; $tls::locals = -2612;
//; $tls::plocals = 1128;
//; $tls::prev = -1044;
//; $tls::pprev = 2696;
//; $tls::next = -1040;
//; $tls::pnext = 2700;
//; $tls::stackptr = -1036;
//; $tls::pstackptr = 2704;
//; $tls::sig = -1032;
//; $tls::psig = 2708;
//; $tls::stacklock = -1028;
//; $tls::pstacklock = 2712;
//; $tls::stack = -1024; //; $tls::stack = -1024;
//; $tls::pstack = 2716;
//; $tls::padding = 0; //; $tls::padding = 0;
//; $tls::ppadding = 3740;
//; __DATA__ //; __DATA__
#define tls_func (-3736) #define tls_func (-3740)
#define tls_saved_errno (-3732) #define tls_pfunc (0)
#define tls_sa_flags (-3728) #define tls_saved_errno (-3736)
#define tls_oldmask (-3724) #define tls_psaved_errno (4)
#define tls_newmask (-3720) #define tls_sa_flags (-3732)
#define tls_event (-3716) #define tls_psa_flags (8)
#define tls_errno_addr (-3712) #define tls_oldmask (-3728)
#define tls_initialized (-3708) #define tls_poldmask (12)
#define tls_sigmask (-3704) #define tls_newmask (-3724)
#define tls_sigwait_mask (-3700) #define tls_pnewmask (16)
#define tls_sigwait_info (-3696) #define tls_event (-3720)
#define tls_threadkill (-3692) #define tls_pevent (20)
#define tls_infodata (-3688) #define tls_errno_addr (-3716)
#define tls_tid (-3540) #define tls_perrno_addr (24)
#define tls_local_clib (-3536) #define tls_initialized (-3712)
#define tls_locals (-2608) #define tls_pinitialized (28)
#define tls_prev (-1040) #define tls_sigmask (-3708)
#define tls_next (-1036) #define tls_psigmask (32)
#define tls_stackptr (-1032) #define tls_sigwait_mask (-3704)
#define tls_sig (-1028) #define tls_psigwait_mask (36)
#define tls_sigwait_info (-3700)
#define tls_psigwait_info (40)
#define tls_threadkill (-3696)
#define tls_pthreadkill (44)
#define tls_infodata (-3692)
#define tls_pinfodata (48)
#define tls_tid (-3544)
#define tls_ptid (196)
#define tls_local_clib (-3540)
#define tls_plocal_clib (200)
#define tls_locals (-2612)
#define tls_plocals (1128)
#define tls_prev (-1044)
#define tls_pprev (2696)
#define tls_next (-1040)
#define tls_pnext (2700)
#define tls_stackptr (-1036)
#define tls_pstackptr (2704)
#define tls_sig (-1032)
#define tls_psig (2708)
#define tls_stacklock (-1028)
#define tls_pstacklock (2712)
#define tls_stack (-1024) #define tls_stack (-1024)
#define tls_pstack (2716)
#define tls_padding (0) #define tls_padding (0)
#define tls_ppadding (3740)