Commit Graph

48 Commits

Author SHA1 Message Date
Christopher Faylor bfebe413bd * i686.din: New file.
* x86_64.din: New file.
* common.din: New file.
* cygwin.din: Delete.
* cygwin64.din: Delete.
* gendef: Rework to take options rather than using positional parameters.
Accept multiple files as input.
2013-04-30 23:43:08 +00:00
Corinna Vinschen 61522196c7 * Merge in cygwin-64bit-branch. 2013-04-23 09:44:36 +00:00
Christopher Faylor 6e75c72b89 Throughout, change __attribute__ ((regparm (N))) to just __regN. Throughout,
(mainly in fhandler*) start fixing gcc 4.7.2 mismatch between regparm
definitions and declarations.
* gendef: Define some functions to take @ declaration to accommodate _regN
defines which use __stdcall.
* gentls_offsets: Define __regN macros as empty.
* autoload.cc (wsock_init): Remove unneeded regparm attribute.
* winsup.h (__reg1): Define.
(__reg2): Define.
(__reg3): Define.
* advapi32.cc (DuplicateTokenEx): Coerce some initializers to avoid warnings
from gcc 4.7.2.
* exceptions.cc (status_info): Declare struct to use NTSTATUS.
(cygwin_exception::dump_exception): Coerce e->ExceptionCode to NTSTATUS.
* fhandler_clipboard.cc (cygnativeformat): Redefine as UINT to avoid gcc 4.7.2
warnings.
(fhandler_dev_clipboard::read): Ditto.
2013-01-21 04:34:52 +00:00
Christopher Faylor 9873ac53d7 * cygtls.h (_cygtls::get_signal_arrived): Add parameter to make lock/unlock
conditional.
* exceptions.cc (_cygtls::interrupt_setup): Don't get a lock when setting
signal_arrived since we already have one.
* gendef: Add some comments to make it easier to find functions.
2012-12-07 17:23:22 +00:00
Christopher Faylor 588b40e260 * gendef: Tighten up whitespace detection. 2012-08-15 17:29:58 +00:00
Christopher Faylor 0427598641 * gendef: Delete unneeded read from <IN> which ate an arbitrary line from
cygwin.din.
2012-08-15 17:07:47 +00:00
Christopher Faylor d57a4725b1 * exceptions.cc (sigdelayed): Move declaration to sigproc.h.
* sigproc.h (sigdelayed): Make symbol globally available.
* gendef (sigdelayed): Specifically zero incyg and stacklock.
* signal.cc (sigwaitinfo): Lock _my_tls and try harder to clean up signal
information.
2012-08-15 16:35:00 +00:00
Christopher Faylor dd06381996 * cygtls.cc (_cygtls::reset_signal_arrived): New function.
(set_signal_arrived::~set_signal_arrived): Use reset_signal_arrived to reset
state.
* exceptions.cc (sig_handle_tty_stop): Use WAIT_SIGNALED rather than assume we
know the return from cancelable_wait.
(_cygtls::interrupt_setup): Modify to allow calling when executing in
non-cygwin code via sigdelayed.  Always reset signal_arrived.
* gendef: Throughout use start_offset rather than the completely wrong
sizeof__cygtls.
(_sigdelayed): Rewrite to avoid duplication when calling the signal handler.
(sigreturn): Delete.
* gentls_offsets: Define start_offset rather than sizeof__cygtls.
* tlsoffsets.h: Regenerate.
2012-07-29 21:43:29 +00:00
Christopher Faylor 962f9a2ccc * DevNotes: Add entry cgf-000013.
* cygserver_ipc.h (ipc_set_proc_info): Use _cygtls::ipc_set_proc_info to set
per-thread signal arrived value.
* cygthread.cc (cygthread::detach): Use per-thread signal_arrived via
set_thread_waiting.
* fork.cc (_cygtls::fixup_after_fork): Clear signal_arrived.
(_cygtls::remove): Close any signal_arrived handle when thread exists.
(_cygtls::find_tls): Remove unneeded function.
* cygtls.h: Update copyright.
(class _cygtls): Reorganize to help avoid rebuilding newlib when structure
changes.
(_cygtls::event): Delete.
(_cygtls::threadkill): Ditto.
(_cygtls::signal_waiting): Declare new bool.
(_cygtls::find_tls): Delete declaration.
(_cygtls::set_threadkill): Ditto.
(_cygtls::reset_threadkill): Ditto.
(_cygtls::set_signal_arrived): Declare new function.
(class set_thread_waiting): Declare new class.
* cygwait.cc (cw_nowait_storage): Define.
(cygwait): Set per-thread signal_arrived via set_thread_waiting.  Don't
special-case _main_tls.
* cygwait.h (cw_nowait): Define.
(cw_infinite): Ditto.
(cygwait): Redefine pathological wait-only case.
* dcrt0.cc (dll_crt0_0): Remove call to now-defunct events_init().
(dll_crt0_1): Remove call to now-defunct create_signal_arrived().
* exceptions.cc: Reflect set_signal_mask() argument reordering throughout.
Remove signal mask synchronization throughout.
(events_init): Delete definition.
(mask_sync): Delete now-unneeded mask synchronization.
(set_signal_mask): Reverse order of arguments to "standard" to, from layout.
Rename "newmask" argument to "setmask".  Remove debugging.
(sig_handle_tty_stop): Use cancelable_wait rather than WFMO.
(_cygtls::interrupt_setup): Don't treat "threadkill" events specially.
Conditionally set signal_arrived depending on whether the thread has created it
or not.
(sigpacket::process): Reorganize to reflect thread-specific sending of signals
which is more in line with the way it was actually supposed to work.
* fhandler_socket.cc (get_inet_addr): Use cancelable_wait rather than
IsEventSignalled to avoid potential race.
(fhandler_socket::wait_for_events): Set signal_arrived event using
set_thread_waiting().
(fhandler_socket::close): Use cygwait for the case of just waiting 10 ms for a
signal.
* fhandler_tape.cc (fhandler_dev_tape::_lock): Use cancelable_wait rather than
WFMO.  Redo switch/case tests accordingly.
* fhandler_termios.cc (fhandler_termios::bg_check): Use cygwait for case of
just waiting 0 ms for a potential signal.
* fhandler_tty.cc (fhandler_pty_master::process_slave_output): Use
cancelable_wait rather than WFSO.
* fhandler_windows.cc (fhandler_windows::read): Set per-thread signal_arrived
via set_thread_waiting().
* flock.cc (lf_setlock): Ditto.
* select.cc (pselect): Ditto.  Set per-thread signal_arrived using
set_thread_waiting().
* gendef: Don't special case handling of _cygtls::sig for threads.
* gentls_offsets: Use #pragma once in tlsoffsets.h.
* ntdll.h: Use #pragma once.
* poll.cc: Reflect set_signal_mask() argument reordering.
* posix_ipc.cc (ipc_mutex_lock): Use cancelable_wait rather than WFMO.
(ipc_cond_timedwait): Set perl-thread signal arrived using
set_thread_waiting().
* security.h: Use #pragma once.
* signal.cc (abort): Reflect set_signal_mask() argument reordering.
(clock_nanosleep): Ditto.  Change call to cancelable_wait to properly specify
handling of cancel and interrupt.
(sigwaitinfo): Remove handling of per-thread event in favor of per-thread
signal_arrived.  Use cancelable_wait rather than WFSO.
* sigproc.cc (signal_arrived): Delete definition.
(create_signal_arrived): Ditto.
* sigproc.h (signal_arrived): Delete declaration.
(set_signal_mask): Avoid defining as a "C" function.  Don't conditionally
declare.
(create_signal_arrived): Delete declaration.
* syscalls.cc (rename): Use cygwait() rather than WFSO.
* thread.h (fast_mutex::lock): Use cw_infinite rather than LARGE_NULL.
* wait.cc (wait4): Ditto.
* thread.cc (pthread_mutex::lock): Ditto.
(pthread::join): Ditto.
(semaphore::_wait): Ditto.
(pthread_kill): Remove set_threadkill() accommodation.
* tlsoffsets.h: Regenerate.
2012-07-21 22:58:20 +00:00
Christopher Faylor 56d06b9af3 * gendef (sigdelayed): Remember to pop all of the saved registers.
(sigreturn): Add "leave" label.
2011-12-16 16:32:25 +00:00
Christopher Faylor 08e4b6acb7 * exceptions.cc (_cygtls::call_signal_handler): Fix debugging to not go to
console.
* fhandler.cc (fhandler_base_overlapped::wait_overlapped): Add temporary kludge
to work around problem of make closing a handler while it is being read.
* gendef (sigdelayed): Don't call a function if sig has been cleared.
* sigproc.h (cygwait): Simplify slightly.
2011-12-16 05:27:15 +00:00
Christopher Faylor 8f937028d9 * exceptions.cc (exception::handle): Drop abbreviation for "exception" since I
never remember what it stands for.
(sig_handle_tty_stop): Remove obsolete call to sig_handle_tty_stop.
(_cygtls::call_signal_handler): Rework to grab signal information from
_main_tls if none is set for _my_tls.  Try harder to keep thread locked.
(reset_signal_arrived): Delete.
* fhandler.cc (fhandler_base_overlapped::wait_overlapped): Use new cygWFMO call
to wait for an event + standard cygwin stuff.  Modify debug output to
acccomodate new function.
* fhandler_console.cc (fhandler_console::read): Replace WaitForMultipleObjects
with cygWFMO.
* fhandler_socket.cc (get_inet_addr): Add comment.
* gendef (_sigdelayed): Remove call to reset_signal_arrived.
* sigproc.cc (_cygtls::signal_exit): Don't close my_readsig here unless we're
in the signal thread.
(create_signal_arrived): Create signal_arrived as auto-reset so that only one
thread is woken when a signal arrives.
* sigproc.h (cygWFMO): New function.
(reset_signal_arrived): Delete declaration.
2011-12-04 17:58:24 +00:00
Christopher Faylor 0b6fbd396c * exceptions.cc (_cygtls::interrupt_now): Revert to checking for "spinning"
when choosing to defer signal.
(_cygtls::call_signal_handler): Grab func when we have the lock.
* gendef: Update copyright.
(__sigbe): Simplify slightly.
(_sigdelayed): Grab a lock before manipulating stuff.
(_cygtls::pop): Properly return popped value.
(stabilize_sig_stack): Set incyg when we have the lock.
* sigproc.cc: Update copyright.
2010-08-01 19:10:52 +00:00
Christopher Faylor 3a7c5515b2 * gendef: Throughout, remove lock from xchgl since it is implied.
(__ZN7_cygtls3popEv): Avoid potential (but probably nonexistent) race when
clearing element after pop.
2010-07-18 20:10:22 +00:00
Christopher Faylor 084ea5108e Throughout change all calls of low_priority_sleep (0) to yield ().
* miscfuncs.cc (yield): Rename from low_priority_sleep.  Remove all of the
logic which called Sleep() and just use SwitchToThread.
* miscfuncs.h (yield): Rename from low_priority_sleep.
(SLEEP_0_STAY_LOW): Delete unused define.
* shared.cc (memory_init): Move heap_init() call directly after shared memory
initialization to more closely mimic long-standing program flow.
* tty.cc (tty_list::terminate): Replace call to low_priority_sleep with Sleep.
2010-03-12 23:13:48 +00:00
Christopher Faylor 91000b5d66 * gendef (cleanup): Rename from 'nocr'. Remove comments and trailing spaces.
* cygwin.din: Add long-needed comment describing what dll_crt0__FP11per_process
demangles to.
2009-06-28 18:23:35 +00:00
Christopher Faylor 59328e28c4 * speclib: Semi-revert to previous version but don't try to generate
well-formed import library.  Instead, just extract appropriate symbols and let
later libcygwin.a on link line fill in the rest of the import stuff.
* gendef: Hopefully no-op modification to allow easier post-processing on
symbol values.
2009-04-09 21:02:53 +00:00
Corinna Vinschen 01cdb57d40 * gendef: Remove STABS directives. 2009-03-14 09:14:47 +00:00
Corinna Vinschen a7d2cc16e2 * Fix copyright dates. 2008-04-01 13:22:47 +00:00
Christopher Faylor 813767de3d * exceptions.cc (_cygtls::handle_exceptions): Only call rtl_unwind when
exiting.  Just return, don't set thread context.
* gendef (_setjmp): Store %fs:0 in jmp_buf.
(_sjfault): Ditto.
(_ljfault): Restore %fs:0 from jmp_buf.
(_longjmp): Ditto.
2008-03-01 13:18:22 +00:00
Christopher Faylor a680a53258 * gendef (sigbe): Reset "incyg" while the stack lock is active to avoid a
potential race.
2007-08-09 17:20:09 +00:00
Christopher Faylor 2346864a45 * cygheap.cc (cygheap_fixup_in_child): Don't close parent handle here. Let the
caller do that.
* dcrt0.cc (child_info_spawn::handle_spawn): Close parent handle here to allow
fixup_after_exec functions to use it.
* cygtls.cc (_cygtls::call2): Avoid calling exit thread if called with
*crt0_1 functions.
* cygtls.h (_cygtls::isinitialized): Check that we actually have a tls before
seeing if it is initialized.
* gendef (_sigfe_maybe): Ditto.
* dcrt0.cc (dll_crt0_1): Remove static, use just one argument.
* dll_init.cc (dllcrt0_info): New structure.
(dll_dllcrt0): Change into a front-end to renamed dll_dllcrt0_1 so that we'll
always be assured of having something like a tls.
(dll_dllcrt0_1): New function, basically renamed from from dll_dllcrt0.
Unconditionally call _my_tls.init_exception_handler now that we are assured of
having a tls.  Change variable name from "linking" to "linked".
* winsup.h (dll_crt0_1): Declare.
(dll_dllcrt0_1): Ditto.
2006-06-02 00:09:50 +00:00
Christopher Faylor 9badd94adb * cygtls.cc (_cygtls::remove): Reset initialized flag right away if we were
previously initialized.
* cygtls.h (_cygtls::initialized): Move nearer the end to catch situation when
Windows 98 mysteriously changes pieces of cygtls when thread is detaching.
* gendef (__sigfe_maybe): Simplify slightly.
* tlsoffsets.h: Regenerate.
2006-03-13 04:26:57 +00:00
Christopher Faylor 51f90b2f01 * cygtls.h (CYGTLS_INITIALIZED): Change to a little more unlikely value.
(CYGTLSMAGIC): Delete.
* dcrt0.cc (dll_crt0_0): Call sigproc_init during init startup.
(_dll_crt0): Don't worry about sync_startup.  Just wait for sigthread here.
* dll_init.cc (cygwin_detach_dll): Only pick up tls version of retaddr if we
have a valid tls.
* fork.cc (frok::child): Remove sigproc_init initialization since it happens
much earlier now.
* gendef: Recognize SIGFE_MAYBE.
(fefunc): Generate calls to _sigfe_maybe, if appropriate.
(_sigfe_maybe): New function.
* init.cc (search_for): Always initialize search_for, even on fork.
(calibration_thread): Delete.
(calibration_id): Delete.
(prime_threads): Delete.
(munge_threadfunc): Remove calibration_thread special case.  Avoid calling
thread function if we haven't yet hit the "search_for" thread.
(dll_entry): Remove prime_threads call.  Only call munge_threadfunc when
hwait_sig is active.  Ditto.  for _my_tls.remove ();
* sigproc.cc (hwait_sig): Make global.
(sigproc_init): Don't bother with sync_startup.
(sig_send): Treat flush as a no-op when signals are held.
(wait_sig): Cause signals to be held after fork.
2006-03-12 23:57:05 +00:00
Christopher Faylor ee93375872 * analyze_sigfe: New script.
* dllfixdbg: Add copyright.
* gendef: Ditto.
* gendevices: Ditto.
* gentls_offsets: Ditto.
2006-03-01 20:20:22 +00:00
Christopher Faylor dcd0465b2b * cygtls.cc (_cygtls::handle_threadlist_exception): Make an error fatal.
* cygtls.h (sockaddr_in): Use header rather than defining our own structure.
* exceptions.cc (_cygtls::interrupt_setup): Use exact contents of sa_mask
rather than assuming tht current sig should be masked, too.
(_cygtls::call_signal_handler): Use more aggressive locking.
* gendef (_sigbe): Wait until later before releasing incyg.
(_sigreturn): Remove more arguments to accommodate quasi-sa_sigaction support.
(_sigdelayed): Push arguments for sa_sigaction.  More work needed here.
* signal.cc (sigaction): Implement SA_NODEFER.
* tlsoffsets.h: Regenerate.

* sigproc.cc (wait_sig): Use default buffer size of Windows 9x complains.
* pinfo.cc (_onreturn::dummy_handle): Remove.
(_onreturn::h): Make this a pointer.
(_onreturn::~_onreturn): Detect whether pointer is NULL rather than value is
NULL.
(_onreturn::_onreturn): Set h to NULL initially.
(_onreturn::no_close_p_handle): Set h to NULL.
(winpids::add): Initialize onreturn with value from p.hProcess immediately.
2005-12-23 22:50:20 +00:00
Christopher Faylor 09b0109620 Remove unneeded whitespace.
* cygtls.cc (_cygtls::set_state): Delete.
(_cygtls::reset_exception): Ditto.
(_cygtls::init_thread): Set initialized state directly here.
(_cygtls::push): Remove exception argument.  Don't treat exceptions specially.
* cygtls.h (_cygtls::push): Ditto.
(_cygtls::isinitialized): Don't treat exceptions specially.
(_cygtls::reset_exception): Delete.
(_cygtls::set_state): Ditto.
(_cygtls::handle_exceptions): Don't push ebp on the stack prior to calling
sig_send.  Just set incyg instead.
(_cygtls::interrupt_setup): Accommodate _cygtls::push argument change.
(_cygtls::interrupt_now): Ditto.
(setup_handler): Don't treat exceptions specially.
* gendef (longjmp): Always zero incyg flag.
2005-12-05 20:20:18 +00:00
Christopher Faylor f02b22dcee * fork.cc (frok::child): Change order of cleanup prior to return.
(fork): Save more of the stack.
* gendef: Fix some comments.
* sigproc.cc (wait_sig): Clarify debug output.
2005-10-29 15:19:34 +00:00
Christopher Faylor c461fbf160 * cygtls.h (__ljfault): Declare.
(_cygtls::return_from_fault): Use __ljfault.
* exceptions.cc (set_signal_mask): Revert previous checkin.
* gendef (__sjfault): Split out into a separate function which doesn't bother
with any special signal locking.  routines.
(_ljfault): Return from a __sjfault without bothering with signals.
2005-08-28 23:26:23 +00:00
Christopher Faylor efc7accc9d * gendef: Use nocr to remove \r's from input. gendef (nocr): New function. 2005-07-27 16:16:51 +00:00
Christopher Faylor 893ac8e03c Replace valid memory checks with new myfault class "exception handling", almost
everywhere.  Leave some thread.cc stuff alone for now.
* cygtls.h: Kludge some definitions to avoid including a problematic windows
header.
(_cygtls::_myfault): New entry.
(_cygtls::_myfault_errno): Ditto.
(_cygtls::fault_guarded): New function.
(_cygtls::setup_fault): Ditto.
(_cygtls::return_from_fault): Ditto.
(_cygtls::clear_fault): Ditto.
(myfault): New class.
* exceptions.cc (handle_exceptions): Handle case of guarded fault in system
routine.
* gendef: Add another entry point for setjmp that the compiler doesn't know
about and won't complain about.
* gentls_offsets: Just include windows.h rather than kludging a HANDLE def.
* miscfuncs.cc (check_null_str): Delete.
(check_null_empty_str): Ditto.
(check_null_empty_str_errno): Ditto.
(check_null_str_errno): Ditto.
(__check_null_invalid_struct): Ditto.
(__check_null_invalid_struct_errno): Ditto.
(__check_invalid_read_ptr): Ditto.
(__check_invalid_read_ptr_errno): Ditto.
(dummytest): New function.
(check_iovec_for_read): Delete.
(chec_iovec): Rename from check_iovec_for_write.  Take a read/write parameter.
* tlsoffsets.h: Regenerate.
* winsup.h: Remove check_* declarations.
(check_iovec_for_read): Delete declaration.  Turn into a define instead.
(check_iovec_for_write): Ditto.
(check_iovec): New declaration.
* thread.h: Use ifdef guard name consistent with other header files.
2005-07-03 02:40:30 +00:00
Christopher Faylor 9863b78e7b * cygtls.h (waitq): Declare structure here.
(_cygtls::wq): Declare.
* cygtls.cc (_cygtls::fixup_after_fork): Clear wq.thread_ev to avoid using an
invalid event handle in forked process.
* dcrt0.cc (waitq_storage): Delete.
(threadstuff): Remove waitq_storage.
* perthread.h (per_thread_waitq): Delete.
(waitq_storage): Delete declaration.
* sigproc.cc (sigproc_init): Remove perthread waitq consideration.
* sigproc.h (waitq): Delete declaration.
* wait.cc (wait4): Use _my_tls waitq structure rather than per_thread.
* cygtls.h (_cygtls::newmask): Delete member.
(_cygtls::deltamask): New member.
* gendef (_sigdelayed): Replace the call to set_process_mask by a call to
set_process_mask_delta.
* exceptions.cc (handle_sigsuspend): Do not filter tempmask.  Or
SIG_NONMASKABLE in deltamask as a flag.
(_cygtls::interrupt_setup): Set deltamask only.
(set_process_mask_delta): New function.
(_cygtls::call_signal_handler): Replace the first call to set_process_mask by a
call to set_process_mask_delta.
* tlsoffsets.h: Regenerate.
2004-03-12 03:09:28 +00:00
Christopher Faylor 7ea8e226ee * cygtls.cc (_cygtls::fixup_after_fork): Remove unneeded setting of oldmask.
* exceptions.cc: Remove some __I386__ conditionals.
(handle_exceptions): Move ppid test to outside of a loop for efficiency.
(setup_handler): Make debugging output more wordy.
(_cygtls::call_signal_handler): To avoid a race, use lock/unlock to synchronize
with signal thread and ensure that signal_arrived event has actually been set.
* gendef (_sigfe): Use ebx for all sigstack manipulations to ensure that the
register is saved.  Move setting of incyg to within stack lock to avoid
setup_handler confusion.
(_sigbe): Use ebx for all sigstack manipulations to ensure that the register is
saved.
(_cygtls::pop): Ditto.
(_cygtls::lock): Ditto.
(stabilize_sig_stack): Ditto.
(setjmp): Ditto.
(longjmp): Ditto.
2004-03-12 02:07:39 +00:00
Christopher Faylor 5fb0fe79eb * exceptions.cc (setup_handler): Avoid suspending a thread if it in a cygwin
function, in an exception, spinning, or locked.
* gendef (_sigfe): Move incyg setting earlier.
(sigreturn): Set incyg flag to avoid interrupting called cygwin functions.
(sigdelayed): Ditto.
(stabilize_sig_stack): Ditto.
* sigproc.cc (proc_subproc): Don't restore process lock early in exec case.
* cygtls.h: Reorganize fields in _cygtls slightly.
* tlsoffsets.h: Regenerate.
2004-03-09 01:24:08 +00:00
Christopher Faylor 3a1ccfc8c7 * fork.cc (fork_parent): Save parent pid in a temporary variable since child
could conceivably exit before function returns, rendering the child's shared
memory area invalid.
* cygtls.h (_cygtls::incyg): Declare new field.
(_cygtls::in_exception): Define new function.
* exceptions.cc (setup_handler): Remove locked flag.  Use 'incyg' flag and
in_exception function to determine when we're in a cygwin function.
(_cygtls::call_signal_handler): Decrement incyg flag prior to calling a
handler.  Increment it on return.
* gendef (_sigfe): Increment incyg flag.  Use testl for zero testing rather
than orl, for consistency.
(_sigbe): Decrement incyg flag.  Use testl for zero testing rather than orl,
for consistency.
(_cygtls::pop): Use testl for zero testing rather than orl, for consistency.
(stabilize_sig_stack): Ditto.
2004-03-07 04:57:47 +00:00
Christopher Faylor f2afcfa616 * gendef (sigdelayed): Handle return here rather than going through sigbe to
ensure that flags are properly restored.
2004-03-05 19:09:04 +00:00
Christopher Faylor 08b0a057eb * gendef (sigreturn): Call stabilize_sig_stack to ensure that there are no
pending signals.  Restore edx later.
(sigdelayed): Save edx earlier.
* malloc_wrapper.cc (malloc_init): Add some more debugging output.
2004-03-04 05:31:14 +00:00
Christopher Faylor 241f503c75 * gendef (stabilize_sig_stack): Correctly align this pointer for call to
_cygtls::call_signal_handler.
* gentls_offsets: Output sizeof field.
* tlsoffsets.h: Regenerate.
2004-02-25 04:08:00 +00:00
Christopher Faylor 2d6c4a1a65 * gendef (stabilize_sig_stack): New function.
(setjmp): Import, add sig stack handling.  Store sig stack info.
(longjmp): Call stabilize_sig_stack.  Restore sig stack info.
* config/i386/setjmp.c: Remove.
2004-02-18 20:48:38 +00:00
Christopher Faylor c21e74cce8 * dcrt0.cc (alloc_stack_hard_way): Revert to previous implementation.
(alloc_stack): Ditto.
* exceptions.cc (ctrl_c_handler): Add debugging output.
2004-02-14 04:38:37 +00:00
Christopher Faylor edc4f86ad2 * Makefile.in (clean): Remove sigfe.s.
(sigfe.s): Ensure that sigfe.s will be regenerated if it does not exist.
* dll_init.cc (dll_dllcrt0): Simplify initializing tests.
* exceptions.cc (setup_handler): Detect when stub caller is either spinning or
has acquired the lock after being suspended to avoid windows problems with
suspending a win32 API call.
* cygtls.h (_cygtls::spinning): Declare new element.
* gendef: Remove unused _siglist_index and _siglist declaration.
(_sigfe): Set spinning element when potentially looping, waiting for lock.
(_sigbe): Ditto.
(_cygtls::lock): Ditto.
(_longjmp): Ditto.
* tlsoffsets.h: Regenerate.
* pinfo.cc (_pinfo::exit): Set final exit state here.  Call sigproc_terminate
if invoked with 'norecord'.  Clear any residual _cygtls stuff.
* winsup.h (exit_states): Define ES_FINAL.
* spawn.cc (spawn_guts): Don't call proc_terminate specifically when execing.
Let _pinfo::exit handle that case.
* sigproc.cc (wait_subproc): Always exit loop early when proc_loop_wait.
* init.cc (munge_threadfunc): Eliminate unused argument.
(dll_entry): Reflect above change in call to munge_threadfunc.
2004-02-13 19:34:32 +00:00
Christopher Faylor b3535c2730 * gendef (_sigbe): Zero location on pop.
(_cygtls::pop): Ditto.
2004-02-12 04:55:29 +00:00
Christopher Faylor e431827c7c Rename _threadinfo to _cygtls, throughout.
* cygtls.h (_cygtls::call_signal_handler): Rename from call_signal_handler_now.
(_cygtls::push): Make second argument mandatory.
(_cygtls::fixup_after_fork): Declare new function.
(_cygtls::lock): Ditto.
* cygtls.cc (_cygtls::fixup_after_fork): Define new function.
* dcrt0.cc (cygwin_finished_initializing): Define as bool.
(alloc_stack): Use _tlstop rather than arbitrary variable in probably vain
attempt to avoid strange fork problem on CTRL-C.
(dll_crt0_0): Remove obsolete winpids::init call.
* dll_init.cc (dll_dllcrt0): Detect forkee condition as equivalent to
initializing.
* winsup.h (cygwin_finished_initializing): Declare as bool.
* exceptions.cc (handle_exceptions): Rely on cygwin_finished_initializing to
determine how to handle exception during process startup.
(_cygtls::call_signal_handler): Rename from call_signal_handler_now.
(_cygtls::interrupt_now): Fill in second argument to push.
(signal_fixup_after_fork): Eliminate.
(setup_handler): Initialize locked to avoid potential inappropriate unlock.
Resume thread if it has acquired the stack lock.
(ctrl_c_handler): Just exit if ctrl-c is hit before cygiwn has finished
initializing.
* fork.cc (sync_with_child): Don't call abort since it can cause exit
deadlocks.
(sync_with_child): Change debugging output slightly.
(fork_child): Set cygwin_finished_initializing here.  Call _cygtls fork fixup
and explicitly call sigproc_init.
(fork_parent): Release malloc lock on fork failure.
(vfork): Call signal handler via _my_tls.
* sigproc.cc (sig_send): Ditto.
* syscalls.cc (readv): Ditto.
* termios.cc (tcsetattr): Ditto.
* wait.cc (wait4): Ditto.
* signal.cc (nanosleep): Ditto.
(abort): Ditto.
(kill_pgrp): Avoid killing self if exiting.
* sync.cc (muto::acquire): Remove (temporarily?) ill-advised exiting_thread
check.
* gendef (_sigfe): Be more agressive in protecting stack pointer from other
access by signal thread.
(_cygtls::locked): Define new function.
(_sigbe): Ditto.
(_cygtls::pop): Protect edx.
(_cygtls::lock): Use guaranteed method to set eax to 1.
(longjmp): Aggressively protect signal stack.
* miscfuncs.cc (low_priority_sleep): Reduce "sleep time" for secs == 0.
* pinfo.cc (winpids::set): Counterintuitively use malloc's lock to protect
simultaneous access to the pids list since there are pathological conditions
which can cause malloc to call winpid.
(winpids::init): Eliminate.
* pinfo.h (winpids::cs): Eliminate declaration.
* pinfo.h (winpids::init): Eliminate definition.
2004-02-12 03:01:58 +00:00
Christopher Faylor cec4879206 * debug.h (console_printf): Define for non-debugging condition.
* cygtls.h (_threadinfo::lock): Remove wait argument.
(_threadinfo::interrupt_setup): Remove retaddr argument.
* exceptions.cc (_threadinfo::interrupt_setup): Ditto.
(_threadinfo::interrupt_now): Accommodate change to interrupt_setup argument.
(setup_handler): Ditto.  Always lock sig stack prior to determining interrupt
method.
* gendef (_sigfe): Correct thinko regarding cmpxchg.
(_sigbe): Ditto.
(_threadinfo::lock): Ditto.
(_threadinfo::pop): Eliminate left-over stack unlock.
* sigproc.cc (proc_subproc): Chnage debugging output to printed warning.
2004-02-09 04:04:24 +00:00
Christopher Faylor 6946073e78 * 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-08 19:59:27 +00:00
Christopher Faylor ef33379be8 * exceptions.cc (sig_handle_tty_stop): Avoid races by waiting for both
signal_arrived and for sigCONT.
(sigpacket::process): Enforce sending of both signal_arrived and sigCONT, where
appropriate.
* gendef (sigreturn): Save tls pointer in ebx so that it can jump into
sigdelayed and use the same register.
2004-01-26 22:25:57 +00:00
Christopher Faylor f6936c48f3 * cygwin/include/signal.h: Add copyright notice.
* cygwin.din: Make clock SIGFE.  Add clock_gettime, sigwaitinfo, timer_create,
timer_delete, timer_settime.
* include/cygwin/version.h: Reflect above additions.
* fork.cc (fork_child): Call fixup_timers_after_fork.
* signal.cc (sigwait): Remove unused variable.
* timer.cc: New file.
(clock_gettime): Define new function.
(timer_tracker): Define new struct used by timer functions.
(timer_tracker::timer_tracker): New function.
(to_us): New function.
(timer_thread): New function.
(timer_tracker::settime): New function.
(timer_create): New function.
(timer_settime): New function.
(timer_delete): New function.
(fixup_timers_after_fork): New function.
* cygthread.cc: Bump thread count.
* signal.cc (sigwaitinfo): Define new function.
(sigwait): Redefine based on sigwaitinfo.
* include/cygwin/signal.h (sigwaitinfo): Declare.
(sigwait): Ditto.
* dtable.cc (dtable::vfork_parent_restore): Avoid double close of ctty when
ctty == ctty_on_hold.
* cygtls.h (_threadinfo::threadkill): New element.
(_threadinfo::set_threadkill): Declare new function.
(_threadinfo::reset_threadkill): Declare new function.
* dcrt0.cc (dcrt0_1): Call here so that it will be possible to attach to
running process with #(*& Windows Me/9x.
(initial_env): Try to initialize strace if uninitialized.
* gendef: Don't zero signal if threadkill is set since that will happen in the
called function.
* signal.cc (sigwait): Ensure cleanup in error conditions.
* sigproc.cc (sig_send): Clear packet mask storage.
(wait_subproc): Fill in child exit code in siginfo_t structure.
* thread.cc (pthread_kill): Set threadkill flag.
* tlsoffsets.h: Regenerate.  Throughout, use siginfo_t to fill out all signal
information for "kernel" signals.
* cygtls.h (_threadinfo::set_siginfo): Declare new function.
* cygtls.cc (_threadinfo::set_siginfo): Define new function.
* dcrt0.cc (do_exit): Accommodate siginfo_t considerations.
* exceptions.cc (handle_exceptions): Ditto.
(sig_handle_tty_stop): Ditto.
(ctrl_c_handler): Use killsys() to send signal.
(sigpacket::process): Rename from sig_handle.  Use siginfo_t field from
sigpacket for everything.
(tty_min::kill_pgrp): Accommodate siginfo_t considerations.
(fhandler_termios::bg_check): Ditto.
* fhandler_tty.cc (fhandler_tty_slave::ioctl): Use killsys() to send signal.
* signal.cc (kill_worker): Rewrite to use siginfo_t second argument.
(kill_pgrp): Ditto.
(kill0): Define new function pulled from kill().
(kill): Rewrite as frontend to kill0.
(killsys): Define new function.
* sigproc.cc (sigelem): Eliminate.
(sigpacket): Move to sigproc.h.  Subsume sigelem.
(pending_signals): Use sigpacket rather than sigelem for everything.
(sig_clear): Ditto.
(wait_sig): Ditto.
(sig_send): Rewrite to use siginfo_t argument.
(sig_send): New function wratpper to sig_send with siginfo_t argument.
(wait_subproc): Accommodate siginfo_t considerations.
* thread.cc (pthread_kill): Ditto.
* sigproc.h (sigpacket): Move here.
(sigpacket::process): Declare "new" function.
(sig_handle): Eliminate declaration.
(sig_send): Declare with new paramaters.
(killsys): Declare new function.
(kill_pgrp): Declare.
* winsup.h: Move some signal-specific stuff to sigproc.h.
* include/cygwin/signal.h: Tweak some siginfo_t stuff.
2004-01-19 05:46:54 +00:00
Christopher Faylor 9a4d574b8d Eliminate use of sigframe and sigthread throughout.
* Makefile.in (DLL_OFILES): Add sigfe.o.  Remove reliance on cygwin.def from
cygwin0.dll dependency since dependence on sigfe.o implies that.  Generate def
file on the fly using 'gendef'.
* configure.in: Don't auto-generate cygwin.def.
* configure: Regenerate.
* cygwin.din: Add SIGFE stuff where appropriate.
* dcrt0.cc (dll_crt0_1): Initialize cygwin tls early in process startup.  Set
_main_tls to address of the main thread's cygwin tls.
* debug.h: Remove now unneeded WFSO and WFMO declarations.
* exceptions.cc (_last_thread): Define.
(set_thread_state_for_signals): New function.
(reset_thread_exception_for_signals): Ditto.
(init_thread_for_signals): Ditto.
(delete_thread_for_signals): Ditto.
(capture_thread_for_signals): Ditto.
(handle_exceptions): Set return address explicitly for exceptions prior to
calling sig_send.
(interrupt_on_return): Eliminate.
(setup_handler): Add preliminary implementation for dealing with
thread-specific signals by querying _main_tls.
(signal_exit): Use cygthread::main_thread_id instead of mainthread.id.
(call_signal_handler_now): For now, just handle the main thread.
* fork.cc (vfork): Save and restore main _my_tls.
* gendef: New file.  Generates def file and sigfe.s file.
* gentls_offsets: New file.  Generates offsets for perl to use in sigfe.s.
* how-signals-work.txt: Mention that info is obsolete.
* init.cc (dll_entry): Initialize cygwin tls storage here.
* miscfuncs.cc (low_priority_sleep): Make a C function for easier calling from
asm.
* perthread.h (vfork_save::tls): New element.
* signal.cc (nanosleep): Replace previous use of
sigframe.call_signal_handler_now with straight call to call_signal_handler_now.
(abort): Ditto.
* syscalls.cc (readv): Ditto.
* termios.cc (tcsetattr): Ditto.
* wait.cc (wait4): Ditto.
* sigproc.cc (sig_dispatch_pending): Ditto.
(sig_send): Ditto.
* sigproc.h: Declare call_signal_handler_now.
* thread.cc (pthread::thread_init_wrapper): Initialize cygwin tls.  Remove
obsolete and unworking signal stuff.
* thread.h (verifyable_object::sigs): Eliminate.
(verifyable_object::sigmask): Eliminate.
(verifyable_object::sigtodo): Eliminate.
(verifyable_object::exit): Make attribute noreturn.
(verifyable_object::thread_init_wrapper): Ditto.
(pthread_null::exit): Ditto.
* winbase.h (__stackbase): Always define.
* winsup.h (low_priority_sleep): Declare as a "C" function.
* include/cygwin/version.h: Bump API version to reflect sigwait export.
* include/sys/queue.h: Protect SLIST_ENTRY from previous declaration.
* signal.cc (sigwait): Implement.
* select.cc (fhandler_base::ready_for_read): Add debugging output.
* devices.h: Define more device pointers via their storage.
* devices.in: Don't parse things like /dev/inet/tcp, as they really have no
meaning.
* devices.cc: Regenerate.
* gendevices: Set proper protection for output file.
* cygtls.h: New file.
* gendef: New file.
* gentls_offsets: New file.
* tlsoffsets.h: New file.  Autogenerated.
* config/i386/longjmp.c: Remove.  File subsumed by gendef output.
* config/i386/makefrag: Remove obsolete file.
* fhandler.cc: Remove spurious access_worker declaration.
* spawn.cc (spawnve): Make debugging output more accurate.
* cygwin-gperf: Remove.
* devices.cc: Remove.
2003-11-28 20:55:59 +00:00