From 303057f8c96eb799491aeedf20280cfb148f87bd Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Wed, 24 Apr 2019 09:46:55 +0200
Subject: [PATCH 2/2] WIP <unistd.h>: Bump _POSIX_*, _POSIX2_* and _XOPEN_*

---
 include/unistd.h              | 22 +++++++--------
 sys/sys/unistd.h              | 53 ++++++++++++++++++++---------------
 usr.bin/getconf/sysconf.gperf |  1 +
 3 files changed, 42 insertions(+), 34 deletions(-)

diff --git a/include/unistd.h b/include/unistd.h
index 6c6482bf6a..adf4ae0efe 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -106,21 +106,21 @@ typedef	__uint32_t	uid_t;		/* XXX __uid_t */
  * the POSIX standard; however, if the relevant sysconf() function
  * returns -1, the functions may be stubbed out.
  */
-#define	_POSIX_READER_WRITER_LOCKS	200112L	/* mandatory ([THR]) */
+#define	_POSIX_READER_WRITER_LOCKS	200809L	/* mandatory ([THR]) */
 #define	_POSIX_REGEXP			1	/* mandatory */
 #define	_POSIX_SHELL			1	/* mandatory */
-#define	_POSIX_SPAWN			200112L	/* [SPN] */
-#define	_POSIX_THREAD_ATTR_STACKADDR	200112L	/* [TSA] */
-#define	_POSIX_THREAD_ATTR_STACKSIZE	200112L	/* [TSS] */
-#define	_POSIX_THREAD_PRIO_INHERIT	200112L	/* [TPI] */
-#define	_POSIX_THREAD_PRIO_PROTECT	200112L	/* [TPP] */
-#define	_POSIX_THREAD_PRIORITY_SCHEDULING 200112L /* [TPS] */
+#define	_POSIX_SPAWN			200809L	/* [SPN] */
+#define	_POSIX_THREAD_ATTR_STACKADDR	200809L	/* [TSA] */
+#define	_POSIX_THREAD_ATTR_STACKSIZE	200809L	/* [TSS] */
+#define	_POSIX_THREAD_PRIO_INHERIT	200809L	/* [TPI] */
+#define	_POSIX_THREAD_PRIO_PROTECT	200809L	/* [TPP] */
+#define	_POSIX_THREAD_PRIORITY_SCHEDULING 200809L /* [TPS] */
 #define	_POSIX_THREAD_PROCESS_SHARED	-1	/* [TSH] */
 #define	_POSIX_THREAD_ROBUST_PRIO_INHERIT -1	/* [RPI] */
 #define	_POSIX_THREAD_ROBUST_PRIO_PROTECT -1	/* [RPP] */
-#define	_POSIX_THREAD_SAFE_FUNCTIONS	200112L	/* mandatory ([TSF]) */
+#define	_POSIX_THREAD_SAFE_FUNCTIONS	200809L	/* mandatory ([TSF]) */
 #define	_POSIX_THREAD_SPORADIC_SERVER	-1	/* [TSP] */
-#define	_POSIX_THREADS			200112L	/* mandatory ([THR]) */
+#define	_POSIX_THREADS			200809L	/* mandatory ([THR]) */
 #define	_POSIX_TRACE			-1	/* [TRC] obsolescent */
 #define	_POSIX_TRACE_EVENT_FILTER	-1	/* [TEF] obsolescent */
 #define	_POSIX_TRACE_INHERIT		-1	/* [TRI] obsolescent */
@@ -158,11 +158,9 @@ typedef	__uint32_t	uid_t;		/* XXX __uid_t */
 #define	_XOPEN_REALTIME			-1	/* missing: [ML] and [SIO] */
 #define	_XOPEN_REALTIME_THREADS		-1	/* missing: [RPI] and [RPP] */
 #define	_XOPEN_UNIX			-1
+#define	_XOPEN_UUCP			-1	/* [UU] */
 #endif
 
-/* Define the POSIX.2 version we target for compliance. */
-#define	_POSIX2_VERSION		199212L
-
 /*
  * POSIX-style system configuration variable accessors (for the
  * sysconf function).  The kernel does not directly implement the
diff --git a/sys/sys/unistd.h b/sys/sys/unistd.h
index 7e58352740..b7bdd2ac1b 100644
--- a/sys/sys/unistd.h
+++ b/sys/sys/unistd.h
@@ -36,6 +36,17 @@
 #include <sys/cdefs.h>
 #include <sys/types.h>
 
+/* Define the POSIX.1, POSIX.2 and XPG versions we target for compliance. */
+#ifndef _POSIX_VERSION
+#define	_POSIX_VERSION		200809L
+#endif
+#ifndef _POSIX2_VERSION
+#define	_POSIX2_VERSION		200809L
+#endif
+#ifndef _XOPEN_VERSION
+#define	_XOPEN_VERSION		700
+#endif
+
 /*
  * POSIX options and option groups we unconditionally do or don't
  * implement.  Those options which are implemented (or not) entirely
@@ -52,39 +63,40 @@
  */
 #define	_POSIX_ADVISORY_INFO		-1	/* [ADV] */
 #define	_POSIX_ASYNCHRONOUS_IO		0	/* mandatory ([AIO]) */
-#define	_POSIX_BARRIERS			200112L	/* mandatory ([BAR]) */
+#define	_POSIX_BARRIERS			200809L	/* mandatory ([BAR]) */
 #define	_POSIX_CHOWN_RESTRICTED		1
 #define	_POSIX_CLOCK_SELECTION		-1	/* XXX mandatory ([CS]) */
-#define	_POSIX_CPUTIME			200112L	/* [CPT] */
-#define	_POSIX_FSYNC			200112L	/* [FSC] */
+#define	_POSIX_CPUTIME			200809L	/* [CPT] */
+#define	_POSIX_FSYNC			200809L	/* [FSC] */
 #define	_POSIX_IPV6			0
 #define	_POSIX_JOB_CONTROL		1	/* mandatory */
-#define	_POSIX_MAPPED_FILES		200112L	/* mandatory ([MF]) */
+#define	_POSIX_MAPPED_FILES		200809L	/* mandatory ([MF]) */
 #define	_POSIX_MEMLOCK			-1	/* [ML] */
-#define	_POSIX_MEMLOCK_RANGE		200112L	/* [MLR] */
-#define	_POSIX_MEMORY_PROTECTION	200112L	/* mandatory ([MPR]) */
-#define	_POSIX_MESSAGE_PASSING		200112L	/* [MSG] */
-#define	_POSIX_MONOTONIC_CLOCK		200112L	/* [MON] */
+#define	_POSIX_MEMLOCK_RANGE		200809L	/* [MLR] */
+#define	_POSIX_MEMORY_PROTECTION	200809L	/* mandatory ([MPR]) */
+#define	_POSIX_MESSAGE_PASSING		200809L	/* [MSG] */
+#define	_POSIX_MONOTONIC_CLOCK		200809L	/* [MON] */
 #define	_POSIX_NO_TRUNC			1
 #define	_POSIX_PRIORITIZED_IO		-1	/* [PIO] */
-#define	_POSIX_PRIORITY_SCHEDULING	200112L	/* [PS] */
-#define	_POSIX_RAW_SOCKETS		200112L	/* [RS] */
-#define	_POSIX_REALTIME_SIGNALS		200112L	/* mandatory ([RTS]) */
-#define	_POSIX_SEMAPHORES		200112L	/* mandatory ([SEM]) */
-#define	_POSIX_SHARED_MEMORY_OBJECTS	200112L	/* [SHM] */
-#define	_POSIX_SPIN_LOCKS		200112L	/* mandatory ([SPI]) */
+#define	_POSIX_PRIORITY_SCHEDULING	200809L	/* [PS] */
+#define	_POSIX_RAW_SOCKETS		200809L	/* [RS] */
+#define	_POSIX_REALTIME_SIGNALS		200809L	/* mandatory ([RTS]) */
+#define	_POSIX_SEMAPHORES		200809L	/* mandatory ([SEM]) */
+#define	_POSIX_SHARED_MEMORY_OBJECTS	200809L	/* [SHM] */
+#define	_POSIX_SPIN_LOCKS		200809L	/* mandatory ([SPI]) */
 #define	_POSIX_SPORADIC_SERVER		-1	/* [SS] */
 #define	_POSIX_SYNCHRONIZED_IO		-1	/* [SIO] */
-#define	_POSIX_THREAD_CPUTIME		200112L	/* [TCT] */
-#define	_POSIX_TIMEOUTS			200112L	/* mandatory ([TMO]) */
-#define	_POSIX_TIMERS			200112L	/* XXX mandatory ([TMR]) */
+#define	_POSIX_THREAD_CPUTIME		200809L	/* [TCT] */
+#define	_POSIX_TIMEOUTS			200809L	/* mandatory ([TMO]) */
+#define	_POSIX_TIMERS			200809L	/* XXX mandatory ([TMR]) */
 #define	_POSIX_TYPED_MEMORY_OBJECTS	-1	/* [TYM] */
-#define	_POSIX_VDISABLE			0xff
 
 #if __XSI_VISIBLE
 #define	_XOPEN_SHM			1
+#if __XSI_VISIBLE >= 700
 #define	_XOPEN_STREAMS			-1	/* [XSR] obsolescent */
 #endif
+#endif
 
 /*
  * Although we have saved user/group IDs, we do not use them in setuid
@@ -98,10 +110,7 @@
 #define	_POSIX_SAVED_IDS	1 /* saved set-user-ID and set-group-ID */
 #endif
 
-/* Define the POSIX.1 version we target for compliance. */
-#ifndef _POSIX_VERSION
-#define	_POSIX_VERSION		200112L
-#endif
+#define	_POSIX_VDISABLE			0xff
 
 /* access function */
 #define	F_OK		0	/* test for existence of file */
diff --git a/usr.bin/getconf/sysconf.gperf b/usr.bin/getconf/sysconf.gperf
index 9efac8b8d5..1591f48f68 100644
--- a/usr.bin/getconf/sysconf.gperf
+++ b/usr.bin/getconf/sysconf.gperf
@@ -154,6 +154,7 @@ _XOPEN_REALTIME_THREADS, _SC_XOPEN_REALTIME_THREADS
 _XOPEN_SHM, _SC_XOPEN_SHM
 _XOPEN_STREAMS, _SC_XOPEN_STREAMS
 _XOPEN_UNIX, _SC_XOPEN_UNIX
+_XOPEN_UUCP, _SC_XOPEN_UUCP
 _XOPEN_VERSION, _SC_XOPEN_VERSION
 _XOPEN_XCU_VERSION, _SC_XCU_VERSION
 %%
-- 
2.21.0

