From e7e231e531e62fbda5d7d019ca5d90363a955881 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Mon, 22 Oct 2001 18:39:22 +0000 Subject: Remove 'cb' parameter and modify fhandler_* constructors throughout. * dtable.cc (dtable::build_fhandler): Remove debugging output which uses 'cb'. * exec.cc (execvp): New function. (execvpe): Ditto. * fhandler.cc (fhandler_base::fhandler_base): Use constructor initialization. * fhandler.h (fhandler_tty_common::fhandler_tty_common): Ditto. * fhandler_clipboard.cc (fhandler_dev_clipboard::fhandler_dev_clipboard): Ditto. * fhandler_console.cc (fhandler_console::fhandler_console): Ditto. * fhandler_raw.cc (fhandler_dev_raw::fhandler_dev_raw): Ditto. * fhandler_serial.cc (fhandler_serial::fhandler_serial): Ditto. * fhandler_tty.cc (fhandler_tty_master::fhandler_tty_master): Ditto. (fhandler_tty_slave::fhandler_tty_slave): Ditto. (fhandler_pty_master::fhandler_pty_master): Ditto. * fhandler_windows.cc (fhandler_windows::fhandler_windows): Ditto. --- winsup/cygwin/ChangeLog | 21 +++++++++++++++++ winsup/cygwin/dtable.cc | 3 +-- winsup/cygwin/exec.cc | 47 ++++++++++++++++++++----------------- winsup/cygwin/fhandler.cc | 4 +--- winsup/cygwin/fhandler.h | 11 ++++----- winsup/cygwin/fhandler_clipboard.cc | 10 +++----- winsup/cygwin/fhandler_console.cc | 23 ++++++------------ winsup/cygwin/fhandler_dsp.cc | 1 - winsup/cygwin/fhandler_floppy.cc | 1 - winsup/cygwin/fhandler_random.cc | 3 +-- winsup/cygwin/fhandler_raw.cc | 5 ++-- winsup/cygwin/fhandler_serial.cc | 8 ++----- winsup/cygwin/fhandler_socket.cc | 1 - winsup/cygwin/fhandler_tape.cc | 1 - winsup/cygwin/fhandler_tty.cc | 16 +------------ winsup/cygwin/fhandler_windows.cc | 5 +--- winsup/cygwin/fhandler_zero.cc | 1 - winsup/cygwin/pipe.cc | 1 - 18 files changed, 70 insertions(+), 92 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 9ced6a177..4c22f8ab4 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,23 @@ +2001-10-22 Christopher Faylor + + Remove 'cb' parameter and modify fhandler_* constructors throughout. + * dtable.cc (dtable::build_fhandler): Remove debugging output which + uses 'cb'. + * exec.cc (execvp): New function. + (execvpe): Ditto. + * fhandler.cc (fhandler_base::fhandler_base): Use constructor + initialization. + * fhandler.h (fhandler_tty_common::fhandler_tty_common): Ditto. + * fhandler_clipboard.cc (fhandler_dev_clipboard::fhandler_dev_clipboard): + Ditto. + * fhandler_console.cc (fhandler_console::fhandler_console): Ditto. + * fhandler_raw.cc (fhandler_dev_raw::fhandler_dev_raw): Ditto. + * fhandler_serial.cc (fhandler_serial::fhandler_serial): Ditto. + * fhandler_tty.cc (fhandler_tty_master::fhandler_tty_master): Ditto. + (fhandler_tty_slave::fhandler_tty_slave): Ditto. + (fhandler_pty_master::fhandler_pty_master): Ditto. + * fhandler_windows.cc (fhandler_windows::fhandler_windows): Ditto. + 2001-10-22 Corinna Vinschen Patch suggested by Ian Ray : @@ -8,6 +28,7 @@ 2001-10-22 Corinna Vinschen +>>>>>>> 1.975 * net.cc (get_2k_ifconf): Change multiple IP address naming scheme to Linux style. diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index ff1b0f065..f82be14a2 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -332,8 +332,7 @@ dtable::build_fhandler (int fd, DWORD dev, const char *name, int unit) } } - debug_printf ("%s - cb %d, fd %d, fh %p", fh->get_name () ?: "", fh->cb, - fd, fh); + debug_printf ("%s - fd %d, fh %p", fh->get_name () ?: "", fd, fh); return fd >= 0 ? (fds[fd] = fh) : fh; } diff --git a/winsup/cygwin/exec.cc b/winsup/cygwin/exec.cc index 228aa69b0..21b18cfcf 100644 --- a/winsup/cygwin/exec.cc +++ b/winsup/cygwin/exec.cc @@ -25,8 +25,7 @@ details. */ /* This is called _execve and not execve because the real execve is defined in libc/posix/execve.c. It calls us. */ -extern "C" -int +extern "C" int _execve (const char *path, char *const argv[], char *const envp[]) { static char *const empty_env[] = { 0 }; @@ -36,8 +35,7 @@ _execve (const char *path, char *const argv[], char *const envp[]) return _spawnve (NULL, _P_OVERLAY, path, argv, envp); } -extern "C" -int +extern "C" int execl (const char *path, const char *arg0, ...) { int i; @@ -55,8 +53,7 @@ execl (const char *path, const char *arg0, ...) return _execve (path, (char * const *) argv, cur_environ ()); } -extern "C" -int +extern "C" int execv (const char *path, char * const *argv) { MALLOC_CHECK; @@ -65,8 +62,7 @@ execv (const char *path, char * const *argv) /* the same as a standard exec() calls family, but with NT security support */ -extern "C" -pid_t +extern "C" pid_t sexecve (HANDLE hToken, const char *path, const char *const argv[], const char *const envp[]) { @@ -74,8 +70,7 @@ sexecve (HANDLE hToken, const char *path, const char *const argv[], return -1; } -extern "C" -int +extern "C" int sexecl (HANDLE hToken, const char *path, const char *arg0, ...) { int i; @@ -96,8 +91,7 @@ sexecl (HANDLE hToken, const char *path, const char *arg0, ...) return sexecve (hToken, path, (char * const *) argv, cur_environ ()); } -extern "C" -int +extern "C" int sexecle (HANDLE hToken, const char *path, const char *arg0, ...) { int i; @@ -120,8 +114,7 @@ sexecle (HANDLE hToken, const char *path, const char *arg0, ...) return sexecve(hToken, path, (char * const *) argv, (char * const *) envp); } -extern "C" -int +extern "C" int sexeclp (HANDLE hToken, const char *path, const char *arg0, ...) { int i; @@ -142,8 +135,7 @@ sexeclp (HANDLE hToken, const char *path, const char *arg0, ...) return sexecvpe (hToken, path, (const char * const *) argv, cur_environ ()); } -extern "C" -int +extern "C" int sexeclpe (HANDLE hToken, const char *path, const char *arg0, ...) { int i; @@ -166,16 +158,14 @@ sexeclpe (HANDLE hToken, const char *path, const char *arg0, ...) return sexecvpe (hToken, path, argv, envp); } -extern "C" -int +extern "C" int sexecv (HANDLE hToken, const char *path, const char * const *argv) { MALLOC_CHECK; return sexecve (hToken, path, argv, cur_environ ()); } -extern "C" -int +extern "C" int sexecp (HANDLE hToken, const char *path, const char * const *argv) { MALLOC_CHECK; @@ -199,8 +189,7 @@ strccpy (char *s1, const char **s2, char c) return s1; } -extern "C" -int +extern "C" int sexecvpe (HANDLE hToken, const char *file, const char * const *argv, const char *const *envp) { @@ -208,3 +197,17 @@ sexecvpe (HANDLE hToken, const char *file, const char * const *argv, MALLOC_CHECK; return sexecve (hToken, find_exec (file, buf), argv, envp); } + +extern "C" int +execvp (const char *path, char * const *argv) +{ + path_conv buf; + return execv (find_exec (path, buf), argv); +} + +extern "C" int +execvpe (const char *path, char * const *argv, char *const *envp) +{ + path_conv buf; + return execve (find_exec (path, buf), argv, envp); +} diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index c12c326eb..2e6100a3a 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -1330,6 +1330,7 @@ fhandler_base::operator delete (void *p) /* Normal I/O constructor */ fhandler_base::fhandler_base (DWORD devtype, int unit): + status (devtype), access (0), io_handle (NULL), namehash (0), @@ -1343,7 +1344,6 @@ fhandler_base::fhandler_base (DWORD devtype, int unit): win32_path_name (NULL), open_status (0) { - status = devtype; int bin = __fmode & O_TEXT ? 0 : 1; if (status != FH_DISK && status != FH_CONSOLE) { @@ -1372,7 +1372,6 @@ fhandler_base::~fhandler_base (void) fhandler_disk_file::fhandler_disk_file () : fhandler_base (FH_DISK) { - set_cb (sizeof *this); } int @@ -1601,7 +1600,6 @@ fhandler_disk_file::lock (int cmd, struct flock *fl) fhandler_dev_null::fhandler_dev_null () : fhandler_base (FH_NULL) { - set_cb (sizeof *this); } void diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index 2335484c3..1050df68b 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -160,7 +160,6 @@ class fhandler_base protected: DWORD status; public: - int cb; private: int access; HANDLE io_handle; @@ -194,7 +193,6 @@ public: /* Non-virtual simple accessor functions. */ void set_io_handle (HANDLE x) { io_handle = x; } - void set_cb (size_t size) { cb = size; } DWORD get_device () { return status & FH_DEVMASK; } virtual int get_unit () { return 0; } virtual BOOL is_slow () { return get_device () < FH_SLOW; } @@ -778,7 +776,9 @@ class fhandler_tty_common: public fhandler_termios { public: fhandler_tty_common (DWORD dev, int unit = 0) - : fhandler_termios (dev, unit), ttynum (unit) + : fhandler_termios (dev, unit), output_done_event (NULL), + ioctl_request_event (NULL), ioctl_done_event (NULL), output_mutex (NULL), + input_mutex (NULL), input_available_event (NULL), inuse (NULL), ttynum (unit) { // nothing to do } @@ -791,12 +791,11 @@ public: HANDLE output_mutex, input_mutex; HANDLE input_available_event; HANDLE inuse; // used to indicate that a tty is in use - + int ttynum; // Master tty num. DWORD __acquire_output_mutex (const char *fn, int ln, DWORD ms); void __release_output_mutex (const char *fn, int ln); - int ttynum; // Master tty num. virtual int dup (fhandler_base *child); tty *get_ttyp () { return (tty *)tc; } @@ -866,10 +865,10 @@ class fhandler_tty_master: public fhandler_pty_master { public: /* Constructor */ - fhandler_tty_master (int unit); fhandler_console *console; // device handler to perform real i/o. HANDLE hThread; // process_output thread handle. + fhandler_tty_master (int unit); int init (int); int init_console (); void fixup_after_fork (HANDLE parent); diff --git a/winsup/cygwin/fhandler_clipboard.cc b/winsup/cygwin/fhandler_clipboard.cc index 59bd9660c..19a3c7856 100644 --- a/winsup/cygwin/fhandler_clipboard.cc +++ b/winsup/cygwin/fhandler_clipboard.cc @@ -32,14 +32,10 @@ static const NO_COPY char *CYGWIN_NATIVE = "CYGWIN_NATIVE_CLIPBOARD"; /* this is MT safe because windows format id's are atomic */ static UINT cygnativeformat; -fhandler_dev_clipboard::fhandler_dev_clipboard (): -fhandler_base (FH_CLIPBOARD) +fhandler_dev_clipboard::fhandler_dev_clipboard () + : fhandler_base (FH_CLIPBOARD), pos (0), membuffer (NULL), msize (0), + eof (true) { - set_cb (sizeof *this); - eof = true; - pos = 0; - membuffer = NULL; - msize = 0; /* FIXME: check for errors and loop until we can open the clipboard */ OpenClipboard (NULL); cygnativeformat = RegisterClipboardFormat (CYGWIN_NATIVE); diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index b03f8d130..417fcce1b 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -858,29 +858,21 @@ fhandler_console::tcgetattr (struct termios *t) return res; } -/* - * Constructor. - */ - fhandler_console::fhandler_console () : - fhandler_termios (FH_CONSOLE, -1) + fhandler_termios (FH_CONSOLE, -1), + default_color (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE), + underline_color (FOREGROUND_GREEN | FOREGROUND_BLUE), + dim_color (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE), + meta_mask (LEFT_ALT_PRESSED), state_ (normal), nargs_ (0), savex (0), + savey (0), savebuf (NULL), dwLastButtonState (0), nModifiers (0), + insert_mode (false), use_mouse (false), raw_win32_keyboard_mode (false) { - set_cb (sizeof *this); - default_color = dim_color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; - underline_color = FOREGROUND_GREEN | FOREGROUND_BLUE; - state_ = normal; - nargs_ = 0; for (int i = 0; i < MAXARGS; i++) args_ [i] = 0; - savex = savey = 0; savebufsiz.X = savebufsiz.Y = 0; - savebuf = NULL; scroll_region.Top = 0; scroll_region.Bottom = -1; dwLastCursorPosition.X = -1; dwLastCursorPosition.Y = -1; - dwLastButtonState = 0; - nModifiers = 0; - insert_mode = use_mouse = raw_win32_keyboard_mode = FALSE; /* Set the mask that determines if an input keystroke is modified by META. We set this based on the keyboard layout language loaded for the current thread. The left key always generates @@ -890,7 +882,6 @@ fhandler_console::fhandler_console () : language-specific characters (umlaut, accent grave, etc.). On these keyboards right (called AltGr) is used to produce the shell symbols and should not be interpreted as META. */ - meta_mask = LEFT_ALT_PRESSED; if (PRIMARYLANGID (LOWORD (GetKeyboardLayout (0))) == LANG_ENGLISH) meta_mask |= RIGHT_ALT_PRESSED; diff --git a/winsup/cygwin/fhandler_dsp.cc b/winsup/cygwin/fhandler_dsp.cc index e7f977618..1dd4ff4e1 100644 --- a/winsup/cygwin/fhandler_dsp.cc +++ b/winsup/cygwin/fhandler_dsp.cc @@ -423,7 +423,6 @@ fhandler_dev_dsp::setupwav (const char *pData, int nBytes) fhandler_dev_dsp::fhandler_dev_dsp (): fhandler_base (FH_OSS_DSP) { - set_cb (sizeof *this); } fhandler_dev_dsp::~fhandler_dev_dsp () diff --git a/winsup/cygwin/fhandler_floppy.cc b/winsup/cygwin/fhandler_floppy.cc index 68e9d783d..193e75a37 100644 --- a/winsup/cygwin/fhandler_floppy.cc +++ b/winsup/cygwin/fhandler_floppy.cc @@ -42,7 +42,6 @@ fhandler_dev_floppy::is_eof (int) fhandler_dev_floppy::fhandler_dev_floppy (int unit) : fhandler_dev_raw (FH_FLOPPY, unit) { - set_cb (sizeof *this); } int diff --git a/winsup/cygwin/fhandler_random.cc b/winsup/cygwin/fhandler_random.cc index a933c8140..679b2218d 100644 --- a/winsup/cygwin/fhandler_random.cc +++ b/winsup/cygwin/fhandler_random.cc @@ -24,9 +24,8 @@ details. */ #define PSEUDO_SHIFTVAL (21) fhandler_dev_random::fhandler_dev_random (int nunit) - : fhandler_base (FH_RANDOM), unit(nunit), crypt_prov((HCRYPTPROV)NULL) + : fhandler_base (FH_RANDOM), unit(nunit), crypt_prov((HCRYPTPROV) NULL) { - set_cb (sizeof *this); } int diff --git a/winsup/cygwin/fhandler_raw.cc b/winsup/cygwin/fhandler_raw.cc index 18d2a617c..aff9d8ef3 100644 --- a/winsup/cygwin/fhandler_raw.cc +++ b/winsup/cygwin/fhandler_raw.cc @@ -118,11 +118,10 @@ fhandler_dev_raw::writebuf (void) return ret; } -fhandler_dev_raw::fhandler_dev_raw (DWORD devtype, int unit) - : fhandler_base (devtype) +fhandler_dev_raw::fhandler_dev_raw (DWORD devtype, int nunit) + : fhandler_base (devtype), unit (nunit) { clear (); - this->unit = unit; set_need_fork_fixup (); } diff --git a/winsup/cygwin/fhandler_serial.cc b/winsup/cygwin/fhandler_serial.cc index 3eedd1428..f0b1de876 100644 --- a/winsup/cygwin/fhandler_serial.cc +++ b/winsup/cygwin/fhandler_serial.cc @@ -24,13 +24,9 @@ details. */ /**********************************************************************/ /* fhandler_serial */ -fhandler_serial::fhandler_serial (DWORD devtype, int unit) : - fhandler_base (devtype, unit) +fhandler_serial::fhandler_serial (DWORD devtype, int unit) + : fhandler_base (devtype, unit), vmin_ (0), vtime_ (0), pgrp_ (myself->pgid) { - set_cb (sizeof *this); - vmin_ = 0; - vtime_ = 0; - pgrp_ = myself->pgid; set_need_fork_fixup (); } diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index e8f0d1863..f7c28ff04 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -44,7 +44,6 @@ fhandler_dev_random* entropy_source; fhandler_socket::fhandler_socket () : fhandler_base (FH_SOCKET) { - set_cb (sizeof *this); set_need_fork_fixup (); prot_info_ptr = (LPWSAPROTOCOL_INFOA) cmalloc (HEAP_BUF, sizeof (WSAPROTOCOL_INFOA)); diff --git a/winsup/cygwin/fhandler_tape.cc b/winsup/cygwin/fhandler_tape.cc index cb0ebf9d4..7a738e652 100644 --- a/winsup/cygwin/fhandler_tape.cc +++ b/winsup/cygwin/fhandler_tape.cc @@ -57,7 +57,6 @@ fhandler_dev_tape::is_eof (int win_error) fhandler_dev_tape::fhandler_dev_tape (int unit) : fhandler_dev_raw (FH_TAPE, unit) { - set_cb (sizeof *this); } int diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 5b40f0470..3a6a800a6 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -36,11 +36,8 @@ static DWORD WINAPI process_output (void *); // Output queue thread static DWORD WINAPI process_ioctl (void *); // Ioctl requests thread fhandler_tty_master::fhandler_tty_master (int unit) : - fhandler_pty_master (FH_TTYM, unit) + fhandler_pty_master (FH_TTYM, unit), console (NULL), hThread (NULL) { - set_cb (sizeof *this); - console = NULL; - hThread = NULL; } int @@ -440,17 +437,11 @@ process_ioctl (void *) fhandler_tty_slave::fhandler_tty_slave (int num) : fhandler_tty_common (FH_TTYS, num) { - set_cb (sizeof *this); - ttynum = num; - debug_printf ("unix '%s', win32 '%s'", unix_path_name, win32_path_name); - inuse = NULL; } fhandler_tty_slave::fhandler_tty_slave () : fhandler_tty_common (FH_TTYS, 0) { - set_cb (sizeof *this); - inuse = NULL; } /* FIXME: This function needs to close handles when it has @@ -953,11 +944,6 @@ out: fhandler_pty_master::fhandler_pty_master (DWORD devtype, int unit) : fhandler_tty_common (devtype, unit) { - set_cb (sizeof *this); - ioctl_request_event = NULL; - ioctl_done_event = NULL; - pktmode = need_nl = 0; - inuse = NULL; } int diff --git a/winsup/cygwin/fhandler_windows.cc b/winsup/cygwin/fhandler_windows.cc index 4139a8020..8cf93e45c 100644 --- a/winsup/cygwin/fhandler_windows.cc +++ b/winsup/cygwin/fhandler_windows.cc @@ -47,11 +47,8 @@ The following unix-style calls are supported: */ fhandler_windows::fhandler_windows () - : fhandler_base (FH_WINDOWS) + : fhandler_base (FH_WINDOWS), hWnd_ (NULL), method_ (WINDOWS_POST) { - set_cb (sizeof *this); - hWnd_ = NULL; - method_ = WINDOWS_POST; } int diff --git a/winsup/cygwin/fhandler_zero.cc b/winsup/cygwin/fhandler_zero.cc index 3bca47a03..8c1ba2d8f 100644 --- a/winsup/cygwin/fhandler_zero.cc +++ b/winsup/cygwin/fhandler_zero.cc @@ -18,7 +18,6 @@ details. */ fhandler_dev_zero::fhandler_dev_zero () : fhandler_base (FH_ZERO) { - set_cb (sizeof *this); } int diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc index d9eebb12d..a4039093c 100644 --- a/winsup/cygwin/pipe.cc +++ b/winsup/cygwin/pipe.cc @@ -28,7 +28,6 @@ static const NO_COPY char pipeid_fmt[] = "stupid_pipe.%u.%u"; fhandler_pipe::fhandler_pipe (DWORD devtype) : fhandler_base (devtype), guard (0), writepipe_exists(0), orig_pid (0), id (0) { - set_cb (sizeof *this); } off_t -- cgit v1.2.3