diff options
author | Christopher Faylor <me@cgf.cx> | 2002-12-28 07:10:31 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2002-12-28 07:10:31 +0000 |
commit | 4f3047788006551f7a1462b1e71537bf3daf9875 (patch) | |
tree | a99fc0941f5059b4ccd2b29df7234c44bd00cfbb | |
parent | c8a1455ba6ef15e6b2ef77eef8455106608e57bf (diff) | |
download | newlib-4f3047788006551f7a1462b1e71537bf3daf9875.zip newlib-4f3047788006551f7a1462b1e71537bf3daf9875.tar.gz newlib-4f3047788006551f7a1462b1e71537bf3daf9875.tar.bz2 |
Introduce device class to cygwin throughout. Rename FH_DISK to FH_FS
throughout.
* dcrt0.cc (dll_crt0_1): Initialize device globals via device::init.
* dtable.cc (dtable::init_std_file_from_handle): Use device numbers rather than
names when they are known. Should speed up process startup slightly.
(dtable::build_fhandler_from_name): Pass path_conv device to build_fhandler.
(dtable::build_fhandler): Accept device argument rather than separate
device/unit arguments.
(dtable::build_fhandler): Ditto. Separate switch statement by devices which
take units and those which don't. Build unix/win32 names from device if
required.
(dtable::dup_worker): Reflect changes to build_fhandler arguments.
* dtable.h (dtable::build_fhandler): Ditto.
* fhandler.cc (fhandler_base::set_name): Eliminate unit argument. Use get_unit
to derive unit.
* fhandler.h: Separate FH device defines into devices.h include. Define
is_slow as appropriate for each fhandler_class.
(fhandler_base::dev): New element.
(fhandler_base::fhandler_base): Eliminate unit argument.
(fhandler_base::get_device): Return device number.
(fhandler_base::get_major): Return device major number.
(fhandler_base::get_minor): Return device minor number.
(fhandler_base::get_unit): Ditto.
(fhandler_base::get_native_name): Return device format field.
(fhandler_fifo): New class.
(select_stuff::device_specific): Remove array.
(select_stuff::device_specific_pipe): New class element.
(select_stuff::device_specific_socket): New class element.
(select_stuff::device_specific_serial): New class element.
(select_stuff::select_stuff): Initialize new elements.
* fhandler_disk_file.cc (fhandler_cygdrive::fhandler_cygdrive): Remove unit
initialization.
* fhandler_tty.cc (fhandler_tty_master::init_console): Use "console_dev" global
to initialize captive console used by tty master.
* mmap.cc (mmap_record::devtype_): Remove.
(mmap_record::dev): New.
(mmap_record::mmap_record): Use dev.
(mmap_record::get_device): Implement via dev.
* net.cc (fdsock): Use socket_dev global to initialize socket fhandler.
* path.cc (path_conv::check): Accommodate new path_conv::dev element.
(get_devn): Eliminate.
(get_raw_device_number): Ditto.
(get_device_number): Ditto.
(win32_device_name): Accept dev argument. Use it. Use device::parse to derive
potential device name.
(mount_info::conv_to_win32_path): Accept dev argument. Use it.
* path.h (path_conv::devn): Eliminate.
(path_conv::unit): Ditto.
(path_conv::dev): Declare.
(path_conv::path_conv): Don't initialize deleted members.
(path_conv::is_device): Implement via dev element.
(path_conv::get_devn): Ditto.
(path_conv::get_unitn): Ditto.
* pipe.cc (make_pipe): Use pipe[rw]_dev in fhandler construction.
* select.cc: Use new device_specific_* select class elements
* shared_info.h (CURR_MOUNT_MAGIC): Update.
(mount_info::conv_to_win32_path): Reflect new arguments.
* syscalls.cc (fstat64): Just use get_device() without interpretation for
st_dev element.
(stat_worker): Ditto.
* tty.cc (create_tty_master): Use ttym_dev in fhandler constructor.
(tty::common_init): Check for tty major device number rather than FH_TTYM.
-rw-r--r-- | winsup/cygwin/fhandler.h | 98 |
1 files changed, 42 insertions, 56 deletions
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index f0dde37..b7576ed 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -42,45 +42,11 @@ enum FH_HASACLS = 0x40000000, /* True if fs of file has ACLS */ FH_QUERYOPEN = 0x80000000, /* open file without requesting either read or write access */ - - /* Device flags */ - - /* Slow devices */ - FH_CONSOLE = 0x00000001, /* is a console */ - FH_CONIN = 0x00000002, /* console input */ - FH_CONOUT = 0x00000003, /* console output */ - FH_TTYM = 0x00000004, /* is a tty master */ - FH_TTYS = 0x00000005, /* is a tty slave */ - FH_PTYM = 0x00000006, /* is a pty master */ - FH_SERIAL = 0x00000007, /* is a serial port */ - FH_PIPE = 0x00000008, /* is a pipe */ - FH_PIPER = 0x00000009, /* read end of a pipe */ - FH_PIPEW = 0x0000000a, /* write end of a pipe */ - FH_SOCKET = 0x0000000b, /* is a socket */ - FH_WINDOWS = 0x0000000c, /* is a window */ - FH_SLOW = 0x00000010, /* "slow" device if below this */ - - /* Fast devices */ - FH_DISK = 0x00000010, /* is a disk */ - FH_FLOPPY = 0x00000011, /* is a floppy */ - FH_TAPE = 0x00000012, /* is a tape */ - FH_NULL = 0x00000013, /* is the null device */ - FH_ZERO = 0x00000014, /* is the zero device */ - FH_RANDOM = 0x00000015, /* is a random device */ - FH_MEM = 0x00000016, /* is a mem device */ - FH_CLIPBOARD = 0x00000017, /* is a clipboard device */ - FH_OSS_DSP = 0x00000018, /* is a dsp audio device */ - FH_CYGDRIVE= 0x00000019, /* /cygdrive/x */ - FH_PROC = 0x0000001a, /* /proc */ - FH_REGISTRY =0x0000001b, /* /proc/registry */ - FH_PROCESS = 0x0000001c, /* /proc/<n> */ - - FH_NDEV = 0x0000001d, /* Maximum number of devices */ - FH_DEVMASK = 0x00000fff, /* devices live here */ - FH_BAD = 0xffffffff }; -#define FHDEVN(n) ((n) & FH_DEVMASK) +#include "devices.h" + +#define FHDEVN(n) (n) #define FHISSETF(x) __ISSETF (this, x, FH) #define FHSETF(x) __SETF (this, x, FH) #define FHCLEARF(x) __CLEARF (this, x, FH) @@ -170,18 +136,20 @@ class fhandler_base HANDLE read_state; public: - void set_name (const char * unix_path, const char *win32_path = NULL, int unit = 0); + device dev; + void set_name (const char *unix_path, const char *win32_path = NULL); virtual fhandler_base& operator =(fhandler_base &x); - fhandler_base (DWORD dev, int unit = 0); + fhandler_base (DWORD dev); virtual ~fhandler_base (); /* Non-virtual simple accessor functions. */ void set_io_handle (HANDLE x) { io_handle = x; } - DWORD get_device () { return status & FH_DEVMASK; } - virtual int get_unit () { return 0; } - virtual BOOL is_slow () { return get_device () < FH_SLOW; } + DWORD get_device () { return dev.devn; } + DWORD get_major () { return dev.major; } + DWORD get_minor () { return dev.minor; } + virtual int get_unit () { return dev.minor; } int get_access () { return access; } void set_access (int x) { access = x; } @@ -305,7 +273,7 @@ class fhandler_base virtual int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3))); virtual int ioctl (unsigned int cmd, void *); virtual int fcntl (int cmd, void *); - virtual char const * ttyname () { return get_name(); } + virtual char const *ttyname () { return get_name(); } virtual void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3))); virtual int write (const void *ptr, size_t len); virtual ssize_t readv (const struct iovec *, int iovcnt, ssize_t tot = -1); @@ -354,9 +322,9 @@ class fhandler_base virtual select_record *select_write (select_record *s); virtual select_record *select_except (select_record *s); virtual int ready_for_read (int fd, DWORD howlong); - virtual const char * get_native_name () + virtual const char *get_native_name () { - return windows_device_names[FHDEVN (status)]; + return dev.fmt; } virtual bg_check_types bg_check (int) {return bg_ok;} void clear_readahead () @@ -373,6 +341,7 @@ class fhandler_base virtual void seekdir (DIR *, __off64_t); virtual void rewinddir (DIR *); virtual int closedir (DIR *); + virtual bool is_slow () {return 0;} }; class fhandler_socket: public fhandler_base @@ -390,7 +359,7 @@ class fhandler_socket: public fhandler_base fhandler_socket (); ~fhandler_socket (); int get_socket () { return (int) get_handle(); } - fhandler_socket * is_socket () { return this; } + fhandler_socket *is_socket () { return this; } bool saw_shutdown_read () const {return FHISSETF (SHUTRD);} bool saw_shutdown_write () const {return FHISSETF (SHUTWR);} @@ -449,6 +418,7 @@ class fhandler_socket: public fhandler_base void signal_secret_event (); void close_secret_event (); int __stdcall fstat (struct __stat64 *buf, path_conv *) __attribute__ ((regparm (3))); + bool is_slow () {return 1;} }; class fhandler_pipe: public fhandler_base @@ -477,6 +447,16 @@ class fhandler_pipe: public fhandler_base friend int make_pipe (int fildes[2], unsigned int psize, int mode); HANDLE get_guard () const {return guard;} int ready_for_read (int fd, DWORD howlong); + static int create (fhandler_pipe *[2], unsigned, int, bool = false); + bool is_slow () {return 1;} +}; + +class fhandler_fifo: public fhandler_pipe +{ +public: + fhandler_fifo (); + int open (path_conv *, int flags, mode_t mode = 0); + bool is_slow () {return 1;} }; class fhandler_dev_raw: public fhandler_base @@ -587,7 +567,7 @@ class fhandler_disk_file: public fhandler_base fhandler_disk_file (); fhandler_disk_file (DWORD devtype); - int open (path_conv * real_path, int flags, mode_t mode); + int open (path_conv *real_path, int flags, mode_t mode); int close (); int lock (int, struct flock *); BOOL is_device () { return FALSE; } @@ -681,6 +661,7 @@ class fhandler_serial: public fhandler_base select_record *select_read (select_record *s); select_record *select_write (select_record *s); select_record *select_except (select_record *s); + bool is_slow () {return 1;} }; #define acquire_output_mutex(ms) \ @@ -806,7 +787,7 @@ class fhandler_console: public fhandler_termios void cursor_set (BOOL, int, int); void cursor_get (int *, int *); void cursor_rel (int, int); - const unsigned char * write_normal (unsigned const char*, unsigned const char *); + const unsigned char *write_normal (unsigned const char*, unsigned const char *); void char_command (char); BOOL set_raw_win32_keyboard_mode (BOOL); int output_tcsetattr (int a, const struct termios *t); @@ -849,6 +830,7 @@ class fhandler_console: public fhandler_termios void set_input_state (); void send_winch_maybe (); static tty_min *get_tty_stuff (int); + bool is_slow () {return 1;} }; class fhandler_tty_common: public fhandler_termios @@ -878,7 +860,6 @@ class fhandler_tty_common: public fhandler_termios virtual int dup (fhandler_base *child); tty *get_ttyp () { return (tty *)tc; } - int get_unit () { return ttynum; } int close (); void set_close_on_exec (int val); @@ -886,6 +867,7 @@ class fhandler_tty_common: public fhandler_termios select_record *select_read (select_record *s); select_record *select_write (select_record *s); select_record *select_except (select_record *s); + bool is_slow () {return 1;} }; class fhandler_tty_slave: public fhandler_tty_common @@ -951,6 +933,7 @@ class fhandler_tty_master: public fhandler_pty_master void set_winsize (bool); void fixup_after_fork (HANDLE parent); void fixup_after_exec (HANDLE); + bool is_slow () {return 1;} }; class fhandler_dev_null: public fhandler_base @@ -1070,6 +1053,7 @@ class fhandler_windows: public fhandler_base select_record *select_read (select_record *s); select_record *select_write (select_record *s); select_record *select_except (select_record *s); + bool is_slow () {return 1;} }; class fhandler_dev_dsp : public fhandler_base @@ -1090,7 +1074,7 @@ class fhandler_dev_dsp : public fhandler_base int ioctl (unsigned int cmd, void *); __off64_t lseek (__off64_t, int); int close (void); - int dup (fhandler_base * child); + int dup (fhandler_base *child); void dump (void); void fixup_after_exec (HANDLE); }; @@ -1116,7 +1100,7 @@ class fhandler_virtual : public fhandler_base int write (const void *ptr, size_t len); void __stdcall read (void *ptr, size_t& len) __attribute__ ((regparm (3))); __off64_t lseek (__off64_t, int); - int dup (fhandler_base * child); + int dup (fhandler_base child); int open (path_conv *, int flags, mode_t mode = 0); int close (void); int __stdcall fstat (struct stat *buf, path_conv *pc) __attribute__ ((regparm (3))); @@ -1230,19 +1214,21 @@ class select_stuff { public: ~select_stuff (); - select_stuff (): always_ready (0), windows_used (0), start (0) - { - memset (device_specific, 0, sizeof (device_specific)); - } bool always_ready, windows_used; select_record start; - void *device_specific[FH_NDEV]; + void *device_specific_pipe; + void *device_specific_socket; + void *device_specific_serial; int test_and_set (int i, fd_set *readfds, fd_set *writefds, fd_set *exceptfds); int poll (fd_set *readfds, fd_set *writefds, fd_set *exceptfds); int wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds, DWORD ms); void cleanup (); + select_stuff (): always_ready (0), windows_used (0), start (0), + device_specific_pipe (0), + device_specific_socket (0), + device_specific_serial (0) {} }; int __stdcall set_console_state_for_spawn (); |