OSDN Git Service

Remove 'cb' parameter and modify fhandler_* constructors throughout.
authorcgf <cgf>
Mon, 22 Oct 2001 18:39:21 +0000 (18:39 +0000)
committercgf <cgf>
Mon, 22 Oct 2001 18:39:21 +0000 (18:39 +0000)
* 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.

18 files changed:
winsup/cygwin/ChangeLog
winsup/cygwin/dtable.cc
winsup/cygwin/exec.cc
winsup/cygwin/fhandler.cc
winsup/cygwin/fhandler.h
winsup/cygwin/fhandler_clipboard.cc
winsup/cygwin/fhandler_console.cc
winsup/cygwin/fhandler_dsp.cc
winsup/cygwin/fhandler_floppy.cc
winsup/cygwin/fhandler_random.cc
winsup/cygwin/fhandler_raw.cc
winsup/cygwin/fhandler_serial.cc
winsup/cygwin/fhandler_socket.cc
winsup/cygwin/fhandler_tape.cc
winsup/cygwin/fhandler_tty.cc
winsup/cygwin/fhandler_windows.cc
winsup/cygwin/fhandler_zero.cc
winsup/cygwin/pipe.cc

index 9ced6a1..4c22f8a 100644 (file)
@@ -1,3 +1,23 @@
+2001-10-22  Christopher Faylor  <cgf@redhat.com>
+
+       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  <corinna@vinschen.de>
 
        Patch suggested by Ian Ray <ian.ray@nokia.com>:
@@ -8,6 +28,7 @@
 
 2001-10-22  Corinna Vinschen  <corinna@vinschen.de>
 
+>>>>>>> 1.975
        * net.cc (get_2k_ifconf): Change multiple IP address naming scheme
        to Linux style.
 
index ff1b0f0..f82be14 100644 (file)
@@ -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;
 }
 
index 228aa69..21b18cf 100644 (file)
@@ -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);
+}
index c12c326..2e6100a 100644 (file)
@@ -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
index 2335484..1050df6 100644 (file)
@@ -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);
index 59bd966..19a3c78 100644 (file)
@@ -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);
index b03f8d1..417fcce 100644 (file)
@@ -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 <ALT> key always generates
@@ -890,7 +882,6 @@ fhandler_console::fhandler_console () :
      language-specific characters (umlaut, accent grave, etc.).  On
      these keyboards right <ALT> (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;
 
index e7f9776..1dd4ff4 100644 (file)
@@ -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 ()
index 68e9d78..193e75a 100644 (file)
@@ -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
index a933c81..679b221 100644 (file)
@@ -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
index 18d2a61..aff9d8e 100644 (file)
@@ -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 ();
 }
 
index 3eedd14..f0b1de8 100644 (file)
@@ -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 ();
 }
 
index e8f0d18..f7c28ff 100644 (file)
@@ -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));
index cb0ebf9..7a738e6 100644 (file)
@@ -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
index 5b40f04..3a6a800 100644 (file)
@@ -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
index 4139a80..8cf93e4 100644 (file)
@@ -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
index 3bca47a..8c1ba2d 100644 (file)
@@ -18,7 +18,6 @@ details. */
 fhandler_dev_zero::fhandler_dev_zero ()
   : fhandler_base (FH_ZERO)
 {
-  set_cb (sizeof *this);
 }
 
 int
index d9eebb1..a403909 100644 (file)
@@ -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