newlib/winsup/cygwin/devices.h
Christopher Faylor 9a4d574b8d Eliminate use of sigframe and sigthread throughout.
* Makefile.in (DLL_OFILES): Add sigfe.o.  Remove reliance on cygwin.def from
cygwin0.dll dependency since dependence on sigfe.o implies that.  Generate def
file on the fly using 'gendef'.
* configure.in: Don't auto-generate cygwin.def.
* configure: Regenerate.
* cygwin.din: Add SIGFE stuff where appropriate.
* dcrt0.cc (dll_crt0_1): Initialize cygwin tls early in process startup.  Set
_main_tls to address of the main thread's cygwin tls.
* debug.h: Remove now unneeded WFSO and WFMO declarations.
* exceptions.cc (_last_thread): Define.
(set_thread_state_for_signals): New function.
(reset_thread_exception_for_signals): Ditto.
(init_thread_for_signals): Ditto.
(delete_thread_for_signals): Ditto.
(capture_thread_for_signals): Ditto.
(handle_exceptions): Set return address explicitly for exceptions prior to
calling sig_send.
(interrupt_on_return): Eliminate.
(setup_handler): Add preliminary implementation for dealing with
thread-specific signals by querying _main_tls.
(signal_exit): Use cygthread::main_thread_id instead of mainthread.id.
(call_signal_handler_now): For now, just handle the main thread.
* fork.cc (vfork): Save and restore main _my_tls.
* gendef: New file.  Generates def file and sigfe.s file.
* gentls_offsets: New file.  Generates offsets for perl to use in sigfe.s.
* how-signals-work.txt: Mention that info is obsolete.
* init.cc (dll_entry): Initialize cygwin tls storage here.
* miscfuncs.cc (low_priority_sleep): Make a C function for easier calling from
asm.
* perthread.h (vfork_save::tls): New element.
* signal.cc (nanosleep): Replace previous use of
sigframe.call_signal_handler_now with straight call to call_signal_handler_now.
(abort): Ditto.
* syscalls.cc (readv): Ditto.
* termios.cc (tcsetattr): Ditto.
* wait.cc (wait4): Ditto.
* sigproc.cc (sig_dispatch_pending): Ditto.
(sig_send): Ditto.
* sigproc.h: Declare call_signal_handler_now.
* thread.cc (pthread::thread_init_wrapper): Initialize cygwin tls.  Remove
obsolete and unworking signal stuff.
* thread.h (verifyable_object::sigs): Eliminate.
(verifyable_object::sigmask): Eliminate.
(verifyable_object::sigtodo): Eliminate.
(verifyable_object::exit): Make attribute noreturn.
(verifyable_object::thread_init_wrapper): Ditto.
(pthread_null::exit): Ditto.
* winbase.h (__stackbase): Always define.
* winsup.h (low_priority_sleep): Declare as a "C" function.
* include/cygwin/version.h: Bump API version to reflect sigwait export.
* include/sys/queue.h: Protect SLIST_ENTRY from previous declaration.
* signal.cc (sigwait): Implement.
* select.cc (fhandler_base::ready_for_read): Add debugging output.
* devices.h: Define more device pointers via their storage.
* devices.in: Don't parse things like /dev/inet/tcp, as they really have no
meaning.
* devices.cc: Regenerate.
* gendevices: Set proper protection for output file.
* cygtls.h: New file.
* gendef: New file.
* gentls_offsets: New file.
* tlsoffsets.h: New file.  Autogenerated.
* config/i386/longjmp.c: Remove.  File subsumed by gendef output.
* config/i386/makefrag: Remove obsolete file.
* fhandler.cc: Remove spurious access_worker declaration.
* spawn.cc (spawnve): Make debugging output more accurate.
* cygwin-gperf: Remove.
* devices.cc: Remove.
2003-11-28 20:55:59 +00:00

176 lines
5.1 KiB
C

/* devices.h
Copyright 2002, 2003 Red Hat, Inc.
This file is part of Cygwin.
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
typedef unsigned short _major_t;
typedef unsigned short _minor_t;
typedef mode_t _mode_t;
typedef __dev32_t _dev_t;
#define FHDEV(maj, min) ((((unsigned) (maj)) << (sizeof (_major_t) * 8)) | (unsigned) (min))
#define _minor(dev) ((dev) & ((1 << (sizeof (_minor_t) * 8)) - 1))
#define _major(dev) ((dev) >> (sizeof (_major_t) * 8))
enum fh_devices
{
FH_TTY = FHDEV (5, 0),
FH_CONSOLE = FHDEV (5, 1),
FH_PTYM = FHDEV (5, 2), /* /dev/ptmx */
FH_CONIN = FHDEV (5, 255),
FH_CONOUT = FHDEV (5, 254),
DEV_TTYM_MAJOR = 128,
FH_TTYM = FHDEV (DEV_TTYM_MAJOR, 0),
FH_TTYM_MAX= FHDEV (DEV_TTYM_MAJOR, 255),
DEV_TTYS_MAJOR = 136,
FH_TTYS = FHDEV (DEV_TTYS_MAJOR, 0), /* FIXME: Should separate ttys and ptys */
FH_TTYS_MAX= FHDEV (DEV_TTYS_MAJOR, 255), /* FIXME: Should separate ttys and ptys */
DEV_SERIAL_MAJOR = 117,
FH_SERIAL = FHDEV (117, 0), /* /dev/ttyS? */
FH_WINDOWS = FHDEV (13, 255),
FH_CLIPBOARD=FHDEV (13, 254),
FH_PIPE = FHDEV (0, 255),
FH_PIPER = FHDEV (0, 254),
FH_PIPEW = FHDEV (0, 253),
FH_FIFO = FHDEV (0, 252),
FH_PROC = FHDEV (0, 250),
FH_REGISTRY= FHDEV (0, 249),
FH_PROCESS = FHDEV (0, 248),
FH_FS = FHDEV (0, 247), /* filesystem based device */
DEV_FLOPPY_MAJOR = 2,
FH_FLOPPY = FHDEV (DEV_FLOPPY_MAJOR, 0),
DEV_CDROM_MAJOR = 11,
FH_CDROM = FHDEV (DEV_CDROM_MAJOR, 0),
DEV_TAPE_MAJOR = 9,
FH_TAPE = FHDEV (DEV_TAPE_MAJOR, 0),
FH_NTAPE = FHDEV (DEV_TAPE_MAJOR, 128),
FH_MAXNTAPE= FHDEV (DEV_TAPE_MAJOR, 255),
DEV_SD_MAJOR = 8,
DEV_SD1_MAJOR = 65,
FH_SD = FHDEV (DEV_SD_MAJOR, 0),
FH_SD1 = FHDEV (DEV_SD1_MAJOR, 0),
FH_SDA = FHDEV (DEV_SD_MAJOR, 0),
FH_SDB = FHDEV (DEV_SD_MAJOR, 16),
FH_SDC = FHDEV (DEV_SD_MAJOR, 32),
FH_SDD = FHDEV (DEV_SD_MAJOR, 48),
FH_SDE = FHDEV (DEV_SD_MAJOR, 64),
FH_SDF = FHDEV (DEV_SD_MAJOR, 80),
FH_SDG = FHDEV (DEV_SD_MAJOR, 96),
FH_SDH = FHDEV (DEV_SD_MAJOR, 112),
FH_SDI = FHDEV (DEV_SD_MAJOR, 128),
FH_SDJ = FHDEV (DEV_SD_MAJOR, 144),
FH_SDK = FHDEV (DEV_SD_MAJOR, 160),
FH_SDL = FHDEV (DEV_SD_MAJOR, 176),
FH_SDM = FHDEV (DEV_SD_MAJOR, 192),
FH_SDN = FHDEV (DEV_SD_MAJOR, 208),
FH_SDO = FHDEV (DEV_SD_MAJOR, 224),
FH_SDP = FHDEV (DEV_SD_MAJOR, 240),
FH_SDQ = FHDEV (DEV_SD1_MAJOR, 0),
FH_SDR = FHDEV (DEV_SD1_MAJOR, 16),
FH_SDS = FHDEV (DEV_SD1_MAJOR, 32),
FH_SDT = FHDEV (DEV_SD1_MAJOR, 48),
FH_SDU = FHDEV (DEV_SD1_MAJOR, 64),
FH_SDV = FHDEV (DEV_SD1_MAJOR, 80),
FH_SDW = FHDEV (DEV_SD1_MAJOR, 96),
FH_SDX = FHDEV (DEV_SD1_MAJOR, 112),
FH_SDY = FHDEV (DEV_SD1_MAJOR, 128),
FH_SDZ = FHDEV (DEV_SD1_MAJOR, 144),
FH_MEM = FHDEV (1, 1),
FH_KMEM = FHDEV (1, 2), /* not implemented yet */
FH_NULL = FHDEV (1, 3),
FH_ZERO = FHDEV (1, 4),
FH_PORT = FHDEV (1, 5),
FH_RANDOM = FHDEV (1, 8),
FH_URANDOM = FHDEV (1, 9),
FH_OSS_DSP = FHDEV (14, 3),
DEV_CYGDRIVE_MAJOR = 98,
FH_CYGDRIVE= FHDEV (DEV_CYGDRIVE_MAJOR, 0),
FH_CYGDRIVE_A= FHDEV (DEV_CYGDRIVE_MAJOR, 'a'),
FH_CYGDRIVE_Z= FHDEV (DEV_CYGDRIVE_MAJOR, 'z'),
DEV_TCP_MAJOR = 30,
FH_TCP = FHDEV (DEV_TCP_MAJOR, 36),
FH_UDP = FHDEV (DEV_TCP_MAJOR, 39),
FH_ICMP = FHDEV (DEV_TCP_MAJOR, 33),
FH_UNIX = FHDEV (DEV_TCP_MAJOR, 120),
FH_STREAM = FHDEV (DEV_TCP_MAJOR, 121),
FH_DGRAM = FHDEV (DEV_TCP_MAJOR, 122),
FH_BAD = FHDEV (0, 0)
};
struct device
{
const char *name;
union
{
_dev_t devn;
struct
{
_minor_t minor;
_major_t major;
};
};
const char *native;
_mode_t mode;
bool dev_on_fs;
static const device *lookup (const char *, unsigned int = 0xffffffff);
void parse (const char *);
void parse (_major_t major, _minor_t minor);
void parse (_dev_t dev);
inline bool setunit (unsigned n)
{
minor = n;
return true;
}
static void init ();
void tty_to_real_device ();
inline operator int () const {return devn;}
inline void setfs (bool x) {dev_on_fs = x;}
inline bool isfs () const {return dev_on_fs;}
};
extern const device *console_dev;
extern const device *ttym_dev;
extern const device *ttys_dev;
extern const device *urandom_dev;
extern const device dev_dgram_storage;
#define dgram_dev (&dev_dgram_storage)
extern const device dev_stream_storage;
#define stream_dev (&dev_stream_storage)
extern const device dev_tcp_storage;
#define tcp_dev (&dev_tcp_storage)
extern const device dev_udp_storage;
#define udp_dev (&dev_udp_storage)
extern const device dev_piper_storage;
#define piper_dev (&dev_piper_storage)
extern const device dev_pipew_storage;
#define pipew_dev (&dev_pipew_storage)
extern const device dev_proc_storage;
#define proc_dev (&dev_proc_storage)
extern const device dev_cygdrive_storage;
#define cygdrive_dev (&dev_cygdrive_storage)
extern const device dev_fh_storage;
#define fh_dev (&dev_fh_storage)
extern const device dev_fs_storage;
#define fs_dev (&dev_fs_storage)