This is the mail archive of the newlib@sourceware.org mailing list for the newlib 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]

[PATCH 2/2] cygwin: make POSIX/XSI version macros dependent on feature test macros


Each version of SUS specifies a different value for _POSIX_VERSION,
_POSIX2_VERSION, and _XOPEN_VERSION.  glibc also changes the value
of the other _POSIX2_ variables but not the _POSIX_* variables.

_POSIX_TIMERS should be set to a version number, not just 1.

The _POSIX_V7_* macros were missing, which was not noticed because
the V6 values were aliased in sysconf (<unistd.h>).

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
---
 newlib/libc/include/sys/features.h | 35 +++++++++++++++++++++++------------
 1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/newlib/libc/include/sys/features.h b/newlib/libc/include/sys/features.h
index 86297de..4cf1b28 100644
--- a/newlib/libc/include/sys/features.h
+++ b/newlib/libc/include/sys/features.h
@@ -382,10 +382,9 @@ extern "C" {
 
 #ifdef __CYGWIN__
 
-#if !defined(__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L
-#define _POSIX_VERSION				200809L
-#define _POSIX2_VERSION				200809L
-#define _XOPEN_VERSION				   600
+#if __POSIX_VISIBLE
+#define _POSIX_VERSION				(long)__POSIX_VISIBLE
+#endif
 
 #define _POSIX_ADVISORY_INFO			200809L
 /* #define _POSIX_ASYNCHRONOUS_IO		    -1 */
@@ -428,16 +427,20 @@ extern "C" {
 /* #define _POSIX_THREAD_SPORADIC_SERVER	    -1 */
 #define _POSIX_THREADS				200809L
 /* #define _POSIX_TIMEOUTS			    -1 */
-#define _POSIX_TIMERS				     1
+#define _POSIX_TIMERS				200809L
 /* #define _POSIX_TRACE				    -1 */
 /* #define _POSIX_TRACE_EVENT_FILTER		    -1 */
 /* #define _POSIX_TRACE_INHERIT			    -1 */
 /* #define _POSIX_TRACE_LOG			    -1 */
 /* #define _POSIX_TYPED_MEMORY_OBJECTS		    -1 */
 #define _POSIX_VDISABLE				   '\0'
-#define _POSIX2_C_BIND				200809L
-#define _POSIX2_C_DEV				200809L
-#define _POSIX2_CHAR_TERM			200809L
+
+#if __POSIX_VISIBLE >= 2
+#define _POSIX2_VERSION				(long)__POSIX_VISIBLE
+#define _POSIX2_C_VERSION			_POSIX2_VERSION
+#define _POSIX2_C_BIND				_POSIX2_VERSION
+#define _POSIX2_C_DEV				_POSIX2_VERSION
+#define _POSIX2_CHAR_TERM			_POSIX2_VERSION
 /* #define _POSIX2_FORT_DEV			    -1 */
 /* #define _POSIX2_FORT_RUN			    -1 */
 /* #define _POSIX2_LOCALEDEF			    -1 */
@@ -447,8 +450,10 @@ extern "C" {
 /* #define _POSIX2_PBS_LOCATE			    -1 */
 /* #define _POSIX2_PBS_MESSAGE			    -1 */
 /* #define _POSIX2_PBS_TRACK			    -1 */
-#define _POSIX2_SW_DEV				200809L
-#define _POSIX2_UPE				200809L
+#define _POSIX2_SW_DEV				_POSIX2_VERSION
+#define _POSIX2_UPE				_POSIX2_VERSION
+#endif /* __POSIX_VISIBLE >= 2 */
+
 #define _POSIX_V6_ILP32_OFF32			    -1
 #ifdef __LP64__
 #define _POSIX_V6_ILP32_OFFBIG			    -1
@@ -459,10 +464,17 @@ extern "C" {
 #define _POSIX_V6_LP64_OFF64			    -1
 #define _POSIX_V6_LPBIG_OFFBIG			    -1
 #endif
+#define _POSIX_V7_ILP32_OFF32			_POSIX_V6_ILP32_OFF32
+#define _POSIX_V7_ILP32_OFFBIG			_POSIX_V6_ILP32_OFFBIG
+#define _POSIX_V7_LP64_OFF64			_POSIX_V6_LP64_OFF64
+#define _POSIX_V7_LPBIG_OFFBIG			_POSIX_V6_LPBIG_OFFBIG
 #define _XBS5_ILP32_OFF32			_POSIX_V6_ILP32_OFF32
 #define _XBS5_ILP32_OFFBIG			_POSIX_V6_ILP32_OFFBIG
 #define _XBS5_LP64_OFF64			_POSIX_V6_LP64_OFF64
 #define _XBS5_LPBIG_OFFBIG			_POSIX_V6_LPBIG_OFFBIG
+
+#if __XSI_VISIBLE
+#define _XOPEN_VERSION				__XSI_VISIBLE
 #define _XOPEN_CRYPT				     1
 #define _XOPEN_ENH_I18N				     1
 /* #define _XOPEN_LEGACY			    -1 */
@@ -471,8 +483,7 @@ extern "C" {
 #define _XOPEN_SHM				     1
 /* #define _XOPEN_STREAMS			    -1 */
 /* #define _XOPEN_UNIX				    -1 */
-
-#endif /* !__STRICT_ANSI__ || __cplusplus || __STDC_VERSION__ >= 199901L */
+#endif /* __XSI_VISIBLE */
 
 /* The value corresponds to UNICODE version 4.0, which is the version
    supported by XP.  Newlib supports 5.2 (2011) but so far Cygwin needs
-- 
2.7.4


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