[PATCH v1 2/3] Feature test macro overhaul
Yaakov Selkowitz
yselkowitz@cygwin.com
Fri Feb 12 06:23:00 GMT 2016
On 2016-02-12 00:22, Yaakov Selkowitz wrote:
> Since the issue with our feature test macros keeps coming up, here's
> what I have so far. Obviously I still need to break it up into decent
> size commits, but I have tested it somewhat. Comments welcome.
Part two attached.
--
Yaakov
-------------- next part --------------
diff --git a/newlib/libc/include/ctype.h b/newlib/libc/include/ctype.h
index 56ad5ab..54843ea 100644
--- a/newlib/libc/include/ctype.h
+++ b/newlib/libc/include/ctype.h
@@ -2,6 +2,7 @@
#define _CTYPE_H_
#include "_ansi.h"
+#include <sys/cdefs.h>
_BEGIN_STD_C
@@ -19,11 +20,11 @@ int _EXFUN(isxdigit,(int __c));
int _EXFUN(tolower, (int __c));
int _EXFUN(toupper, (int __c));
-#if !defined(__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L
+#if __ISOC99_VISIBLE
int _EXFUN(isblank, (int __c));
#endif
-#ifndef __STRICT_ANSI__
+#if __MISC_VISIBLE || __XOPEN_VISIBLE
int _EXFUN(isascii, (int __c));
int _EXFUN(toascii, (int __c));
#define _tolower(__c) ((unsigned char)(__c) - 'A' + 'a')
@@ -68,8 +69,7 @@ extern __IMPORT char *__ctype_ptr__;
#define isgraph(__c) (__ctype_lookup(__c)&(_P|_U|_L|_N))
#define iscntrl(__c) (__ctype_lookup(__c)&_C)
-#if defined(__GNUC__) && \
- (!defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901L)
+#if defined(__GNUC__) && __ISOC99_VISIBLE
#define isblank(__c) \
__extension__ ({ __typeof__ (__c) __x = (__c); \
(__ctype_lookup(__x)&_B) || (int) (__x) == '\t';})
@@ -98,13 +98,14 @@ extern __IMPORT char *__ctype_ptr__;
(void) __ctype_ptr__[__x]; (tolower) (__x);})
# endif /* _MB_EXTENDED_CHARSETS* */
# endif /* __GNUC__ */
-#endif /* !__cplusplus */
-#ifndef __STRICT_ANSI__
+#if __MISC_VISIBLE || __XOPEN_VISIBLE
#define isascii(__c) ((unsigned)(__c)<=0177)
#define toascii(__c) ((__c)&0177)
#endif
+#endif /* !__cplusplus */
+
/* For C++ backward-compatibility only. */
extern __IMPORT _CONST char _ctype_[];
diff --git a/newlib/libc/include/dirent.h b/newlib/libc/include/dirent.h
index 6fefc03..6135b9f 100644
--- a/newlib/libc/include/dirent.h
+++ b/newlib/libc/include/dirent.h
@@ -3,9 +3,10 @@
#ifdef __cplusplus
extern "C" {
#endif
+#include <sys/cdefs.h>
#include <sys/dirent.h>
-#if !defined(MAXNAMLEN) && !defined(_POSIX_SOURCE)
+#if !defined(MAXNAMLEN) && __BSD_VISIBLE
#define MAXNAMLEN 1024
#endif
diff --git a/newlib/libc/include/fnmatch.h b/newlib/libc/include/fnmatch.h
index 06311fc..a94e923 100644
--- a/newlib/libc/include/fnmatch.h
+++ b/newlib/libc/include/fnmatch.h
@@ -33,21 +33,21 @@
#ifndef _FNMATCH_H_
#define _FNMATCH_H_
+#include <sys/cdefs.h>
+
#define FNM_NOMATCH 1 /* Match failed. */
#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. */
-#if defined(_GNU_SOURCE) || !defined(_ANSI_SOURCE) && !defined(_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(const char *, const char *, int);
__END_DECLS
diff --git a/newlib/libc/include/grp.h b/newlib/libc/include/grp.h
index ee75d3f..8971400 100644
--- a/newlib/libc/include/grp.h
+++ b/newlib/libc/include/grp.h
@@ -49,7 +49,7 @@
#include <cygwin/grp.h>
#endif
-#if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE)
+#if __BSD_VISIBLE
#define _PATH_GROUP "/etc/group"
#endif
@@ -67,15 +67,17 @@ extern "C" {
#ifndef __INSIDE_CYGWIN__
struct group *getgrgid (gid_t);
struct group *getgrnam (const char *);
+#if __MISC_VISIBLE || __POSIX_VISIBLE
int getgrnam_r (const char *, struct group *,
char *, size_t, struct group **);
int getgrgid_r (gid_t, struct group *,
char *, size_t, struct group **);
-#if __BSD_VISIBLE || __XSI_VISIBLE >= 500
+#endif /* __MISC_VISIBLE || __POSIX_VISIBLE */
+#if __MISC_VISIBLE || __XOPEN2_VISIBLE
struct group *getgrent (void);
void setgrent (void);
void endgrent (void);
-#endif /* __BSD_VISIBLE || __XSI_VISIBLE >= 500 */
+#endif /* __MISC_VISIBLE || __XOPEN2_VISIBLE */
#if __BSD_VISIBLE
int initgroups (const char *, gid_t);
#endif /* __BSD_VISIBLE */
diff --git a/newlib/libc/include/limits.h b/newlib/libc/include/limits.h
index 190f1f7..f601fea 100644
--- a/newlib/libc/include/limits.h
+++ b/newlib/libc/include/limits.h
@@ -2,6 +2,7 @@
# define _LIBC_LIMITS_H_ 1
#include <newlib.h>
+#include <sys/cdefs.h>
# ifdef _MB_LEN_MAX
# define MB_LEN_MAX _MB_LEN_MAX
@@ -96,8 +97,7 @@
# define __LONG_LONG_MAX__ 9223372036854775807LL
# endif
-# if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
- (defined(__cplusplus) && __cplusplus >= 201103L)
+# if __ISOC99_VISIBLE
/* Minimum and maximum values a `signed long long int' can hold. */
# undef LLONG_MIN
# define LLONG_MIN (-LLONG_MAX-1)
@@ -109,7 +109,7 @@
# define ULLONG_MAX (LLONG_MAX * 2ULL + 1)
# endif
-# if defined (__GNU_LIBRARY__) ? defined (__USE_GNU) : !defined (__STRICT_ANSI__)
+# if __GNU_VISIBLE
/* Minimum and maximum values a `signed long long int' can hold. */
# undef LONG_LONG_MIN
# define LONG_LONG_MIN (-LONG_LONG_MAX-1)
diff --git a/newlib/libc/include/math.h b/newlib/libc/include/math.h
index 3f6766a..27972ad 100644
--- a/newlib/libc/include/math.h
+++ b/newlib/libc/include/math.h
@@ -3,6 +3,7 @@
#define _MATH_H_
#include <sys/reent.h>
+#include <sys/cdefs.h>
#include <machine/ieeefp.h>
#include "_ansi.h"
@@ -136,9 +137,7 @@ extern double fmod _PARAMS((double, double));
#endif /* ! defined (__math_68881) */
#endif /* ! defined (_REENT_ONLY) */
-#if !defined(__STRICT_ANSI__) || defined(__cplusplus) || \
- (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
-
+#if __ISOC99_VISIBLE
/* ISO C99 types and macros. */
/* FIXME: FLT_EVAL_METHOD should somehow be gotten from float.h (which is hard,
@@ -468,35 +467,39 @@ extern long long int llrintl _PARAMS((_LONG_DOUBLE));
#endif /* __i386__ */
#endif /* !_LDBL_EQ_DBL */
-#endif /* !defined (__STRICT_ANSI__) || defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) */
-
-#if !defined (__STRICT_ANSI__) || defined(__cplusplus)
+#endif /* __ISOC99_VISIBLE */
+#if __MISC_VISIBLE
extern double drem _PARAMS((double, double));
-extern void sincos _PARAMS((double, double *, double *));
+extern float dremf _PARAMS((float, float));
extern double gamma_r _PARAMS((double, int *));
extern double lgamma_r _PARAMS((double, int *));
+extern float gammaf_r _PARAMS((float, int *));
+extern float lgammaf_r _PARAMS((float, int *));
+#endif
+#if __MISC_VISIBLE || __XOPEN_VISIBLE
extern double y0 _PARAMS((double));
extern double y1 _PARAMS((double));
extern double yn _PARAMS((int, double));
extern double j0 _PARAMS((double));
extern double j1 _PARAMS((double));
extern double jn _PARAMS((int, double));
+#endif
-extern float dremf _PARAMS((float, float));
-extern void sincosf _PARAMS((float, float *, float *));
-extern float gammaf_r _PARAMS((float, int *));
-extern float lgammaf_r _PARAMS((float, int *));
-
+#if __MISC_VISIBLE || __XOPEN6_VISIBLE
extern float y0f _PARAMS((float));
extern float y1f _PARAMS((float));
extern float ynf _PARAMS((int, float));
extern float j0f _PARAMS((float));
extern float j1f _PARAMS((float));
extern float jnf _PARAMS((int, float));
+#endif
/* GNU extensions */
+#if __GNU_VISIBLE
+extern void sincos _PARAMS((double, double *, double *));
+extern void sincosf _PARAMS((float, float *, float *));
# ifndef exp10
extern double exp10 _PARAMS((double));
# endif
@@ -509,11 +512,9 @@ extern float exp10f _PARAMS((float));
# ifndef pow10f
extern float pow10f _PARAMS((float));
# endif
+#endif /* __GNU_VISIBLE */
-#endif /* !defined (__STRICT_ANSI__) || defined(__cplusplus) */
-
-#ifndef __STRICT_ANSI__
-
+#if __MISC_VISIBLE || __XOPEN_VISIBLE
/* The gamma functions use a global variable, signgam. */
#ifndef _REENT_ONLY
#define signgam (*__signgam())
@@ -521,7 +522,9 @@ extern int *__signgam _PARAMS((void));
#endif /* ! defined (_REENT_ONLY) */
#define __signgam_r(ptr) _REENT_SIGNGAM(ptr)
+#endif /* __MISC_VISIBLE || __XOPEN_VISIBLE */
+#if __SVID_VISIBLE
/* The exception structure passed to the matherr routine. */
/* We have a problem when using C++ since `exception' is a reserved
name in C++. */
@@ -554,11 +557,11 @@ extern int matherr _PARAMS((struct exception *e));
#define TLOSS 5
#define PLOSS 6
-#endif /* ! defined (__STRICT_ANSI__) */
+#endif /* __SVID_VISIBLE */
/* Useful constants. */
-#if !defined(__STRICT_ANSI__) || ((_XOPEN_SOURCE - 0) >= 500)
+#if __BSD_VISIBLE || __XOPEN5_VISIBLE
#define MAXFLOAT 3.40282347e+38F
@@ -578,7 +581,7 @@ extern int matherr _PARAMS((struct exception *e));
#endif
-#ifndef __STRICT_ANSI__
+#if __BSD_VISIBLE
#define M_TWOPI (M_PI * 2.0)
#define M_3PI_4 2.3561944901923448370E0
@@ -610,7 +613,7 @@ extern __IMPORT _LIB_VERSION_TYPE _LIB_VERSION;
#define _XOPEN_ __fdlibm_xopen
#define _POSIX_ __fdlibm_posix
-#endif /* ! defined (__STRICT_ANSI__) */
+#endif /* __BSD_VISIBLE */
_END_STD_C
diff --git a/newlib/libc/include/pthread.h b/newlib/libc/include/pthread.h
index 907970f..d30bfc7 100644
--- a/newlib/libc/include/pthread.h
+++ b/newlib/libc/include/pthread.h
@@ -329,7 +329,7 @@ void _EXFUN(_pthread_cleanup_pop,
_pthread_cleanup_pop(&_pthread_clup_ctx, (_execute)); \
} while (0)
-#if defined(_GNU_SOURCE)
+#if __GNU_VISIBLE
void _EXFUN(_pthread_cleanup_push_defer,
(struct _pthread_cleanup_context *_context,
void (*_routine)(void *), void *_arg));
@@ -347,7 +347,7 @@ void _EXFUN(_pthread_cleanup_pop_restore,
#define pthread_cleanup_pop_restore_np(_execute) \
_pthread_cleanup_pop_restore(&_pthread_clup_ctx, (_execute)); \
} while (0)
-#endif /* defined(_GNU_SOURCE) */
+#endif /* __GNU_VISIBLE */
#if defined(_POSIX_THREAD_CPUTIME)
diff --git a/newlib/libc/include/pwd.h b/newlib/libc/include/pwd.h
index 3dea4ee..727c60c 100644
--- a/newlib/libc/include/pwd.h
+++ b/newlib/libc/include/pwd.h
@@ -63,14 +63,14 @@ struct passwd {
struct passwd *getpwuid (uid_t);
struct passwd *getpwnam (const char *);
-#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 500
+#if __POSIX2001_VISIBLE
int getpwnam_r (const char *, struct passwd *,
char *, size_t , struct passwd **);
int getpwuid_r (uid_t, struct passwd *, char *,
size_t, struct passwd **);
#endif
-#if __XSI_VISIBLE >= 500
+#if __XOPEN5_VISIBLE
struct passwd *getpwent (void);
void setpwent (void);
void endpwent (void);
diff --git a/newlib/libc/include/signal.h b/newlib/libc/include/signal.h
index 8c50a2e..0324ae7 100644
--- a/newlib/libc/include/signal.h
+++ b/newlib/libc/include/signal.h
@@ -2,15 +2,18 @@
#define _SIGNAL_H_
#include "_ansi.h"
+#include <sys/cdefs.h>
#include <sys/signal.h>
_BEGIN_STD_C
typedef int sig_atomic_t; /* Atomic entity type (ANSI) */
-#ifndef _POSIX_SOURCE
+#if __BSD_VISIBLE
typedef _sig_func_ptr sig_t; /* BSD naming */
+#endif
+#if __GNU_VISIBLE
typedef _sig_func_ptr sighandler_t; /* glibc naming */
-#endif /* !_POSIX_SOURCE */
+#endif
#define SIG_DFL ((_sig_func_ptr)0) /* Default action */
#define SIG_IGN ((_sig_func_ptr)1) /* Ignore action */
diff --git a/newlib/libc/include/stdio.h b/newlib/libc/include/stdio.h
index 9d8fd86..5fed1a2 100644
--- a/newlib/libc/include/stdio.h
+++ b/newlib/libc/include/stdio.h
@@ -128,7 +128,7 @@ typedef _fpos64_t fpos64_t;
#define L_tmpnam FILENAME_MAX
#endif
-#ifndef __STRICT_ANSI__
+#if __BSD_VISIBLE
#define P_tmpdir "/tmp"
#endif
@@ -166,7 +166,7 @@ typedef _fpos64_t fpos64_t;
FILE * _EXFUN(tmpfile, (void));
char * _EXFUN(tmpnam, (char *));
-#if __BSD_VISIBLE || __XSI_VISIBLE || __POSIX_VISIBLE >= 200112
+#if __BSD_VISIBLE || __POSIX2001_VISIBLE
char * _EXFUN(tempnam, (const char *, const char *));
#endif
int _EXFUN(fclose, (FILE *));
@@ -230,7 +230,7 @@ int _EXFUN(rename, (const char *, const char *));
int _EXFUN(_rename, (const char *, const char *));
#endif
#endif
-#if !defined(__STRICT_ANSI__) || defined(__USE_XOPEN2K)
+#if __LARGEFILE_VISIBLE
#ifdef _COMPILING_NEWLIB
int _EXFUN(fseeko, (FILE *, _off_t, int));
_off_t _EXFUN(ftello, ( FILE *));
@@ -242,16 +242,32 @@ off_t _EXFUN(ftello, ( FILE *));
#if __GNU_VISIBLE
int _EXFUN(fcloseall, (_VOID));
#endif
-#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) || (__cplusplus >= 201103L)
#ifndef _REENT_ONLY
+#if __ISOC99_VISIBLE
+int _EXFUN(snprintf, (char *__restrict, size_t, const char *__restrict, ...)
+ _ATTRIBUTE ((__format__ (__printf__, 3, 4))));
+int _EXFUN(vsnprintf, (char *__restrict, size_t, const char *__restrict, __VALIST)
+ _ATTRIBUTE ((__format__ (__printf__, 3, 0))));
+int _EXFUN(vfscanf, (FILE *__restrict, const char *__restrict, __VALIST)
+ _ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
+int _EXFUN(vscanf, (const char *, __VALIST)
+ _ATTRIBUTE ((__format__ (__scanf__, 1, 0))));
+int _EXFUN(vsscanf, (const char *__restrict, const char *__restrict, __VALIST)
+ _ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
+#endif
+#if __GNU_VISIBLE
+int _EXFUN(asprintf, (char **__restrict, const char *__restrict, ...)
+ _ATTRIBUTE ((__format__ (__printf__, 2, 3))));
+int _EXFUN(vasprintf, (char **, const char *, __VALIST)
+ _ATTRIBUTE ((__format__ (__printf__, 2, 0))));
+#endif
+#if __MISC_VISIBLE /* Newlib-specific */
int _EXFUN(asiprintf, (char **, const char *, ...)
_ATTRIBUTE ((__format__ (__printf__, 2, 3))));
char * _EXFUN(asniprintf, (char *, size_t *, const char *, ...)
_ATTRIBUTE ((__format__ (__printf__, 3, 4))));
char * _EXFUN(asnprintf, (char *__restrict, size_t *__restrict, const char *__restrict, ...)
_ATTRIBUTE ((__format__ (__printf__, 3, 4))));
-int _EXFUN(asprintf, (char **__restrict, const char *__restrict, ...)
- _ATTRIBUTE ((__format__ (__printf__, 2, 3))));
#ifndef diprintf
int _EXFUN(diprintf, (int, const char *, ...)
_ATTRIBUTE ((__format__ (__printf__, 2, 3))));
@@ -268,8 +284,6 @@ int _EXFUN(siprintf, (char *, const char *, ...)
_ATTRIBUTE ((__format__ (__printf__, 2, 3))));
int _EXFUN(siscanf, (const char *, const char *, ...)
_ATTRIBUTE ((__format__ (__scanf__, 2, 3))));
-int _EXFUN(snprintf, (char *__restrict, size_t, const char *__restrict, ...)
- _ATTRIBUTE ((__format__ (__printf__, 3, 4))));
int _EXFUN(sniprintf, (char *, size_t, const char *, ...)
_ATTRIBUTE ((__format__ (__printf__, 3, 4))));
int _EXFUN(vasiprintf, (char **, const char *, __VALIST)
@@ -278,50 +292,48 @@ char * _EXFUN(vasniprintf, (char *, size_t *, const char *, __VALIST)
_ATTRIBUTE ((__format__ (__printf__, 3, 0))));
char * _EXFUN(vasnprintf, (char *, size_t *, const char *, __VALIST)
_ATTRIBUTE ((__format__ (__printf__, 3, 0))));
-int _EXFUN(vasprintf, (char **, const char *, __VALIST)
- _ATTRIBUTE ((__format__ (__printf__, 2, 0))));
int _EXFUN(vdiprintf, (int, const char *, __VALIST)
_ATTRIBUTE ((__format__ (__printf__, 2, 0))));
int _EXFUN(vfiprintf, (FILE *, const char *, __VALIST)
_ATTRIBUTE ((__format__ (__printf__, 2, 0))));
int _EXFUN(vfiscanf, (FILE *, const char *, __VALIST)
_ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
-int _EXFUN(vfscanf, (FILE *__restrict, const char *__restrict, __VALIST)
- _ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
int _EXFUN(viprintf, (const char *, __VALIST)
_ATTRIBUTE ((__format__ (__printf__, 1, 0))));
int _EXFUN(viscanf, (const char *, __VALIST)
_ATTRIBUTE ((__format__ (__scanf__, 1, 0))));
-int _EXFUN(vscanf, (const char *, __VALIST)
- _ATTRIBUTE ((__format__ (__scanf__, 1, 0))));
int _EXFUN(vsiprintf, (char *, const char *, __VALIST)
_ATTRIBUTE ((__format__ (__printf__, 2, 0))));
int _EXFUN(vsiscanf, (const char *, const char *, __VALIST)
_ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
int _EXFUN(vsniprintf, (char *, size_t, const char *, __VALIST)
_ATTRIBUTE ((__format__ (__printf__, 3, 0))));
-int _EXFUN(vsnprintf, (char *__restrict, size_t, const char *__restrict, __VALIST)
- _ATTRIBUTE ((__format__ (__printf__, 3, 0))));
-int _EXFUN(vsscanf, (const char *__restrict, const char *__restrict, __VALIST)
- _ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
+#endif /* __MISC_VISIBLE */
#endif /* !_REENT_ONLY */
-#endif /* !__STRICT_ANSI__ */
/*
* Routines in POSIX 1003.1:2001.
*/
-#ifndef __STRICT_ANSI__
+#if __POSIX_VISIBLE
#ifndef _REENT_ONLY
FILE * _EXFUN(fdopen, (int, const char *));
#endif
int _EXFUN(fileno, (FILE *));
+#endif
+#if __MISC_VISIBLE || (__XOPEN_VISIBLE && !__POSIX2001_VISIBLE)
int _EXFUN(getw, (FILE *));
+int _EXFUN(putw, (int, FILE *));
+#endif
+#if __MISC_VISIBLE || __POSIX2_VISIBLE
int _EXFUN(pclose, (FILE *));
FILE * _EXFUN(popen, (const char *, const char *));
-int _EXFUN(putw, (int, FILE *));
+#endif
+#if __BSD_VISIBLE
void _EXFUN(setbuffer, (FILE *, char *, int));
int _EXFUN(setlinebuf, (FILE *));
+#endif
+#if __MISC_VISIBLE || __POSIX_VISIBLE
int _EXFUN(getc_unlocked, (FILE *));
int _EXFUN(getchar_unlocked, (void));
void _EXFUN(flockfile, (FILE *));
@@ -329,13 +341,13 @@ int _EXFUN(ftrylockfile, (FILE *));
void _EXFUN(funlockfile, (FILE *));
int _EXFUN(putc_unlocked, (int, FILE *));
int _EXFUN(putchar_unlocked, (int));
-#endif /* ! __STRICT_ANSI__ */
+#endif /* __MISC_VISIBLE || __POSIX_VISIBLE */
/*
* Routines in POSIX 1003.1:200x.
*/
-#ifndef __STRICT_ANSI__
+#if __POSIX2008_VISIBLE
# ifndef _REENT_ONLY
# ifndef dprintf
int _EXFUN(dprintf, (int, const char *__restrict, ...)
@@ -345,13 +357,13 @@ FILE * _EXFUN(fmemopen, (void *__restrict, size_t, const char *__restrict));
/* getdelim - see __getdelim for now */
/* getline - see __getline for now */
FILE * _EXFUN(open_memstream, (char **, size_t *));
-#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809
-int _EXFUN(renameat, (int, const char *, int, const char *));
-#endif
int _EXFUN(vdprintf, (int, const char *__restrict, __VALIST)
_ATTRIBUTE ((__format__ (__printf__, 2, 0))));
# endif
#endif
+#if __ATFILE_VISIBLE
+int _EXFUN(renameat, (int, const char *, int, const char *));
+#endif
/*
* Recursive versions of the above.
@@ -495,7 +507,7 @@ int _EXFUN(fpurge, (FILE *));
ssize_t _EXFUN(__getdelim, (char **, size_t *, int, FILE *));
ssize_t _EXFUN(__getline, (char **, size_t *, FILE *));
-#if __BSD_VISIBLE
+#if __MISC_VISIBLE
void _EXFUN(clearerr_unlocked, (FILE *));
int _EXFUN(feof_unlocked, (FILE *));
int _EXFUN(ferror_unlocked, (FILE *));
@@ -545,7 +557,7 @@ int _EXFUN(__swbuf_r, (struct _reent *, int, FILE *));
* Stdio function-access interface.
*/
-#ifndef __STRICT_ANSI__
+#if __BSD_VISIBLE
# ifdef __LARGE64_FILES
FILE *_EXFUN(funopen,(const _PTR __cookie,
int (*__readfn)(_PTR __c, char *__buf,
@@ -582,7 +594,9 @@ FILE *_EXFUN(_funopen_r,(struct _reent *, const _PTR __cookie,
(fpos_t (*)())0, (int (*)())0)
# define fwopen(__cookie, __fn) funopen(__cookie, (int (*)())0, __fn, \
(fpos_t (*)())0, (int (*)())0)
+#endif /* __BSD_VISIBLE */
+#if __GNU_VISIBLE
typedef ssize_t cookie_read_function_t(void *__cookie, char *__buf, size_t __n);
typedef ssize_t cookie_write_function_t(void *__cookie, const char *__buf,
size_t __n);
@@ -606,7 +620,7 @@ FILE *_EXFUN(fopencookie,(void *__cookie,
const char *__mode, cookie_io_functions_t __functions));
FILE *_EXFUN(_fopencookie_r,(struct _reent *, void *__cookie,
const char *__mode, cookie_io_functions_t __functions));
-#endif /* ! __STRICT_ANSI__ */
+#endif /* __GNU_VISIBLE */
#ifndef __CUSTOM_FILE_IO__
/*
@@ -686,14 +700,14 @@ _ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
#define ferror(p) __sferror(p)
#define clearerr(p) __sclearerr(p)
-#if __BSD_VISIBLE
+#if __MISC_VISIBLE
#define feof_unlocked(p) __sfeof(p)
#define ferror_unlocked(p) __sferror(p)
#define clearerr_unlocked(p) __sclearerr(p)
-#endif /* __BSD_VISIBLE */
+#endif /* __MISC_VISIBLE */
#endif /* _REENT_SMALL */
-#if 0 /*ndef __STRICT_ANSI__ - FIXME: must initialize stdio first, use fn */
+#if 0 /* __POSIX_VISIBLE - FIXME: must initialize stdio first, use fn */
#define fileno(p) __sfileno(p)
#endif
@@ -704,11 +718,13 @@ _ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
#endif /* lint */
#endif /* __CYGWIN__ */
-#ifndef __STRICT_ANSI__
+#if __MISC_VISIBLE
/* fast always-buffered version, true iff error */
#define fast_putc(x,p) (--(p)->_w < 0 ? \
__swbuf_r(_REENT, (int)(x), p) == EOF : (*(p)->_p = (x), (p)->_p++, 0))
+#endif
+#if __XOPEN_VISIBLE
#define L_cuserid 9 /* posix says it goes in stdio.h :( */
#ifdef __CYGWIN__
#define L_ctermid 16
@@ -720,7 +736,7 @@ _ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
#define getchar() getc(stdin)
#define putchar(x) putc(x, stdout)
-#ifndef __STRICT_ANSI__
+#if __MISC_VISIBLE || __POSIX_VISIBLE
#define getchar_unlocked() getc_unlocked(stdin)
#define putchar_unlocked(x) putc_unlocked(x, stdout)
#endif
diff --git a/newlib/libc/include/stdlib.h b/newlib/libc/include/stdlib.h
index fd6315b..eb6e898 100644
--- a/newlib/libc/include/stdlib.h
+++ b/newlib/libc/include/stdlib.h
@@ -40,9 +40,7 @@ typedef struct
long rem; /* remainder */
} ldiv_t;
-#if !defined(__STRICT_ANSI__) || \
- (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
- (defined(__cplusplus) && __cplusplus >= 201103L)
+#if __ISOC99_VISIBLE
typedef struct
{
long long int quot; /* quotient */
@@ -68,7 +66,7 @@ _VOID _EXFUN(abort,(_VOID) _ATTRIBUTE ((__noreturn__)));
int _EXFUN(abs,(int));
int _EXFUN(atexit,(_VOID (*__func)(_VOID)));
double _EXFUN(atof,(const char *__nptr));
-#ifndef __STRICT_ANSI__
+#if __MISC_VISIBLE
float _EXFUN(atoff,(const char *__nptr));
#endif
int _EXFUN(atoi,(const char *__nptr));
@@ -88,7 +86,7 @@ char * _EXFUN(getenv,(const char *__string));
char * _EXFUN(_getenv_r,(struct _reent *, const char *__string));
char * _EXFUN(_findenv,(_CONST char *, int *));
char * _EXFUN(_findenv_r,(struct _reent *, _CONST char *, int *));
-#ifndef __STRICT_ANSI__
+#if __POSIX2008_VISIBLE
extern char *suboptarg; /* getsubopt(3) external variable */
int _EXFUN(getsubopt,(char **, char * const *, char **));
#endif
@@ -105,41 +103,52 @@ size_t _EXFUN(mbstowcs,(wchar_t *__restrict, const char *__restrict, size_t));
size_t _EXFUN(_mbstowcs_r,(struct _reent *, wchar_t *__restrict, const char *__restrict, size_t, _mbstate_t *));
size_t _EXFUN(wcstombs,(char *__restrict, const wchar_t *__restrict, size_t));
size_t _EXFUN(_wcstombs_r,(struct _reent *, char *__restrict, const wchar_t *__restrict, size_t, _mbstate_t *));
-#ifndef __STRICT_ANSI__
#ifndef _REENT_ONLY
+#if __BSD_VISIBLE || __POSIX2008_VISIBLE
char * _EXFUN(mkdtemp,(char *));
+#endif
+#if __GNU_VISIBLE
int _EXFUN(mkostemp,(char *, int));
int _EXFUN(mkostemps,(char *, int, int));
+#endif
+#if __MISC_VISIBLE || __POSIX2001_VISIBLE || __XOPEN2_VISIBLE
int _EXFUN(mkstemp,(char *));
+#endif
+#if __MISC_VISIBLE
int _EXFUN(mkstemps,(char *, int));
+#endif
+#if __BSD_VISIBLE || (__XOPEN2_VISIBLE && !__POSIX2001_VISIBLE)
char * _EXFUN(mktemp,(char *) _ATTRIBUTE ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))));
#endif
+#endif /* !_REENT_ONLY */
char * _EXFUN(_mkdtemp_r, (struct _reent *, char *));
int _EXFUN(_mkostemp_r, (struct _reent *, char *, int));
int _EXFUN(_mkostemps_r, (struct _reent *, char *, int, int));
int _EXFUN(_mkstemp_r, (struct _reent *, char *));
int _EXFUN(_mkstemps_r, (struct _reent *, char *, int));
char * _EXFUN(_mktemp_r, (struct _reent *, char *) _ATTRIBUTE ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))));
-#endif
_VOID _EXFUN(qsort,(_PTR __base, size_t __nmemb, size_t __size, __compar_fn_t _compar));
int _EXFUN(rand,(_VOID));
_PTR _EXFUN_NOTHROW(realloc,(_PTR __r, size_t __size));
-#ifndef __STRICT_ANSI__
+#if __BSD_VISIBLE
_PTR _EXFUN(reallocf,(_PTR __r, size_t __size));
+_PTR _EXFUN(_reallocf_r,(struct _reent *, _PTR, size_t));
+#endif
+#if __BSD_VISIBLE || __XOPEN2_VISIBLE
char * _EXFUN(realpath, (const char *__restrict path, char *__restrict resolved_path));
+#endif
+#if __BSD_VISIBLE
int _EXFUN(rpmatch, (const char *response));
#endif
_VOID _EXFUN(srand,(unsigned __seed));
double _EXFUN(strtod,(const char *__restrict __n, char **__restrict __end_PTR));
double _EXFUN(_strtod_r,(struct _reent *,const char *__restrict __n, char **__restrict __end_PTR));
-#if !defined(__STRICT_ANSI__) || \
- (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
- (defined(__cplusplus) && __cplusplus >= 201103L)
+#if __ISOC99_VISIBLE
float _EXFUN(strtof,(const char *__restrict __n, char **__restrict __end_PTR));
#endif
-#ifndef __STRICT_ANSI__
+#if __MISC_VISIBLE
/* the following strtodf interface is deprecated...use strtof instead */
-# ifndef strtodf
+# ifndef strtodf
# define strtodf strtof
# endif
#endif
@@ -150,24 +159,27 @@ unsigned long _EXFUN(_strtoul_r,(struct _reent *,const char *__restrict __n, cha
int _EXFUN(system,(const char *__string));
-#ifndef __STRICT_ANSI__
+#if __SVID_VISIBLE || __XOPEN2_VISIBLE
long _EXFUN(a64l,(const char *__input));
char * _EXFUN(l64a,(long __input));
char * _EXFUN(_l64a_r,(struct _reent *,long __input));
+#endif
+#if __MISC_VISIBLE
int _EXFUN(on_exit,(_VOID (*__func)(int, _PTR),_PTR __arg));
-#endif /* ! __STRICT_ANSI__ */
-#if !defined(__STRICT_ANSI__) || \
- (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
- (defined(__cplusplus) && __cplusplus >= 201103L)
+#endif
+#if __ISOC99_VISIBLE
_VOID _EXFUN(_Exit,(int __status) _ATTRIBUTE ((__noreturn__)));
#endif
-#ifndef __STRICT_ANSI__
+#if __SVID_VISIBLE || __XOPEN_VISIBLE
int _EXFUN(putenv,(char *__string));
int _EXFUN(_putenv_r,(struct _reent *, char *__string));
-_PTR _EXFUN(_reallocf_r,(struct _reent *, _PTR, size_t));
+#endif
+#if __BSD_VISIBLE || __POSIX2001_VISIBLE
int _EXFUN(setenv,(const char *__string, const char *__value, int __overwrite));
int _EXFUN(_setenv_r,(struct _reent *, const char *__string, const char *__value, int __overwrite));
+#endif
+#if __XOPEN2_VISIBLE && !__POSIX2001_VISIBLE
char * _EXFUN(gcvt,(double,int,char *));
char * _EXFUN(gcvtf,(float,int,char *));
char * _EXFUN(fcvt,(double,int,int *,int *));
@@ -176,15 +188,19 @@ char * _EXFUN(ecvt,(double,int,int *,int *));
char * _EXFUN(ecvtbuf,(double, int, int*, int*, char *));
char * _EXFUN(fcvtbuf,(double, int, int*, int*, char *));
char * _EXFUN(ecvtf,(float,int,int *,int *));
-char * _EXFUN(dtoa,(double, int, int, int *, int*, char**));
#endif
char * _EXFUN(__itoa,(int, char *, int));
char * _EXFUN(__utoa,(unsigned, char *, int));
-#ifndef __STRICT_ANSI__
+#if __MISC_VISIBLE
+char * _EXFUN(dtoa,(double, int, int, int *, int*, char**));
char * _EXFUN(itoa,(int, char *, int));
char * _EXFUN(utoa,(unsigned, char *, int));
+#endif
+#if __POSIX_VISIBLE
int _EXFUN(rand_r,(unsigned *__seed));
+#endif
+#if __SVID_VISIBLE || __XOPEN_VISIBLE
double _EXFUN(drand48,(_VOID));
double _EXFUN(_drand48_r,(struct _reent *));
double _EXFUN(erand48,(unsigned short [3]));
@@ -205,44 +221,37 @@ unsigned short *
_EXFUN(_seed48_r,(struct _reent *, unsigned short [3]));
_VOID _EXFUN(srand48,(long));
_VOID _EXFUN(_srand48_r,(struct _reent *, long));
-#endif /* ! __STRICT_ANSI__ */
-#if !defined(__STRICT_ANSI__) || \
- (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
- (defined(__cplusplus) && __cplusplus >= 201103L)
+#endif /* __SVID_VISIBLE || __XOPEN_VISIBLE */
+#if __ISOC99_VISIBLE
long long _EXFUN(atoll,(const char *__nptr));
#endif
-#ifndef __STRICT_ANSI__
long long _EXFUN(_atoll_r,(struct _reent *, const char *__nptr));
-#endif /* ! __STRICT_ANSI__ */
-#if !defined(__STRICT_ANSI__) || \
- (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
- (defined(__cplusplus) && __cplusplus >= 201103L)
+#if __ISOC99_VISIBLE
long long _EXFUN(llabs,(long long));
lldiv_t _EXFUN(lldiv,(long long __numer, long long __denom));
long long _EXFUN(strtoll,(const char *__restrict __n, char **__restrict __end_PTR, int __base));
#endif
-#ifndef __STRICT_ANSI__
long long _EXFUN(_strtoll_r,(struct _reent *, const char *__restrict __n, char **__restrict __end_PTR, int __base));
-#endif /* ! __STRICT_ANSI__ */
-#if !defined(__STRICT_ANSI__) || \
- (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
- (defined(__cplusplus) && __cplusplus >= 201103L)
+#if __ISOC99_VISIBLE
unsigned long long _EXFUN(strtoull,(const char *__restrict __n, char **__restrict __end_PTR, int __base));
#endif
-#ifndef __STRICT_ANSI__
unsigned long long _EXFUN(_strtoull_r,(struct _reent *, const char *__restrict __n, char **__restrict __end_PTR, int __base));
#ifndef __CYGWIN__
+#if __MISC_VISIBLE
_VOID _EXFUN(cfree,(_PTR));
+#endif
+#if __BSD_VISIBLE || __POSIX2001_VISIBLE
int _EXFUN(unsetenv,(const char *__string));
int _EXFUN(_unsetenv_r,(struct _reent *, const char *__string));
#endif
+#endif /* !__CYGWIN__ */
#ifdef __rtems__
+#if __POSIX2001_VISIBLE
int _EXFUN(posix_memalign,(void **, size_t, size_t));
#endif
-
-#endif /* ! __STRICT_ANSI__ */
+#endif
char * _EXFUN(_dtoa_r,(struct _reent *, double, int, int, int *, int*, char**));
#ifndef __CYGWIN__
@@ -260,7 +269,9 @@ _VOID _EXFUN(__eprintf,(const char *, const char *, unsigned int, const char *))
_BSD_SOURCE, you get the BSD version; otherwise you get the GNU
version. We want that #undef qsort_r will still let you
invoke the underlying function, but that requires gcc support. */
-#ifdef _BSD_SOURCE
+#if __GNU_VISIBLE
+_VOID _EXFUN(qsort_r,(_PTR __base, size_t __nmemb, size_t __size, int (*_compar)(const _PTR, const _PTR, _PTR), _PTR __thunk));
+#elif __BSD_VISIBLE
# ifdef __GNUC__
_VOID _EXFUN(qsort_r,(_PTR __base, size_t __nmemb, size_t __size, _PTR __thunk, int (*_compar)(_PTR, const _PTR, const _PTR)))
__asm__ (__ASMNAME ("__bsd_qsort_r"));
@@ -268,16 +279,12 @@ _VOID _EXFUN(qsort_r,(_PTR __base, size_t __nmemb, size_t __size, _PTR __thunk,
_VOID _EXFUN(__bsd_qsort_r,(_PTR __base, size_t __nmemb, size_t __size, _PTR __thunk, int (*_compar)(_PTR, const _PTR, const _PTR)));
# define qsort_r __bsd_qsort_r
# endif
-#elif __GNU_VISIBLE
-_VOID _EXFUN(qsort_r,(_PTR __base, size_t __nmemb, size_t __size, int (*_compar)(const _PTR, const _PTR, _PTR), _PTR __thunk));
#endif
/* On platforms where long double equals double. */
#ifdef _HAVE_LONG_DOUBLE
extern long double _strtold_r (struct _reent *, const char *__restrict, char **__restrict);
-#if !defined(__STRICT_ANSI__) || \
- (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
- (defined(__cplusplus) && __cplusplus >= 201103L)
+#if __ISOC99_VISIBLE
extern long double strtold (const char *__restrict, char **__restrict);
#endif
#endif /* _HAVE_LONG_DOUBLE */
@@ -285,13 +292,13 @@ extern long double strtold (const char *__restrict, char **__restrict);
/*
* If we're in a mode greater than C99, expose C11 functions.
*/
-#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
+#if __ISOC11_VISIBLE
void * aligned_alloc(size_t, size_t) __malloc_like __alloc_align(1)
__alloc_size(2);
int at_quick_exit(void (*)(void));
_Noreturn void
quick_exit(int);
-#endif /* __ISO_C_VISIBLE >= 2011 */
+#endif /* __ISOC11_VISIBLE */
_END_STD_C
diff --git a/newlib/libc/include/string.h b/newlib/libc/include/string.h
index 84dd6b0..b2de8ea 100644
--- a/newlib/libc/include/string.h
+++ b/newlib/libc/include/string.h
@@ -43,28 +43,30 @@ char *_EXFUN(strtok,(char *__restrict, const char *__restrict));
#endif
size_t _EXFUN(strxfrm,(char *__restrict, const char *__restrict, size_t));
-#if __POSIX_VISIBLE
+#if __MISC_VISIBLE || __POSIX_VISIBLE
char *_EXFUN(strtok_r,(char *__restrict, const char *__restrict, char **__restrict));
#endif
-#if __BSD_VISIBLE
+#if __BSD_VISIBLE || (__POSIX_VISIBLE && !__POSIX2008_VISIBLE)
int _EXFUN(bcmp,(const void *, const void *, size_t));
void _EXFUN(bcopy,(const void *, void *, size_t));
void _EXFUN(bzero,(void *, size_t));
+#endif
+#if __MISC_VISIBLE || __POSIX2008_VISIBLE
int _EXFUN(ffs,(int));
+#endif
+#if __BSD_VISIBLE || (__POSIX_VISIBLE && !__POSIX2008_VISIBLE)
char *_EXFUN(index,(const char *, int));
#endif
-#if __BSD_VISIBLE || __XSI_VISIBLE
+#if __MISC_VISIBLE || __POSIX_VISIBLE
_PTR _EXFUN(memccpy,(_PTR __restrict, const _PTR __restrict, int, size_t));
#endif
#if __GNU_VISIBLE
_PTR _EXFUN(mempcpy,(_PTR, const _PTR, size_t));
_PTR _EXFUN(memmem, (const _PTR, size_t, const _PTR, size_t));
-#endif
_PTR _EXFUN(memrchr,(const _PTR, int, size_t));
-#if __GNU_VISIBLE
_PTR _EXFUN(rawmemchr,(const _PTR, int));
#endif
-#if __BSD_VISIBLE
+#if __BSD_VISIBLE || (__POSIX_VISIBLE && !__POSIX2008_VISIBLE)
char *_EXFUN(rindex,(const char *, int));
#endif
char *_EXFUN(stpcpy,(char *__restrict, const char *__restrict));
@@ -76,17 +78,12 @@ int _EXFUN(strcasecmp,(const char *, const char *));
char *_EXFUN(strcasestr,(const char *, const char *));
char *_EXFUN(strchrnul,(const char *, int));
#endif
-#if __XSI_VISIBLE >= 500
+#if __MISC_VISIBLE || __POSIX2008_VISIBLE || __XOPEN2_VISIBLE
char *_EXFUN(strdup,(const char *));
-#endif
-#ifndef __STRICT_ANSI__
char *_EXFUN(_strdup_r,(struct _reent *, const char *));
#endif
-#if __XSI_VISIBLE >= 700
+#if __POSIX2008_VISIBLE
char *_EXFUN(strndup,(const char *, size_t));
-#endif
-
-#ifndef __STRICT_ANSI__
char *_EXFUN(_strndup_r,(struct _reent *, const char *, size_t));
#endif
@@ -101,7 +98,7 @@ int _EXFUN(ffsll, (long long));
invoke the underlying function, but that requires gcc support. */
#if __GNU_VISIBLE
char *_EXFUN(strerror_r,(int, char *, size_t));
-#else
+#elif __POSIX2001_VISIBLE
# ifdef __GNUC__
int _EXFUN(strerror_r,(int, char *, size_t))
#ifdef __ASMNAME
@@ -124,19 +121,14 @@ size_t _EXFUN(strlcpy,(char *, const char *, size_t));
#if __BSD_VISIBLE || __POSIX_VISIBLE
int _EXFUN(strncasecmp,(const char *, const char *, size_t));
#endif
-#if !defined(__STRICT_ANSI__) || __POSIX_VISIBLE >= 200809 || \
- __XSI_VISIBLE >= 700
+#if __POSIX2008_VISIBLE
size_t _EXFUN(strnlen,(const char *, size_t));
#endif
#if __BSD_VISIBLE
char *_EXFUN(strsep,(char **, const char *));
#endif
-/*
- * The origin of these is unknown to me so I am conditionalizing them
- * on __STRICT_ANSI__. Finetuning this is definitely needed. --joel
- */
-#if !defined(__STRICT_ANSI__)
+#if __MISC_VISIBLE
char *_EXFUN(strlwr,(char *));
char *_EXFUN(strupr,(char *));
#endif
@@ -149,7 +141,7 @@ char *_EXFUN(strsignal, (int __signo));
int _EXFUN(strtosigno, (const char *__name));
#endif
-#if defined _GNU_SOURCE && defined __GNUC__
+#if __GNU_VISIBLE && defined __GNUC__
#define strdupa(__s) \
(__extension__ ({const char *__in = (__s); \
size_t __len = strlen (__in) + 1; \
@@ -161,7 +153,7 @@ int _EXFUN(strtosigno, (const char *__name));
char *__out = (char *) __builtin_alloca (__len); \
__out[__len-1] = '\0'; \
(char *) memcpy (__out, __in, __len-1);}))
-#endif /* _GNU_SOURCE && __GNUC__ */
+#endif /* __GNU_VISIBLE && __GNUC__ */
/* There are two common basename variants. If you do NOT #include <libgen.h>
and you do
diff --git a/newlib/libc/include/strings.h b/newlib/libc/include/strings.h
index 131d81d..95c492e 100644
--- a/newlib/libc/include/strings.h
+++ b/newlib/libc/include/strings.h
@@ -9,12 +9,12 @@
#include "_ansi.h"
#include <sys/reent.h>
-
+#include <sys/cdefs.h>
#include <sys/types.h> /* for size_t */
_BEGIN_STD_C
-#if !defined __STRICT_ANSI__ && _POSIX_VERSION < 200809L
+#if __BSD_VISIBLE || (__POSIX_VISIBLE && !__POSIX2008_VISIBLE)
/*
* Marked LEGACY in Open Group Base Specifications Issue 6/IEEE Std 1003.1-2004
* Removed from Open Group Base Specifications Issue 7/IEEE Std 1003.1-2008
@@ -24,7 +24,7 @@ void _EXFUN(bcopy,(const void *, void *, size_t));
void _EXFUN(bzero,(void *, size_t));
char *_EXFUN(index,(const char *, int));
char *_EXFUN(rindex,(const char *, int));
-#endif /* ! __STRICT_ANSI__ */
+#endif /* __BSD_VISIBLE || (__POSIX_VISIBLE && !__POSIX2008_VISIBLE) */
int _EXFUN(ffs,(int));
int _EXFUN(strcasecmp,(const char *, const char *));
diff --git a/newlib/libc/include/sys/_default_fcntl.h b/newlib/libc/include/sys/_default_fcntl.h
index eb674ae..44357e5 100644
--- a/newlib/libc/include/sys/_default_fcntl.h
+++ b/newlib/libc/include/sys/_default_fcntl.h
@@ -65,7 +65,7 @@ extern "C" {
#define O_SEARCH _FEXECSRCH
#endif
-#ifndef _POSIX_SOURCE
+#if __MISC_VISIBLE
/*
* Flags that work for fcntl(fd, F_SETFL, FXXXX)
@@ -97,7 +97,7 @@ extern "C" {
#define FEXCL _FEXCL
#define FNOCTTY _FNOCTTY
-#endif /* !_POSIX_SOURCE */
+#endif /* __MISC_VISIBLE */
/* XXX close on exec request; must match UF_EXCLOSE in user.h */
#define FD_CLOEXEC 1 /* posix */
@@ -108,20 +108,20 @@ extern "C" {
#define F_SETFD 2 /* Set fildes flags (close on exec) */
#define F_GETFL 3 /* Get file flags */
#define F_SETFL 4 /* Set file flags */
-#ifndef _POSIX_SOURCE
+#if __BSD_VISIBLE || __POSIX2001_VISIBLE
#define F_GETOWN 5 /* Get owner - for ASYNC */
#define F_SETOWN 6 /* Set owner - for ASYNC */
-#endif /* !_POSIX_SOURCE */
+#endif /* __BSD_VISIBLE || __POSIX2001_VISIBLE */
#define F_GETLK 7 /* Get record-locking information */
#define F_SETLK 8 /* Set or Clear a record-lock (Non-Blocking) */
#define F_SETLKW 9 /* Set or Clear a record-lock (Blocking) */
-#ifndef _POSIX_SOURCE
+#if __MISC_VISIBLE
#define F_RGETLK 10 /* Test a remote lock to see if it is blocked */
#define F_RSETLK 11 /* Set or unlock a remote lock */
#define F_CNVT 12 /* Convert a fhandle to an open fd */
#define F_RSETLKW 13 /* Set or Clear remote record-lock(Blocking) */
-#endif /* !_POSIX_SOURCE */
-#ifdef __CYGWIN__
+#endif /* __MISC_VISIBLE */
+#if __POSIX2008_VISIBLE
#define F_DUPFD_CLOEXEC 14 /* As F_DUPFD, but set close-on-exec flag */
#endif
@@ -129,11 +129,11 @@ extern "C" {
#define F_RDLCK 1 /* read lock */
#define F_WRLCK 2 /* write lock */
#define F_UNLCK 3 /* remove lock(s) */
-#ifndef _POSIX_SOURCE
+#if __MISC_VISIBLE
#define F_UNLKSYS 4 /* remove remote locks for a given system */
-#endif /* !_POSIX_SOURCE */
+#endif /* __MISC_VISIBLE */
-#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809 || defined(__CYGWIN__)
+#if __BSD_VISIBLE || __POSIX2008_VISIBLE
/* Special descriptor value to denote the cwd in calls to openat(2) etc. */
#define AT_FDCWD -2
@@ -166,7 +166,7 @@ struct flock {
};
#endif /* __CYGWIN__ */
-#ifndef _POSIX_SOURCE
+#if __MISC_VISIBLE
/* extended file segment locking set data type */
struct eflock {
short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */
@@ -178,13 +178,13 @@ struct eflock {
long l_rpid; /* Remote process id wanting this lock */
long l_rsys; /* Remote system id wanting this lock */
};
-#endif /* !_POSIX_SOURCE */
+#endif /* __MISC_VISIBLE */
#include <sys/types.h>
#include <sys/stat.h> /* sigh. for the mode bits for open/creat */
extern int open _PARAMS ((const char *, int, ...));
-#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809 || defined(__CYGWIN__)
+#if __ATFILE_VISIBLE
extern int openat _PARAMS ((int, const char *, int, ...));
#endif
extern int creat _PARAMS ((const char *, mode_t));
@@ -192,7 +192,7 @@ extern int fcntl _PARAMS ((int, int, ...));
#if __BSD_VISIBLE
extern int flock _PARAMS ((int, int));
#endif
-#ifdef __CYGWIN__
+#ifdef __CYGWIN__ /* __GNU_VISIBLE */
#include <sys/time.h>
extern int futimesat _PARAMS ((int, const char *, const struct timeval *));
#endif
diff --git a/newlib/libc/include/sys/_timeval.h b/newlib/libc/include/sys/_timeval.h
index 0a4c539..fe37eed 100644
--- a/newlib/libc/include/sys/_timeval.h
+++ b/newlib/libc/include/sys/_timeval.h
@@ -29,6 +29,7 @@
#ifndef _SYS__TIMEVAL_H_
#define _SYS__TIMEVAL_H_
+#include <sys/cdefs.h>
#include <machine/types.h>
#ifndef _SUSECONDS_T_DECLARED
diff --git a/newlib/libc/include/sys/config.h b/newlib/libc/include/sys/config.h
index 5297bef..c536698 100644
--- a/newlib/libc/include/sys/config.h
+++ b/newlib/libc/include/sys/config.h
@@ -232,9 +232,6 @@
#if defined(__CYGWIN__)
#include <cygwin/config.h>
-#if !defined (__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L)
-#define __USE_XOPEN2K 1
-#endif
#endif
#if defined(__rtems__)
diff --git a/newlib/libc/include/sys/select.h b/newlib/libc/include/sys/select.h
index de779e6..7b4776b 100644
--- a/newlib/libc/include/sys/select.h
+++ b/newlib/libc/include/sys/select.h
@@ -19,10 +19,9 @@ details. */
includes the W32api winsock[2].h header must know what it is doing;
it must not call the Cygwin select function.
*/
-# if !(defined (_POSIX_SOURCE) || defined (_WINSOCK_H) || defined (_WINSOCKAPI_) || defined (__USE_W32_SOCKETS))
+# if !(defined (_WINSOCK_H) || defined (_WINSOCKAPI_) || defined (__USE_W32_SOCKETS))
#include <sys/cdefs.h>
-
#include <sys/_sigset.h>
#include <sys/_timeval.h>
#include <sys/timespec.h>
@@ -73,14 +72,16 @@ __BEGIN_DECLS
int select __P ((int __n, fd_set *__readfds, fd_set *__writefds,
fd_set *__exceptfds, struct timeval *__timeout));
+#if __POSIX2001_VISIBLE
int pselect __P ((int __n, fd_set *__readfds, fd_set *__writefds,
fd_set *__exceptfds, const struct timespec *__timeout,
const sigset_t *__set));
+#endif
__END_DECLS
-#endif
+#endif /* !__INSIDE_CYGWIN_NET__ */
-#endif /* !_POSIX_SOURCE, !__INSIDE_CYGWIN_NET__ */
+#endif /* !(_WINSOCK_H || _WINSOCKAPI_ || __USE_W32_SOCKETS) */
#endif /* sys/select.h */
diff --git a/newlib/libc/include/sys/signal.h b/newlib/libc/include/sys/signal.h
index 3ff0eb7..1a271e3 100644
--- a/newlib/libc/include/sys/signal.h
+++ b/newlib/libc/include/sys/signal.h
@@ -13,8 +13,6 @@ extern "C" {
#include <sys/_sigset.h>
#include <sys/_timespec.h>
-/* #ifndef __STRICT_ANSI__*/
-
#if !defined(_SIGSET_T_DECLARED)
#define _SIGSET_T_DECLARED
typedef __sigset_t sigset_t;
@@ -77,7 +75,8 @@ typedef struct {
#define SA_NOCLDSTOP 0x1 /* Do not generate SIGCHLD when children stop */
#define SA_SIGINFO 0x2 /* Invoke the signal catching function with */
/* three arguments instead of one. */
-#if __BSD_VISIBLE || __XSI_VISIBLE || __POSIX_VISIBLE >= 200112
+
+#if __BSD_VISIBLE || __POSIX2008_VISIBLE || __XOPEN2_VISIBLE
#define SA_ONSTACK 0x4 /* Signal delivery will be on a separate stack. */
#endif
@@ -125,7 +124,7 @@ struct sigaction
};
#endif /* defined(__rtems__) */
-#if __BSD_VISIBLE || __XSI_VISIBLE || __POSIX_VISIBLE >= 200112
+#if __BSD_VISIBLE || __POSIX2008_VISIBLE || __XOPEN2_VISIBLE
/*
* Minimum and default signal stack constants. Allow for target overrides
* from <sys/features.h>.
@@ -187,7 +186,7 @@ int _EXFUN(_kill, (pid_t, int));
int _EXFUN(kill, (pid_t, int));
-#if defined(__CYGWIN__) || defined(__rtems__)
+#if __BSD_VISIBLE || __XOPEN2_VISIBLE
int _EXFUN(killpg, (pid_t, int));
int _EXFUN(sigaction, (int, const struct sigaction *, struct sigaction *));
int _EXFUN(sigaddset, (sigset_t *, const int));
@@ -198,12 +197,11 @@ int _EXFUN(sigemptyset, (sigset_t *));
int _EXFUN(sigpending, (sigset_t *));
int _EXFUN(sigsuspend, (const sigset_t *));
int _EXFUN(sigpause, (int));
+#endif
-#if defined(__CYGWIN__) || defined(__rtems__)
-#if __BSD_VISIBLE || __XSI_VISIBLE || __POSIX_VISIBLE >= 200112
+#if __BSD_VISIBLE || __POSIX2008_VISIBLE || __XOPEN2_VISIBLE
int _EXFUN(sigaltstack, (const stack_t *__restrict, stack_t *__restrict));
#endif
-#endif
#if defined(_POSIX_THREADS)
#ifdef __CYGWIN__
@@ -230,10 +228,6 @@ int _EXFUN(sigqueue, (pid_t pid, int signo, const union sigval value));
#endif /* defined(_POSIX_REALTIME_SIGNALS) */
-#endif /* defined(__CYGWIN__) || defined(__rtems__) */
-
-/* #endif __STRICT_ANSI__ */
-
#if defined(___AM29K__)
/* These all need to be defined for ANSI C, but I don't think they are
meaningful. */
@@ -354,7 +348,7 @@ int _EXFUN(sigqueue, (pid_t pid, int signo, const union sigval value));
#endif
#if defined(__CYGWIN__)
-#if __POSIX_VISIBLE >= 200809
+#if __POSIX2008_VISIBLE
#include <sys/ucontext.h>
#endif
#endif
diff --git a/newlib/libc/include/sys/stat.h b/newlib/libc/include/sys/stat.h
index 47caf1c..7574820 100644
--- a/newlib/libc/include/sys/stat.h
+++ b/newlib/libc/include/sys/stat.h
@@ -82,12 +82,12 @@ struct stat
#define S_ISUID 0004000 /* set user id on execution */
#define S_ISGID 0002000 /* set group id on execution */
#define S_ISVTX 0001000 /* save swapped text even after use */
-#ifndef _POSIX_SOURCE
+#if __BSD_VISIBLE
#define S_IREAD 0000400 /* read permission, owner */
#define S_IWRITE 0000200 /* write permission, owner */
#define S_IEXEC 0000100 /* execute/search permission, owner */
#define S_ENFMT 0002000 /* enforcement-mode locking */
-#endif /* !_POSIX_SOURCE */
+#endif /* !_BSD_VISIBLE */
#define S_IFMT _IFMT
#define S_IFDIR _IFDIR
@@ -124,7 +124,7 @@ struct stat
#define S_IWOTH 0000002 /* write permission, other */
#define S_IXOTH 0000001/* execute/search permission, other */
-#ifndef _POSIX_SOURCE
+#if __BSD_VISIBLE
#define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) /* 0777 */
#define ALLPERMS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) /* 07777 */
#define DEFFILEMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) /* 0666 */
@@ -157,19 +157,15 @@ int _EXFUN(lstat,( const char *__restrict __path, struct stat *__restrict __buf
int _EXFUN(mknod,( const char *__path, mode_t __mode, dev_t __dev ));
#endif
-#if (__POSIX_VISIBLE >= 200809 || defined (__CYGWIN__)) && !defined(__INSIDE_CYGWIN__)
+#if __ATFILE_VISIBLE && !defined(__INSIDE_CYGWIN__)
int _EXFUN(fchmodat, (int, const char *, mode_t, int));
-#endif
-#if (__BSD_VISIBLE || __POSIX_VISIBLE >= 200809 || defined (__CYGWIN__)) && !defined(__INSIDE_CYGWIN__)
int _EXFUN(fstatat, (int, const char *__restrict , struct stat *__restrict, int));
int _EXFUN(mkdirat, (int, const char *, mode_t));
int _EXFUN(mkfifoat, (int, const char *, mode_t));
-#endif
-#if (__BSD_VISIBLE || __XSI_VISIBLE >= 700 || defined (__CYGWIN__)) && !defined(__INSIDE_CYGWIN__)
int _EXFUN(mknodat, (int, const char *, mode_t, dev_t));
-#endif
-#if (__BSD_VISIBLE || __POSIX_VISIBLE >= 200809 || defined (__CYGWIN__)) && !defined(__INSIDE_CYGWIN__)
int _EXFUN(utimensat, (int, const char *, const struct timespec *, int));
+#endif
+#if __POSIX2008_VISIBLE && !defined(__INSIDE_CYGWIN__)
int _EXFUN(futimens, (int, const struct timespec *));
#endif
diff --git a/newlib/libc/include/sys/time.h b/newlib/libc/include/sys/time.h
index 521be68..e24ffa5 100644
--- a/newlib/libc/include/sys/time.h
+++ b/newlib/libc/include/sys/time.h
@@ -416,24 +416,27 @@ int tvtohz(struct timeval *tv);
#include <sys/cdefs.h>
__BEGIN_DECLS
-int _EXFUN(setitimer, (int __which, const struct itimerval *__restrict __value,
- struct itimerval *__restrict __ovalue));
int _EXFUN(utimes, (const char *__path, const struct timeval *__tvp));
#if __BSD_VISIBLE
int _EXFUN(adjtime, (const struct timeval *, struct timeval *));
int _EXFUN(futimes, (int, const struct timeval *));
-int _EXFUN(futimesat, (int, const char *, const struct timeval [2]));
int _EXFUN(lutimes, (const char *, const struct timeval *));
int _EXFUN(settimeofday, (const struct timeval *, const struct timezone *));
#endif
-#if __XSI_VISIBLE
+#if __MISC_VISIBLE || (__POSIX2001_VISIBLE && !__POSIX2008_VISIBLE)
int _EXFUN(getitimer, (int __which, struct itimerval *__value));
+int _EXFUN(setitimer, (int __which, const struct itimerval *__restrict __value,
+ struct itimerval *__restrict __ovalue));
int _EXFUN(gettimeofday, (struct timeval *__restrict __p,
void *__restrict __tz));
#endif
+#if __GNU_VISIBLE
+int _EXFUN(futimesat, (int, const char *, const struct timeval [2]));
+#endif
+
#ifdef _COMPILING_NEWLIB
int _EXFUN(_gettimeofday, (struct timeval *__p, void *__tz));
#endif
diff --git a/newlib/libc/include/sys/types.h b/newlib/libc/include/sys/types.h
index 5dd6c75..10926da 100644
--- a/newlib/libc/include/sys/types.h
+++ b/newlib/libc/include/sys/types.h
@@ -84,11 +84,13 @@ typedef quad_t * qaddr_t;
#define _ST_INT32
#endif
-# if __BSD_VISIBLE
-
+#if __BSD_VISIBLE
# define physadr physadr_t
# define quad quad_t
+#endif
+/* These types are required by netinet/*.h on Cygwin */
+#if __BSD_VISIBLE || defined(__CYGWIN__)
#ifndef _BSDTYPES_DEFINED
/* also defined in mingw/gmon.h and in w32api/winsock[2].h */
#ifndef __u_char_defined
@@ -109,11 +111,13 @@ typedef unsigned long u_long;
#endif
#define _BSDTYPES_DEFINED
#endif
+#endif /*__BSD_VISIBLE || __CYGWIN__ */
+#if __MISC_VISIBLE
typedef unsigned short ushort; /* System V compatibility */
typedef unsigned int uint; /* System V compatibility */
typedef unsigned long ulong; /* System V compatibility */
-# endif /*__BSD_VISIBLE */
+#endif
#ifndef __clock_t_defined
typedef _CLOCK_T_ clock_t;
diff --git a/newlib/libc/include/sys/unistd.h b/newlib/libc/include/sys/unistd.h
index a1ad12e..6672a01 100644
--- a/newlib/libc/include/sys/unistd.h
+++ b/newlib/libc/include/sys/unistd.h
@@ -24,63 +24,67 @@ int _EXFUN(chmod, (const char *__path, mode_t __mode ));
#if !defined(__INSIDE_CYGWIN__)
int _EXFUN(chown, (const char *__path, uid_t __owner, gid_t __group ));
#endif
-#if defined(__CYGWIN__) || defined(__rtems__)
+#if __BSD_VISIBLE || (__XOPEN2_VISIBLE && !__POSIX2001_VISIBLE)
int _EXFUN(chroot, (const char *__path ));
#endif
int _EXFUN(close, (int __fildes ));
-#if defined(__CYGWIN__)
+#if __POSIX2_VISIBLE
size_t _EXFUN(confstr, (int __name, char *__buf, size_t __len));
#endif
char * _EXFUN(ctermid, (char *__s ));
char * _EXFUN(cuserid, (char *__s ));
-#if defined(__CYGWIN__)
+#if __BSD_VISIBLE || (__XOPEN_VISIBLE && !__XOPEN5_VISIBLE)
int _EXFUN(daemon, (int nochdir, int noclose));
#endif
int _EXFUN(dup, (int __fildes ));
int _EXFUN(dup2, (int __fildes, int __fildes2 ));
-#if defined(__CYGWIN__)
+#if __GNU_VISIBLE
int _EXFUN(dup3, (int __fildes, int __fildes2, int flags));
int _EXFUN(eaccess, (const char *__path, int __mode));
+#endif
+#if __BSD_VISIBLE || (__XOPEN_VISIBLE && !__XOPEN5_VISIBLE)
void _EXFUN(endusershell, (void));
+#endif
+#if __GNU_VISIBLE
int _EXFUN(euidaccess, (const char *__path, int __mode));
#endif
int _EXFUN(execl, (const char *__path, const char *, ... ));
int _EXFUN(execle, (const char *__path, const char *, ... ));
int _EXFUN(execlp, (const char *__file, const char *, ... ));
-#if defined(__CYGWIN__)
+#if defined(__CYGWIN__) /* QNX */
int _EXFUN(execlpe, (const char *__file, const char *, ... ));
#endif
int _EXFUN(execv, (const char *__path, char * const __argv[] ));
int _EXFUN(execve, (const char *__path, char * const __argv[], char * const __envp[] ));
int _EXFUN(execvp, (const char *__file, char * const __argv[] ));
-#if defined(__CYGWIN__)
+#if __GNU_VISIBLE
int _EXFUN(execvpe, (const char *__file, char * const __argv[], char * const __envp[] ));
#endif
-#if __POSIX_VISIBLE >= 200809 || __BSD_VISIBLE || defined(__CYGWIN__)
+#if __ATFILE_VISIBLE
int _EXFUN(faccessat, (int __dirfd, const char *__path, int __mode, int __flags));
#endif
-#if defined(__CYGWIN__) || defined(__rtems__) || defined(__SPU__)
+#if __BSD_VISIBLE || __XOPEN2_VISIBLE
int _EXFUN(fchdir, (int __fildes));
#endif
int _EXFUN(fchmod, (int __fildes, mode_t __mode ));
#if !defined(__INSIDE_CYGWIN__)
int _EXFUN(fchown, (int __fildes, uid_t __owner, gid_t __group ));
#endif
-#if __POSIX_VISIBLE >= 200809 || __BSD_VISIBLE || defined(__CYGWIN__)
+#if __ATFILE_VISIBLE
int _EXFUN(fchownat, (int __dirfd, const char *__path, uid_t __owner, gid_t __group, int __flags));
#endif
-#if defined(__CYGWIN__)
+#if __POSIX2008_VISIBLE
int _EXFUN(fexecve, (int __fd, char * const __argv[], char * const __envp[] ));
#endif
pid_t _EXFUN(fork, (void ));
long _EXFUN(fpathconf, (int __fd, int __name ));
int _EXFUN(fsync, (int __fd));
int _EXFUN(fdatasync, (int __fd));
-#if defined(__CYGWIN__)
+#if __GNU_VISIBLE
char * _EXFUN(get_current_dir_name, (void));
#endif
char * _EXFUN(getcwd, (char *__buf, size_t __size ));
-#if defined(__CYGWIN__)
+#if __BSD_VISIBLE || (__XOPEN_VISIBLE && !__XOPEN5_VISIBLE)
int _EXFUN(getdomainname ,(char *__name, size_t __len));
#endif
#if !defined(__INSIDE_CYGWIN__)
@@ -89,31 +93,35 @@ uid_t _EXFUN(geteuid, (void ));
gid_t _EXFUN(getgid, (void ));
#endif
int _EXFUN(getgroups, (int __gidsetsize, gid_t __grouplist[] ));
-#if defined(__CYGWIN__)
+#if __BSD_VISIBLE || __XOPEN2_VISIBLE
long _EXFUN(gethostid, (void));
#endif
char * _EXFUN(getlogin, (void ));
-#if defined(_POSIX_THREAD_SAFE_FUNCTIONS)
+#if defined(POSIX_THREAD_SAFE_FUNCTIONS)
int _EXFUN(getlogin_r, (char *name, size_t namesize) );
#endif
char * _EXFUN(getpass, (const char *__prompt));
int _EXFUN(getpagesize, (void));
-#if defined(__CYGWIN__)
+#if __BSD_VISIBLE
int _EXFUN(getpeereid, (int, uid_t *, gid_t *));
#endif
pid_t _EXFUN(getpgid, (pid_t));
pid_t _EXFUN(getpgrp, (void ));
pid_t _EXFUN(getpid, (void ));
pid_t _EXFUN(getppid, (void ));
-#if defined(__CYGWIN__) || defined(__rtems__)
+#if __POSIX2008_VISIBLE || __XOPEN2_VISIBLE
pid_t _EXFUN(getsid, (pid_t));
#endif
#if !defined(__INSIDE_CYGWIN__)
uid_t _EXFUN(getuid, (void ));
#endif
-#ifdef __CYGWIN__
+#if __BSD_VISIBLE || (__XOPEN_VISIBLE && !__XOPEN5_VISIBLE)
char * _EXFUN(getusershell, (void));
+#endif
+#if __BSD_VISIBLE || (__XOPEN2_VISIBLE && !__POSIX2008_VISIBLE)
char * _EXFUN(getwd, (char *__buf ));
+#endif
+#if __BSD_VISIBLE
int _EXFUN(iruserok, (unsigned long raddr, int superuser, const char *ruser, const char *luser));
#endif
int _EXFUN(isatty, (int __fildes ));
@@ -124,14 +132,14 @@ int _EXFUN(issetugid, (void));
int _EXFUN(lchown, (const char *__path, uid_t __owner, gid_t __group ));
#endif
int _EXFUN(link, (const char *__path1, const char *__path2 ));
-#if __POSIX_VISIBLE >= 200809 || __BSD_VISIBLE || defined(__CYGWIN__)
+#if __ATFILE_VISIBLE
int _EXFUN(linkat, (int __dirfd1, const char *__path1, int __dirfd2, const char *__path2, int __flags ));
#endif
int _EXFUN(nice, (int __nice_value ));
#if !defined(__INSIDE_CYGWIN__)
off_t _EXFUN(lseek, (int __fildes, off_t __offset, int __whence ));
#endif
-#if defined(__SPU__) || defined(__CYGWIN__)
+#if __MISC_VISIBLE || __XOPEN2_VISIBLE
#define F_ULOCK 0
#define F_LOCK 1
#define F_TLOCK 2
@@ -140,41 +148,41 @@ int _EXFUN(lockf, (int __fd, int __cmd, off_t __len));
#endif
long _EXFUN(pathconf, (const char *__path, int __name ));
int _EXFUN(pause, (void ));
-#ifdef __CYGWIN__
+#if __POSIX1C_VISIBLE
int _EXFUN(pthread_atfork, (void (*)(void), void (*)(void), void (*)(void)));
#endif
int _EXFUN(pipe, (int __fildes[2] ));
-#ifdef __CYGWIN__
+#if __GNU_VISIBLE
int _EXFUN(pipe2, (int __fildes[2], int flags));
#endif
ssize_t _EXFUN(pread, (int __fd, void *__buf, size_t __nbytes, off_t __offset));
ssize_t _EXFUN(pwrite, (int __fd, const void *__buf, size_t __nbytes, off_t __offset));
_READ_WRITE_RETURN_TYPE _EXFUN(read, (int __fd, void *__buf, size_t __nbyte ));
-#if defined(__CYGWIN__)
+#if __BSD_VISIBLE
int _EXFUN(rresvport, (int *__alport));
int _EXFUN(revoke, (char *__path));
#endif
int _EXFUN(rmdir, (const char *__path ));
-#if defined(__CYGWIN__)
+#if __BSD_VISIBLE
int _EXFUN(ruserok, (const char *rhost, int superuser, const char *ruser, const char *luser));
#endif
void * _EXFUN(sbrk, (ptrdiff_t __incr));
#if !defined(__INSIDE_CYGWIN__)
-#if defined(__CYGWIN__) || defined(__rtems__)
+#if __BSD_VISIBLE || __POSIX2001_VISIBLE
int _EXFUN(setegid, (gid_t __gid ));
int _EXFUN(seteuid, (uid_t __uid ));
#endif
int _EXFUN(setgid, (gid_t __gid ));
#endif
-#if defined(__CYGWIN__)
+#if __BSD_VISIBLE
int _EXFUN(setgroups, (int ngroups, const gid_t *grouplist ));
#endif
-#if __BSD_VISIBLE || (defined(_XOPEN_SOURCE) && __XSI_VISIBLE < 500)
+#if __BSD_VISIBLE || (__XOPEN_VISIBLE && !__XOPEN5_VISIBLE)
int _EXFUN(sethostname, (const char *, size_t));
#endif
int _EXFUN(setpgid, (pid_t __pid, pid_t __pgid ));
int _EXFUN(setpgrp, (void ));
-#if defined(__CYGWIN__) && !defined(__INSIDE_CYGWIN__)
+#if !defined(__INSIDE_CYGWIN__) && (__BSD_VISIBLE || __XOPEN2_VISIBLE)
int _EXFUN(setregid, (gid_t __rgid, gid_t __egid));
int _EXFUN(setreuid, (uid_t __ruid, uid_t __euid));
#endif
@@ -182,7 +190,7 @@ pid_t _EXFUN(setsid, (void ));
#if !defined(__INSIDE_CYGWIN__)
int _EXFUN(setuid, (uid_t __uid ));
#endif
-#if defined(__CYGWIN__)
+#if __BSD_VISIBLE || (__XOPEN_VISIBLE && !__XOPEN5_VISIBLE)
void _EXFUN(setusershell, (void));
#endif
unsigned _EXFUN(sleep, (unsigned int __seconds ));
@@ -191,9 +199,7 @@ long _EXFUN(sysconf, (int __name ));
pid_t _EXFUN(tcgetpgrp, (int __fildes ));
int _EXFUN(tcsetpgrp, (int __fildes, pid_t __pgrp_id ));
char * _EXFUN(ttyname, (int __fildes ));
-#if defined(__CYGWIN__) || defined(__rtems__)
int _EXFUN(ttyname_r, (int, char *, size_t));
-#endif
int _EXFUN(unlink, (const char *__path ));
int _EXFUN(usleep, (useconds_t __useconds));
int _EXFUN(vhangup, (void ));
@@ -210,9 +216,9 @@ int getopt(int, char * const [], const char *);
extern int optreset; /* getopt(3) external variable */
#endif
-#ifndef _POSIX_SOURCE
+#if __BSD_VISIBLE || (__XOPEN2_VISIBLE && !__POSIX2008_VISIBLE)
pid_t _EXFUN(vfork, (void ));
-#endif /* _POSIX_SOURCE */
+#endif
#ifdef _COMPILING_NEWLIB
/* Provide prototypes for most of the _<systemcall> names that are
@@ -255,14 +261,14 @@ char * _EXFUN(mktemp, (char *));
void _EXFUN(sync, (void));
#endif
+#if __BSD_VISIBLE || __POSIX2001_VISIBLE || __XOPEN2_VISIBLE
ssize_t _EXFUN(readlink, (const char *__restrict __path,
char *__restrict __buf, size_t __buflen));
-#if __POSIX_VISIBLE >= 200809 || __BSD_VISIBLE || defined(__CYGWIN__)
+int _EXFUN(symlink, (const char *__name1, const char *__name2));
+#endif
+#if __ATFILE_VISIBLE
ssize_t _EXFUN(readlinkat, (int __dirfd1, const char *__restrict __path,
char *__restrict __buf, size_t __buflen));
-#endif
-int _EXFUN(symlink, (const char *__name1, const char *__name2));
-#if __POSIX_VISIBLE >= 200809 || __BSD_VISIBLE || defined(__CYGWIN__)
int _EXFUN(symlinkat, (const char *, int, const char *));
int _EXFUN(unlinkat, (int, const char *, int));
#endif
diff --git a/newlib/libc/include/time.h b/newlib/libc/include/time.h
index b9d1f20..07d009b 100644
--- a/newlib/libc/include/time.h
+++ b/newlib/libc/include/time.h
@@ -8,6 +8,7 @@
#define _TIME_H_
#include "_ansi.h"
+#include <sys/cdefs.h>
#include <sys/reent.h>
#define __need_size_t
@@ -76,11 +77,14 @@ _END_STD_C
extern "C" {
#endif
-#ifndef __STRICT_ANSI__
+#if __XOPEN_VISIBLE
char *_EXFUN(strptime, (const char *__restrict,
const char *__restrict,
struct tm *__restrict));
+#endif
+#if __POSIX_VISIBLE
_VOID _EXFUN(tzset, (_VOID));
+#endif
_VOID _EXFUN(_tzset_r, (struct _reent *));
typedef struct __tzrule_struct
@@ -106,6 +110,7 @@ __tzinfo_type *_EXFUN (__gettzinfo, (_VOID));
/* getdate functions */
#ifdef HAVE_GETDATE
+#if __XOPEN2_VISIBLE
#ifndef _REENT_ONLY
#define getdate_err (*__getdate_err())
int *_EXFUN(__getdate_err,(_VOID));
@@ -121,21 +126,27 @@ struct tm * _EXFUN(getdate, (const char *));
7 there is no line in the template that matches the input,
8 invalid input specification */
#endif /* !_REENT_ONLY */
+#endif /* __XOPEN2_VISIBLE */
+#if __GNU_VISIBLE
/* getdate_r returns the error code as above */
int _EXFUN(getdate_r, (const char *, struct tm *));
+#endif /* __GNU_VISIBLE */
#endif /* HAVE_GETDATE */
/* defines for the opengroup specifications Derived from Issue 1 of the SVID. */
+#if __SVID_VISIBLE || __XOPEN_VISIBLE
extern __IMPORT long _timezone;
extern __IMPORT int _daylight;
+#endif
+#if __POSIX_VISIBLE
extern __IMPORT char *_tzname[2];
/* POSIX defines the external tzname being defined in time.h */
#ifndef tzname
#define tzname _tzname
#endif
-#endif /* !__STRICT_ANSI__ */
+#endif /* __POSIX_VISIBLE */
#ifdef __cplusplus
}
More information about the Newlib
mailing list