diff options
Diffstat (limited to 'winsup/cygwin/local_includes')
-rw-r--r-- | winsup/cygwin/local_includes/fhandler.h | 9 | ||||
-rw-r--r-- | winsup/cygwin/local_includes/thread.h | 31 | ||||
-rw-r--r-- | winsup/cygwin/local_includes/tty.h | 6 |
3 files changed, 35 insertions, 11 deletions
diff --git a/winsup/cygwin/local_includes/fhandler.h b/winsup/cygwin/local_includes/fhandler.h index 8c71d84..03f20c8 100644 --- a/winsup/cygwin/local_includes/fhandler.h +++ b/winsup/cygwin/local_includes/fhandler.h @@ -1979,6 +1979,7 @@ class fhandler_termios: public fhandler_base virtual off_t lseek (off_t, int); pid_t tcgetsid (); virtual int fstat (struct stat *buf); + int tcflow (int); fhandler_termios (void *) {} @@ -2143,12 +2144,12 @@ class dev_console char cons_rabuf[40]; // cannot get longer than char buf[40] in char_command char *cons_rapoi; bool cursor_key_app_mode; - bool disable_master_thread; + volatile bool disable_master_thread; tty::cons_mode curr_input_mode; tty::cons_mode curr_output_mode; DWORD prev_input_mode; DWORD prev_output_mode; - bool master_thread_suspended; + volatile bool master_thread_suspended; int num_processed; /* Number of input events in the current input buffer already processed by cons_master_thread(). */ @@ -2273,6 +2274,7 @@ private: int tcflush (int); int tcsetattr (int a, const struct termios *t); int tcgetattr (struct termios *t); + int tcdrain (); int ioctl (unsigned int cmd, void *); int init (HANDLE, DWORD, mode_t, int64_t = 0); @@ -2368,7 +2370,7 @@ private: void setup_pcon_hand_over (); static void pcon_hand_over_proc (); - static tty::cons_mode cons_mode_on_close (); + static tty::cons_mode cons_mode_on_close (handle_set_t *); friend tty_min * tty_list::get_cttyp (); }; @@ -2391,6 +2393,7 @@ class fhandler_pty_common: public fhandler_termios DWORD __acquire_output_mutex (const char *fn, int ln, DWORD ms); void __release_output_mutex (const char *fn, int ln); + int tcdrain (); int close (int flag = -1); off_t lseek (off_t, int); bool bytes_available (DWORD& n); diff --git a/winsup/cygwin/local_includes/thread.h b/winsup/cygwin/local_includes/thread.h index b349628..3955609 100644 --- a/winsup/cygwin/local_includes/thread.h +++ b/winsup/cygwin/local_includes/thread.h @@ -221,13 +221,12 @@ public: ~pthread_key (); static void fixup_before_fork () { - keys.for_each (&pthread_key::_fixup_before_fork); + for_each (_fixup_before_fork); } static void fixup_after_fork () { - keys.fixup_after_fork (); - keys.for_each (&pthread_key::_fixup_after_fork); + for_each (_fixup_after_fork); } static void run_all_destructors () @@ -246,21 +245,39 @@ public: for (int i = 0; i < PTHREAD_DESTRUCTOR_ITERATIONS; ++i) { iterate_dtors_once_more = false; - keys.for_each (&pthread_key::run_destructor); + for_each (run_destructor); if (!iterate_dtors_once_more) break; } } - /* List support calls */ - class pthread_key *next; private: - static List<pthread_key> keys; + int key_idx; + static class keys_list { + LONG64 seq; + LONG64 busy_cnt; + pthread_key *key; + static bool used (LONG64 seq1) { return (seq1 & 3) != 0; } + static bool ready (LONG64 seq1) { return (seq1 & 3) == 2; } + public: + keys_list () : seq (0), busy_cnt (INT64_MIN), key (NULL) {} + friend class pthread_key; + } keys[PTHREAD_KEYS_MAX]; void _fixup_before_fork (); void _fixup_after_fork (); void (*destructor) (void *); void run_destructor (); void *fork_buf; + static void for_each (void (pthread_key::*callback) ()) { + for (size_t cnt = 0; cnt < PTHREAD_KEYS_MAX; cnt++) + { + if (!keys_list::ready (keys[cnt].seq)) + continue; + if (InterlockedIncrement64 (&keys[cnt].busy_cnt) > 0) + (keys[cnt].key->*callback) (); + InterlockedDecrement64 (&keys[cnt].busy_cnt); + } + } }; class pthread_attr: public verifyable_object diff --git a/winsup/cygwin/local_includes/tty.h b/winsup/cygwin/local_includes/tty.h index 2a047d7..a418ab1 100644 --- a/winsup/cygwin/local_includes/tty.h +++ b/winsup/cygwin/local_includes/tty.h @@ -30,6 +30,9 @@ details. */ #define MIN_CTRL_C_SLOP 50 #endif +#define BY_TCFLOW 2 +#define BY_VSTOP 1 + typedef void *HPCON; #include "devices.h" @@ -43,7 +46,8 @@ class tty_min public: pid_t pgid; - bool output_stopped; /* FIXME: Maybe do this with a mutex someday? */ + volatile int output_stopped; /* FIXME: Maybe do this with a mutex someday? */ + volatile int input_stopped; fh_devices ntty; ULONGLONG last_ctrl_c; /* tick count of last ctrl-c */ bool is_console; |