From 9c9fc8be39a6814e77a4acb68423219995e7570f Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Mon, 18 Mar 2019 08:50:06 +0100
Subject: [PATCH] WIP: Move <sys/termios.h> to <termios.h>. Not really needed
 by the kernel.

---
 Makefile_upgrade.inc           |  1 +
 include/Makefile               |  7 ++-----
 {sys/sys => include}/termios.h | 10 +++-------
 sys/conf/kern.fwd.mk           |  3 +--
 sys/sys/_termios.h             |  4 ++++
 sys/sys/param.h                |  3 ++-
 sys/sys/tty.h                  | 17 +++++------------
 7 files changed, 18 insertions(+), 27 deletions(-)
 rename {sys/sys => include}/termios.h (95%)

diff --git a/Makefile_upgrade.inc b/Makefile_upgrade.inc
index 903f1ddf6c..5d9c772bc1 100644
--- a/Makefile_upgrade.inc
+++ b/Makefile_upgrade.inc
@@ -3502,6 +3502,7 @@ TO_REMOVE+=/usr/include/sys/semaphore.h
 TO_REMOVE+=/usr/share/man/man2/brk.2.gz
 TO_REMOVE+=/usr/share/man/man1/ld-elf.so.1.1.gz
 TO_REMOVE+=/usr/share/misc/man.template
+TO_REMOVE+=/usr/include/sys/termios.h
 
 .if !defined(WANT_INSTALLER)
 TO_REMOVE+=/usr/sbin/dfuibe_installer
diff --git a/include/Makefile b/include/Makefile
index 8d53d7cff6..ce67c70927 100644
--- a/include/Makefile
+++ b/include/Makefile
@@ -23,9 +23,7 @@ INCS=	a.out.h ar.h assert.h bitstring.h cpio.h ctype.h db.h \
 	stdalign.h stdarg.h stdbool.h \
 	stddef.h stdint.h stdio.h stdlib.h stdnoreturn.h \
 	string.h stringlist.h strings.h sysexits.h \
-	tar.h time.h \
-	timeconv.h \
-	timers.h ttyent.h \
+	tar.h termios.h time.h timeconv.h timers.h ttyent.h \
 	uchar.h unistd.h ulimit.h utime.h utmp.h utmpx.h \
 	uuid.h vis.h \
 	wchar.h wctype.h wordexp.h xlocale.h
@@ -37,8 +35,7 @@ INCS+=	hesiod.h
 # Only for default SHARED=copies case
 SHDRS=	soundcard.h joystick.h
 
-LHDRS=	aio.h errno.h fcntl.h linker_set.h poll.h sched.h \
-	syslog.h termios.h ucontext.h
+LHDRS=	aio.h errno.h fcntl.h linker_set.h poll.h sched.h syslog.h ucontext.h
 
 # directories which also contain header files that need to be copied.
 # Other directories, like 'bus' and 'netproto', are created using mtree.
diff --git a/sys/sys/termios.h b/include/termios.h
similarity index 95%
rename from sys/sys/termios.h
rename to include/termios.h
index 698d457b60..f33cc229b0 100644
--- a/sys/sys/termios.h
+++ b/include/termios.h
@@ -30,8 +30,8 @@
  * $FreeBSD: src/sys/sys/termios.h,v 1.13.2.1 2001/03/06 06:31:44 jhb Exp $
  */
 
-#ifndef _SYS_TERMIOS_H_
-#define	_SYS_TERMIOS_H_
+#ifndef _TERMIOS_H_
+#define	_TERMIOS_H_
 
 #include <sys/cdefs.h>
 #include <sys/_termios.h>
@@ -42,10 +42,6 @@ typedef	__pid_t pid_t;
 #define	_PID_T_DECLARED
 #endif
 
-#if __BSD_VISIBLE
-#define	CCEQ(val, c)	((c) == (val) ? (val) != _POSIX_VDISABLE : 0)
-#endif
-
 /*
  * Commands passed to tcsetattr() for setting the termios structure.
  */
@@ -101,7 +97,7 @@ __END_DECLS
 /*
  * END OF PROTECTED INCLUDE.
  */
-#endif /* !_SYS_TERMIOS_H_ */
+#endif /* !_TERMIOS_H_ */
 
 #if __BSD_VISIBLE
 #include <sys/ttydefaults.h>
diff --git a/sys/conf/kern.fwd.mk b/sys/conf/kern.fwd.mk
index 3257218419..4dc98c7609 100644
--- a/sys/conf/kern.fwd.mk
+++ b/sys/conf/kern.fwd.mk
@@ -23,8 +23,7 @@ ${_fwd}: ${_h}
 # mimic a standard user include topology.  Only the virtual kernel
 # build uses these.  e.g. in order for #include <fcntl.h> to work.
 #
-_lhdrs= aio.h errno.h fcntl.h linker_set.h poll.h syslog.h \
-	termios.h ucontext.h
+_lhdrs= aio.h errno.h fcntl.h linker_set.h poll.h syslog.h ucontext.h
 _LHDRS=
 .for _h in ${_lhdrs}
 _fwd:=	${_MACHINE_FWD}/include/${_h}
diff --git a/sys/sys/_termios.h b/sys/sys/_termios.h
index 582e96562d..440f6878c3 100644
--- a/sys/sys/_termios.h
+++ b/sys/sys/_termios.h
@@ -222,4 +222,8 @@ struct termios {
 	speed_t		c_ospeed;	/* output speed */
 };
 
+#if __BSD_VISIBLE
+#define	CCEQ(val, c)	((c) == (val) ? (val) != _POSIX_VDISABLE : 0)
+#endif
+
 #endif /* !_SYS__TERMIOS_H_ */
diff --git a/sys/sys/param.h b/sys/sys/param.h
index 3d89690b6b..321232dc81 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -196,9 +196,10 @@
  *	    had to be rewritten.  libc brk() removed entirely.  These changes
  *	    are required to allow mmap hints to utilize lowered data rlimits.
  * 500504 - removed <sys/semaphore.h>, only <semaphore.h> remains
+ * 500505 - rename <sys/termios.h> to <termios.h>
  */
 #undef __DragonFly_version
-#define __DragonFly_version 500504	/* propagated to newvers */
+#define __DragonFly_version 500505	/* propagated to newvers */
 
 #include <sys/_null.h>
 
diff --git a/sys/sys/tty.h b/sys/sys/tty.h
index 4829ace9d8..de90b5e5a7 100644
--- a/sys/sys/tty.h
+++ b/sys/sys/tty.h
@@ -33,22 +33,11 @@
  *
  *	@(#)tty.h	8.6 (Berkeley) 1/21/94
  * $FreeBSD: src/sys/sys/tty.h,v 1.53.2.1 2001/02/26 04:23:21 jlemon Exp $
- * $DragonFly: src/sys/sys/tty.h,v 1.12 2006/09/10 01:26:40 dillon Exp $
  */
 
 #ifndef _SYS_TTY_H_
 #define	_SYS_TTY_H_
 
-#ifndef _SYS_TERMIOS_H_
-#include <sys/termios.h>
-#endif
-#ifndef _SYS_EVENT_H_
-#include <sys/event.h>
-#endif
-#ifdef _KERNEL
-#include <sys/device.h>
-#endif
-
 /*
  * Clists are character lists, which is a variable length linked list
  * of cblocks, with a count of the number of characters in the list.
@@ -63,8 +52,12 @@ struct clist {
 
 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
 
-#ifndef _SYS_QUEUE_H_
+#include <sys/_termios.h>
+#include <sys/event.h>
 #include <sys/queue.h>
+#include <sys/ttycom.h>
+#ifdef _KERNEL
+#include <sys/device.h>
 #endif
 #ifndef _SYS_THREAD_H_
 #include <sys/thread.h>
-- 
2.21.0

