tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

misuse of _XOPEN_SOURCE in headers?



There are some places in our headers where _XOPEN_SOURCE
is checked against the values 3 or 4.
As I understand our <sys/featuretest.h>, susv3 and the
standards(5) manpages of OSF1 and Solaris, _XOPEN_SOURCE
should be either not defined at all, just defined (meaning
XSH4.2 or so), or defined to a value >=500.
Now some source just defining _XOPEN_SOURCE, which should
give access to XSH4.2 functions, doesn't get definitions
protected by eg "(_XOPEN_SOURCE - 0) >= 4".

I'm not a standards expert; the best I can suggest is to
clean that stuff up, see the appended patch.

best regards
Matthias





-------------------------------------------------------------------
-------------------------------------------------------------------
Forschungszentrum Juelich GmbH
52425 Juelich

Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzende des Aufsichtsrats: MinDir'in Baerbel Brumme-Bothe
Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
Dr. Ulrich Krafft (stellv. Vorsitzender), Prof. Dr. Harald Bolt,
Dr. Sebastian M. Schmidt
-------------------------------------------------------------------
-------------------------------------------------------------------
#
# old_revision [3dbce43c2b9181ef74c43650dcf06557f4bf0e05]
#
# patch "include/stdlib.h"
#  from [88587e8ce3d55c5347354cf95f9b9645aed4ec24]
#    to [52e457853e469c2bc62ff94d083fe1544f21607d]
# 
# patch "include/time.h"
#  from [5a467972d6ced07b05059a2d8734368774d4f61c]
#    to [f60c17a63404186d60a6ec3e1795c6d7c02ac0b7]
# 
# patch "include/unistd.h"
#  from [25d0161a650f3d01faf19f39fae34aba52d92c42]
#    to [bde0a15b46201cbfef82cdceb02aec5c28126da8]
# 
# patch "include/wordexp.h"
#  from [b19cc0c68f1d6192bfb14ad730cd6aae6be953f6]
#    to [7693915911c1705e5494f10f1d52f8b4f3a41489]
#
============================================================
--- include/stdlib.h    88587e8ce3d55c5347354cf95f9b9645aed4ec24
+++ include/stdlib.h    52e457853e469c2bc62ff94d083fe1544f21607d
@@ -148,7 +148,7 @@ int  rand_r(unsigned int *);
 /*
  * X/Open Portability Guide >= Issue 4
  */
-#if (_XOPEN_SOURCE - 0) >= 4 || defined(_NETBSD_SOURCE)
+#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
 double  drand48(void);
 double  erand48(unsigned short[3]);
 long    jrand48(unsigned short[3]);
============================================================
--- include/time.h      5a467972d6ced07b05059a2d8734368774d4f61c
+++ include/time.h      f60c17a63404186d60a6ec3e1795c6d7c02ac0b7
@@ -117,7 +117,7 @@ void tzset(void);
 /*
  * X/Open Portability Guide >= Issue 4
  */
-#if (_XOPEN_SOURCE - 0) >= 4 || defined(_NETBSD_SOURCE)
+#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
 extern int daylight;
 #ifndef __LIBC12_SOURCE__
 extern long int timezone __RENAME(__timezone13);
============================================================
--- include/unistd.h    25d0161a650f3d01faf19f39fae34aba52d92c42
+++ include/unistd.h    bde0a15b46201cbfef82cdceb02aec5c28126da8
@@ -147,7 +147,7 @@ ssize_t      write(int, const void *, size_t
 /*
  * IEEE Std 1003.2-92, adopted in X/Open Portability Guide Issue 4 and later
  */
-#if (_POSIX_C_SOURCE - 0) >= 2 || (_XOPEN_SOURCE - 0) >= 4 || \
+#if (_POSIX_C_SOURCE - 0) >= 2 || defined(_XOPEN_SOURCE) || \
     defined(_NETBSD_SOURCE)
 int     getopt(int, char * const [], const char *);
 
@@ -216,7 +216,7 @@ int  nice(int);
 /*
  * X/Open Portability Guide <= Issue 3
  */
-#if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0) <= 3
+#if defined(_XOPEN_SOURCE)
 int     rename(const char *, const char *) __RENAME(__posix_rename);
 #endif
 
@@ -224,7 +224,7 @@ int  rename(const char *, const char *) 
 /*
  * X/Open Portability Guide >= Issue 4
  */
-#if (_XOPEN_SOURCE - 0) >= 4 || defined(_NETBSD_SOURCE)
+#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
 __aconst char *crypt(const char *, const char *);
 int     encrypt(char *, int);
 char   *getpass(const char *);
============================================================
--- include/wordexp.h   b19cc0c68f1d6192bfb14ad730cd6aae6be953f6
+++ include/wordexp.h   7693915911c1705e5494f10f1d52f8b4f3a41489
@@ -67,7 +67,7 @@ typedef struct {
 #define        WRDE_BADVAL     2               /* undefined variable */
 #define        WRDE_CMDSUB     3               /* command substitution not 
allowed */
 #define        WRDE_NOSPACE    4               /* no memory for result */
-#if (_XOPEN_SOURCE - 0) >= 4 || defined(_NETBSD_SOURCE)
+#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
 #define        WRDE_NOSYS      5               /* obsolete, reserved */
 #endif
 #define        WRDE_SYNTAX     6               /* shell syntax error */


Home | Main Index | Thread Index | Old Index