Commit Graph

2451 Commits

Author SHA1 Message Date
Christopher Faylor 9279515ae1 * dtable.cc (dtable::delete_archetype): Add debugging.
(dtable::release): Move archetype deletion here.
(dtable::vfork_child_dup): Increment ctty usecount to catch later
close_all_files case in parent/child.
(dtable::vfork_child_fixup): Avoid using cygheap->foo where this should really
be using local references.  Call close on archetyped handles since the handles
haven't had the noninherit flag set.
* fhandler_tty.cc (fhandler_tty_slave::close): Remove archetype deletion code.
Add defensive error message when DEBUGGING.
(fhandler_tty_common::set_close_on_exec): Use more robust method for checking
whether to set handles into noninherit if there is an archetype associated with
the fhandler.
2003-12-12 20:46:03 +00:00
Christopher Faylor fac0681d6c * dcrt0.cc (alloc_stack): Move _main_tls if stack is relocated. 2003-12-12 05:04:47 +00:00
Christopher Faylor c76d70d7c0 * miscfuncs.cc (low_priority_sleep): Correct thinko which caused SetPriority to
be called unnecessarily.
* thread.cc (pthread::init_main_thread): Call new create_cancel_event function.
(pthread::precreate): Ditto.
(pthread::postcreate): Remove cancel_event creation.
(pthread::create_cancel_event): Define new function.
* thread.h (pthread::create_cancel_event): Declare new function.
2003-12-12 04:15:32 +00:00
Corinna Vinschen 97cb9b9de4 * fhandler_serial.cc (fhandler_serial::tcflush): Simplify. Remove
read polling loop to avoid a hang with streaming devices.
2003-12-11 18:07:42 +00:00
Christopher Faylor 992406a5ea * pinfo.cc (_pinfo::set_ctty): Correct stupid typo. 2003-12-11 06:19:36 +00:00
Christopher Faylor 8e10c4311f * cygheap.h (cygheap_types): Add HEAP_ARCHETYPES.
(init_cheap::ctty): Change to pointer.
* dtable.h (dtable::find_archetype): Declare new function.
(dtable::add_archetype): Declare new function.
(dtable::delete_archetype): Declare new function.
(dtable::narchetypes): Declare.
(dtable::farchetypes): Declare.
(dtable::initial_archetype_size): Declare.
(dtable::dtable): Initialize new fields.
(dtable::initial_archetype_size): Declare.
* dtable.cc (dtable::find_archetype): Define new function.
(dtable::add_archetype): Define new function.
(dtable::delete_archetype): Define new function.
(dtable::initial_archetype_size): Define.
* fhandler.h (fhandler_base::archetype): Declare.
(fhandler_base::usecount): Declare.
* fhandler.cc (fhandler_base::fhandler_base): Initialize new fields.
* fhandler_console.cc (fhandler_console::get_tty_stuff): Pass NULL to third
argument of set_ctty.
* fhandler_tty.cc (fhandler_tty_slave::open): Accommodate new archetype method
to create only one instance of a tty.
(fhandler_tty_slave::close): Don't close handles unless archetype usecount is
zero.  When that happens, close archetype too.
(fhandler_tty_slave::dup): Just copy archetype.  Set use count appropriately.
Set ctty, if appropriate.
(fhandler_tty_common::dup): Remove slave considerations.
(fhandler_tty_common::set_close_on_exec): Remove cygheap->ctty considerations.
* pinfo.cc (_pinfo::set_ctty): Accommodate new archetype methods.
* pinfo.h (_pinfo::set_ctty): Make third argument explicit.
* syscalls.cc (close_all_files): Decrement controlling tty use count before
closing all handles to allow controlling tty to be closed.  Remove previous
controlling tty considerations.
2003-12-11 06:12:41 +00:00
Christopher Faylor 3f23411449 remove debug output 2003-12-10 04:08:50 +00:00
Christopher Faylor ce40c6baf7 * fhandler_tty.cc (fhandler_tty_common::dup): Just copy cygheap->ctty to child
if duping the current ctty.
(fhandler_tty_common::close): Move debugging statement earlier in function.
(fhandler_tty_slave::close): Return success when closing ctty.
* syscalls.cc (close_all_files): Avoid calling fhandler_tty_slave close method
so that open_fhs will not be decremented when closing cygheap ctty.
(setsid): Ditto.
* dcrt0.cc (do_exit): Reorganize to avoid leaving a critical section active
after vfork.
* fhandler.h (fhandler_tty_slave::get_unit): Remove regparm parameter since it
can't work in a virtualized function.
2003-12-10 03:19:19 +00:00
Christopher Faylor 7176387b4f * pinfo.cc (_pinfo::set_ctty): Don't copy over existing ctty if it is active. 2003-12-09 03:27:05 +00:00
Christopher Faylor ac5ba8b0de * thread.cc (pthread::precreate): Delete duplicate setting of cancel_event. 2003-12-08 06:32:46 +00:00
Christopher Faylor da915a3aa6 * fhandler.h (fhandler_tty_slave::ttyname): Use name from pc since it is
guaranteed to be accurate.
* fhandler_tty.cc (fhandler_tty_slave::open): Increment open_fhs appropriate
when copying ctty.
(fhandler_tty_slave::close): Remove special case handling for exit_state.  Use
ctty < 0 check instead.
(fhandler_tty_common::close): Set io_handle to NULL after closing.
* syscalls.cc (close_all_files): Specifically close cygheap->ctty, if
appropriate.
2003-12-08 06:27:05 +00:00
Christopher Faylor 1b11f4fd72 * wait.cc (wait4): Move sawsig initialization inside loop. 2003-12-08 00:22:56 +00:00
Christopher Faylor 1c5c9a6bfb * spawn.cc (spawn_guts): Change type back to 'int' after erroneous change
below.
2003-12-08 00:21:17 +00:00
Christopher Faylor 2e008fb91f Change use of BOOL, TRUE, FALSE to bool, true, false, as appropriate,
throughout.
* tty.cc (tty::common_init): Remove call to SetKernelObjectSecurity and edit
some comments.
* cygheap.h (init_cygheap::ctty): Add new element.
* devices.in (device::parse): Remove special handling for /dev/tty.
* devices.cc: Regenerate.
* dtable.cc (build_fh_pc): Don't reset /dev/tty device.  Let the device opener
do that.
* fhandler_termios.cc (tty_min::set_ctty): Redefine to _pinfo class.
* fhandler_tty.cc (fhandler_tty_common::set_close_on_exec): Avoid setting
noninherit flag for ctty.
* tty.h: Move BOOLs to bools.
(tty_min::set_ctty): Redeclare to _pinfo class.
* pinfo.cc (_pinfo::set_ctty): Define new function based on tty_min::set_ctty.
Change first argument from tty number to tty_min class.
* pinfo.h (_pinfo::set_ctty): Declare.
* fhandler_console.cc (fhandler_console::get_tty_stuff): Reflect move of
set_ctty to _pinfo class.
* fhandler_tty.cc (fhandler_tty_slave::open): Treat FH_TTY specially.  Use
saved cygheap value if it exists.  Otherwise convert to real device and save on
first time open.
(fhandler_tty_common::dup): Potentially set controlling tty if duping a slave
tty.
* syscalls.cc (setsid): Close controlling tty in cygheap.
* tty.cc: Change some BOOLs to bools.
2003-12-07 22:37:12 +00:00
Corinna Vinschen 2e3ff06d3c * syscalls.cc (locked_append): New.
(updwtmp): Remove mutex code and call locked_append.
	(pututline): Ditto.
2003-12-07 12:56:59 +00:00
Christopher Faylor ae2543ed76 * exceptions.cc (_threadinfo::remove): Avoid a linked list walk. 2003-12-07 03:27:51 +00:00
Christopher Faylor 73262d7a44 * cygtls.h (_threadinfo::find_tls): New function.
* exceptions.cc (_threadinfo::find_tls): Rename from find_tls.  Use critical
section to protect access to linked list.
2003-12-07 02:56:52 +00:00
Christopher Faylor fcc47fd001 * exceptions.cc (_threadinfo::remove): Avoid returning without unlocking
critical section in the (hopefully impossible) case of an unrecognized thread.
2003-12-07 02:33:31 +00:00
Christopher Faylor 2b6d15a908 * cygtls.h: Add more "don't parse this" guards.
(_threadinfo::init_thread): Rename from 'init'.
(_threadinfo::init): Declare new function.
(_threadinfo::protect_linked_list): Declare new critical section.
* dcrt0.cc (dll_crt0_1): Call init_thread to initialize thread stuff.
(_dll_crt0): Call _threadinfo::init prior to invoking dll_crt0_1.
* exceptions.cc (_threadinfo::init_thread): Rename from 'init'.
(_threadinfo::init): Define new function.  Protect linked list manipulation
with new critical section.
(_threadinfo::call): Reflect function name change.
(_threadinfo::remove): Protect linked list manipulation with new critical
section
* gentls_offsets: Rework to allow multi-line "don't parse this" protection.
* init.cc (dll_entry): Don't remove threads info stuff here since the remove
function uses a critical section which can't be used during thread creation or
destruction.
* thread.cc (pthread::exit): Call _threadinfo remove function here.
2003-12-06 18:08:38 +00:00
Christopher Faylor aeab6ea658 * cygthread.cc (cygthread::stub2): Remove myself from the list of threads
monitored by signals since this thread will never call raise or sigwait.
(cygthread::simplestub2): Ditto.  Set ev here.
(cygthread::cygthread): Don't set ev here for freerange thread.
2003-12-05 05:29:17 +00:00
Christopher Faylor 78f3155ced * path.cc (slash_unc_prefix_p): Allow '.' as a valid character after '\\' in a
UNC path.
2003-12-05 04:33:40 +00:00
Christopher Faylor 57e6aca667 * exceptions.cc (setup_handler): Remove ill-advised debugging output. 2003-12-05 04:20:48 +00:00
Corinna Vinschen 592db10ed7 * include/cygwin/types.h (struct __fcntl64): Fix datatype of l_start. 2003-12-04 09:37:55 +00:00
Corinna Vinschen 145b4dc249 Substitute 0x7fffffff and 0xffffffff by INT32_MAX and UINT32_MAX
throughout, except in assembler code.
2003-12-03 16:35:52 +00:00
Corinna Vinschen d2fa946e51 * fhandler_disk_file.cc (fhandler_disk_file::lock): Use UINT32_MAX
instead of 0xffffffff.  Accomodate Win 9x bug in evaluating length
	of area to lock when given length is 0.
2003-12-03 11:22:49 +00:00
Corinna Vinschen 1843517401 * fhandler_disk_file.cc (fhandler_disk_file::lock): Interchange
values of off_low and off_high.
2003-12-03 09:58:23 +00:00
Corinna Vinschen e2a39e2efa * fcntl.cc (fcntl_worker): Remove static storage class.
* flock.cc (flock): Use struct __flock64. Call fcntl_worker.
	Use Cygwin errno functions instead of accessing errno directly.
	* winsup.h: Declare fcntl_worker.
2003-12-03 09:55:42 +00:00
Corinna Vinschen 941c9bf805 * fcntl.cc (_fcntl): Whitespace cleanup. 2003-12-03 09:16:37 +00:00
Christopher Faylor d1eb7a4615 * cygthread.cc (cygthread::stub): Properly establish _threadinfo environment.
(cygthread::stub2): New function.
(cygthread::simplestub): Ditto.
(cygthread::simplestub2): New function.
* cygthread.h (cygthread::stub2): Declare new function.
(cygthread::simplestub2): Ditto.
* cygtls.h (_threadinfo::call): Declare new function.
(_threadinfo::call2): Ditto.
* dcrt0.cc (dll_crt0_1): Accommodate new _threadinfo::init which doesn't return
pointer to tls.
(_dll_crt0): Remove obsolete DECLARE_TLS_STORAGE.
(dll_crt0): Ditto.
* exceptions.cc (_threadinfo::call): New function.
(_threadinfo::call2): Ditto.
(_threadinfo::init): Don't return pointer.
* thread.cc (pthread::thread_init_wrapper): Properly establish _threadinfo
environment.
(pthread::thread_init_wrapper2): New function.
* thread.h (pthread::thread_init_wrapper): Remove noreturn attribute
(pthread::thread_init_wrapper2): Declare new function.
* winbase.h: Remove obsolete code.
2003-12-03 05:21:55 +00:00
Christopher Faylor af9ef8abb2 * Makefile.in: Change the way that -f options are appended to CFLAGS, slightly. 2003-12-03 00:21:21 +00:00
Christopher Faylor e575a697ba * fcntl.cc (_fcntl): Silence a compiler warning. 2003-12-02 23:47:28 +00:00
Christopher Faylor 93e4038242 * pinfo.cc (pinfo::init): Use shared_name to construct the mapname. 2003-12-02 04:10:56 +00:00
Christopher Faylor 5c9cceced7 white space 2003-12-02 01:36:08 +00:00
Thomas Pfaff 693dd53815 Change tab to space in Changelog. 2003-12-01 22:13:58 +00:00
Thomas Pfaff 94d2416049 * thread.cc (pthread_rwlock::add_reader): Remove mx parameter for
List_insert call.
(pthread::prepare): Ensure race safeness when adding function
pointers to atfork lists by using List_insert.
* thread.h (List_insert): Use InterlockedCompareExchangePointer to
ensure race safeness without using a mutex.
(List_remove): Use InterlockedCompareExchangePointer to
ensure race safeness with List_insert.
(List::insert): Remove mx parameter for	List_insert call.
2003-12-01 22:10:57 +00:00
Corinna Vinschen dc3998682a * Makefile.in (OBSOLETE_FUNCTIONS): Add fcntl.
(NEW_FUNCTIONS): Add fcntl64.
	* cygwin.din: Export fcntl64.  Make fcntl being SIGFE.
	* fcntl.cc (fcntl_worker): New function.
	(fcntl64): New function.
	(_fcntl): Call fcntl_worker.  Convert 32 bit flock structure into
	64 bit flock structure and vice versa.
	* fhandler.cc (fhandler_base::lock): Change 2nd parameter to
	struct __flock64 *.
	* fhandler_disk_file.cc (fhandler_disk_file::lock): Ditto.  Rework
	to be 64 bit aware.
	* fhandler.h: Accomodate above method argument changes.
	* include/cygwin/types.h: Add struct __flock32 and __flock64.
	Define struct flock according to setting of __CYGWIN_USE_BIG_TYPES__.
	* include/cygwin/version.h: Bump API minor number.
2003-12-01 17:26:28 +00:00
Corinna Vinschen 6c2b784612 * cygheap.cc (cygheap_init): Set cygheap->shared_prefix.
* cygheap.h (struct init_cygheap): Add shared_prefix.
	* shared.cc (shared_name): Use cygheap->shared_prefix.
2003-12-01 15:03:43 +00:00
Corinna Vinschen 4febe95f89 * shared.cc (shared_name): Take into account the SE_CREATE_GLOBAL_NAME
privilege when building the name string.
	(open_shared): Remove the call to OpenFileMapping.
	(shared_info::initialize): Move cygheap initialization to ...
	(memory_init): ... here. Suppress now useless shared_h variable.
	(user_shared_initialize): Make tu a cygpsid.
2003-12-01 11:16:20 +00:00
Corinna Vinschen cb766c47bb * include/tzfile.h: Remove duplicate definition of TM_SUNDAY.
* localtime.cc: Point TZDIR to the /usr/share/zoneinfo directory used
	by the tzcode package.
2003-12-01 10:39:17 +00:00
Corinna Vinschen b406ed7b51 * flock.cc: Renamed from flock.c. 2003-11-30 10:43:04 +00:00
Christopher Faylor fcac349166 * pinfo.h: Remove global_sigs declaration.
* siginfo.h: Move global_sigs declaration here.
* Makefile.in: Remove duplicate compiler flag.
2003-11-30 02:21:04 +00:00
Christopher Faylor b63ba3b6aa * exceptions.cc (_threadinfo::pop): Zero *contents* of popped stack location
rather than the actual stack pointer.
2003-11-30 02:19:45 +00:00
Corinna Vinschen f3a1e23eb3 * Makefile.in: (DLL_OFILES): Add flock.o.
* cygwin.din: Export flock.
	* flock.c: New file.
	* include/sys/file.h: Include sys/cdefs.h.
	Add function prototype for flock().
	Add some comments from BSD's header for further clarity.
	(L_SET, L_CURR, L_INCR, L_XTND): Redefine as the macros
	SEEK_SET, SEEK_CUR, SEEK_CUR, & SEEK_END respectively.
	(LOCK_SH,LOCK_EX,LOCK_NB,LOCK_UN): New macros for flock().
	* include/cygwin/version.h: Bump API minor number.
2003-11-29 23:00:51 +00:00
Christopher Faylor b50fe8212f * sigproc.cc (no_signals_available): Fix so that non-zero exit state is a true
condition rather than errnoneously only checking other states when exist_state
was zero.
2003-11-29 00:31:37 +00:00
Christopher Faylor 62e070d72e * pinfo.h (_pinfo::getthread2signal): Remove obsolete function.
* cygtls.h (_threadinfo): Define tid more precisely.
(_threadinfo::operator HANDLE): Define.
* exceptions.cc (_threadinfo::interupt_now): Use _threadinfo HANDLE operator to
derive thread handle.
(setup_handler): Ditto.
* sigproc.cc: Reorganize includes.
2003-11-29 00:26:40 +00:00
Christopher Faylor 13584f077b * pinfo.h (_pinfo::getsig): Remove obsolete function, here and throughout.
* exceptions.cc: Ditto.
* fhandler_termios.cc: Ditto.
* signal.cc: Ditto.
* sigproc.cc: Ditto.
* Makefile.in: Revert previous change which made a cygwin.din newer than a
version.h a warning rather than an error.
2003-11-28 22:13:57 +00:00
Christopher Faylor 74d893b13c * cygwin.din: Re-add inexplicably missing semaphore/msg functions. 2003-11-28 21:39:08 +00:00
Christopher Faylor 965f78cbbe * gendevices: Issue error when shilka is missing. 2003-11-28 21:20:15 +00:00
Christopher Faylor abd2fa9994 * include/cygwin/signal.h: New file.
(also check in tlsoffsets.h, missed by previous checkin)
2003-11-28 21:01:09 +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