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:
authorChristopher Faylor <me@cgf.cx>2001-10-08 09:50:33 +0400
committerChristopher Faylor <me@cgf.cx>2001-10-08 09:50:33 +0400
commit97405ef5b07997c805ebd2a6c3ecbe4440c92346 (patch)
treeab8b63cbc031a3deb5aa78c0c1403ad4c769ff93
parent2c774ac3f368e61613be8af75eba028d820b5a4b (diff)
* dtable.cc (dtable::build_fhandler): Allocate correct amount for given
fhandler class. * fhandler.h (fhandler_union): Properly define rather than relying on fhandler_console being "big enough".
-rw-r--r--winsup/cygwin/ChangeLog7
-rw-r--r--winsup/cygwin/dtable.cc38
-rw-r--r--winsup/cygwin/fhandler.h31
3 files changed, 48 insertions, 28 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 5d9a82858..9733d3825 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,10 @@
+Mon Oct 8 01:47:27 2001 Christopher Faylor <cgf@cygnus.com>
+
+ * dtable.cc (dtable::build_fhandler): Allocate correct amount for given
+ fhandler class.
+ * fhandler.h (fhandler_union): Properly define rather than relying on
+ fhandler_console being "big enough".
+
Mon Oct 8 00:25:18 2001 Christopher Faylor <cgf@cygnus.com>
* external.cc (fillout_pinfo): Reset counter whenever we initialize the
diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc
index be60d11c0..faca5356b 100644
--- a/winsup/cygwin/dtable.cc
+++ b/winsup/cygwin/dtable.cc
@@ -255,73 +255,73 @@ dtable::build_fhandler_from_name (int fd, const char *name, HANDLE handle,
return fh;
}
+#define cnew(name) new ((void *) ccalloc (HEAP_FHANDLER, 1, sizeof (name))) name
fhandler_base *
dtable::build_fhandler (int fd, DWORD dev, const char *name, int unit)
{
fhandler_base *fh;
- void *buf = ccalloc (HEAP_FHANDLER, 1, sizeof (fhandler_union) + 100);
dev &= FH_DEVMASK;
switch (dev)
{
case FH_TTYM:
- fh = new (buf) fhandler_tty_master (name, unit);
+ fh = cnew (fhandler_tty_master) (name, unit);
break;
case FH_CONSOLE:
case FH_CONIN:
case FH_CONOUT:
- fh = new (buf) fhandler_console (name);
+ fh = cnew (fhandler_console) (name);
inc_console_fds ();
break;
case FH_PTYM:
- fh = new (buf) fhandler_pty_master (name);
+ fh = cnew (fhandler_pty_master) (name);
break;
case FH_TTYS:
if (unit < 0)
- fh = new (buf) fhandler_tty_slave (name);
+ fh = cnew (fhandler_tty_slave) (name);
else
- fh = new (buf) fhandler_tty_slave (unit, name);
+ fh = cnew (fhandler_tty_slave) (unit, name);
break;
case FH_WINDOWS:
- fh = new (buf) fhandler_windows (name);
+ fh = cnew (fhandler_windows) (name);
break;
case FH_SERIAL:
- fh = new (buf) fhandler_serial (name, dev, unit);
+ fh = cnew (fhandler_serial) (name, dev, unit);
break;
case FH_PIPE:
case FH_PIPER:
case FH_PIPEW:
- fh = new (buf) fhandler_pipe (name, dev);
+ fh = cnew (fhandler_pipe) (name, dev);
break;
case FH_SOCKET:
- fh = new (buf) fhandler_socket (name);
+ fh = cnew (fhandler_socket) (name);
break;
case FH_DISK:
- fh = new (buf) fhandler_disk_file (NULL);
+ fh = cnew (fhandler_disk_file) (NULL);
break;
case FH_FLOPPY:
- fh = new (buf) fhandler_dev_floppy (name, unit);
+ fh = cnew (fhandler_dev_floppy) (name, unit);
break;
case FH_TAPE:
- fh = new (buf) fhandler_dev_tape (name, unit);
+ fh = cnew (fhandler_dev_tape) (name, unit);
break;
case FH_NULL:
- fh = new (buf) fhandler_dev_null (name);
+ fh = cnew (fhandler_dev_null) (name);
break;
case FH_ZERO:
- fh = new (buf) fhandler_dev_zero (name);
+ fh = cnew (fhandler_dev_zero) (name);
break;
case FH_RANDOM:
- fh = new (buf) fhandler_dev_random (name, unit);
+ fh = cnew (fhandler_dev_random) (name, unit);
break;
case FH_MEM:
- fh = new (buf) fhandler_dev_mem (name, unit);
+ fh = cnew (fhandler_dev_mem) (name, unit);
break;
case FH_CLIPBOARD:
- fh = new (buf) fhandler_dev_clipboard (name);
+ fh = cnew (fhandler_dev_clipboard) (name);
break;
case FH_OSS_DSP:
- fh = new (buf) fhandler_dev_dsp (name);
+ fh = cnew (fhandler_dev_dsp) (name);
break;
default:
{
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 5a07c43c9..d1ebe0a7f 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -1019,18 +1019,31 @@ public:
void fixup_after_exec (HANDLE);
};
-#if 0
-/* You can't do this */
typedef union
{
- fhandler_normal normal;
- fhandler_dev_null dev_null;
- fhandler bare;
- fhandler_serial tty;
+ char base[sizeof(fhandler_base)];
+ char console[sizeof(fhandler_console)];
+ char dev_clipboard[sizeof(fhandler_dev_clipboard)];
+ char dev_dsp[sizeof(fhandler_dev_dsp)];
+ char dev_floppy[sizeof(fhandler_dev_floppy)];
+ char dev_mem[sizeof(fhandler_dev_mem)];
+ char dev_null[sizeof(fhandler_dev_null)];
+ char dev_random[sizeof(fhandler_dev_random)];
+ char dev_raw[sizeof(fhandler_dev_raw)];
+ char dev_tape[sizeof(fhandler_dev_tape)];
+ char dev_zero[sizeof(fhandler_dev_zero)];
+ char disk_file[sizeof(fhandler_disk_file)];
+ char pipe[sizeof(fhandler_pipe)];
+ char pty_master[sizeof(fhandler_pty_master)];
+ char serial[sizeof(fhandler_serial)];
+ char socket[sizeof(fhandler_socket)];
+ char termios[sizeof(fhandler_termios)];
+ char tty_common[sizeof(fhandler_tty_common)];
+ char tty_master[sizeof(fhandler_tty_master)];
+ char tty_slave[sizeof(fhandler_tty_slave)];
+ char windows[sizeof(fhandler_windows)];
} fhandler_union;
-#else
-#define fhandler_union fhandler_console
-#endif
+
struct select_record
{
int fd;