[PATCH v2 4/4] Feature test macro overhaul
Yaakov Selkowitz
yselkowi@redhat.com
Tue Feb 23 03:26:00 GMT 2016
-------------- next part --------------
diff --git a/winsup/cygwin/include/cygwin/stdlib.h b/winsup/cygwin/include/cygwin/stdlib.h
index 62792cf..5d109a0 100644
--- a/winsup/cygwin/include/cygwin/stdlib.h
+++ b/winsup/cygwin/include/cygwin/stdlib.h
@@ -28,26 +28,34 @@ __uint32_t arc4random_uniform(__uint32_t);
const char *getprogname (void);
void setprogname (const char *);
-#ifndef __STRICT_ANSI__
+#if __GNU_VISIBLE
char *canonicalize_file_name (const char *);
+#endif
+#if __BSD_VISIBLE || __POSIX_VISIBLE > 200112
int unsetenv (const char *);
-#endif /*__STRICT_ANSI__*/
-#if !defined(__STRICT_ANSI__) || (__XSI_VISIBLE >= 500)
+#endif
+#if __BSD_VISIBLE || __SVID_SOURCE || __XSI_VISIBLE >= 4
char *initstate (unsigned seed, char *state, size_t size);
long random (void);
char *setstate (const char *state);
void srandom (unsigned);
#endif
-#ifndef __STRICT_ANSI__
+#if __XSI_VISIBLE
char *ptsname (int);
-int ptsname_r(int, char *, size_t);
-int getpt (void);
int grantpt (int);
int unlockpt (int);
-#endif /*__STRICT_ANSI__*/
+#endif
+#if __GNU_VISIBLE
+int ptsname_r(int, char *, size_t);
+int getpt (void);
+#endif
+#if __XSI_VISIBLE >= 600
int posix_openpt (int);
+#endif
+#if __POSIX_VISIBLE >= 200112
int posix_memalign (void **, size_t, size_t);
+#endif
#ifdef _COMPILING_NEWLIB
#define unsetenv UNUSED_unsetenv
@@ -55,7 +63,9 @@ int posix_memalign (void **, size_t, size_t);
#endif
extern _PTR memalign _PARAMS ((size_t, size_t));
+#if __BSD_VISIBLE || (__XSI_VISIBLE >= 4 && __POSIX_VISIBLE < 200112)
extern _PTR valloc _PARAMS ((size_t));
+#endif
#undef _malloc_r
#define _malloc_r(r, s) malloc (s)
diff --git a/winsup/cygwin/include/cygwin/time.h b/winsup/cygwin/include/cygwin/time.h
index 6a82ae6..1f8a989 100644
--- a/winsup/cygwin/include/cygwin/time.h
+++ b/winsup/cygwin/include/cygwin/time.h
@@ -24,17 +24,18 @@ time_t __cdecl timegm (struct tm *);
#define TIMER_RELTIME 0 /* For compatibility with HP/UX, Solaris, others? */
-#ifndef __STRICT_ANSI__
-
+#if __SVID_VISIBLE
extern int stime (const time_t *);
+#endif
+#if __SVID_VISIBLE || __XSI_VISIBLE
extern int daylight __asm__ (_SYMSTR (_daylight));
#ifndef __timezonefunc__
extern long timezone __asm__ (_SYMSTR (_timezone));
#endif
-#endif /*__STRICT_ANSI__*/
+#endif /* __SVID_VISIBLE || __XSI_VISIBLE */
#ifdef __cplusplus
}
diff --git a/winsup/cygwin/include/endian.h b/winsup/cygwin/include/endian.h
index d59d2c8..960e61c 100644
--- a/winsup/cygwin/include/endian.h
+++ b/winsup/cygwin/include/endian.h
@@ -12,6 +12,7 @@ details. */
#define _ENDIAN_H_
#include <sys/config.h>
+#include <sys/cdefs.h>
#include <bits/endian.h>
/*#ifdef __USE_BSD*/
@@ -27,7 +28,7 @@ details. */
# define __LONG_LONG_PAIR(HI, LO) HI, LO
#endif
-#if /*defined __USE_BSD ||*/ ! defined _POSIX_SOURCE
+#if __BSD_VISIBLE
#include <byteswap.h>
@@ -71,7 +72,7 @@ details. */
#endif /*__BYTE_ORDER == __BIG_ENDIAN*/
-#endif /*__USE_BSD || !_POSIX_SOURCE*/
+#endif /*__BSD_VISIBLE*/
#endif /*_ENDIAN_H_*/
diff --git a/winsup/cygwin/include/fenv.h b/winsup/cygwin/include/fenv.h
index b49033f..4976913 100644
--- a/winsup/cygwin/include/fenv.h
+++ b/winsup/cygwin/include/fenv.h
@@ -11,6 +11,8 @@ details. */
#ifndef _FENV_H_
#define _FENV_H_
+#include <sys/cdefs.h>
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -133,14 +135,14 @@ extern const fenv_t *_fe_dfl_env;
type "pointer to const-qualified fenv_t",may also be specified by
the implementation. */
-#ifdef _GNU_SOURCE
+#if __GNU_VISIBLE
/* If possible, the GNU C Library defines a macro FE_NOMASK_ENV which
represents an environment where every exception raised causes a trap
to occur. You can test for this macro using #ifdef. It is only defined
if _GNU_SOURCE is defined. */
extern const fenv_t *_fe_nomask_env;
#define FE_NOMASK_ENV (_fe_nomask_env)
-#endif /* _GNU_SOURCE */
+#endif /* __GNU_VISIBLE */
/* The following shall be declared as functions and may also be
diff --git a/winsup/cygwin/include/fnmatch.h b/winsup/cygwin/include/fnmatch.h
index e4500ab..556d3b1 100644
--- a/winsup/cygwin/include/fnmatch.h
+++ b/winsup/cygwin/include/fnmatch.h
@@ -39,21 +39,21 @@
#ifndef _FNMATCH_H_
#define _FNMATCH_H_
+#include <sys/cdefs.h>
+
#define FNM_NOMATCH 1 /* Match failed. */
#define FNM_NOSYS 2 /* Function not supported (unused). */
#define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */
#define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */
#define FNM_PERIOD 0x04 /* Period must be matched by period. */
-#ifndef _POSIX_SOURCE
+#if __GNU_VISIBLE
#define FNM_LEADING_DIR 0x08 /* Ignore /<tail> after Imatch. */
#define FNM_CASEFOLD 0x10 /* Case insensitive search. */
#define FNM_IGNORECASE FNM_CASEFOLD
#define FNM_FILE_NAME FNM_PATHNAME
#endif
-#include <sys/cdefs.h>
-
__BEGIN_DECLS
int fnmatch __P((const char *, const char *, int));
__END_DECLS
diff --git a/winsup/cygwin/include/glob.h b/winsup/cygwin/include/glob.h
index 5f1b420..0376cc3 100644
--- a/winsup/cygwin/include/glob.h
+++ b/winsup/cygwin/include/glob.h
@@ -80,7 +80,7 @@ typedef struct {
#define GLOB_NOMATCH (-3) /* No match and GLOB_NOCHECK was not set. */
#define GLOB_NOSYS (-4) /* Obsolete: source comptability only. */
-#ifndef _POSIX_SOURCE
+#if __GNU_VISIBLE
#define GLOB_ALTDIRFUNC 0x0040 /* Use alternately specified directory funcs. */
#define GLOB_BRACE 0x0080 /* Expand braces ala csh. */
#define GLOB_MAGCHAR 0x0100 /* Pattern had globbing characters. */
@@ -92,7 +92,7 @@ typedef struct {
/* source compatibility, these are the old names */
#define GLOB_MAXPATH GLOB_LIMIT
#define GLOB_ABEND GLOB_ABORTED
-#endif /* __BSD_VISIBLE */
+#endif /* __GNU_VISIBLE */
__BEGIN_DECLS
diff --git a/winsup/cygwin/include/limits.h b/winsup/cygwin/include/limits.h
index e093d28..c17cd0a 100644
--- a/winsup/cygwin/include/limits.h
+++ b/winsup/cygwin/include/limits.h
@@ -110,7 +110,7 @@ details. */
#define __LONG_LONG_MAX__ 9223372036854775807LL
#endif
-#if defined (__GNU_LIBRARY__) ? defined (__USE_GNU) : !defined (__STRICT_ANSI__)
+#if __GNU_VISIBLE
#undef LONG_LONG_MIN
#define LONG_LONG_MIN (-LONG_LONG_MAX-1)
#undef LONG_LONG_MAX
diff --git a/winsup/cygwin/include/sys/dirent.h b/winsup/cygwin/include/sys/dirent.h
index 46c34ab..dd02617 100644
--- a/winsup/cygwin/include/sys/dirent.h
+++ b/winsup/cygwin/include/sys/dirent.h
@@ -12,6 +12,7 @@
#ifndef _SYS_DIRENT_H
#define _SYS_DIRENT_H
+#include <sys/cdefs.h>
#include <sys/types.h>
#include <limits.h>
@@ -72,22 +73,28 @@ int closedir (DIR *);
int dirfd (DIR *);
-#ifndef _POSIX_SOURCE
+#if __MISC_VISIBLE || __XSI_VISIBLE
#ifndef __INSIDE_CYGWIN__
long telldir (DIR *);
void seekdir (DIR *, long loc);
#endif
+#endif
+#if __MISC_VISIBLE || __POSIX_VISIBLE >= 200809
int scandir (const char *__dir,
struct dirent ***__namelist,
int (*select) (const struct dirent *),
int (*compar) (const struct dirent **, const struct dirent **));
+int alphasort (const struct dirent **__a, const struct dirent **__b);
+#endif
+#if __GNU_VISIBLE
int scandirat (int __dirfd, const char *__dir, struct dirent ***__namelist,
int (*select) (const struct dirent *),
int (*compar) (const struct dirent **, const struct dirent **));
+#endif
-int alphasort (const struct dirent **__a, const struct dirent **__b);
+#if __BSD_VISIBLE
#ifdef _DIRENT_HAVE_D_TYPE
/* File types for `d_type'. */
enum
@@ -116,5 +123,5 @@ enum
# define IFTODT(mode) (((mode) & 0170000) >> 12)
# define DTTOIF(dirtype) ((dirtype) << 12)
#endif /* _DIRENT_HAVE_D_TYPE */
-#endif /* _POSIX_SOURCE */
+#endif /* __BSD_VISIBLE */
#endif /*_SYS_DIRENT_H*/
diff --git a/winsup/cygwin/libc/fnmatch.c b/winsup/cygwin/libc/fnmatch.c
index 8c38678..fc43765 100644
--- a/winsup/cygwin/libc/fnmatch.c
+++ b/winsup/cygwin/libc/fnmatch.c
@@ -38,6 +38,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)fnmatch.c 8.2 (Berkeley) 4/16/94";
#endif /* LIBC_SCCS and not lint */
+#include "winsup.h"
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/lib/libc/gen/fnmatch.c 288309 2015-09-27 12:52:18Z jilles $");
diff --git a/winsup/cygwin/libc/strfmon.c b/winsup/cygwin/libc/strfmon.c
index d06bbab..91f0f84 100644
--- a/winsup/cygwin/libc/strfmon.c
+++ b/winsup/cygwin/libc/strfmon.c
@@ -25,12 +25,12 @@
*
*/
-#include <sys/cdefs.h>
#if 0
__FBSDID("$FreeBSD: src/lib/libc/stdlib/strfmon.c,v 1.19 2008/04/24 07:49:00 ru Exp $");
#endif
#include "winsup.h"
+#include <sys/cdefs.h>
#include <sys/types.h>
#include <ctype.h>
#include <errno.h>
More information about the Newlib
mailing list