Subject: Question about ioctls.h

From: Martin Schulze <[email-masked]>
Date: Tue, 24 Jul 2001 01:03:43 +0200

Quoting <asm/ioctls.h>:

> #if defined(__USE_MISC) || defined (__KERNEL__)
> #define tIOC            ('t' << 8)
> #endif

Could somebody try to explain this to me?  I'm especially interested
in the #if part.  Why isn't tIOC defined normally?  It is used later.
in the file - and it is used externally by rp-pppoe for example.

Regards,

	Joey

-- 
All language designers are arrogant.  Goes with the territory...
	-- Larry Wall

---

From: Ralf Baechle <[email-masked]>
Date: Tue, 24 Jul 2001 01:27:58 +0200

> in the file - and it is used externally by rp-pppoe for example.

Overly paranoid attempt at keeping the namespace cleaner than Mr Proper
himself.

  Ralf

---

From: Ralf Baechle <[email-masked]>
Date: Tue, 24 Jul 2001 01:56:11 +0200

> Overly paranoid attempt at keeping the namespace cleaner than Mr Proper

Try the patch below.

  Ralf

Index: include/asm-mips64/ioctls.h
===================================================================
RCS file: /home/pub/cvs/linux/include/asm-mips64/ioctls.h,v
retrieving revision 1.2
diff -u -r1.2 ioctls.h
--- include/asm-mips64/ioctls.h	2001/07/09 00:25:38	1.2
+++ include/asm-mips64/ioctls.h	2001/07/23 23:55:09
@@ -3,17 +3,14 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 1995, 1996, 1999 by Ralf Baechle
+ * Copyright (C) 1995, 1996, 2001 Ralf Baechle
+ * Copyright (C) 2001 MIPS Technologies, Inc.
  */
-#ifndef _ASM_IOCTLS_H
-#define _ASM_IOCTLS_H
+#ifndef __ASM_IOCTLS_H
+#define __ASM_IOCTLS_H
 
 #include <asm/ioctl.h>
 
-#if defined(__USE_MISC) || defined (__KERNEL__)
-#define tIOC		('t' << 8)
-#endif
-
 #define TCGETA		0x5401
 #define TCSETA		0x5402
 #define TCSETAW		0x5403
@@ -37,31 +34,27 @@
 #define TIOCMBIC	0x741c		/* bic modem bits */
 #define TIOCMSET	0x741a		/* set all modem bits */
 #define TIOCPKT		0x5470		/* pty: set/clear packet mode */
-#define		TIOCPKT_DATA		0x00	/* data packet */
-#define		TIOCPKT_FLUSHREAD	0x01	/* flush packet */
-#define		TIOCPKT_FLUSHWRITE	0x02	/* flush packet */
-#define		TIOCPKT_STOP		0x04	/* stop output */
-#define		TIOCPKT_START		0x08	/* start output */
-#define		TIOCPKT_NOSTOP		0x10	/* no more ^S, ^Q */
-#define		TIOCPKT_DOSTOP		0x20	/* now do ^S ^Q */
-#if 0
-#define		TIOCPKT_IOCTL		0x40	/* state change of pty driver */
-#endif
+#define	 TIOCPKT_DATA		0x00	/* data packet */
+#define	 TIOCPKT_FLUSHREAD	0x01	/* flush packet */
+#define	 TIOCPKT_FLUSHWRITE	0x02	/* flush packet */
+#define	 TIOCPKT_STOP		0x04	/* stop output */
+#define	 TIOCPKT_START		0x08	/* start output */
+#define	 TIOCPKT_NOSTOP		0x10	/* no more ^S, ^Q */
+#define	 TIOCPKT_DOSTOP		0x20	/* now do ^S ^Q */
+/* #define  TIOCPKT_IOCTL		0x40	state change of pty driver */
 #define TIOCSWINSZ	_IOW('t', 103, struct winsize)	/* set window size */
 #define TIOCGWINSZ	_IOR('t', 104, struct winsize)	/* get window size */
 #define TIOCNOTTY	0x5471		/* void tty association */
-#define TIOCSETD	(tIOC | 1)
-#define TIOCGETD	(tIOC | 0)
+#define TIOCSETD	0x7401
+#define TIOCGETD	0x7400
 
 #define FIOCLEX		0x6601
 #define FIONCLEX	0x6602		/* these numbers need to be adjusted. */
 #define FIOASYNC	0x667d
 #define FIONBIO		0x667e
 
-#if defined(__USE_MISC) || defined (__KERNEL__)
-#define TIOCGLTC	(tIOC | 116)		/* get special local chars */
-#define TIOCSLTC	(tIOC | 117)		/* set special local chars */
-#endif
+#define TIOCGLTC	0x7474			/* get special local chars */
+#define TIOCSLTC	0x7475			/* set special local chars */
 #define TIOCSPGRP	_IOW('t', 118, int)	/* set pgrp of tty */
 #define TIOCGPGRP	_IOR('t', 119, int)	/* get pgrp of tty */
 #define TIOCCONS	_IOW('t', 120, int)	/* become virtual console */
@@ -69,20 +62,16 @@
 #define FIONREAD	0x467f
 #define TIOCINQ		FIONREAD
 
-#if defined(__USE_MISC) || defined (__KERNEL__)
-#define TIOCGETP        (tIOC | 8)
-#define TIOCSETP        (tIOC | 9)
-#define TIOCSETN        (tIOC | 10)		/* TIOCSETP wo flush */
-#endif
+#define TIOCGETP        0x7408
+#define TIOCSETP        0x7409
+#define TIOCSETN        0x740a			/* TIOCSETP wo flush */
  
-#if 0
-#define	TIOCSETA	_IOW('t', 20, struct termios) /* set termios struct */
-#define	TIOCSETAW	_IOW('t', 21, struct termios) /* drain output, set */
-#define	TIOCSETAF	_IOW('t', 22, struct termios) /* drn out, fls in, set */
-#define	TIOCGETD	_IOR('t', 26, int)	/* get line discipline */
-#define	TIOCSETD	_IOW('t', 27, int)	/* set line discipline */
+/* #define TIOCSETA	_IOW('t', 20, struct termios) set termios struct */
+/* #define TIOCSETAW	_IOW('t', 21, struct termios) drain output, set */
+/* #define TIOCSETAF	_IOW('t', 22, struct termios) drn out, fls in, set */
+/* #define TIOCGETD	_IOR('t', 26, int)	get line discipline */
+/* #define TIOCSETD	_IOW('t', 27, int)	set line discipline */
 						/* 127-124 compat */
-#endif
 
 /* I hope the range from 0x5480 on is free ... */
 #define TIOCSCTTY	0x5480		/* become controlling tty */
@@ -114,4 +103,4 @@
 #define TIOCGHAYESESP	0x5493 /* Get Hayes ESP configuration */
 #define TIOCSHAYESESP	0x5494 /* Set Hayes ESP configuration */
 
-#endif /* _ASM_IOCTLS_H */
+#endif /* __ASM_IOCTLS_H */
Index: include/asm-mips/ioctls.h
===================================================================
RCS file: /home/pub/cvs/linux/include/asm-mips/ioctls.h,v
retrieving revision 1.8
diff -u -r1.8 ioctls.h
--- include/asm-mips/ioctls.h	1998/08/25 09:21:56	1.8
+++ include/asm-mips/ioctls.h	2001/07/23 23:55:09
@@ -1,20 +1,16 @@
-/* $Id: ioctls.h,v 1.5 1998/08/19 21:58:11 ralf Exp $
- *
+/*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 1995, 1996 by Ralf Baechle
+ * Copyright (C) 1995, 1996, 2001 Ralf Baechle
+ * Copyright (C) 2001 MIPS Technologies, Inc.
  */
-#ifndef __ASM_MIPS_IOCTLS_H
-#define __ASM_MIPS_IOCTLS_H
+#ifndef __ASM_IOCTLS_H
+#define __ASM_IOCTLS_H
 
 #include <asm/ioctl.h>
 
-#if defined(__USE_MISC) || defined (__KERNEL__)
-#define tIOC		('t' << 8)
-#endif
-
 #define TCGETA		0x5401
 #define TCSETA		0x5402
 #define TCSETAW		0x5403
@@ -38,31 +34,27 @@
 #define TIOCMBIC	0x741c		/* bic modem bits */
 #define TIOCMSET	0x741a		/* set all modem bits */
 #define TIOCPKT		0x5470		/* pty: set/clear packet mode */
-#define		TIOCPKT_DATA		0x00	/* data packet */
-#define		TIOCPKT_FLUSHREAD	0x01	/* flush packet */
-#define		TIOCPKT_FLUSHWRITE	0x02	/* flush packet */
-#define		TIOCPKT_STOP		0x04	/* stop output */
-#define		TIOCPKT_START		0x08	/* start output */
-#define		TIOCPKT_NOSTOP		0x10	/* no more ^S, ^Q */
-#define		TIOCPKT_DOSTOP		0x20	/* now do ^S ^Q */
-#if 0
-#define		TIOCPKT_IOCTL		0x40	/* state change of pty driver */
-#endif
+#define	 TIOCPKT_DATA		0x00	/* data packet */
+#define	 TIOCPKT_FLUSHREAD	0x01	/* flush packet */
+#define	 TIOCPKT_FLUSHWRITE	0x02	/* flush packet */
+#define	 TIOCPKT_STOP		0x04	/* stop output */
+#define	 TIOCPKT_START		0x08	/* start output */
+#define	 TIOCPKT_NOSTOP		0x10	/* no more ^S, ^Q */
+#define	 TIOCPKT_DOSTOP		0x20	/* now do ^S ^Q */
+/* #define  TIOCPKT_IOCTL		0x40	state change of pty driver */
 #define TIOCSWINSZ	_IOW('t', 103, struct winsize)	/* set window size */
 #define TIOCGWINSZ	_IOR('t', 104, struct winsize)	/* get window size */
 #define TIOCNOTTY	0x5471		/* void tty association */
-#define TIOCSETD	(tIOC | 1)
-#define TIOCGETD	(tIOC | 0)
+#define TIOCSETD	0x7401
+#define TIOCGETD	0x7400
 
 #define FIOCLEX		0x6601
 #define FIONCLEX	0x6602		/* these numbers need to be adjusted. */
 #define FIOASYNC	0x667d
 #define FIONBIO		0x667e
 
-#if defined(__USE_MISC) || defined (__KERNEL__)
-#define TIOCGLTC	(tIOC | 116)		/* get special local chars */
-#define TIOCSLTC	(tIOC | 117)		/* set special local chars */
-#endif
+#define TIOCGLTC	0x7474			/* get special local chars */
+#define TIOCSLTC	0x7475			/* set special local chars */
 #define TIOCSPGRP	_IOW('t', 118, int)	/* set pgrp of tty */
 #define TIOCGPGRP	_IOR('t', 119, int)	/* get pgrp of tty */
 #define TIOCCONS	_IOW('t', 120, int)	/* become virtual console */
@@ -70,20 +62,16 @@
 #define FIONREAD	0x467f
 #define TIOCINQ		FIONREAD
 
-#if defined(__USE_MISC) || defined (__KERNEL__)
-#define TIOCGETP        (tIOC | 8)
-#define TIOCSETP        (tIOC | 9)
-#define TIOCSETN        (tIOC | 10)		/* TIOCSETP wo flush */
-#endif
+#define TIOCGETP        0x7408
+#define TIOCSETP        0x7409
+#define TIOCSETN        0x740a			/* TIOCSETP wo flush */
  
-#if 0
-#define	TIOCSETA	_IOW('t', 20, struct termios) /* set termios struct */
-#define	TIOCSETAW	_IOW('t', 21, struct termios) /* drain output, set */
-#define	TIOCSETAF	_IOW('t', 22, struct termios) /* drn out, fls in, set */
-#define	TIOCGETD	_IOR('t', 26, int)	/* get line discipline */
-#define	TIOCSETD	_IOW('t', 27, int)	/* set line discipline */
+/* #define TIOCSETA	_IOW('t', 20, struct termios) set termios struct */
+/* #define TIOCSETAW	_IOW('t', 21, struct termios) drain output, set */
+/* #define TIOCSETAF	_IOW('t', 22, struct termios) drn out, fls in, set */
+/* #define TIOCGETD	_IOR('t', 26, int)	get line discipline */
+/* #define TIOCSETD	_IOW('t', 27, int)	set line discipline */
 						/* 127-124 compat */
-#endif
 
 /* I hope the range from 0x5480 on is free ... */
 #define TIOCSCTTY	0x5480		/* become controlling tty */
@@ -115,4 +103,4 @@
 #define TIOCGHAYESESP	0x5493 /* Get Hayes ESP configuration */
 #define TIOCSHAYESESP	0x5494 /* Set Hayes ESP configuration */
 
-#endif /* __ASM_MIPS_IOCTLS_H */
+#endif /* __ASM_IOCTLS_H */

---

From: Martin Schulze <[email-masked]>
Date: Tue, 24 Jul 2001 10:04:18 +0200

> > Overly paranoid attempt at keeping the namespace cleaner than Mr Proper

Thanks, looks good and works well.  Somebody should commit it.

Regards,

	Joey

-- 
In the beginning was the word, and the word was content-type: text/plain

---

From: Ralf Baechle <[email-masked]>
Date: Tue, 24 Jul 2001 13:23:38 +0200

> Thanks, looks good and works well.  Somebody should commit it.

I immediately commited it for both 2.2 and 2.4, mips and mips64.  You can
follow the commits on the [email-masked] mailing lists.  Just
subscribe via Majordomo.

  Ralf