Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--winsup/cygwin/ChangeLog15
-rw-r--r--winsup/cygwin/fhandler_tty.cc10
-rw-r--r--winsup/cygwin/tty.cc38
-rw-r--r--winsup/cygwin/tty.h34
4 files changed, 61 insertions, 36 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 885221db6..2d6d8382f 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,18 @@
+2004-05-12 Pierre Humblet <pierre.humblet@ieee.org>
+
+ * tty.h: Remove the %d or %x from all cygtty strings.
+ (tty::open_output_mutex): Only declare.
+ (tty::open_input_mutex): Ditto.
+ (tty::open_mutex): New definition.
+ * fhandler_tty.cc (fhandler_tty_slave::open): Declare buf with
+ size CYG_MAX_PATH and replace __small_printf calls by shared_name.
+ * tty.cc (tty::create_inuse): Ditto.
+ (tty::get_event): Ditto.
+ (tty::common_init): Ditto.
+ (tty::open_output_mutex): New method definition.
+ (tty::open_input_mutex): Ditto.
+ (tty::open_mutex): New method.
+
2004-05-10 Corinna Vinschen <corinna@vinschen.de>
* fhandler.cc (fhandler_base::open): Set file attributes to correct
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 717a9924d..6233971cb 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -466,14 +466,14 @@ fhandler_tty_slave::open (int flags, mode_t)
set_flags ((flags & ~O_TEXT) | O_BINARY);
/* Create synchronisation events */
- char buf[40];
+ char buf[CYG_MAX_PATH];
/* output_done_event may or may not exist. It will exist if the tty
was opened by fhandler_tty_master::init, normally called at
startup if use_tty is non-zero. It will not exist if this is a
pty opened by fhandler_pty_master::open. In the former case, tty
output is handled by a separate thread which controls output. */
- __small_sprintf (buf, OUTPUT_DONE_EVENT, get_unit ());
+ shared_name (buf, OUTPUT_DONE_EVENT, get_unit ());
output_done_event = OpenEvent (EVENT_ALL_ACCESS, TRUE, buf);
if (!(output_mutex = get_ttyp ()->open_output_mutex ()))
@@ -488,7 +488,7 @@ fhandler_tty_slave::open (int flags, mode_t)
__seterrno ();
return 0;
}
- __small_sprintf (buf, INPUT_AVAILABLE_EVENT, get_unit ());
+ shared_name (buf, INPUT_AVAILABLE_EVENT, get_unit ());
if (!(input_available_event = OpenEvent (EVENT_ALL_ACCESS, TRUE, buf)))
{
termios_printf ("open input event failed, %E");
@@ -498,9 +498,9 @@ fhandler_tty_slave::open (int flags, mode_t)
/* The ioctl events may or may not exist. See output_done_event,
above. */
- __small_sprintf (buf, IOCTL_REQUEST_EVENT, get_unit ());
+ shared_name (buf, IOCTL_REQUEST_EVENT, get_unit ());
ioctl_request_event = OpenEvent (EVENT_ALL_ACCESS, TRUE, buf);
- __small_sprintf (buf, IOCTL_DONE_EVENT, get_unit ());
+ shared_name (buf, IOCTL_DONE_EVENT, get_unit ());
ioctl_done_event = OpenEvent (EVENT_ALL_ACCESS, TRUE, buf);
/* FIXME: Needs a method to eliminate tty races */
diff --git a/winsup/cygwin/tty.cc b/winsup/cygwin/tty.cc
index 7e3aeb9c4..000de2e6e 100644
--- a/winsup/cygwin/tty.cc
+++ b/winsup/cygwin/tty.cc
@@ -310,21 +310,41 @@ bool
tty::alive (const char *fmt)
{
HANDLE ev;
- char buf[sizeof (TTY_MASTER_ALIVE) + 16];
+ char buf[CYG_MAX_PATH];
- __small_sprintf (buf, fmt, ntty);
+ shared_name (buf, fmt, ntty);
if ((ev = OpenEvent (EVENT_ALL_ACCESS, FALSE, buf)))
CloseHandle (ev);
return ev != NULL;
}
+HANDLE
+tty::open_output_mutex ()
+{
+ return open_mutex (OUTPUT_MUTEX);
+}
+
+HANDLE
+tty::open_input_mutex ()
+{
+ return open_mutex (INPUT_MUTEX);
+}
+
+HANDLE
+tty::open_mutex (const char *mutex)
+{
+ char buf[CYG_MAX_PATH];
+ shared_name (buf, mutex, ntty);
+ return OpenMutex (MUTEX_ALL_ACCESS, TRUE, buf);
+}
+
HANDLE
tty::create_inuse (const char *fmt)
{
HANDLE h;
- char buf[sizeof (TTY_MASTER_ALIVE) + 16];
+ char buf[CYG_MAX_PATH];
- __small_sprintf (buf, fmt, ntty);
+ shared_name (buf, fmt, ntty);
h = CreateEvent (&sec_all, TRUE, FALSE, buf);
termios_printf ("%s = %p", buf, h);
if (!h)
@@ -348,9 +368,9 @@ HANDLE
tty::get_event (const char *fmt, BOOL manual_reset)
{
HANDLE hev;
- char buf[40];
+ char buf[CYG_MAX_PATH];
- __small_sprintf (buf, fmt, ntty);
+ shared_name (buf, fmt, ntty);
if (!(hev = CreateEvent (&sec_all, manual_reset, FALSE, buf)))
{
termios_printf ("couldn't create %s", buf);
@@ -440,8 +460,8 @@ tty::common_init (fhandler_pty_master *ptym)
if (!(ptym->input_available_event = get_event (INPUT_AVAILABLE_EVENT, TRUE)))
return false;
- char buf[40];
- __small_sprintf (buf, OUTPUT_MUTEX, ntty);
+ char buf[CYG_MAX_PATH];
+ shared_name (buf, OUTPUT_MUTEX, ntty);
if (!(ptym->output_mutex = CreateMutex (&sec_all, FALSE, buf)))
{
termios_printf ("can't create %s", buf);
@@ -449,7 +469,7 @@ tty::common_init (fhandler_pty_master *ptym)
return false;
}
- __small_sprintf (buf, INPUT_MUTEX, ntty);
+ shared_name (buf, INPUT_MUTEX, ntty);
if (!(ptym->input_mutex = CreateMutex (&sec_all, FALSE, buf)))
{
termios_printf ("can't create %s", buf);
diff --git a/winsup/cygwin/tty.h b/winsup/cygwin/tty.h
index 94d98048b..d29b2e903 100644
--- a/winsup/cygwin/tty.h
+++ b/winsup/cygwin/tty.h
@@ -8,7 +8,6 @@ This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
-
/* tty tables */
#define INP_BUFFER_SIZE 256
@@ -18,15 +17,15 @@ details. */
/* Input/Output/ioctl events */
-#define OUTPUT_DONE_EVENT "cygtty%d.output.done"
-#define IOCTL_REQUEST_EVENT "cygtty%d.ioctl.request"
-#define IOCTL_DONE_EVENT "cygtty%d.ioctl.done"
-#define RESTART_OUTPUT_EVENT "cygtty%d.output.restart"
-#define INPUT_AVAILABLE_EVENT "cygtty%d.input.avail"
-#define OUTPUT_MUTEX "cygtty%d.output.mutex"
-#define INPUT_MUTEX "cygtty%d.input.mutex"
-#define TTY_SLAVE_ALIVE "cygtty%x.slave_alive"
-#define TTY_MASTER_ALIVE "cygtty%x.master_alive"
+#define OUTPUT_DONE_EVENT "cygtty.output.done"
+#define IOCTL_REQUEST_EVENT "cygtty.ioctl.request"
+#define IOCTL_DONE_EVENT "cygtty.ioctl.done"
+#define RESTART_OUTPUT_EVENT "cygtty.output.restart"
+#define INPUT_AVAILABLE_EVENT "cygtty.input.avail"
+#define OUTPUT_MUTEX "cygtty.output.mutex"
+#define INPUT_MUTEX "cygtty.input.mutex"
+#define TTY_SLAVE_ALIVE "cygtty.slave_alive"
+#define TTY_MASTER_ALIVE "cygtty.master_alive"
#include <sys/termios.h>
@@ -105,18 +104,9 @@ public:
HWND gethwnd () {return hwnd;}
void sethwnd (HWND wnd) {hwnd = wnd;}
bool make_pipes (fhandler_pty_master *ptym);
- HANDLE open_output_mutex ()
- {
- char buf[80];
- __small_sprintf (buf, OUTPUT_MUTEX, ntty);
- return OpenMutex (MUTEX_ALL_ACCESS, TRUE, buf);
- }
- HANDLE open_input_mutex ()
- {
- char buf[80];
- __small_sprintf (buf, INPUT_MUTEX, ntty);
- return OpenMutex (MUTEX_ALL_ACCESS, TRUE, buf);
- }
+ HANDLE open_mutex (const char *mutex);
+ HANDLE open_output_mutex ();
+ HANDLE open_input_mutex ();
bool exists ()
{
HANDLE h = open_output_mutex ();