aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/fhandler_serial.cc
AgeCommit message (Collapse)AuthorFilesLines
2022-08-05Cygwin: Reorganize cygwin source dirCorinna Vinschen1-1138/+0
Create subdirs and move files accordingly: - DevDocs: doc files - fhandler: fhandler sources, split fhandler.cc into base.cc and null.cc - local_includes: local include files - scripts: scripts called during build - sec: security sources Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-29Cygwin: remove regparm.hKen Brown1-2/+2
This file defines the macros __reg1, __reg2, and __reg3, which are defined to be empty on 64-bit Cygwin. Remove all occurrences of these macros.
2021-02-02fhandler_serial.cc: MARK and SPACE parity for serial portMarek Smetana1-1/+10
2020-08-05Cygwin: Add 'fallthrough' pseudo keyword for switch/case useCorinna Vinschen1-1/+1
This patch has been inspired by the Linux kernel patch 294f69e662d1 compiler_attributes.h: Add 'fallthrough' pseudo keyword for switch/case use written by Joe Perches <joe AT perches DOT com> based on an idea from Dan Carpenter <dan DOT carpenter AT oracle DOT com>. The following text is from the original log message: Reserve the pseudo keyword 'fallthrough' for the ability to convert the various case block /* fallthrough */ style comments to appear to be an actual reserved word with the same gcc case block missing fallthrough warning capability. All switch/case blocks now should end in one of: break; fallthrough; goto <label>; return [expression]; continue; In C mode, GCC supports the __fallthrough__ attribute since 7.1, the same time the warning and the comment parsing were introduced. Cygwin-only: add an explicit -Wimplicit-fallthrough=5 to the build flags.
2020-03-26Cygwin: serial: fix GCC warningCorinna Vinschen1-1/+1
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-03-25Revert "Cygwin: serial: read: if VMIN > 0, wait for VMIN chars in inbound queue"github/topic/serial_iotopic/serial_ioCorinna Vinschen1-26/+12
This reverts commit 082f2513c721e942d0fd563c4dc9117eee3513ab. Turns out, Linux as well as BSD really only wait for the smaller number, MIN or # of requested bytes. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-03-25fhandler_serial: fix commentsCorinna Vinschen1-3/+3
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-03-25Cygwin: serial: read: if VMIN > 0, wait for VMIN chars in inbound queueCorinna Vinschen1-12/+26
Per termios, read waits for MIN chars even if the number of requested bytes is less. This requires to add WaitCommEvent to wait non-busily for MIN chars prior to calling ReadFile, so, reintroduce it. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-03-23Cygwin: serial: use per call OVERLAPPED structsCorinna Vinschen1-55/+15
Sharing the OVERLAPPED struct and event object in there between read and select calls in the fhandler might have been a nice optimization way back when, but it is a dangerous, not thread-safe approach. Fix this by creating per-fhandler, per-call OVERLAPPED structs and event objects on demand. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-03-23Cygwin: serial: tcsetattr: set timeouts unconditionallyCorinna Vinschen1-41/+38
tcsetattr checks if the VTIME and VMIN values changed and only calls SetCommTimeouts if so. That's a problem if tcsetattr is supposed to set VTIME and VIMN to 0, because these are the start values anyway. But this requires to set ReadIntervalTimeout to MAXDWORD, which just doesn't happen. Fix this by dropping the over-optimization of checking the old values before calling SetCommTimeouts, Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-03-22Cygwin: serial: avoid overrun of vtimeCorinna Vinschen1-4/+4
After changing the type of fhandler_serial::vtime_ to cc_t, vtime_ must be stored in 10s of seconds, not in milliseconds. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-03-22Cygwin: serial: revamp overlapped IO in read and selectCorinna Vinschen1-65/+46
Get rid of WaitCommEvent and using overlapped_armed to share the same overlapped operation between read and select. Rather, make sure to cancel the overlapped IO before leaving any of these functions. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-03-22Cygwin: serial: read: revamp raw_read, change vmin_ and vtime_ to cc_tCorinna Vinschen1-91/+115
- Datatypes were incorrect, especially vmin_ and vtime_. Change them to cc_t, as in user space. - Error checking had a gap or two. Debug output used the wrong formatting. - Don't use ev member for ClearCommError and WaitCommEvent. Both returned values are different (error value vs. event code). The values are not used elsewhere so it doesn't make sense to store them in the object. Therefore, drop ev member. - Some variable names were not very helpful. Especially using n as lpNumberOfBytesTransferred from GetOverlappedResult and then actually printing it as if it makes sense was quite puzzeling. - Rework the loop and the definition of minchars so that it still makes sense when looping. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-03-16Cygwin: serial: wait for CancelIo completionCorinna Vinschen1-1/+1
Per https://devblogs.microsoft.com/oldnewthing/20110202-00/?p=11613 GetOverlappedResult must be called blocking, waiting for the overlapped operation to complete. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-03-12Cygwin: serial: try fix o_nonblockCorinna Vinschen1-0/+10
2020-03-02Cygwin: ioctl: TIOCINQ: always return number of chars in the inbound queueCorinna Vinschen1-8/+1
So far ioctl(TIOCINQ) could end up returning -1 with errno set to EINVAL if a non-zero device error mask has been returned by ClearCommError. This doesn't reflect Linux behaviour, which always returns the number of chars in the inbound queue, independent of any I/O error condition. EINVAL was a pretty weird error code to use in this scenario, too. Fix this by dropping all checking for device errors in the TIOCINQ case. Just return the number of chars in the inbound queue. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-23Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout optioncygwin-2_5_2-releaseCorinna Vinschen1-3/+0
Bump GPLv2+ to GPLv3+ for some files, clarify BSD 2-clause. Everything else stays under GPLv3+. New Linking Exception exempts resulting executables from LGPLv3 section 4. Add CONTRIBUTORS file to keep track of licensing. Remove 'Copyright Red Hat Inc' comments. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2014-10-20 * fhandler_serial.cc: Revert debug code accidentally checked in onCorinna Vinschen1-1/+1
2014-08-18.
2014-08-18 * dtable.cc (dtable::init_std_file_from_handle): Mention that consoleCorinna Vinschen1-1/+1
handles are kernel objects since Windows 8. * fhandler.h (enum conn_state): Add "listener" state. (class fhandler_socket): Drop listener status flag. (fhandler_socket::lseek): Return -1 and errno ESPIPE. (fhandler_serial::lseek): Ditto. * fhandler_socket.cc (fhandler_socket::listen): Set connect_state to listener. Add comment. (fhandler_socket::accept4): Explicitely check if the socket is listening and fail with EINVAL, if not. Explain why we have to do that. (fhandler_socket::recv_internal): Explicitely check if the socket is connected if it's a stream socket. Explain why we have to do that. (fhandler_socket::getpeereid): Drop now redundant test.
2013-05-01Throughout, (mainly in fhandler*) fix remaining gcc 4.7 mismatchYaakov Selkowitz1-2/+2
warnings between regparm definitions and declarations. * smallprint.cc (__small_vswprintf): Conditionalize declaration and setting of l_opt for only x86_64. * spawn.cc (child_info_spawn::worker): Remove unused 'pid' variable. * thread.cc (verifyable_object_isvalid): Temporarily define as non-inline with gcc 4.7+, regardless of target.
2013-04-23 * Merge in cygwin-64bit-branch.Corinna Vinschen1-18/+18
2013-01-21Throughout, update copyrights to reflect dates which correspond to main-branchChristopher Faylor1-2/+2
checkins. Regularize copyright format.
2012-11-26 * fhandler_registry.cc: Drop Mingw.org considerations.Corinna Vinschen1-4/+0
* fhandler_serial.cc: Ditto. * fhandler_socket.cc: Ditto. * fhandler_tape.cc: Ditto. * fhandler_tty.cc: Ditto. * net.cc: Ditto. * ntdll.h: Ditto. * sched.cc: Ditto. * sec_helper.cc: Ditto.
2012-06-28 * fhandler_serial.cc: Fix includes for IOCTL codes to support Mingw64.Corinna Vinschen1-0/+5
* fhandler_tape.cc: Ditto. * flock.cc (allow_others_to_sync): Use PISECURITY_DESCRIPTOR since PSECURITY_DESCRIPTOR is supposed to be the opaque type. * ntdll.h: Remove CreateDisposition flags again, now that they are defined in Mingw64's ntdef.h. Ditto for Create/Open flags.
2012-06-17Add '#include "cygwait.h"' throughout, where appropriate.Christopher Faylor1-4/+5
* DevNotes: Add entry cgf-000012. * Makefile.in (DLL_OFILES): Add cygwait.o. * sigproc.h: Remove cygwait definitions. * cygwait.h: New file. Define/declare Cygwin waitfor functions. * cygwait.cc: Ditto. * exceptions.cc: Include cygwait.h. (handle_sigsuspend): Accommodate change in cancelable_wait arguments. (sigpacket::process): Display thread tls in debugging output. * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Use symbolic names for signal and cancel return. * fhandler_console.cc (fhandler_console::read): Ditto. (fhandler_dev_dsp::Audio_out::waitforspace): Ditto. fhandler_dev_dsp::Audio_in::waitfordata): Ditto. * fhandler_fifo.cc (fhandler_fifo::wait): Ditto. * fhandler_serial.cc (fhandler_serial::raw_read): Ditto. * fhandler_tty.cc (fhandler_pty_slave::read): Ditto. * select.cc (cygwin_select): Ditto. * wait.cc (wait4): Ditto. * thread.cc (cancelable_wait): Move definition to cygwait.h. (pthread_cond::wait): Accommodate change in cancelable_wait arguments. (pthread_mutex::lock): Ditto. (pthread_spinlock::lock): Ditto. (pthread::join): Ditto. (pthread::thread_init_wrapper): Display tls in debugging output. (semaphore::_timedwait): Ditto. * thread.h (cw_sig_wait): Move to cygwait.h. (cw_cancel_action): Delete. (cancelable_wait): Move declaration to cygwait.h.
2012-05-25 * fhandler_serial.cc (fhandler_serial::raw_read): Check forCorinna Vinschen1-1/+1
ERROR_OPERATION_ABORTED rather than ERROR_IO_INCOMPLETE after CancelIo.
2012-05-25 * fhandler_serial.cc (fhandler_serial::raw_read): Just call ReadFileCorinna Vinschen1-12/+9
directly in case of non-blocking I/O and handle result gracefully.
2012-03-08 * Throughout, replace usage of w32api's min with MIN from sys/param.h.Corinna Vinschen1-1/+2
2012-02-26 * environ.cc (dos_file_warning): Drop declaration.Corinna Vinschen1-2/+1
(ignore_case_with_glob): Ditto. (allow_winsymlinks): Ditto. (reset_com): Move definition to globals.cc. (struct parse_thing): Add "detect_bloda" option. * fhandler_serial.cc (fhandler_serial::open): Drop (incorrect) declaration of reset_com. * globals.cc (ignore_case_with_glob): Move definition into C++-only block. (dos_file_warning): Define. (allow_winsymlinks): Define. (reset_com): Define. (detect_bloda): Define. * path.cc (dos_file_warning): Drop definition here. (allow_winsymlinks): Drop definition here.
2011-12-13* cygthread.h (cygthread::name): Very minor formatting tweak.Christopher Faylor1-6/+0
* exceptions.cc (_cygtls::call_signal_handler): Add paranoid debugging output. * sigproc.h (cygwait): Call signal handler when signal is detected and loop as appropriate. * fhandler.h (fhandler_base_overlapped::wait_return): Remove overlapped_signal. * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Remove restartable signal accommodations in light of cygwait improvements. (fhandler_base_overlapped::raw_read): Remove now-obsolete signal loop behavior. (fhandler_base_overlapped::raw_write): Ditto. * fhandler_console.cc (fhandler_console::read): Ditto. * fhandler_serial.cc (fhandler_serial::raw_read): Ditto. (fhandler_serial::raw_write): Ditto. * fhandler_tty.cc (fhandler_pty_slave::read): Ditto. * ioctl.cc (ioctl): Add standard syscall introducer and leaver debug output.
2011-12-09Rename cygWFMO to cygwait throughout and use the magic of polymorphism to "waitChristopher Faylor1-2/+2
for stuff". * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Use simplified arg form of cygwait. * fhandler_console.cc (fhandler_console::read): Ditto. * fhandler_audio.cc (fhandler_dev_dsp::Audio_out::waitforspac): Ditto. (fhandler_dev_dsp::Audio_in::waitfordata): Ditto. * fhandler_fifo.cc (fhandler_fifo::wait): Ditto. * fhandler_serial.cc (fhandler_serial::raw_read): Ditto. (fhandler_serial::raw_write): Ditto. * select.cc (cygwin_select): Ditto. * sigproc.h (cygwait): Rename from cygWFMO. Define two argument and single argument forms of this function. * fhandler_tty.cc (fhandler_pty_slave::open): Use method to query if tty is open. (fhandler_pty_slave::read): Send SIGHUP when master is detected as closed. (fhandler_pty_common::close): Close input_available_event in callers since master may need to signal it first. (fhandler_pty_master::close): Lie and set input_available_event when closing, then close input_available_event. (fhandler_pty_slave::close): Close input_available_event explicitly here. * tty.h (tty::is_master_closed): Declare new method.
2011-12-04* sigproc.cc (cygWFMO): Don't assume that cancellable event is alwaysChristopher Faylor1-8/+2
available. * fhandler_dsp.cc (fhandler_dev_dsp::Audio_out::waitforspace): Use cygWFMO instead of WaitForMultipleObjects. (fhandler_dev_dsp::Audio_in::waitfordata): Ditto. * fhandler_fifo.cc (fhandler_fifo::wait): Ditto. * fhandler_serial.cc (fhandler_serial::raw_read): Ditto. (fhandler_serial::raw_write): Ditto. * fhandler_tty.cc (fhandler_pty_slave::read): Ditto. * select.cc (cygwin_select): Ditto for degenerate case.
2011-12-03Throughout, remove extra space after function name from debugging output.Christopher Faylor1-1/+1
Throughout, change syscalls to report on return values using new %R format option. * smallprint.cc (__small_vsprintf): Add parsing for %R to report on return values and possible errno from syscalls. * errno.cc (errmap): Add PRIVILEGE_NOT_HELD. * fhandler_tty.cc (fhandler_pty_master::setup): When creating a thread use shorter name to reduce debuggging output. * select.cc (start_thread_pipe): Ditto. (start_thread_serial): Ditto. (start_thread_socket): Ditto. (start_thread_mailslot): Ditto. * sigproc.cc (talktome): Ditto.
2011-10-15* cygerrno.h (__set_errno): Modify debugging output to make searching straceChristopher Faylor1-2/+2
logs easier. Throughout, change /dev/tty* to /dev/pty*. Throughout, add flags argument to fhandler_*::dup methods. * devices.in: Rename (temporarily?) /dev/ttyN to /dev/ptyN. Add /dev/ptymN devices for pty masters. * devices.cc: Regenerate. * devices.h (MAX_CONSOLES): Set to max number supported by devices.in. (fh_devices::FH_PTMX): Rename from FH_PTYM. (device::operator int): Return by reference. * dtable.cc (fh_alloc): Take pc as an argument rather than just the device. This makes debugging easier since more information is available. Actually implement handling for already-allocated pty master devices. Make different decisions when generating fhandler for not-opened devices. Add kludge to deal with opening /dev/tty. (cnew_no_ctor): New macro. (build_fh_pc): Make debugging output more verbose. Use new clone() fhandler interface to duplicate archetypes. Reset last term opened. (dtable::dup_worker): Use Use new clone() fhandler interface to duplicate archetypes. Pass flags to child dup handler. (dtable::dup3): Set O_NOCTTY flag if newfd is not stdin/stdout/stderr. * fhandler.cc (fhandler_base::reset): Rename from operator =() and reduce functionality and sense of copy direction. (fhandler_base::open_with_arch): Use published interface to query io_handle(). Use new copyto() fhandler method to copy from/to found archetype. * fhandler.h: Throughout, delete size(), add copyout, clone, and fhandler_* (void *) methods. (fhandler_base::reset): Rename from operator =(). (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): change "protected" region to "private". (fhandler_termios::is_dev_tty): Delete. (fhandler_termios): Rearrange protected/public. (fhandler_termios::fhandler_termios): Remember last fhandler_termios "opened". (fhandler_termios::~fhandler_termios): Forget last fhandler_termios opened. (ioctl): Rename from ioctl_termios. Take a void * argument. Reflect argument change in pinfo::set_ctty. (fhandler_console::dup): Declare new function. Set ctty here if appropriate. (fhandler_pty_master::from_master): Privatize. (fhandler_pty_master::to_master): Ditto. (fhandler_pty_master::dwProcessId): Ditto. (fhandler_pty_master::fhandler_pty_master): Add an `int' argument. (fhandler_pty_master::open_setup): Declare new function. (fhandler_pty_master::~fhandler_pty_master): Declare new method. (fhandler_nodevice): Remove commented out function declaration. * fhandler_console.cc: Use get_ttyp() instead of tc() throughout. (fhandler_console::dup): Define new function to set controlling ctty on dup, as appropriate. (fhandler_console::ioctl): Reflect ioctl_termios name change. (fhandler_console::setup): Rename from get_tty_stuff. (fhandler_console::open_setup): Reflect argument change in pinfo::set_ctty. (fhandler_console::fhandler_console): Set _tc here. * fhandler_termios.cc (handler_termios::ioctl): Rename. Take a void * arg like other ioctl functions. * fhandler_tty.cc (fhandler_pty_slave::dup): Call myself->set_ctty to potentially reset the controlling terminal. (fhandler_pty_slave::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_slave::fhandler_pty_slave): Take a "unit" argument. Call setup() here so that we will know the unit number of this fhandler as soon as possible. Set the unit as appropriate. (handler_pty_master::open): Move most stuff to constructor and open_setup. (handler_pty_slave::open_setup): Reflect argument change in pinfo::set_ctty. (handler_pty_master::open_setup): Define new function. (fhandler_pty_master::cleanup): Clear handles as a flag that the destructor does not have to do "close" operations. (fhandler_pty_master::close): Ditto. (fhandler_pty_master::~fhandler_pty_master): Define new method. (fhandler_pty_master::ioctl): Reflect name/arg change for ioctl_termios. (fhandler_pty_master::setup): Allocate tty here. Rely on handles being returned from allocated test rather than opening them here. Avoid setting _need_nl here since it is already zeroed in the constructor. Set up device information with DEV_TTYM_MAJOR. * path.h (path_conv &operator =): Take a const argument. (path_conv::dup): Ditto. (pathconv_arg::PC_OPEN): New enum. (pathconv_arg::PC_CTTY): Ditto. (path_types::PATH_CTTY): Ditto. (path_types::PATH_OPEN): Ditto. (path_conv::isopen): New method. (path_conv::isctty_capable): Ditto. * path.cc (path_conv::check): Set PATH_OPEN and PATH_CTTY as appropriate. * pipe.cc (fhandler_pipe::open): Use copyto to copy pipe handle. * syscall.cc (open): Reinstate fd > 2 check to disallow resetting ctty on non-std* handles. * tty.cc (tty_list::allocate): Pass out handles for allocated tty. use `not_allocated' to find unallocated ttys. Avoid keeping the lock since the allocation of the tty should be sufficient to prevent multiple access. (tty::not_allocated): Clarify comment. Rename. Return handles when an unused tty is found. Simply test for existing tty. (tty::exists): Rewrite to use `not_allocated'. * tty.h (NTTYS): Reset down to actual number supported by devices.in. (tty::not_allocated): Declare new function. (tty_list::allocate): Pass out read/write tty handles. Zero them when not found. * fhandler_proc.cc: Reflect name change from FH_PTYM -> FH_PTMX. * pinfo.h (pinfo::set_ctty): Reduce/reorder arguments passed in. * pinfo.cc (pinfo::set_ctty): Ditto. Just use tc() built into the passed-in fhandler_termios pointer. Return true if ctty is assigned. * syscalls.cc (open): Call build_fh_pc with PC_OPEN flag. Set PC_CTTY if appropriate. (stat_worker): Remove is_dev_tty () stuff.
2011-07-31 * fhandler.h (class fhandler_dev_mem): Remove dup method declaration.Corinna Vinschen1-2/+0
* fhandler_clipboard.cc (fhandler_dev_clipboard::dup): Accommodate the fact that the entire fhandler gets copied over to the child in operator =. * fhandler_floppy.cc (fhandler_dev_floppy::dup): Ditto. * fhandler_raw.cc (fhandler_dev_raw::dup): Ditto. * fhandler_serial.cc (fhandler_serial::dup): Ditto. * fhandler_socket.cc (fhandler_socket::dup): Ditto. * fhandler_virtual.cc (fhandler_virtual::dup): Ditto. * fhandler_mem.cc (fhandler_dev_mem::dup): Ditto. Remove entirely.
2011-07-21Corinna Vinschen <corinna@vinschen.de>Christopher Faylor1-23/+27
* fhandler.cc: Add #include for asm/socket.h for dealing with FIONREAD. (fhandler_base::ioctl): Special-case errno for FIONREAD. * fhandler_dsp.cc (fhandler_dev_dsp::ioctl): Rename parameter for consistency. Call fhandler_base::ioctl to decode default condition. * fhandler_serial.cc (fhandler_serial::ioctl): Ditto. * fhandler_tty.cc (fhandler_pty_slave::ioctl): Call fhandler_base::ioctl to decode default condition. * fhandler_windows.cc (fhandler_windows::ioctl): Ditto.
2011-07-13 * fhandler_serial.cc (fhandler_serial::raw_read): Handle non-blockingCorinna Vinschen1-1/+21
case more thoroughly.
2011-05-04 * fhandler.h (class fhandler_base): Remove uninterruptible_io statusCorinna Vinschen1-2/+0
flag. (fhandler_base::ready_for_read): Remove declaration. (fhandler_socket::ready_for_read): Ditto. (fhandler_pipe::ready_for_read): Ditto. (fhandler_tty_master::is_slow): Remove. * fhandler_console.cc (fhandler_console::open): Drop setting uninterruptible_io. * fhandler_serial.cc (fhandler_serial::open): Ditto. * fhandler_tty.cc (fhandler_tty_slave::fhandler_tty_slave): Ditto. (fhandler_tty_master::init_console): Ditto. * pipe.cc (fhandler_pipe::fhandler_pipe): Ditto. (fhandler_pipe::open): Ditto. (_pipe): Ditto. * select.cc (fhandler_pipe::ready_for_read): Remove. (fhandler_base::ready_for_read): Remove. * syscalls.cc (readv): Drop unneeded wait variable. Remove entire test which might lead to calling ready_for_read. Remove now unused label out.
2011-05-02 * fhandler_serial.cc (fhandler_serial::raw_read): Add restartabilityCorinna Vinschen1-7/+40
after a signal. Add cancelability. (fhandler_serial::raw_write): Wait for write to succeed if O_NONBLOCK is not set. Add signal handling and cancelability.
2009-07-24* sigproc.h (wait_for_sigthread): Eliminate parameter.Christopher Faylor1-2/+2
* sigproc.cc (wait_for_sigthread): Ditto. Don't synchronize with wait_sig after receiving an event that it is ready to go. (init_sig_pipe): New function. (wait_sig): Call init_sig_pipe to create pipes for communicating signals to this process. Don't send sigCONT signal when initializing. * fork.cc (frok::child): Accommodate wait_for_sigpipe parameter change. * fhandler.h (fhandler_*::write): Make ssize_t/__stdcall. (fhandler_*::write_overlapped): Ditto. (fhandler_*::raw_write): Ditto. (fhandler_*::readv): Ditto. (fhandler_*::writev): Ditto. (fhandler_*::raw_read): Make __stdcall. * fhandler: Accommodate changes to read/write functions throughout. * fhandler_clipboard.cc: Ditto. * fhandler_console.cc: Ditto. * fhandler_dsp.cc: Ditto. * fhandler_fifo.cc: Ditto. * fhandler_mailslot.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_random.cc: Ditto. * fhandler_tape.cc: Ditto. * fhandler_tty.cc: Ditto. * fhandler_virtual.cc: Ditto. * fhandler_windows.cc: Ditto. * fhandler_zero.cc: Ditto. * syscalls.cc (readv): Use ssize_t as temp variable. * fhandler.cc (fhandler_base::read): Coerce returned len to signed or it will never be treated as < 0. (fhandler_base::wait_overlapped): Minimize calls to GetLastError. Remove duplicate debugging test. Fix error return. * fhandler.h (fhandler_fifo::fifo_name): Declare new function. (fhandler_fifo::close): Ditto. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto. * fhandler.cc (fhandler_fifo::fifo_name): Define new function. (FIFO_BUF_SIZE): New define. (cnp): Ditto. (fhandler_fifo::open): Rework. Use cnp to open named pipe. Always open write side as a client. Open dummy client when writing and can't connect. (wait): Rework. Implement fifo_wait_for_next_client. Handle signals during connect better. Add new fifo_wait_for_server code which polls (sigh) waiting for server. (fhandler_fifo::raw_read): Handle transition states when one client closes and another is available. (fhandler_fifo::close): Define. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto.
2009-07-03* dcrt0.cc (jit_debug): New global.Christopher Faylor1-2/+2
(initial_env): Set jit_debug when we are automatically starting a gdb process. * dtable.cc (dtable::get_debugger_info): Don't tty tricks when we are being debugged by our own captive gdb, as determined by jit_debug == true. (dtable::init_std_file_from_handle): Detect errors when initializing a tty early rather than at random points later. * fhandler.h (fhandler_*::init): Return int to indicate success/failure. * fhandler.cc (fhandler_base::init): Reflect change in return value. * pipe.cc (fhandler_pipe::init): Ditto. (fhandler_pipe::create_selectable): Don't say we're retrying when we aren't. * fhandler_console.cc (fhandler_console::init): Ditto. Return success/failure. * fhandler_serial.cc (fhandler_serial::init): Ditto. * fhandler_tty.cc (fhandler_tty_slave::init): Ditto. (fhandler_tty_slave::open): Make debugging output more detailed. * tty.cc (tty_list::terminate): Don't close I/O handles before all slaves have checked in. (tty::slave_alive): Make a non-inlined function. Check if tty pipe handles can be created as an additional exists check. * tty.h (tty::slave_alive): Just define here.
2009-01-03Remove unneeded header files from source files throughout. Update copyrightsChristopher Faylor1-2/+1
where appropriate. * globals.cc: New file for generic global variables. * mkglobals_h: New file to generate globals.h. * mkstatic: New Script used to build a (currently non-working) static libcygwin_s.a. * Makefile.in: Add unused rule to build a non-working libcygwin_s.a. (DLL_OFILES): Add globals.o. Make all objects rely on globals.h. (globals.h): New target. Generate globals.h. * cygtls.h: Honor new CYGTLS_HANDLE define to control when the HANDLE operator is allowed in _cygtls. * dcrt0.cc: Move most globals to globals.cc. * init.cc: Ditto. * environ.cc (strip_title_path): Remove now-unneeded extern. * fhandler_serial.cc (fhandler_serial::open): Ditto. * pinfo.cc: Ditto. (commune_process): Ditto. * shared.cc: Ditto. * glob.cc: Ditto. * strace.cc: Ditto. * exceptions.cc: Define CYGTLS_HANDLE before including winsup.h. * path.cc (stat_suffixes): Move here. * security.h: Add forward class path_conv declaration. * smallprint.cc (__small_vsprintf): Make a true c++ function. (__small_sprintf): Ditto. (small_printf): Ditto. (console_printf): Ditto. (__small_vswprintf): Ditto. (__small_swprintf): Ditto. * spawn.cc (spawn_guts): Remove _stdcall decoration in favor of regparm. (hExeced): Move to globals.cc * strfuncs.cc (current_codepage): Ditto. (active_codepage): Ditto. * sync.cc (lock_process::locker): Move here from dcrt0.cc. * syscalls.cc (stat_suffixes): Move to path.cc. * tty.cc (tty::create_master): Uncapitalize fatal warning for consistency. * winsup.h: Include globals.h to declare most of the grab bag list of globals which were previously defined here. * mount.h: Move USER_* defines back to shared_info.h. * speclib: Force temporary directory cleanup.
2008-04-07Remove unneeded header files from source files throughout.Christopher Faylor1-2/+0
2007-02-23 * exceptions.cc (dummy_ctrl_c_handler): Remove.Corinna Vinschen1-18/+2
(init_console_handler): Drop has_null_console_handler_routine checks. * fhandler_raw.cc (fhandler_dev_raw::open): Drop has_raw_devices check. * fhandler_serial.cc (fhandler_serial::open): Drop .supports_reading_modem_output_lines check. * miscfuncs.cc (low_priority_sleep): Drop has_switch_to_thread check. * shared.cc (open_shared): Drop needs_memory_protection checks. * spawn.cc (spawn_guts): Drop start_proc_suspended check. * uname.cc (uname): Drop has_valid_processorlevel check. * wincap.cc: Remove has_raw_devices, has_valid_processorlevel, supports_reading_modem_output_lines, needs_memory_protection, has_switch_to_thread, start_proc_suspended and has_null_console_handler_routine throughout. * wincap.h: Ditto.
2007-02-05 * fhandler_serial.cc (fhandler_serial::tcsetattr): Add support forCorinna Vinschen1-0/+72
baud rates up to 3000000 baud. Add missing 128K and 256K cases. (fhandler_serial::tcgetattr): Ditto. * include/sys/termios.h: Add baud rate definitions from B460800 up to B3000000.
2006-08-17 * fhandler_serial.cc (raw_read): Evaluate minchars taking theCorinna Vinschen1-14/+8
vmin_ > ulen case into account. Simplify evaluating the bytes to read. Don't use bytes in Queue value from ClearCommError call in case vtime_ is > 0. Reformat GetOverlappedResult call. Simplify call to ReadFile.
2005-11-14* cygheap.h (init_cygheap::manage_console_count): Declare new function.Christopher Faylor1-2/+3
(init_cygheap::console_count): Renamed from open_fhs. Make private. * cygheap.cc (init_cygheap::manage_console_count): Define new function. * dtable.cc (dtable::fixup_after_exec): Always call fixup_after_exec on elements of fd even when they are about to be closed. * fhandler.h (report_tty_counts): Remove open_fhs from debugging output. * fhandler_console.cc (fhandler_console::open): Use manage_console_count rather than manipulating count directly. (fhandler_console::close): Ditto. (fhandler_console::fixup_after_fork): Ditto. (fhandler_console::fixup_after_exec): Ditto. Don't close handles if close_on_exec. * fhandler_tty.cc (fhandler_tty_slave::open): Use manage_console_count() rather than manipulating count directly. Reflect change in arguments to report_tty_counts(). (fhandler_tty_slave::close): Ditto for both. (fhandler_tty_slave::dup): Ditto for both. (fhandler_tty_slave::ioctl): Use myctty() rather than raw ctty #. (fhandler_tty_slave::fixup_after_fork): Reflect change in arguments to report_tty_counts(). (fhandler_tty_master::init_console): Use manage_console_count() rather than manipulating count directly. * fhandler_clipboard.cc (fhandler_dev_clipboard::fixup_after_exec): Don't perform any operations if close_on_exec. * fhandler_dsp.cc (fhandler_dev_dsp::fixup_after_exec): Ditto. * fhandler_raw.cc (fhandler_dev_raw::fixup_after_exec): Ditto. * fhandler_serial.cc (fhandler_serial::fixup_after_exec): Ditto. * pinfo.h (_pinfo::_ctty): Declare new function. (myctty): Declare new macro. (__ctty): Declare new macro. * pinfo.cc (_pinfo::_ctty): Define new function. (_pinfo::set_ctty): Use manage_console_count() rather than manipulating count directly. * signal.cc (kill_pgrp): Use myctty() and __ctty() macros rather than raw ctty #. * syscalls.cc (setsid): Ditto. Use manage_console_count() rather than manipulating count directly.
2005-09-28 Revert erroneous checkin.Corinna Vinschen1-2/+2
2005-09-28 * fhandler.h (class fhandler_dev_raw): Delete current_position andCorinna Vinschen1-2/+2
eof_detected status flag. Delete is_eom and is_eof methods. Move drive_size, bytes_per_sector, eom_detected status flag, as well as the methods read_file, write_file, raw_read and raw_write to ... (class fhandler_dev_floppy): ... here. Remove is_eom and is_eof methods. Add dup method. * fhandler_floppy.cc (IS_EOM): New macro. (fhandler_dev_floppy::is_eom): Remove. (fhandler_dev_floppy::is_eof): Remove. (fhandler_dev_floppy::fhandler_dev_floppy): Initialize status flags. (fhandler_dev_floppy::get_drive_info): Only call EX functions on systems supporting them and stop suffering strange delays. (fhandler_dev_floppy::read_file): Move here, drop setting current_position. (fhandler_dev_floppy::write_file): Move here, drop setting current_position. (fhandler_dev_floppy::open): Rearrange comment. (fhandler_dev_floppy::dup): New method. (fhandler_dev_floppy::get_current_position): New inline method. Use instead of former current_position were appropriate. (fhandler_dev_floppy::raw_read): Move here. Drop EOF handling. (fhandler_dev_floppy::raw_write): Move here. Drop EOF handling. (fhandler_dev_floppy::lseek): Remove useless conditions. Convert sector_aligned_offset to LARGE_INTEGER to improve SetFilePointer call. (fhandler_dev_floppy::ioctl): Move blocksize check in RDSETBLK case to here. * fhandler_raw.cc (fhandler_dev_raw::is_eom): Remove. (fhandler_dev_raw::is_eof): Remove. (fhandler_dev_raw::write_file): Remove. (fhandler_dev_raw::read_file): Remove. (fhandler_dev_raw::raw_read): Remove. (fhandler_dev_raw::raw_write): Remove. (fhandler_dev_raw::dup): Drop copying removed members. (fhandler_dev_raw::ioctl): Drop blocksize testing. * wincap.h: Implement has_disk_ex_ioctls throughout. * wincap.cc: Ditto. (wincap_vista): Preliminary wincaps for Windows Vista/Longhorn. (wincapc::init): Add Vista/Longhorn handling.
2005-09-14Remove some more unneeded 'return;'s throughout.Christopher Faylor1-1/+0