OSDN Git Service

* fhandler.h (fhandler_base::status): Declare private.
authorcorinna <corinna>
Fri, 9 Apr 2004 12:09:45 +0000 (12:09 +0000)
committercorinna <corinna>
Fri, 9 Apr 2004 12:09:45 +0000 (12:09 +0000)
(fhandler_base::open_status): Ditto.
(class fhandler_socket): Move status bits into private bitfield struct
type status_flags.  Change accessor methods appropriately.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate
above status bit changes.
* tty.h: Remove status bit enumerator.
(TTYISSETF): Remove.
(TTYSETF): Remove.
(TTYCLEARF): Remove.
(TTYCONDSETF): Remove.
(tty_min::status): Define as private bitfield struct type status_flags.
Add appropriate accessor methods.
* fhandler_console.cc: Use tty_min::status accessor methods throughout.
* fhandler_termios.cc: Ditto.
* winsup.h (__ISSETF): Remove.
(__SETF): Remove.
(__CLEARF): Remove.
(__CONDSETF): Remove.

winsup/cygwin/ChangeLog
winsup/cygwin/fhandler.h
winsup/cygwin/fhandler_console.cc
winsup/cygwin/fhandler_socket.cc
winsup/cygwin/fhandler_termios.cc
winsup/cygwin/tty.h
winsup/cygwin/winsup.h

index 35c176d..ff8dfdc 100644 (file)
@@ -1,5 +1,27 @@
 2004-04-09  Corinna Vinschen  <corinna@vinschen.de>
 
+       * fhandler.h (fhandler_base::status): Declare private.
+       (fhandler_base::open_status): Ditto.
+       (class fhandler_socket): Move status bits into private bitfield struct
+       type status_flags.  Change accessor methods appropriately.
+       * fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate
+       above status bit changes.
+       * tty.h: Remove status bit enumerator.
+       (TTYISSETF): Remove.
+       (TTYSETF): Remove.
+       (TTYCLEARF): Remove.
+       (TTYCONDSETF): Remove.
+       (tty_min::status): Define as private bitfield struct type status_flags.
+       Add appropriate accessor methods.
+       * fhandler_console.cc: Use tty_min::status accessor methods throughout.
+       * fhandler_termios.cc: Ditto.
+       * winsup.h (__ISSETF): Remove.
+       (__SETF): Remove.
+       (__CLEARF): Remove.
+       (__CONDSETF): Remove.
+
+2004-04-09  Corinna Vinschen  <corinna@vinschen.de>
+
        * fhandler.cc (fhandler_base::write): Use bool parameter in calls to
        set_did_lseek.
        (fhandler_base::fhandler_base): Accomodate new status and open_status
index 1392055..b889c84 100644 (file)
@@ -71,7 +71,6 @@ class fhandler_base
   friend class dtable;
   friend void close_all_files ();
 
- protected:
   struct status_flags
   {
     unsigned rbinary            : 1; /* binary read mode */
@@ -92,7 +91,7 @@ class fhandler_base
     unsigned close_on_exec      : 1; /* close-on-exec */
     unsigned need_fork_fixup    : 1; /* Set if need to fixup after fork. */
 
-    public:
+   public:
     status_flags () :
       rbinary (0), rbinset (0), wbinary (0), wbinset (0), no_handle (0),
       async_io (0), uninterruptible_io (0), append_mode (0), lseeked (0),
@@ -355,9 +354,17 @@ class fhandler_socket: public fhandler_base
   HANDLE secret_event;
   struct _WSAPROTOCOL_INFOA *prot_info_ptr;
   char *sun_path;
-  unsigned sock_saw_shut_rd      : 1; /* Socket saw a SHUT_RD */
-  unsigned sock_saw_shut_wr      : 1; /* Socket saw a SHUT_WR */
-  unsigned had_connect_or_listen : 2;
+  struct status_flags
+  {
+    unsigned sock_saw_shut_rd      : 1; /* Socket saw a SHUT_RD */
+    unsigned sock_saw_shut_wr      : 1; /* Socket saw a SHUT_WR */
+    unsigned had_connect_or_listen : 2;
+   public:
+    status_flags () :
+      sock_saw_shut_rd (0), sock_saw_shut_wr (0),
+      had_connect_or_listen (unconnected)
+      {}
+  } status;
 
  public:
   fhandler_socket ();
@@ -365,20 +372,22 @@ class fhandler_socket: public fhandler_base
   int get_socket () { return (int) get_handle(); }
   fhandler_socket *is_socket () { return this; }
 
-  bool saw_shutdown_read () const {return sock_saw_shut_rd;}
-  bool saw_shutdown_write () const {return sock_saw_shut_wr;}
+  bool saw_shutdown_read () const { return status.sock_saw_shut_rd; }
+  bool saw_shutdown_write () const { return status.sock_saw_shut_wr; }
 
-  void set_shutdown_read () { sock_saw_shut_rd = 1;}
-  void set_shutdown_write () { sock_saw_shut_wr = 1;}
+  void set_shutdown_read () { status.sock_saw_shut_rd = 1;}
+  void set_shutdown_write () { status.sock_saw_shut_wr = 1;}
 
-  bool is_unconnected () const { return had_connect_or_listen == unconnected; }
+  bool is_unconnected () const
+       { return status.had_connect_or_listen == unconnected; }
   bool is_connect_pending () const
-    { return had_connect_or_listen == connect_pending; }
-  bool is_connected () const { return had_connect_or_listen == connected; }
+    { return status.had_connect_or_listen == connect_pending; }
+  bool is_connected () const
+       { return status.had_connect_or_listen == connected; }
   void set_connect_state (connect_state newstate)
-    had_connect_or_listen = newstate; }
+       { status.had_connect_or_listen = newstate; }
   connect_state get_connect_state () const
-    { return (connect_state) had_connect_or_listen; }
+       { return (connect_state) status.had_connect_or_listen; }
 
   int bind (const struct sockaddr *name, int namelen);
   int connect (const struct sockaddr *name, int namelen);
index afac56c..66d92f7 100644 (file)
@@ -154,10 +154,8 @@ set_console_state_for_spawn ()
   if (shared_console_info != NULL)
     {
       /* ACK.  Temporarily define for use in TTYSETF macro */
-#     define tc &shared_console_info->tty_min_state
       SetConsoleMode (h, ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT);
-      TTYSETF (RSTCONS);
-#     undef tc
+      shared_console_info->tty_min_state.set_rstcons ();
     }
 
   CloseHandle (h);
@@ -538,7 +536,7 @@ sig_exit:
 void
 fhandler_console::set_input_state ()
 {
-  if (TTYISSETF (RSTCONS))
+  if (tc->needs_rstcons ())
     input_tcsetattr (0, &tc->ti);
 }
 
@@ -660,7 +658,7 @@ fhandler_console::open (int flags, mode_t)
       SetConsoleMode (get_io_handle (), ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT | cflags);
     }
 
-  TTYCLEARF (RSTCONS);
+  tc->clear_rstcons ();
   set_open_status ();
   cygheap->open_fhs++;
   debug_printf ("incremented open_fhs, now %d", cygheap->open_fhs);
@@ -844,7 +842,7 @@ fhandler_console::input_tcsetattr (int, struct termios const *t)
                      res, t, flags, t->c_lflag, t->c_iflag);
     }
 
-  TTYCLEARF (RSTCONS);
+  tc->clear_rstcons ();
   return res;
 }
 
index d322e9d..4ce4abe 100644 (file)
@@ -124,9 +124,7 @@ get_inet_addr (const struct sockaddr *in, int inlen,
 fhandler_socket::fhandler_socket () :
   fhandler_base (),
   sun_path (NULL),
-  sock_saw_shut_rd (0),
-  sock_saw_shut_wr (0),
-  had_connect_or_listen (unconnected)
+  status ()
 {
   set_need_fork_fixup ();
   prot_info_ptr = (LPWSAPROTOCOL_INFOA) cmalloc (HEAP_BUF,
index ed8d3b2..636f782 100644 (file)
@@ -31,7 +31,7 @@ fhandler_termios::tcinit (tty_min *this_tc, bool force)
 
   tc = this_tc;
 
-  if (force || !TTYISSETF (INITIALIZED))
+  if (force || !tc->is_initialized ())
     {
       tc->ti.c_iflag = BRKINT | ICRNL | IXON;
       tc->ti.c_oflag = OPOST | ONLCR;
@@ -58,7 +58,7 @@ fhandler_termios::tcinit (tty_min *this_tc, bool force)
 
       tc->ti.c_ispeed = tc->ti.c_ospeed = B38400;
       tc->pgid = myself->pgid;
-      TTYSETF (INITIALIZED);
+      tc->initialize ();
     }
 }
 
index c5d0152..355e21b 100644 (file)
@@ -30,17 +30,6 @@ details. */
 
 #include <sys/termios.h>
 
-enum
-{
-  TTY_INITIALIZED = 1,         /* Set if tty is initialized */
-  TTY_RSTCONS = 2              /* Set if console needs to be set to "non-cooked" */
-};
-
-#define TTYISSETF(x)   __ISSETF (tc, x, TTY)
-#define TTYSETF(x)     __SETF (tc, x, TTY)
-#define TTYCLEARF(x)   __CLEARF (tc, x, TTY)
-#define TTYCONDSETF(n, x) __CONDSETF(n, tc, x, TTY)
-
 #ifndef MIN_CTRL_C_SLOP
 #define MIN_CTRL_C_SLOP 50
 #endif
@@ -48,13 +37,24 @@ enum
 class tty_min
 {
   pid_t sid;   /* Session ID of tty */
+  struct status_flags
+  {
+    unsigned initialized : 1; /* Set if tty is initialized */
+    unsigned rstcons     : 1; /* Set if console needs to be set to "non-cooked" */
+  } status;
+
 public:
-  DWORD status;
   pid_t pgid;
   int output_stopped;
   int ntty;
   DWORD last_ctrl_c;   // tick count of last ctrl-c
 
+  void initialize () { status.initialized = 1; }
+  bool is_initialized () { return status.initialized; }
+  void set_rstcons () { status.rstcons = 1; }
+  void clear_rstcons () { status.rstcons = 1; }
+  bool needs_rstcons () { return status.rstcons; }
+
   tty_min (int t = -1, pid_t s = -1) : sid (s), ntty (t) {}
   void setntty (int n) {ntty = n;}
   pid_t getpgid () {return pgid;}
index a7e38d7..3dbb3ce 100644 (file)
@@ -131,16 +131,6 @@ extern int cygserver_running;
 
 #define TITLESIZE 1024
 
-/* status bit manipulation */
-#define __ISSETF(what, x, prefix) \
-  ((what)->status & prefix##_##x)
-#define __SETF(what, x, prefix) \
-  ((what)->status |= prefix##_##x)
-#define __CLEARF(what, x, prefix) \
-  ((what)->status &= ~prefix##_##x)
-#define __CONDSETF(n, what, x, prefix) \
-  ((n) ? __SETF (what, x, prefix) : __CLEARF (what, x, prefix))
-
 #include "debug.h"
 
 /* Events/mutexes */