This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: TAB*, NL*, BS* etc in <sys/ioctls.h> in GNU/Hurd and GNU/BSD


Roland McGrath, le Fri 07 Sep 2007 16:24:44 -0700, a écrit :
> > +#define			TAB3	0x00000c00
> >  #define		XTABS		0x00000c00	/* expand tabs on output */
> 
> Old BSD never had a TAB3.  Since TAB3 really means XTABS, if you define it
> at all, use XTABS in the rhs.

Oops, sorry, that was left from my previous patch.

> > +#if defined __USE_MISC || defined __USE_XOPEN
> [...]
> > +# define TAB3	(3 << 10)	/* Expand tabs to spaces.  */
> 
> We already have the OXTABS [__USE_BSD] that means this.  That should be the
> value of TAB3.  Since there is really no TAB3 in the BSD compat defines,
> there is no conflict with using that value.  __USE_BSD is a subset of these
> conditions, so TAB3 will always be defined.  Use TAB3 in the rhs of OXTABS.

Ok, updated patch below.

> Now would be a good time to double-check that all the bits/termios.h values
> are aligned with the BSD values.  e.g. 
> http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/termios.h?rev=1.29&content-type=text/x-cvsweb-markup

Erf, defining OLCUC to 0x10 was actually a bad idea since it's OCRNL in
BSD's oflags.  In the patch below I used bit 7 since in BSD ioctl that
was EVENP which is !PARODD cflag in termio. But maybe BSD people will
define a flag for bit 7 someday so we should choose something else?

There's also a problem with BSD's CDTRCTS, which is CRTS_IFLOW in GNU
(part of CRTSCTS).  I don't see how to fix it without either not support
DTR/CTS on GNU or make existing binaries that use RTSCTS suddenly try to
use DTR/CTS too (or just half of it).

Else it's all the same.

> The bits/ioctls.h values should match BSD's sys/ioctl_compat.h.

It's all the same too.

Samuel

2007-09-08  Samuel Thibault  <samuel.thibault@ens-lyon.org>

	* bits/ioctls.h (NL0, NL1, TAB0, TAB1, TAB2, CR0, CR1, CR2, CR3, FF0,
	FF1, BS0, BS1): Undefine these at start if they are already defined to
	avoid collision with termios.h.
	(NLDLY, TABDLY, CRDLY, VTDLY, BSDLY): Remove macros.
	* bits/termios.h [__USE_MISC || __USE_XOPEN] (NL0, NL1, TAB0,
	TAB1, TAB2, CR0, CR1, CR2, CR3, FF0, FF1, BS0, BS1): Likewise.
	(OLCUC): Change value of macro.
	[__USE_BSD || __USE_XOPEN] (OCRNL, ONOCR, ONLRET): New macros.
	[__USE_MISC || __USE_XOPEN] (NLDLY, NL0, NL1, TABDLY, TAB0, TAB1, TAB2,
	TAB3, CRDLY, CR0, CR1, CR2, CR3, FFDLY, FF0, FF1, BSDLY, BS0, BS1): New
	macros.
	[__USE_BSD] (B7200, B14400, B28800, B76800): New macros.
	(VTDLY, VT0, VT1): New macros.

Index: sysdeps/mach/hurd/bits/ioctls.h
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/mach/hurd/bits/ioctls.h,v
retrieving revision 1.10
diff -u -p -r1.10 ioctls.h
--- sysdeps/mach/hurd/bits/ioctls.h	7 Sep 2007 20:38:57 -0000	1.10
+++ sysdeps/mach/hurd/bits/ioctls.h	7 Sep 2007 23:57:20 -0000
@@ -25,6 +25,46 @@
 
 /* These macros are also defined in <bits/termios.h> (with numerically
    identical values) but this serves to shut up cpp's complaining. */
+
+#ifdef NL0
+# undef 
+#endif
+#ifdef NL1
+# undef 
+#endif
+#ifdef TAB0
+# undef 
+#endif
+#ifdef TAB1
+# undef 
+#endif
+#ifdef TAB2
+# undef 
+#endif
+#ifdef CR0
+# undef 
+#endif
+#ifdef CR1
+# undef 
+#endif
+#ifdef CR2
+# undef 
+#endif
+#ifdef CR3
+# undef 
+#endif
+#ifdef FF0
+# undef 
+#endif
+#ifdef FF1
+# undef 
+#endif
+#ifdef BS0
+# undef 
+#endif
+#ifdef BS1
+# undef 
+#endif
 #ifdef MDMBUF
 # undef MDMBUF
 #endif
@@ -284,31 +324,25 @@ enum __ioctl_datum { IOC_8, IOC_16, IOC_
 #define		ODDP		0x00000040	/* get/send odd parity */
 #define		EVENP		0x00000080	/* get/send even parity */
 #define		ANYP		0x000000c0	/* get any parity/send none */
-#define		NLDLY		0x00000300	/* \n delay */
-#define		NLDELAY		NLDLY		/* traditional BSD name */
+#define		NLDELAY		0x00000300	/* \n delay */
 #define			NL0	0x00000000
 #define			NL1	0x00000100	/* tty 37 */
 #define			NL2	0x00000200	/* vt05 */
 #define			NL3	0x00000300
-#define		TABDLY		0x00000c00	/* horizontal tab delay */
-#define		TBDELAY		TABDLY		/* traditional BSD name */
+#define		TBDELAY		0x00000c00	/* horizontal tab delay */
 #define			TAB0	0x00000000
 #define			TAB1	0x00000400	/* tty 37 */
 #define			TAB2	0x00000800
-#define			TAB3	0x00000c00
 #define		XTABS		0x00000c00	/* expand tabs on output */
-#define		CRDLY		0x00003000	/* \r delay */
-#define		CRDELAY		CRDLY		/* traditional BSD name */
+#define		CRDELAY		0x00003000	/* \r delay */
 #define			CR0	0x00000000
 #define			CR1	0x00001000	/* tn 300 */
 #define			CR2	0x00002000	/* tty 37 */
 #define			CR3	0x00003000	/* concept 100 */
-#define		VTDLY		0x00004000	/* vertical tab delay */
-#define		VTDELAY		VTDLY		/* traditional BSD name */
+#define		VTDELAY		0x00004000	/* vertical tab delay */
 #define			FF0	0x00000000
 #define			FF1	0x00004000	/* tty 37 */
-#define		BSDLY		0x00008000	/* \b delay */
-#define		BSDELAY		BSDLY		/* traditional BSD name */
+#define		BSDELAY		0x00008000	/* \b delay */
 #define			BS0	0x00000000
 #define			BS1	0x00008000
 #define		ALLDELAY	(NLDELAY|TBDELAY|CRDELAY|VTDELAY|BSDELAY)
Index: bits/termios.h
===================================================================
RCS file: /cvs/glibc/libc/bits/termios.h,v
retrieving revision 1.7
diff -u -p -r1.7 termios.h
--- bits/termios.h	26 Jul 2001 21:23:31 -0000	1.7
+++ bits/termios.h	7 Sep 2007 23:57:18 -0000
@@ -24,6 +24,50 @@
 /* These macros are also defined in some <bits/ioctls.h> files (with
    numerically identical values), but this serves to shut up cpp's
    complaining. */
+#if defined __USE_MISC || defined __USE_XOPEN
+
+# ifdef NL0
+#  undef 
+# endif
+# ifdef NL1
+#  undef 
+# endif
+# ifdef TAB0
+#  undef 
+# endif
+# ifdef TAB1
+#  undef 
+# endif
+# ifdef TAB2
+#  undef 
+# endif
+# ifdef CR0
+#  undef 
+# endif
+# ifdef CR1
+#  undef 
+# endif
+# ifdef CR2
+#  undef 
+# endif
+# ifdef CR3
+#  undef 
+# endif
+# ifdef FF0
+#  undef 
+# endif
+# ifdef FF1
+#  undef 
+# endif
+# ifdef BS0
+#  undef 
+# endif
+# ifdef BS1
+#  undef 
+# endif
+
+#endif /* __USE_MISC || __USE_XOPEN */
+
 #ifdef __USE_BSD
 
 # ifdef MDMBUF
@@ -93,12 +137,41 @@ struct termios
 #define	OPOST	(1 << 0)	/* Perform output processing.  */
 #ifdef	__USE_BSD
 # define ONLCR	(1 << 1)	/* Map NL to CR-NL on output.  */
-# define OXTABS	(1 << 2)	/* Expand tabs to spaces.  */
+# define OXTABS	TAB3		/* Expand tabs to spaces.  */
 # define ONOEOT	(1 << 3)	/* Discard EOT (^D) on output.  */
 #endif
+#if defined __USE_BSD || defined __USE_XOPEN
+# define OCRNL	(1 << 4)	/* Map CR to NL.  */
+# define ONOCR	(1 << 5)	/* Discard CR's when on column 0.  */
+# define ONLRET	(1 << 6)	/* Move to column 0 on NL.  */
+#endif
 #ifdef __USE_GNU
-# define OLCUC	(1 << 9)	/* Translate lower case output to upper case */
+# define OLCUC	(1 << 7)	/* Translate lower case output to upper case */
 #endif
+#if defined __USE_MISC || defined __USE_XOPEN
+# define NLDLY	(3 << 8)	/* NL delay.  */
+# define NL0	(0 << 8)	/* NL type 0.  */
+# define NL1	(1 << 8)	/* NL type 1.  */
+# define TABDLY	(3 << 10)	/* TAB delay.  */
+# define TAB0	(0 << 10)	/* TAB delay type 0.  */
+# define TAB1	(1 << 10)	/* TAB delay type 1.  */
+# define TAB2	(2 << 10)	/* TAB delay type 2.  */
+# define TAB3	(1 << 2)	/* Expand tabs to spaces.  */
+# define CRDLY	(3 << 12)	/* CR delay.  */
+# define CR0	(0 << 12)	/* CR delay type 0.  */
+# define CR1	(1 << 12)	/* CR delay type 1.  */
+# define CR2	(2 << 12)	/* CR delay type 2.  */
+# define CR3	(3 << 12)	/* CR delay type 3.  */
+# define FFDLY	(1 << 14)	/* FF delay.  */
+# define FF0	(0 << 14)	/* FF delay type 0.  */
+# define FF1	(1 << 14)	/* FF delay type 1.  */
+# define BSDLY	(1 << 15)	/* BS delay.  */
+# define BS0	(0 << 15)	/* BS delay type 0.  */
+# define BS1	(1 << 15)	/* BS delay type 1.  */
+#endif /* __USE_MISC || __USE_XOPEN */
+#define VTDLY	(1 << 20)	/* VT delay.  */
+#define VT0	(0 << 20)	/* VT delay type 0.  */
+#define VT1	(1 << 20)	/* VT delay type 1.  */
 
   /* Control modes.  */
   tcflag_t c_cflag;
@@ -216,6 +289,12 @@ struct termios
 # define EXTA	19200
 # define EXTB	38400
 #endif
+#ifdef	__USE_BSD
+#define B7200	7200
+#define B14400	14400
+#define B28800	28800
+#define B76800	76800
+#endif
 #define	B57600	57600
 #define	B115200	115200
 #define	B230400	230400


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]