Commit Graph

26 Commits

Author SHA1 Message Date
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
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
Robert Collins 95d02d5b9b 2003-11-11 Robert Collins <rbtcollins@hotmail.com>
Ron Parker <rdparker@butlermfg.com>

	* bsdlib.cc: Update throughout to use CYG_MAX_PATH rather than MAX_PATH.
	* cygheap.h: Ditto.
	* dcrt0.cc: Ditto.
	* delqueue.cc: Ditto.
	* dlfcn.cc: Ditto.
	* dll_init.cc: Ditto.
	* dll_init.h: Ditto.
	* dtable.cc: Ditto.
	* environ.cc: Ditto.
	* environ.h: Ditto.
	* exceptions.cc: Ditto.
	* external.cc: Ditto.
	* fhandler_disk_file.cc: Ditto.
	* fhandler_proc.cc: Ditto.
	* fhandler_process.cc: Ditto.
	* fhandler_raw.cc: Ditto.
	* fhandler_registry.cc: Ditto.
	* fhandler_socket.cc: Ditto.
	* fhandler_virtual.cc: Ditto.
	* miscfuncs.cc: Ditto.
	* mmap.cc: Ditto.
	* netdb.cc: Ditto.
	* path.cc: Ditto.
	* path.h: Ditto.
	* pinfo.cc: Ditto.
	* pinfo.h: Ditto.
	* pthread.cc: Ditto.
	* registry.cc: Ditto.
	* shared.cc: Ditto.
	* shared_info.h: Ditto.
	* smallprint.c: Ditto.
	* spawn.cc: Ditto.
	* strace.cc: Ditto.
	* syscalls.cc: Ditto.
	* thread.h: Ditto.
	* uinfo.cc: Ditto.
	* winsup.h: Ditto.
	* include/limits.h: Ditto.
	* include/cygwin/config.h: Ditto.
	* include/sys/param.h: Ditto.
2003-11-14 23:40:06 +00:00
Christopher Faylor 8398809e7d * miscfuncs.cc (low_priority_sleep): Make a "C" function.
* winsup.h (low_priority_sleep): Revert previous change to declaration.
2003-11-10 21:28:02 +00:00
Corinna Vinschen d845665e0f * miscfunc.cc (__check_invalid_read_ptr): New function.
* winsup.h: Declare.
2003-10-27 08:28:37 +00:00
Christopher Faylor e2bc5017fa * syscalls.cc (mount): Don't check win32_path when doing cygdrive mount. 2003-08-28 02:04:16 +00:00
Christopher Faylor d688945c44 * miscfuncs.cc (low_priority_sleep): Sleep at same priority as main thread.
* sigproc.cc (wait_sig): Keep looping if there are more signals to consider and
we are flushing signals.
(sig_send): Put nonsync signals in the correct bucket.
2003-08-21 03:18:46 +00:00
Corinna Vinschen e136dbc297 Split ChangeLog, create ChangeLog-2002.
Fix copyright dates.
2003-01-10 12:32:49 +00:00
Christopher Faylor d5223b2b0a * cygthread.cc (cygthread::cygthread): Be more noisy about odd condition.
* miscfuncs.cc (low_priority_sleep): Sleep in regular priority if that's what
we're currently running at.
2003-01-10 03:13:45 +00:00
Christopher Faylor 13af9a149d * exceptions.cc (sigthread::get_winapi_lock): Just do standard 'give up
timeslice' wait.
(setup_handler): Revamp YA to attempt to deliver signal multiple times on
failure rather than punting to wait_sig.
* miscfuncs.cc (low_priority_sleep): Accept INFINITE sleep to mean "don't reset
the priority after setting it to idle".  Return previous priority.
* winsup.h (SLEEP_0_STAY_LOW): Define.
(low_priority_sleep): Return an int.
* sigproc.h: Define WAIT_SIG_PRIORITY here.
* sigproc.cc: Remove WAIT_SIG_PRIORITY definition.
2002-11-22 04:43:47 +00:00
Christopher Faylor 6597785dc2 * exceptions.cc (setup_handler): Add debugging output. Set thread priority to
idle if pending signals to allow other threads to get into interruptible state.
* miscfuncs.cc (sys_mbstowcs): Save current thread in variable to avoid an OS
call.
* wait.cc (wait_sig): Reset thread priority each time through loop since the
priority may have been set down to deal with pending signals.
2002-11-15 04:35:13 +00:00
Christopher Faylor c0a02a4b42 * miscfuncs.cc (low_priority_sleep): New function. Use throughout where code
is supposed to be giving up time slice.
* fhandler_console.cc (fhandler_console::read): Switch button 2/3 output escape
sequences to be consistent with xterm.
2002-11-13 19:36:12 +00:00
Christopher Faylor 831d6fa520 * external.cc (cygwin_internal): Implement CW_CMDLINE.
* pinfo.h (SIGCOMMUNE): New signal type.
(commune_result): New structure for commune functions.
(picom): New enum for commune functions.
(_pinfo::hello_pid): New.  Pid who's communicating with me.
(_pinfo::tothem): New.  Handle of communicating pipe.
(_pinfo::fromthem): Ditto.
(_pinfo::commune_recv): Declare.
(_pinfo::commune_send): Declare.
(_pinfo::alive): Declare.
(_pinfo::cmdline): Declare.
(_pinfo::lock): Declare.
* pinfo.cc (set_myself): Initialize new _pinfo lock.
(_pinfo::alive): Define.  Determines if process still exists.
(_pinfo::commune_recv): Define.  Receive info from another cooperating process.
(_pinfo::commune_send): Define.  Send info to another cooperating process.
(_pinfo::cmdline): Define.  Determine command line of a given process.
* include/sys/cygwin.h (CW_CMDLINE): Define.
*sigproc.cc (talktome): Communicate with any processes who want to talk to me.
(wait_sig): Honor __SIGCOMMUNE.
* fhandler.cc (fhandler_virtual::fixup_after_exec): Declare.
* fhandler_proc.cc: Use malloc/free/realloc throughout rather than cmalloc
since buffers don't need to be propagated to subprocesses.
* fhandler_registry.cc: Ditto.
* fhandler_virtual.cc: Ditto.
(fhandler_virtual::fixup_after_exec): Define.
* fhandler_process.cc: Ditto for malloc/free/realloc.
(process_listin): Add "cmdline".
(fhandler_process::fill_filebuf): Implement PROCESS_CMDLINE.
* miscfuncs.cc (isalpha_array): New array populated with xor values for alpha
characters to switch from one case to another.
* string.h (cygwin_strcasematch): New asm implementation of case match.
* string.h (cygwin_nstrcasematch): New asm implementation of counted case
match.
2002-10-30 21:05:18 +00:00
Christopher Faylor ab7f9b938f * miscfuncs.cc (check_iovec_for_read): Don't check buffer when zero length
iov_len.
(check_iovec_for_write): Ditto.
* fhandler.h (fhandler_base::readv): New method.
(fhandler_base::writev): Ditto.
* fhandler.cc (fhandler_base::readv): New method.
(fhandler_base::writev): Ditto.
* syscalls.cc (_read): Delegate to readv(2).
(_write): Ditto, mutatis mutandi.
(readv): Rewrite, based on the old _read code, to use the new
fhandler_base::readv method.  Improve access mode handling and ensure all calls
reach the final strace statement.
(writev): Ditto, mutatis mutandi.
* include/sys/uio.h (struct iovec): Change field types to match SUSv3.
* winsup.h (check_iovec_for_read): New function.
(check_iovec_for_write): Ditto.
* miscfuncs.cc (check_iovec_for_read): Ditto.
(check_iovec_for_write): Ditto.
2002-08-30 15:47:10 +00:00
Conrad Scott b4f06520f4 * winsup.h (__check_null_invalid_struct): Make ptr argument non-const.
(__check_null_invalid_struct_errno): Ditto.
	* miscfuncs.cc (__check_null_invalid_struct): Ditto.
	(__check_null_invalid_struct_errno): Ditto.
	(__check_invalid_read_ptr_errno): Remove superfluous cast.
	* net.cc (get): Set appropriate errno if fd is not a socket.
	(cygwin_sendto): Fix parameter checking.
	(cygwin_recvfrom): Ditto.
	(cygwin_setsockopt): Ditto.
	(cygwin_getsockopt): Ditto.
	(cygwin_connect): Ditto.
	(cygwin_gethostbyaddr): Ditto.
	(cygwin_accept): Ditto.
	(cygwin_bind): Ditto.
	(cygwin_getsockname): Ditto.
	(cygwin_listen): Ditto.
	(cygwin_getpeername): Ditto.
	(cygwin_send): Ditto.
	(cygwin_shutdown): Ditto.  Move sigframe to fhandler_socket.
	(cygwin_recvmsg): Fix parameter checking.  Add tracing.
	(cygwin_sendmsg): Ditto.
	* fhandler_socket.cc (fhandler_socket::shutdown): Add sigframe.
	* resource.cc (setrlimit): Fix parameter checking.
2002-08-08 17:03:20 +00:00
Christopher Faylor f279e522b0 * autoload (noload): Avoid clobbering bx register.
* environ.cc (codepage_init): Use case insensitive match.
* fhandler_console.cc (cp_get_internal): Delete.
(con_to_str): Use get_cp to derive code page.
(str_to_con): Ditto.
* miscfuncs.cc (get_cp): New function.
(sys_wcstombs): New function.  Converted from macro.
(sys_mbstowcs): Ditto.
* winsup.h: Reflect above changes.
2002-06-26 05:29:41 +00:00
Christopher Faylor 1cf0d8510a * debug.cc (makethread): Eliminate unneeded function call.
* miscfuncs.cc (tls_ix): Predefine.
* perthread.h (set_reent): Eliminate.
(get_reent): Ditto.
* winbase.h (my_tlsalloc): Use global stack base pointer.  Set newly allocated
location to NULL.
(my_tlssetvalue): Use global stack base pointer.
(my_tlsgetvalue): Ditto.
2001-11-30 06:19:58 +00:00
Christopher Faylor 4d029f3940 * cygwin.din (ualarm): New export.
* dcrt0.cc (_dll_crt0): Add experimental tls storage declaration.
(dll_crt0): Ditto.
* debug.cc (thread_stub): Ditto.
* thread.cc: Minor cleanup.
(__pthread_create): Add experimental tls storage declaration.
* miscfuncs.cc: Define tls index.
* winsup.h: Declare experimental tls storage.
* window.cc (alarm): Use old timer return from setitimer.
(ualarm): New function.
2001-11-28 00:06:35 +00:00
Christopher Faylor 5a64d86941 * dtable.cc (dtable::vfork_parent_restore): Add debugging statement.
* exceptions.cc (try_to_debug): Spin only as long as we don't have a debugger
attached.
* fhandler.h (fhandler_base::set_nohandle): New method.
(fhandler_base::get_nohandle): New method.
* fhandler.cc (fhandler_base::dup): Avoid duplicating handle if there is no
handle.
* fhandler_disk_file.cc (fhandler_disk_file::opendir): Set nohandle flag on
dummy fd.
* Makefile.in: Make intermediate library for eventual inclusion in libcygwin.a
* fhandler.h (fhandler_pipe::fhandler_pipe): Remove default argument setting
since it is no longer used.
* miscfuncs.cc (check_null_str): New function.
(+check_null_str_errno): Ditto.
* net.cc: Add defensive buffer checking throughout.
(cygwin_sendto): Protect against invalid fd.
(cygwin_recvfrom): Ditto.
(cygwin_getpeername): Ditto.
(cygwin_recv): Ditto.
(cygwin_send): Ditto.
* winsup.h: Declare a new function.
* select.cc (set_bits): Fix conditional for setting fd in exceptfds.
* dtable.cc (dtable::build_fhandler): Create fhandler_pipe using correct device
type.
* path.cc (get_devn): Set correct pipe device type from device name.
2001-11-24 03:11:39 +00:00
Christopher Faylor a0626ebe27 Ensure that all fhandler_*::read definitions are __stdcall throughout.
* fhandler.cc (fhandler_base::set_inheritance): Be more defensive in debugging
code.
* fhandler.h: Adjust regparms throughout to reflect passing 'this' parameter.
* fhandler_console.cc (fhandler_console::read): Remove unneeded test.  Only
honor "key down" events.
* miscfuncs.cc (strcasestr): Reorganize for efficient code use.
(check_null_empty_str_errno): Ditto.
(__check_null_invalid_struct_errno): Ditto.
(__check_invalid_read_ptr_errno): Ditto.
* syscalls.cc (_read): Return 0 when length == 0, as per Single UNIX
Specification.
2001-10-24 04:16:45 +00:00
Corinna Vinschen 8b6234ca12 * miscfuncs.cc (__check_invalid_read_ptr_errno): Return error, if any. 2001-10-22 11:31:39 +00:00
Christopher Faylor 6fdd213161 * miscfuncs.cc (+__check_invalid_read_ptr_errno): New function.
* syscalls.c (_write): Validate that write buffer is accessible for reading,
not writing.
* winsup.h: Declare new function, increase regparmization of check_* functions.
2001-10-20 05:08:21 +00:00
Christopher Faylor 1ff9f4b937 * cygheap.h (init_cygheap): Move heap pointers here.
* include/sys/cygwin.h (perprocess): Remove heap pointers.
* dcrt0.cc (__cygwin_user_data): Reflect obsolete perprocess stuff.
(_dll_crt0): Don't initialize heap pointers.
(cygwin_dll_init): Ditto.
(release_upto): Use heap pointers from cygheap.
* heap.h: Ditto.
* fork.cc (fork_parent): Ditto.  Don't set heap pointers in ch.
(fork_child): Remove obsolete sigproc_fixup_after_fork.
* shared.cc (memory_init): Reorganize so that cygheap initialization is called
prior to regular heap since regular heap uses cygheap now.
* sigproc.cc (proc_subproc): Eliminate zombies allocation.
(sigproc_init): Move zombies alloation here.  Don't free up array on fork, just
reuse it.
(sigproc_fixup_after_fork): Eliminate.
* sigproc.h: Ditto.
* include/cygwin/version.h: Reflect change to perprocess structure.
2001-09-07 21:32:07 +00:00
Christopher Faylor 57c89867f5 Move appropriate variables to NO_COPY segment, throughout. 2001-09-06 05:17:22 +00:00
Christopher Faylor 7a4078ee34 Change check_null_empty_path* to check_null_empty_str* throughout.
* path.cc (path_conv::check): Add signal protection here since retrieving info
about remote shares can take some time.
* path.h (check_null_empty_str_errno): Convert to a function prototype.
* path.cc (check_null_empty_str): Move to miscfuncs.cc.
* miscfuncs.cc (check_null_empty_str_errno): New function.
(__check_null_invalid_struct): Ditto.
(__check_null_invalid_struct_errno): Ditto.
(check_null_empty_str): Change from VirtualQuery to IsBadWritePtr.
* thread.cc (check_valid_pointer): Ditto.
* resource.cc (getrlimit): Use check_null_invalid_struct macro for checking
validity of pointer.
(setrlimit): Ditto.
2001-06-28 02:19:57 +00:00
DJ Delorie 2556e737ec * Makefile.in: add miscfuncs.cc
* miscfuncs.cc: new, miscellaneous functions
* winsup.h: define table-driven tolower/toupper
* environ.cc: use them
* fhandler_console.cc: ditto
* fhandler_termios: ditto
* path.cc: ditto
(strncasematch, strcasematch, strcasestr): move to miscfuncs.cc
2000-10-19 03:12:44 +00:00