libc: update to a recent newlib version.

This commit is contained in:
Our Air Quality 2017-04-13 13:52:05 +10:00
parent cd23acaa4a
commit af4ac44cb5
77 changed files with 4496 additions and 9989 deletions

View file

@ -79,7 +79,7 @@ Current status is alpha quality, actively developed. AP STATION mode (ie wifi cl
* [FreeRTOS](http://www.freertos.org/) V9.0.0 * [FreeRTOS](http://www.freertos.org/) V9.0.0
* [lwIP](http://lwip.wikia.com/wiki/LwIP_Wiki) v2.0.3, with [some modifications](https://github.com/ourairquality/lwip/). * [lwIP](http://lwip.wikia.com/wiki/LwIP_Wiki) v2.0.3, with [some modifications](https://github.com/ourairquality/lwip/).
* [newlib](https://github.com/projectgus/newlib-xtensa) v2.2.0, with patches for xtensa support and locking stubs for thread-safe operation on FreeRTOS. * [newlib](https://github.com/ourairquality/newlib) v2.5.0, with patches for xtensa support and locking stubs for thread-safe operation on FreeRTOS.
For details of how third party libraries are integrated, [see the wiki page](https://github.com/SuperHouse/esp-open-rtos/wiki/Third-Party-Libraries). For details of how third party libraries are integrated, [see the wiki page](https://github.com/SuperHouse/esp-open-rtos/wiki/Third-Party-Libraries).

View file

@ -13,6 +13,7 @@
#include <esp/uart.h> #include <esp/uart.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdout_redirect.h> #include <stdout_redirect.h>
#include <sys/time.h>
extern void *xPortSupervisorStackPointer; extern void *xPortSupervisorStackPointer;
@ -135,6 +136,14 @@ int _stat_r(struct _reent *r, const char *pathname, void *buf);
__attribute__((weak, alias("syscall_returns_enosys"))) __attribute__((weak, alias("syscall_returns_enosys")))
off_t _lseek_r(struct _reent *r, int fd, off_t offset, int whence); off_t _lseek_r(struct _reent *r, int fd, off_t offset, int whence);
__attribute__((weak, alias("_gettimeofday_r")))
int _gettimeofday_r _PARAMS ((struct _reent *r, struct timeval *now, void *p)) {
now->tv_sec = 0;
now->tv_usec = 0;
errno = ENOSYS;
return -1;
}
/* Generic stub for any newlib syscall that fails with errno ENOSYS /* Generic stub for any newlib syscall that fails with errno ENOSYS
("Function not implemented") and a return value equivalent to ("Function not implemented") and a return value equivalent to
(int)-1. */ (int)-1. */

View file

@ -1,3 +1 @@
Newlib 2.2.0 with xtensa & locking patches, built from commit daa6ae40cdc8099f54c3e68a586fc1b906169c5a Newlib from git://sourceware.org/git/newlib-cygwin.git with xtensa & locking patches see https://github.com/ourairquality/newlib and built from commit cca8337a4eff8d590c54ce0a9cf335041d949296
For details on newlib in esp-open-rtos, see https://github.com/SuperHouse/esp-open-rtos/wiki/libc-configuration

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,12 @@
/* _newlib_version.h. Generated from _newlib_version.hin by configure. */
/* Version macros for internal and downstream use. */
#ifndef _NEWLIB_VERSION_H__
#define _NEWLIB_VERSION_H__ 1
#define _NEWLIB_VERSION "2.5.0"
#define __NEWLIB__ 2
#define __NEWLIB_MINOR__ 5
#define __NEWLIB_PATCHLEVEL__ 0
#endif /* !_NEWLIB_VERSION_H__ */

View file

@ -24,10 +24,12 @@ float complex cacosf(float complex);
/* 7.3.5.2 The casin functions */ /* 7.3.5.2 The casin functions */
double complex casin(double complex); double complex casin(double complex);
float complex casinf(float complex); float complex casinf(float complex);
long double complex casinl(long double complex);
/* 7.3.5.1 The catan functions */ /* 7.3.5.1 The catan functions */
double complex catan(double complex); double complex catan(double complex);
float complex catanf(float complex); float complex catanf(float complex);
long double complex catanl(long double complex);
/* 7.3.5.1 The ccos functions */ /* 7.3.5.1 The ccos functions */
double complex ccos(double complex); double complex ccos(double complex);
@ -74,6 +76,7 @@ float complex cexpf(float complex);
/* 7.3.7.2 The clog functions */ /* 7.3.7.2 The clog functions */
double complex clog(double complex); double complex clog(double complex);
float complex clogf(float complex); float complex clogf(float complex);
long double complex clogl(long double complex);
/* 7.3.8 Power and absolute-value functions */ /* 7.3.8 Power and absolute-value functions */
/* 7.3.8.1 The cabs functions */ /* 7.3.8.1 The cabs functions */
@ -83,6 +86,7 @@ float complex clogf(float complex);
float cabsf(float complex) __RENAME(__c99_cabsf); float cabsf(float complex) __RENAME(__c99_cabsf);
#endif #endif
*/ */
long double cabsl(long double complex) ;
double cabs(double complex) ; double cabs(double complex) ;
float cabsf(float complex) ; float cabsf(float complex) ;
@ -93,31 +97,56 @@ float complex cpowf(float complex, float complex);
/* 7.3.8.3 The csqrt functions */ /* 7.3.8.3 The csqrt functions */
double complex csqrt(double complex); double complex csqrt(double complex);
float complex csqrtf(float complex); float complex csqrtf(float complex);
long double complex csqrtl(long double complex);
/* 7.3.9 Manipulation functions */ /* 7.3.9 Manipulation functions */
/* 7.3.9.1 The carg functions */ /* 7.3.9.1 The carg functions */
double carg(double complex); double carg(double complex);
float cargf(float complex); float cargf(float complex);
long double cargl(long double complex);
/* 7.3.9.2 The cimag functions */ /* 7.3.9.2 The cimag functions */
double cimag(double complex); double cimag(double complex);
float cimagf(float complex); float cimagf(float complex);
/*long double cimagl(long double complex); */ long double cimagl(long double complex);
/* 7.3.9.3 The conj functions */ /* 7.3.9.3 The conj functions */
double complex conj(double complex); double complex conj(double complex);
float complex conjf(float complex); float complex conjf(float complex);
/*long double complex conjl(long double complex); */
/* 7.3.9.4 The cproj functions */ /* 7.3.9.4 The cproj functions */
double complex cproj(double complex); double complex cproj(double complex);
float complex cprojf(float complex); float complex cprojf(float complex);
/*long double complex cprojl(long double complex); */
/* 7.3.9.5 The creal functions */ /* 7.3.9.5 The creal functions */
double creal(double complex); double creal(double complex);
float crealf(float complex); float crealf(float complex);
/*long double creall(long double complex); */ long double creall(long double complex);
#if __GNU_VISIBLE
double complex clog10(double complex);
float complex clog10f(float complex);
#endif
#if defined(__CYGWIN__)
long double complex cacosl(long double complex);
long double complex ccosl(long double complex);
long double complex csinl(long double complex);
long double complex ctanl(long double complex);
long double complex cacoshl(long double complex);
long double complex casinhl(long double complex);
long double complex catanhl(long double complex);
long double complex ccoshl(long double complex);
long double complex csinhl(long double complex);
long double complex ctanhl(long double complex);
long double complex cexpl(long double complex);
long double complex cpowl(long double complex, long double complex);
long double complex conjl(long double complex);
long double complex cprojl(long double complex);
#if __GNU_VISIBLE
long double complex clog10l(long double complex);
#endif
#endif /* __CYGWIN__ */
__END_DECLS __END_DECLS

View file

@ -0,0 +1,30 @@
/* POSIX.1 symbolic constants for c_mode field of cpio archive format */
#ifndef _CPIO_H
#define _CPIO_H
#define C_IRUSR 0000400 /* Read by owner */
#define C_IWUSR 0000200 /* Write by owner */
#define C_IXUSR 0000100 /* Execute by owner */
#define C_IRGRP 0000040 /* Read by group */
#define C_IWGRP 0000020 /* Write by group */
#define C_IXGRP 0000010 /* Execute by group */
#define C_IROTH 0000004 /* Read by others */
#define C_IWOTH 0000002 /* Write by others */
#define C_IXOTH 0000001 /* Execute by others */
#define C_ISUID 0004000 /* Set user ID */
#define C_ISGID 0002000 /* Set group ID */
#define C_ISVTX 0001000 /* On directories, restricted deletion flag */
#define C_ISDIR 0040000 /* Directory */
#define C_ISFIFO 0010000 /* FIFO */
#define C_ISREG 0100000 /* Regular file */
#define C_ISBLK 0060000 /* Block special */
#define C_ISCHR 0020000 /* Character special */
#define C_ISCTG 0110000 /* Reserved */
#define C_ISLNK 0120000 /* Symbolic link */
#define C_ISSOCK 0140000 /* Socket */
#define MAGIC "070707"
#endif /* _CPIO_H */

View file

@ -2,6 +2,11 @@
#define _CTYPE_H_ #define _CTYPE_H_
#include "_ansi.h" #include "_ansi.h"
#include <sys/cdefs.h>
#if __POSIX_VISIBLE >= 200809 || __MISC_VISIBLE || defined (_COMPILING_NEWLIB)
#include <xlocale.h>
#endif
_BEGIN_STD_C _BEGIN_STD_C
@ -19,17 +24,39 @@ int _EXFUN(isxdigit,(int __c));
int _EXFUN(tolower, (int __c)); int _EXFUN(tolower, (int __c));
int _EXFUN(toupper, (int __c)); int _EXFUN(toupper, (int __c));
#if !defined(__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L #if __ISO_C_VISIBLE >= 1999
int _EXFUN(isblank, (int __c)); int _EXFUN(isblank, (int __c));
#endif #endif
#ifndef __STRICT_ANSI__ #if __MISC_VISIBLE || __XSI_VISIBLE
int _EXFUN(isascii, (int __c)); int _EXFUN(isascii, (int __c));
int _EXFUN(toascii, (int __c)); int _EXFUN(toascii, (int __c));
#define _tolower(__c) ((unsigned char)(__c) - 'A' + 'a') #define _tolower(__c) ((unsigned char)(__c) - 'A' + 'a')
#define _toupper(__c) ((unsigned char)(__c) - 'a' + 'A') #define _toupper(__c) ((unsigned char)(__c) - 'a' + 'A')
#endif #endif
#if __POSIX_VISIBLE >= 200809
extern int isalnum_l (int __c, locale_t __l);
extern int isalpha_l (int __c, locale_t __l);
extern int isblank_l (int __c, locale_t __l);
extern int iscntrl_l (int __c, locale_t __l);
extern int isdigit_l (int __c, locale_t __l);
extern int isgraph_l (int __c, locale_t __l);
extern int islower_l (int __c, locale_t __l);
extern int isprint_l (int __c, locale_t __l);
extern int ispunct_l (int __c, locale_t __l);
extern int isspace_l (int __c, locale_t __l);
extern int isupper_l (int __c, locale_t __l);
extern int isxdigit_l(int __c, locale_t __l);
extern int tolower_l (int __c, locale_t __l);
extern int toupper_l (int __c, locale_t __l);
#endif
#if __MISC_VISIBLE
extern int isascii_l (int __c, locale_t __l);
extern int toascii_l (int __c, locale_t __l);
#endif
#define _U 01 #define _U 01
#define _L 02 #define _L 02
#define _N 04 #define _N 04
@ -39,22 +66,20 @@ int _EXFUN(toascii, (int __c));
#define _X 0100 #define _X 0100
#define _B 0200 #define _B 0200
#ifndef _MB_CAPABLE const char *__locale_ctype_ptr (void);
_CONST # define __CTYPE_PTR (__locale_ctype_ptr ())
#endif
extern __IMPORT char *__ctype_ptr__;
#ifndef __cplusplus #ifndef __cplusplus
/* These macros are intentionally written in a manner that will trigger /* These macros are intentionally written in a manner that will trigger
a gcc -Wall warning if the user mistakenly passes a 'char' instead a gcc -Wall warning if the user mistakenly passes a 'char' instead
of an int containing an 'unsigned char'. Note that the sizeof will of an int containing an 'unsigned char'. Note that the sizeof will
always be 1, which is what we want for mapping EOF to __ctype_ptr__[0]; always be 1, which is what we want for mapping EOF to __CTYPE_PTR[0];
the use of a raw index inside the sizeof triggers the gcc warning if the use of a raw index inside the sizeof triggers the gcc warning if
__c was of type char, and sizeof masks side effects of the extra __c. __c was of type char, and sizeof masks side effects of the extra __c.
Meanwhile, the real index to __ctype_ptr__+1 must be cast to int, Meanwhile, the real index to __CTYPE_PTR+1 must be cast to int,
since isalpha(0x100000001LL) must equal isalpha(1), rather than being since isalpha(0x100000001LL) must equal isalpha(1), rather than being
an out-of-bounds reference on a 64-bit machine. */ an out-of-bounds reference on a 64-bit machine. */
#define __ctype_lookup(__c) ((__ctype_ptr__+sizeof(""[__c]))[(int)(__c)]) #define __ctype_lookup(__c) ((__CTYPE_PTR+sizeof(""[__c]))[(int)(__c)])
#define isalpha(__c) (__ctype_lookup(__c)&(_U|_L)) #define isalpha(__c) (__ctype_lookup(__c)&(_U|_L))
#define isupper(__c) ((__ctype_lookup(__c)&(_U|_L))==_U) #define isupper(__c) ((__ctype_lookup(__c)&(_U|_L))==_U)
@ -68,13 +93,45 @@ extern __IMPORT char *__ctype_ptr__;
#define isgraph(__c) (__ctype_lookup(__c)&(_P|_U|_L|_N)) #define isgraph(__c) (__ctype_lookup(__c)&(_P|_U|_L|_N))
#define iscntrl(__c) (__ctype_lookup(__c)&_C) #define iscntrl(__c) (__ctype_lookup(__c)&_C)
#if defined(__GNUC__) && \ #if defined(__GNUC__) && __ISO_C_VISIBLE >= 1999
(!defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901L)
#define isblank(__c) \ #define isblank(__c) \
__extension__ ({ __typeof__ (__c) __x = (__c); \ __extension__ ({ __typeof__ (__c) __x = (__c); \
(__ctype_lookup(__x)&_B) || (int) (__x) == '\t';}) (__ctype_lookup(__x)&_B) || (int) (__x) == '\t';})
#endif #endif
#if __POSIX_VISIBLE >= 200809
const char *__locale_ctype_ptr_l (locale_t);
#define __ctype_lookup_l(__c,__l) ((__locale_ctype_ptr_l(__l)+sizeof(""[__c]))[(int)(__c)])
#define isalpha_l(__c,__l) (__ctype_lookup_l(__c,__l)&(_U|_L))
#define isupper_l(__c,__l) ((__ctype_lookup_l(__c,__l)&(_U|_L))==_U)
#define islower_l(__c,__l) ((__ctype_lookup_l(__c,__l)&(_U|_L))==_L)
#define isdigit_l(__c,__l) (__ctype_lookup_l(__c,__l)&_N)
#define isxdigit_l(__c,__l) (__ctype_lookup_l(__c,__l)&(_X|_N))
#define isspace_l(__c,__l) (__ctype_lookup_l(__c,__l)&_S)
#define ispunct_l(__c,__l) (__ctype_lookup_l(__c,__l)&_P)
#define isalnum_l(__c,__l) (__ctype_lookup_l(__c,__l)&(_U|_L|_N))
#define isprint_l(__c,__l) (__ctype_lookup_l(__c,__l)&(_P|_U|_L|_N|_B))
#define isgraph_l(__c,__l) (__ctype_lookup_l(__c,__l)&(_P|_U|_L|_N))
#define iscntrl_l(__c,__l) (__ctype_lookup_l(__c,__l)&_C)
#if defined(__GNUC__)
#define isblank_l(__c, __l) \
__extension__ ({ __typeof__ (__c) __x = (__c); \
(__ctype_lookup_l(__x,__l)&_B) || (int) (__x) == '\t';})
#endif
#endif /* __POSIX_VISIBLE >= 200809 */
#if __MISC_VISIBLE || __XSI_VISIBLE
#define isascii(__c) ((unsigned)(__c)<=0177)
#define toascii(__c) ((__c)&0177)
#endif
#if __MISC_VISIBLE
#define isascii_l(__c,__l) ((__l),(unsigned)(__c)<=0177)
#define toascii_l(__c,__l) ((__l),(__c)&0177)
#endif
/* Non-gcc versions will get the library versions, and will be /* Non-gcc versions will get the library versions, and will be
slightly slower. These macros are not NLS-aware so they are slightly slower. These macros are not NLS-aware so they are
@ -92,18 +149,17 @@ extern __IMPORT char *__ctype_ptr__;
function. */ function. */
# define toupper(__c) \ # define toupper(__c) \
__extension__ ({ __typeof__ (__c) __x = (__c); \ __extension__ ({ __typeof__ (__c) __x = (__c); \
(void) __ctype_ptr__[__x]; (toupper) (__x);}) (void) __CTYPE_PTR[__x]; (toupper) (__x);})
# define tolower(__c) \ # define tolower(__c) \
__extension__ ({ __typeof__ (__c) __x = (__c); \ __extension__ ({ __typeof__ (__c) __x = (__c); \
(void) __ctype_ptr__[__x]; (tolower) (__x);}) (void) __CTYPE_PTR[__x]; (tolower) (__x);})
# endif /* _MB_EXTENDED_CHARSETS* */ # endif /* _MB_EXTENDED_CHARSETS* */
# endif /* __GNUC__ */ # endif /* __GNUC__ */
#endif /* !__cplusplus */
#ifndef __STRICT_ANSI__ #if __POSIX_VISIBLE >= 200809
#define isascii(__c) ((unsigned)(__c)<=0177) #endif /* __POSIX_VISIBLE >= 200809 */
#define toascii(__c) ((__c)&0177)
#endif #endif /* !__cplusplus */
/* For C++ backward-compatibility only. */ /* For C++ backward-compatibility only. */
extern __IMPORT _CONST char _ctype_[]; extern __IMPORT _CONST char _ctype_[];

View file

@ -0,0 +1,51 @@
/*
* Copyright (c) 2016 Joel Sherrill <joel@rtems.org>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _POSIX_DEVCTL_h_
#define _POSIX_DEVCTL_h_
/*
* The posix_devctl() method is defined by POSIX 1003.26-2003. Aside
* from the single method, it adds the following requirements:
*
* + define _POSIX_26_VERSION to 200312L
* + add _SC_POSIX_26_VERSION in <unistd.h>. Return _POSIX_26_VERSION
* + application must define _POSIX_26_C_SOURCE to use posix_devctl().
* + posix_devctl() is prototyped in <devctl.h>
*/
#ifdef _POSIX_26_C_SOURCE
#include <sys/cdefs.h>
int posix_devctl(
int fd,
int dcmd,
void *__restrict dev_data_ptr,
size_t nbyte,
int *__restrict dev_info_ptr
);
#endif
#endif

View file

@ -3,9 +3,10 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include <sys/cdefs.h>
#include <sys/dirent.h> #include <sys/dirent.h>
#if !defined(MAXNAMLEN) && !defined(_POSIX_SOURCE) #if !defined(MAXNAMLEN) && __BSD_VISIBLE
#define MAXNAMLEN 1024 #define MAXNAMLEN 1024
#endif #endif

View file

@ -33,21 +33,21 @@
#ifndef _FNMATCH_H_ #ifndef _FNMATCH_H_
#define _FNMATCH_H_ #define _FNMATCH_H_
#include <sys/cdefs.h>
#define FNM_NOMATCH 1 /* Match failed. */ #define FNM_NOMATCH 1 /* Match failed. */
#define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */ #define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */
#define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */ #define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */
#define FNM_PERIOD 0x04 /* Period must be matched by period. */ #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_LEADING_DIR 0x08 /* Ignore /<tail> after Imatch. */
#define FNM_CASEFOLD 0x10 /* Case insensitive search. */ #define FNM_CASEFOLD 0x10 /* Case insensitive search. */
#define FNM_IGNORECASE FNM_CASEFOLD #define FNM_IGNORECASE FNM_CASEFOLD
#define FNM_FILE_NAME FNM_PATHNAME #define FNM_FILE_NAME FNM_PATHNAME
#endif #endif
#include <sys/cdefs.h>
__BEGIN_DECLS __BEGIN_DECLS
int fnmatch(const char *, const char *, int); int fnmatch(const char *, const char *, int);
__END_DECLS __END_DECLS

View file

@ -49,7 +49,7 @@
#include <cygwin/grp.h> #include <cygwin/grp.h>
#endif #endif
#if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE) #if __BSD_VISIBLE
#define _PATH_GROUP "/etc/group" #define _PATH_GROUP "/etc/group"
#endif #endif
@ -67,25 +67,20 @@ extern "C" {
#ifndef __INSIDE_CYGWIN__ #ifndef __INSIDE_CYGWIN__
struct group *getgrgid (gid_t); struct group *getgrgid (gid_t);
struct group *getgrnam (const char *); struct group *getgrnam (const char *);
#if __MISC_VISIBLE || __POSIX_VISIBLE
int getgrnam_r (const char *, struct group *, int getgrnam_r (const char *, struct group *,
char *, size_t, struct group **); char *, size_t, struct group **);
int getgrgid_r (gid_t, struct group *, int getgrgid_r (gid_t, struct group *,
char *, size_t, struct group **); char *, size_t, struct group **);
#ifndef _POSIX_SOURCE #endif /* __MISC_VISIBLE || __POSIX_VISIBLE */
#if __MISC_VISIBLE || __XSI_VISIBLE >= 4
struct group *getgrent (void); struct group *getgrent (void);
void setgrent (void); void setgrent (void);
void endgrent (void); void endgrent (void);
#ifndef __CYGWIN__ #endif /* __MISC_VISIBLE || __XSI_VISIBLE >= 4 */
void setgrfile (const char *); #if __BSD_VISIBLE
#endif /* !__CYGWIN__ */
#ifndef _XOPEN_SOURCE
#ifndef __CYGWIN__
char *group_from_gid (gid_t, int);
int setgroupent (int);
#endif /* !__CYGWIN__ */
int initgroups (const char *, gid_t); int initgroups (const char *, gid_t);
#endif /* !_XOPEN_SOURCE */ #endif /* __BSD_VISIBLE */
#endif /* !_POSIX_SOURCE */
#endif /* !__INSIDE_CYGWIN__ */ #endif /* !__INSIDE_CYGWIN__ */
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -4,11 +4,12 @@
#include "_ansi.h" #include "_ansi.h"
#include <machine/ieeefp.h> #include <machine/ieeefp.h>
#include <float.h>
_BEGIN_STD_C _BEGIN_STD_C
/* FIXME FIXME FIXME: /* FIXME FIXME FIXME:
Neither of __ieee_{float,double}_shape_tape seem to be used anywhere Neither of __ieee_{float,double}_shape_type seem to be used anywhere
except in libm/test. If that is the case, please delete these from here. except in libm/test. If that is the case, please delete these from here.
If that is not the case, please insert documentation here describing why If that is not the case, please insert documentation here describing why
they're needed. */ they're needed. */
@ -46,9 +47,7 @@ typedef union
long aslong[2]; long aslong[2];
} __ieee_double_shape_type; } __ieee_double_shape_type;
#endif #elif defined __IEEE_LITTLE_ENDIAN
#ifdef __IEEE_LITTLE_ENDIAN
typedef union typedef union
{ {
@ -92,7 +91,7 @@ typedef union
} __ieee_double_shape_type; } __ieee_double_shape_type;
#endif #endif /* __IEEE_LITTLE_ENDIAN */
#ifdef __IEEE_BIG_ENDIAN #ifdef __IEEE_BIG_ENDIAN
@ -118,9 +117,7 @@ typedef union
} __ieee_float_shape_type; } __ieee_float_shape_type;
#endif #elif defined __IEEE_LITTLE_ENDIAN
#ifdef __IEEE_LITTLE_ENDIAN
typedef union typedef union
{ {
@ -144,10 +141,70 @@ typedef union
} __ieee_float_shape_type; } __ieee_float_shape_type;
#endif /* __IEEE_LITTLE_ENDIAN */
#ifndef _LDBL_EQ_DBL
#ifndef LDBL_MANT_DIG
#error "LDBL_MANT_DIG not defined - should be found in float.h"
#elif LDBL_MANT_DIG == DBL_MANT_DIG
#error "double and long double are the same size but LDBL_EQ_DBL is not defined"
#elif LDBL_MANT_DIG == 53
/* This happens when doubles are 32-bits and long doubles are 64-bits. */
#define EXT_EXPBITS 11
#define EXT_FRACHBITS 20
#define EXT_FRACLBITS 32
#define __ieee_ext_field_type unsigned long
#elif LDBL_MANT_DIG == 64
#define EXT_EXPBITS 15
#define EXT_FRACHBITS 32
#define EXT_FRACLBITS 32
#define __ieee_ext_field_type unsigned int
#elif LDBL_MANT_DIG == 65
#define EXT_EXPBITS 15
#define EXT_FRACHBITS 32
#define EXT_FRACLBITS 32
#define __ieee_ext_field_type unsigned int
#elif LDBL_MANT_DIG == 112
#define EXT_EXPBITS 15
#define EXT_FRACHBITS 48
#define EXT_FRACLBITS 64
#define __ieee_ext_field_type unsigned long long
#elif LDBL_MANT_DIG == 113
#define EXT_EXPBITS 15
#define EXT_FRACHBITS 48
#define EXT_FRACLBITS 64
#define __ieee_ext_field_type unsigned long long
#else
#error Unsupported value for LDBL_MANT_DIG
#endif #endif
#define EXT_EXP_INFNAN ((1 << EXT_EXPBITS) - 1) /* 32767 */
#define EXT_EXP_BIAS ((1 << (EXT_EXPBITS - 1)) - 1) /* 16383 */
#define EXT_FRACBITS (EXT_FRACLBITS + EXT_FRACHBITS)
typedef struct ieee_ext
{
__ieee_ext_field_type ext_fracl : EXT_FRACLBITS;
__ieee_ext_field_type ext_frach : EXT_FRACHBITS;
__ieee_ext_field_type ext_exp : EXT_EXPBITS;
__ieee_ext_field_type ext_sign : 1;
} ieee_ext;
typedef union ieee_ext_u
{
long double extu_ld;
struct ieee_ext extu_ext;
} ieee_ext_u;
#endif /* ! _LDBL_EQ_DBL */
/* FLOATING ROUNDING */ /* FLOATING ROUNDING */
@ -184,19 +241,6 @@ typedef int fp_rdi;
fp_rdi _EXFUN(fpgetroundtoi,(void)); fp_rdi _EXFUN(fpgetroundtoi,(void));
fp_rdi _EXFUN(fpsetroundtoi,(fp_rdi)); fp_rdi _EXFUN(fpsetroundtoi,(fp_rdi));
#undef isnan
#undef isinf
int _EXFUN(isnan, (double));
int _EXFUN(isinf, (double));
int _EXFUN(finite, (double));
int _EXFUN(isnanf, (float));
int _EXFUN(isinff, (float));
int _EXFUN(finitef, (float));
#define __IEEE_DBL_EXPBIAS 1023 #define __IEEE_DBL_EXPBIAS 1023
#define __IEEE_FLT_EXPBIAS 127 #define __IEEE_FLT_EXPBIAS 127
@ -213,22 +257,17 @@ int _EXFUN(finitef, (float));
#define __IEEE_DBL_NAN_EXP 0x7ff #define __IEEE_DBL_NAN_EXP 0x7ff
#define __IEEE_FLT_NAN_EXP 0xff #define __IEEE_FLT_NAN_EXP 0xff
#ifndef __ieeefp_isnanf #ifdef __ieeefp_isnanf
#define __ieeefp_isnanf(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \
((*(long *)&(x) & 0x007fffffL)!=0000000000L))
#endif
#define isnanf(x) __ieeefp_isnanf(x) #define isnanf(x) __ieeefp_isnanf(x)
#ifndef __ieeefp_isinff
#define __ieeefp_isinff(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \
((*(long *)&(x) & 0x007fffffL)==0000000000L))
#endif #endif
#ifdef __ieeefp_isinff
#define isinff(x) __ieeefp_isinff(x) #define isinff(x) __ieeefp_isinff(x)
#ifndef __ieeefp_finitef
#define __ieeefp_finitef(x) (((*(long *)&(x) & 0x7f800000L)!=0x7f800000L))
#endif #endif
#ifdef __ieeefp_finitef
#define finitef(x) __ieeefp_finitef(x) #define finitef(x) __ieeefp_finitef(x)
#endif
#ifdef _DOUBLE_IS_32BITS #ifdef _DOUBLE_IS_32BITS
#undef __IEEE_DBL_EXPBIAS #undef __IEEE_DBL_EXPBIAS

View file

@ -14,6 +14,7 @@
#define _INTTYPES_H #define _INTTYPES_H
#include <newlib.h> #include <newlib.h>
#include <sys/config.h>
#include <sys/_intsup.h> #include <sys/_intsup.h>
#include <stdint.h> #include <stdint.h>
#define __need_wchar_t #define __need_wchar_t
@ -22,7 +23,9 @@
#define __STRINGIFY(a) #a #define __STRINGIFY(a) #a
/* 8-bit types */ /* 8-bit types */
#define __PRI8(x) __STRINGIFY(x) #define __PRI8(x) __INT8 __STRINGIFY(x)
#define __PRI8LEAST(x) __LEAST8 __STRINGIFY(x)
#define __PRI8FAST(x) __FAST8 __STRINGIFY(x)
/* NOTICE: scanning 8-bit types requires use of the hh specifier /* NOTICE: scanning 8-bit types requires use of the hh specifier
* which is only supported on newlib platforms that * which is only supported on newlib platforms that
@ -35,7 +38,9 @@
*/ */
#if defined(_WANT_IO_C99_FORMATS) #if defined(_WANT_IO_C99_FORMATS)
#define __SCN8(x) __STRINGIFY(hh##x) #define __SCN8(x) __INT8 __STRINGIFY(x)
#define __SCN8LEAST(x) __LEAST8 __STRINGIFY(x)
#define __SCN8FAST(x) __FAST8 __STRINGIFY(x)
#endif /* _WANT_IO_C99_FORMATS */ #endif /* _WANT_IO_C99_FORMATS */
@ -58,45 +63,49 @@
#endif /* _WANT_IO_C99_FORMATS */ #endif /* _WANT_IO_C99_FORMATS */
#define PRIdLEAST8 __PRI8(d) #define PRIdLEAST8 __PRI8LEAST(d)
#define PRIiLEAST8 __PRI8(i) #define PRIiLEAST8 __PRI8LEAST(i)
#define PRIoLEAST8 __PRI8(o) #define PRIoLEAST8 __PRI8LEAST(o)
#define PRIuLEAST8 __PRI8(u) #define PRIuLEAST8 __PRI8LEAST(u)
#define PRIxLEAST8 __PRI8(x) #define PRIxLEAST8 __PRI8LEAST(x)
#define PRIXLEAST8 __PRI8(X) #define PRIXLEAST8 __PRI8LEAST(X)
/* Macros below are only enabled for a newlib built with C99 I/O format support. */ /* Macros below are only enabled for a newlib built with C99 I/O format support. */
#if defined(_WANT_IO_C99_FORMATS) #if defined(_WANT_IO_C99_FORMATS)
#define SCNdLEAST8 __SCN8(d) #define SCNdLEAST8 __SCN8LEAST(d)
#define SCNiLEAST8 __SCN8(i) #define SCNiLEAST8 __SCN8LEAST(i)
#define SCNoLEAST8 __SCN8(o) #define SCNoLEAST8 __SCN8LEAST(o)
#define SCNuLEAST8 __SCN8(u) #define SCNuLEAST8 __SCN8LEAST(u)
#define SCNxLEAST8 __SCN8(x) #define SCNxLEAST8 __SCN8LEAST(x)
#endif /* _WANT_IO_C99_FORMATS */ #endif /* _WANT_IO_C99_FORMATS */
#define PRIdFAST8 __PRI8(d) #define PRIdFAST8 __PRI8FAST(d)
#define PRIiFAST8 __PRI8(i) #define PRIiFAST8 __PRI8FAST(i)
#define PRIoFAST8 __PRI8(o) #define PRIoFAST8 __PRI8FAST(o)
#define PRIuFAST8 __PRI8(u) #define PRIuFAST8 __PRI8FAST(u)
#define PRIxFAST8 __PRI8(x) #define PRIxFAST8 __PRI8FAST(x)
#define PRIXFAST8 __PRI8(X) #define PRIXFAST8 __PRI8FAST(X)
/* Macros below are only enabled for a newlib built with C99 I/O format support. */ /* Macros below are only enabled for a newlib built with C99 I/O format support. */
#if defined(_WANT_IO_C99_FORMATS) #if defined(_WANT_IO_C99_FORMATS)
#define SCNdFAST8 __SCN8(d) #define SCNdFAST8 __SCN8FAST(d)
#define SCNiFAST8 __SCN8(i) #define SCNiFAST8 __SCN8FAST(i)
#define SCNoFAST8 __SCN8(o) #define SCNoFAST8 __SCN8FAST(o)
#define SCNuFAST8 __SCN8(u) #define SCNuFAST8 __SCN8FAST(u)
#define SCNxFAST8 __SCN8(x) #define SCNxFAST8 __SCN8FAST(x)
#endif /* _WANT_IO_C99_FORMATS */ #endif /* _WANT_IO_C99_FORMATS */
/* 16-bit types */ /* 16-bit types */
#define __PRI16(x) __STRINGIFY(x) #define __PRI16(x) __INT16 __STRINGIFY(x)
#define __SCN16(x) __STRINGIFY(h##x) #define __PRI16LEAST(x) __LEAST16 __STRINGIFY(x)
#define __PRI16FAST(x) __FAST16 __STRINGIFY(x)
#define __SCN16(x) __INT16 __STRINGIFY(x)
#define __SCN16LEAST(x) __LEAST16 __STRINGIFY(x)
#define __SCN16FAST(x) __FAST16 __STRINGIFY(x)
#define PRId16 __PRI16(d) #define PRId16 __PRI16(d)
@ -113,41 +122,40 @@
#define SCNx16 __SCN16(x) #define SCNx16 __SCN16(x)
#define PRIdLEAST16 __PRI16(d) #define PRIdLEAST16 __PRI16LEAST(d)
#define PRIiLEAST16 __PRI16(i) #define PRIiLEAST16 __PRI16LEAST(i)
#define PRIoLEAST16 __PRI16(o) #define PRIoLEAST16 __PRI16LEAST(o)
#define PRIuLEAST16 __PRI16(u) #define PRIuLEAST16 __PRI16LEAST(u)
#define PRIxLEAST16 __PRI16(x) #define PRIxLEAST16 __PRI16LEAST(x)
#define PRIXLEAST16 __PRI16(X) #define PRIXLEAST16 __PRI16LEAST(X)
#define SCNdLEAST16 __SCN16(d) #define SCNdLEAST16 __SCN16LEAST(d)
#define SCNiLEAST16 __SCN16(i) #define SCNiLEAST16 __SCN16LEAST(i)
#define SCNoLEAST16 __SCN16(o) #define SCNoLEAST16 __SCN16LEAST(o)
#define SCNuLEAST16 __SCN16(u) #define SCNuLEAST16 __SCN16LEAST(u)
#define SCNxLEAST16 __SCN16(x) #define SCNxLEAST16 __SCN16LEAST(x)
#define PRIdFAST16 __PRI16(d) #define PRIdFAST16 __PRI16FAST(d)
#define PRIiFAST16 __PRI16(i) #define PRIiFAST16 __PRI16FAST(i)
#define PRIoFAST16 __PRI16(o) #define PRIoFAST16 __PRI16FAST(o)
#define PRIuFAST16 __PRI16(u) #define PRIuFAST16 __PRI16FAST(u)
#define PRIxFAST16 __PRI16(x) #define PRIxFAST16 __PRI16FAST(x)
#define PRIXFAST16 __PRI16(X) #define PRIXFAST16 __PRI16FAST(X)
#define SCNdFAST16 __SCN16(d) #define SCNdFAST16 __SCN16FAST(d)
#define SCNiFAST16 __SCN16(i) #define SCNiFAST16 __SCN16FAST(i)
#define SCNoFAST16 __SCN16(o) #define SCNoFAST16 __SCN16FAST(o)
#define SCNuFAST16 __SCN16(u) #define SCNuFAST16 __SCN16FAST(u)
#define SCNxFAST16 __SCN16(x) #define SCNxFAST16 __SCN16FAST(x)
/* 32-bit types */ /* 32-bit types */
#if __have_long32 #define __PRI32(x) __INT32 __STRINGIFY(x)
#define __PRI32(x) __STRINGIFY(l##x) #define __SCN32(x) __INT32 __STRINGIFY(x)
#define __SCN32(x) __STRINGIFY(l##x) #define __PRI32LEAST(x) __LEAST32 __STRINGIFY(x)
#else #define __SCN32LEAST(x) __LEAST32 __STRINGIFY(x)
#define __PRI32(x) __STRINGIFY(x) #define __PRI32FAST(x) __FAST32 __STRINGIFY(x)
#define __SCN32(x) __STRINGIFY(x) #define __SCN32FAST(x) __FAST32 __STRINGIFY(x)
#endif
#define PRId32 __PRI32(d) #define PRId32 __PRI32(d)
#define PRIi32 __PRI32(i) #define PRIi32 __PRI32(i)
@ -163,46 +171,44 @@
#define SCNx32 __SCN32(x) #define SCNx32 __SCN32(x)
#define PRIdLEAST32 __PRI32(d) #define PRIdLEAST32 __PRI32LEAST(d)
#define PRIiLEAST32 __PRI32(i) #define PRIiLEAST32 __PRI32LEAST(i)
#define PRIoLEAST32 __PRI32(o) #define PRIoLEAST32 __PRI32LEAST(o)
#define PRIuLEAST32 __PRI32(u) #define PRIuLEAST32 __PRI32LEAST(u)
#define PRIxLEAST32 __PRI32(x) #define PRIxLEAST32 __PRI32LEAST(x)
#define PRIXLEAST32 __PRI32(X) #define PRIXLEAST32 __PRI32LEAST(X)
#define SCNdLEAST32 __SCN32(d) #define SCNdLEAST32 __SCN32LEAST(d)
#define SCNiLEAST32 __SCN32(i) #define SCNiLEAST32 __SCN32LEAST(i)
#define SCNoLEAST32 __SCN32(o) #define SCNoLEAST32 __SCN32LEAST(o)
#define SCNuLEAST32 __SCN32(u) #define SCNuLEAST32 __SCN32LEAST(u)
#define SCNxLEAST32 __SCN32(x) #define SCNxLEAST32 __SCN32LEAST(x)
#define PRIdFAST32 __PRI32(d) #define PRIdFAST32 __PRI32FAST(d)
#define PRIiFAST32 __PRI32(i) #define PRIiFAST32 __PRI32FAST(i)
#define PRIoFAST32 __PRI32(o) #define PRIoFAST32 __PRI32FAST(o)
#define PRIuFAST32 __PRI32(u) #define PRIuFAST32 __PRI32FAST(u)
#define PRIxFAST32 __PRI32(x) #define PRIxFAST32 __PRI32FAST(x)
#define PRIXFAST32 __PRI32(X) #define PRIXFAST32 __PRI32FAST(X)
#define SCNdFAST32 __SCN32(d) #define SCNdFAST32 __SCN32FAST(d)
#define SCNiFAST32 __SCN32(i) #define SCNiFAST32 __SCN32FAST(i)
#define SCNoFAST32 __SCN32(o) #define SCNoFAST32 __SCN32FAST(o)
#define SCNuFAST32 __SCN32(u) #define SCNuFAST32 __SCN32FAST(u)
#define SCNxFAST32 __SCN32(x) #define SCNxFAST32 __SCN32FAST(x)
/* 64-bit types */ /* 64-bit types */
#if __have_long64 #define __PRI64(x) __INT64 __STRINGIFY(x)
#define __PRI64(x) __STRINGIFY(l##x) #define __SCN64(x) __INT64 __STRINGIFY(x)
#define __SCN64(x) __STRINGIFY(l##x)
#elif __have_longlong64
#define __PRI64(x) __STRINGIFY(ll##x)
#define __SCN64(x) __STRINGIFY(ll##x)
#else
#define __PRI64(x) __STRINGIFY(x)
#define __SCN64(x) __STRINGIFY(x)
#endif
#define __PRI64LEAST(x) __LEAST64 __STRINGIFY(x)
#define __SCN64LEAST(x) __LEAST64 __STRINGIFY(x)
#define __PRI64FAST(x) __FAST64 __STRINGIFY(x)
#define __SCN64FAST(x) __FAST64 __STRINGIFY(x)
#if __int64_t_defined
#define PRId64 __PRI64(d) #define PRId64 __PRI64(d)
#define PRIi64 __PRI64(i) #define PRIi64 __PRI64(i)
#define PRIo64 __PRI64(o) #define PRIo64 __PRI64(o)
@ -215,34 +221,36 @@
#define SCNo64 __SCN64(o) #define SCNo64 __SCN64(o)
#define SCNu64 __SCN64(u) #define SCNu64 __SCN64(u)
#define SCNx64 __SCN64(x) #define SCNx64 __SCN64(x)
#endif
#if __int64_t_defined #if __int_least64_t_defined
#define PRIdLEAST64 __PRI64(d) #define PRIdLEAST64 __PRI64LEAST(d)
#define PRIiLEAST64 __PRI64(i) #define PRIiLEAST64 __PRI64LEAST(i)
#define PRIoLEAST64 __PRI64(o) #define PRIoLEAST64 __PRI64LEAST(o)
#define PRIuLEAST64 __PRI64(u) #define PRIuLEAST64 __PRI64LEAST(u)
#define PRIxLEAST64 __PRI64(x) #define PRIxLEAST64 __PRI64LEAST(x)
#define PRIXLEAST64 __PRI64(X) #define PRIXLEAST64 __PRI64LEAST(X)
#define SCNdLEAST64 __SCN64(d) #define SCNdLEAST64 __SCN64LEAST(d)
#define SCNiLEAST64 __SCN64(i) #define SCNiLEAST64 __SCN64LEAST(i)
#define SCNoLEAST64 __SCN64(o) #define SCNoLEAST64 __SCN64LEAST(o)
#define SCNuLEAST64 __SCN64(u) #define SCNuLEAST64 __SCN64LEAST(u)
#define SCNxLEAST64 __SCN64(x) #define SCNxLEAST64 __SCN64LEAST(x)
#endif
#if __int_fast64_t_defined
#define PRIdFAST64 __PRI64FAST(d)
#define PRIiFAST64 __PRI64FAST(i)
#define PRIoFAST64 __PRI64FAST(o)
#define PRIuFAST64 __PRI64FAST(u)
#define PRIxFAST64 __PRI64FAST(x)
#define PRIXFAST64 __PRI64FAST(X)
#define PRIdFAST64 __PRI64(d) #define SCNdFAST64 __SCN64FAST(d)
#define PRIiFAST64 __PRI64(i) #define SCNiFAST64 __SCN64FAST(i)
#define PRIoFAST64 __PRI64(o) #define SCNoFAST64 __SCN64FAST(o)
#define PRIuFAST64 __PRI64(u) #define SCNuFAST64 __SCN64FAST(u)
#define PRIxFAST64 __PRI64(x) #define SCNxFAST64 __SCN64FAST(x)
#define PRIXFAST64 __PRI64(X)
#define SCNdFAST64 __SCN64(d)
#define SCNiFAST64 __SCN64(i)
#define SCNoFAST64 __SCN64(o)
#define SCNuFAST64 __SCN64(u)
#define SCNxFAST64 __SCN64(x)
#endif #endif
/* max-bit types */ /* max-bit types */
@ -271,10 +279,10 @@
#define SCNxMAX __SCNMAX(x) #define SCNxMAX __SCNMAX(x)
/* ptr types */ /* ptr types */
#if defined(_UINTPTR_EQ_ULONGLONG) #if defined (_INTPTR_EQ_LONGLONG)
# define __PRIPTR(x) __STRINGIFY(ll##x) # define __PRIPTR(x) __STRINGIFY(ll##x)
# define __SCNPTR(x) __STRINGIFY(ll##x) # define __SCNPTR(x) __STRINGIFY(ll##x)
#elif defined(_UINTPTR_EQ_ULONG) #elif defined (_INTPTR_EQ_LONG)
# define __PRIPTR(x) __STRINGIFY(l##x) # define __PRIPTR(x) __STRINGIFY(l##x)
# define __SCNPTR(x) __STRINGIFY(l##x) # define __SCNPTR(x) __STRINGIFY(l##x)
#else #else

View file

@ -32,6 +32,9 @@
#include <newlib.h> #include <newlib.h>
#include <sys/config.h> #include <sys/config.h>
#include <sys/cdefs.h> #include <sys/cdefs.h>
#if __POSIX_VISIBLE >= 200809
#include <xlocale.h>
#endif
typedef int nl_item; typedef int nl_item;
@ -301,7 +304,7 @@ enum __nl_item
_NL_COLLATE_CODESET, _NL_COLLATE_CODESET,
/* This MUST be the last entry since it's used to check for an array /* This MUST be the last entry since it's used to check for an array
index in nl_langinfo(). */ index in nl_langinfo(). It also must not exceed _NL_LOCALE_NAME_BASE. */
_NL_LOCALE_EXTENDED_LAST_ENTRY _NL_LOCALE_EXTENDED_LAST_ENTRY
#endif /* __HAVE_LOCALE_INFO_EXTENDED__ */ #endif /* __HAVE_LOCALE_INFO_EXTENDED__ */
@ -309,8 +312,19 @@ enum __nl_item
}; };
/* As an extension, nl_langinfo can retrive the name of a locale
category, with this mapping from setlocale() category (other than
LC_ALL) to nl_item. */
#define _NL_LOCALE_NAME_BASE 100000
#if __GNU_VISIBLE
#define NL_LOCALE_NAME(category) (_NL_LOCALE_NAME_BASE + (category))
#endif
__BEGIN_DECLS __BEGIN_DECLS
char *nl_langinfo(nl_item); char *nl_langinfo (nl_item);
#if __POSIX_VISIBLE >= 200809
char *nl_langinfo_l (nl_item, locale_t);
#endif
__END_DECLS __END_DECLS
#endif /* !_LANGINFO_H_ */ #endif /* !_LANGINFO_H_ */

View file

@ -6,13 +6,27 @@
#define _LIBGEN_H_ #define _LIBGEN_H_
#include "_ansi.h" #include "_ansi.h"
#include <sys/cdefs.h>
#include <sys/reent.h> #include <sys/reent.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
char *_EXFUN(basename, (char *)); /* There are two common basename variants. If you do NOT #include <libgen.h>
and you do
#define _GNU_SOURCE
#include <string.h>
you get the GNU version. Otherwise you get the POSIX versionfor which you
should #include <libgen.h>i for the function prototype. POSIX requires that
#undef basename will still let you invoke the underlying function. However,
this also implies that the POSIX version is used in this case. That's made
sure here. */
#undef basename
#define basename __xpg_basename
char *_EXFUN(basename, (char *)) __asm__(__ASMNAME("basename"));
char *_EXFUN(dirname, (char *)); char *_EXFUN(dirname, (char *));
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -2,6 +2,7 @@
# define _LIBC_LIMITS_H_ 1 # define _LIBC_LIMITS_H_ 1
#include <newlib.h> #include <newlib.h>
#include <sys/cdefs.h>
# ifdef _MB_LEN_MAX # ifdef _MB_LEN_MAX
# define MB_LEN_MAX _MB_LEN_MAX # define MB_LEN_MAX _MB_LEN_MAX
@ -96,8 +97,7 @@
# define __LONG_LONG_MAX__ 9223372036854775807LL # define __LONG_LONG_MAX__ 9223372036854775807LL
# endif # endif
# if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ # if __ISO_C_VISIBLE >= 1999
(defined(__cplusplus) && __cplusplus >= 201103L)
/* Minimum and maximum values a `signed long long int' can hold. */ /* Minimum and maximum values a `signed long long int' can hold. */
# undef LLONG_MIN # undef LLONG_MIN
# define LLONG_MIN (-LLONG_MAX-1) # define LLONG_MIN (-LLONG_MAX-1)
@ -109,7 +109,7 @@
# define ULLONG_MAX (LLONG_MAX * 2ULL + 1) # define ULLONG_MAX (LLONG_MAX * 2ULL + 1)
# endif # 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. */ /* Minimum and maximum values a `signed long long int' can hold. */
# undef LONG_LONG_MIN # undef LONG_LONG_MIN
# define LONG_LONG_MIN (-LONG_LONG_MAX-1) # define LONG_LONG_MIN (-LONG_LONG_MAX-1)

View file

@ -8,6 +8,7 @@
#define _LOCALE_H_ #define _LOCALE_H_
#include "_ansi.h" #include "_ansi.h"
#include <sys/cdefs.h>
#define __need_NULL #define __need_NULL
#include <stddef.h> #include <stddef.h>
@ -20,6 +21,22 @@
#define LC_TIME 5 #define LC_TIME 5
#define LC_MESSAGES 6 #define LC_MESSAGES 6
#if __POSIX_VISIBLE >= 200809 || defined (_COMPILING_NEWLIB)
#include <xlocale.h>
#define LC_ALL_MASK (1 << LC_ALL)
#define LC_COLLATE_MASK (1 << LC_COLLATE)
#define LC_CTYPE_MASK (1 << LC_CTYPE)
#define LC_MONETARY_MASK (1 << LC_MONETARY)
#define LC_NUMERIC_MASK (1 << LC_NUMERIC)
#define LC_TIME_MASK (1 << LC_TIME)
#define LC_MESSAGES_MASK (1 << LC_MESSAGES)
#define LC_GLOBAL_LOCALE ((struct __locale_t *) -1)
#endif /* __POSIX_VISIBLE >= 200809 */
_BEGIN_STD_C _BEGIN_STD_C
struct lconv struct lconv
@ -50,15 +67,30 @@ struct lconv
char int_p_sign_posn; char int_p_sign_posn;
}; };
#ifndef _REENT_ONLY
char *_EXFUN(setlocale,(int category, const char *locale));
struct lconv *_EXFUN(localeconv,(void));
#endif
struct _reent; struct _reent;
char *_EXFUN(_setlocale_r,(struct _reent *, int category, const char *locale)); char *_EXFUN(_setlocale_r,(struct _reent *, int, const char *));
struct lconv *_EXFUN(_localeconv_r,(struct _reent *)); struct lconv *_EXFUN(_localeconv_r,(struct _reent *));
struct __locale_t *_newlocale_r (struct _reent *, int, const char *,
struct __locale_t *);
void _freelocale_r (struct _reent *, struct __locale_t *);
struct __locale_t *_duplocale_r (struct _reent *, struct __locale_t *);
struct __locale_t *_uselocale_r (struct _reent *, struct __locale_t *);
#ifndef _REENT_ONLY
char *_EXFUN(setlocale,(int, const char *));
struct lconv *_EXFUN(localeconv,(void));
#if __POSIX_VISIBLE >= 200809
locale_t newlocale (int, const char *, locale_t);
void freelocale (locale_t);
locale_t duplocale (locale_t);
locale_t uselocale (locale_t);
#endif /* __POSIX_VISIBLE >= 200809 */
#endif /* _REENT_ONLY */
_END_STD_C _END_STD_C
#endif /* _LOCALE_H_ */ #endif /* _LOCALE_H_ */

View file

@ -0,0 +1 @@
/* Use default implementation, see arc4random.h */

View file

@ -46,6 +46,9 @@ typedef __int64_t __int_least64_t;
typedef __uint64_t __uint_least64_t; typedef __uint64_t __uint_least64_t;
#define ___int_least64_t_defined #define ___int_least64_t_defined
typedef __int64_t __intmax_t;
typedef __uint64_t __uintmax_t;
typedef __INTPTR_TYPE__ __intptr_t; typedef __INTPTR_TYPE__ __intptr_t;
typedef __UINTPTR_TYPE__ __uintptr_t; typedef __UINTPTR_TYPE__ __uintptr_t;

View file

@ -0,0 +1,35 @@
#ifndef __MACHINE_ENDIAN_H__
#error "must be included via <machine/endian.h>"
#endif /* !__MACHINE_ENDIAN_H__ */
#include <sys/config.h>
#ifdef __PPC__
/* Get rid of GCC builtin defines on PowerPC */
#ifdef _BIG_ENDIAN
#undef _BIG_ENDIAN
#endif
#ifdef _LITTLE_ENDIAN
#undef _LITTLE_ENDIAN
#endif
#endif /* __PPC__ */
#ifndef _LITTLE_ENDIAN
#define _LITTLE_ENDIAN 1234
#endif
#ifndef _BIG_ENDIAN
#define _BIG_ENDIAN 4321
#endif
#ifndef _PDP_ENDIAN
#define _PDP_ENDIAN 3412
#endif
#ifndef _BYTE_ORDER
#if defined(__IEEE_LITTLE_ENDIAN) || defined(__IEEE_BYTES_LITTLE_ENDIAN)
#define _BYTE_ORDER _LITTLE_ENDIAN
#else
#define _BYTE_ORDER _BIG_ENDIAN
#endif
#endif

View file

@ -0,0 +1,3 @@
#ifndef _SYS_TIME_H_
#error "must be included via <sys/time.h>"
#endif /* !_SYS_TIME_H_ */

View file

@ -1,20 +1,69 @@
#ifndef __MACHINE_ENDIAN_H__ #ifndef __MACHINE_ENDIAN_H__
#define __MACHINE_ENDIAN_H__
#include <sys/config.h> #include <sys/cdefs.h>
#include <sys/_types.h>
#include <machine/_endian.h>
#ifndef BIG_ENDIAN #if _BYTE_ORDER == _LITTLE_ENDIAN
#define BIG_ENDIAN 4321 #define _QUAD_HIGHWORD 1
#endif #define _QUAD_LOWWORD 0
#ifndef LITTLE_ENDIAN
#define LITTLE_ENDIAN 1234
#endif
#ifndef BYTE_ORDER
#if defined(__IEEE_LITTLE_ENDIAN) || defined(__IEEE_BYTES_LITTLE_ENDIAN)
#define BYTE_ORDER LITTLE_ENDIAN
#else #else
#define BYTE_ORDER BIG_ENDIAN #define _QUAD_HIGHWORD 0
#define _QUAD_LOWWORD 1
#endif #endif
#if __BSD_VISIBLE
#define LITTLE_ENDIAN _LITTLE_ENDIAN
#define BIG_ENDIAN _BIG_ENDIAN
#define PDP_ENDIAN _PDP_ENDIAN
#define BYTE_ORDER _BYTE_ORDER
#endif #endif
#ifdef __GNUC__
#define __bswap16(_x) __builtin_bswap16(_x)
#define __bswap32(_x) __builtin_bswap32(_x)
#define __bswap64(_x) __builtin_bswap64(_x)
#else /* __GNUC__ */
static __inline __uint16_t
__bswap16(__uint16_t _x)
{
return ((__uint16_t)((_x >> 8) | ((_x << 8) & 0xff00)));
}
static __inline __uint32_t
__bswap32(__uint32_t _x)
{
return ((__uint32_t)((_x >> 24) | ((_x >> 8) & 0xff00) |
((_x << 8) & 0xff0000) | ((_x << 24) & 0xff000000)));
}
static __inline __uint64_t
__bswap64(__uint64_t _x)
{
return ((__uint64_t)((_x >> 56) | ((_x >> 40) & 0xff00) |
((_x >> 24) & 0xff0000) | ((_x >> 8) & 0xff000000) |
((_x << 8) & ((__uint64_t)0xff << 32)) |
((_x << 24) & ((__uint64_t)0xff << 40)) |
((_x << 40) & ((__uint64_t)0xff << 48)) | ((_x << 56))));
}
#endif /* !__GNUC__ */
#ifndef __machine_host_to_from_network_defined
#if _BYTE_ORDER == _LITTLE_ENDIAN
#define __htonl(_x) __bswap32(_x)
#define __htons(_x) __bswap16(_x)
#define __ntohl(_x) __bswap32(_x)
#define __ntohs(_x) __bswap16(_x)
#else
#define __htonl(_x) ((__uint32_t)(_x))
#define __htons(_x) ((__uint16_t)(_x))
#define __ntohl(_x) ((__uint32_t)(_x))
#define __ntohs(_x) ((__uint16_t)(_x))
#endif
#endif /* __machine_host_to_from_network_defined */
#endif /* __MACHINE_ENDIAN_H__ */ #endif /* __MACHINE_ENDIAN_H__ */

View file

@ -283,6 +283,10 @@
#define __IEEE_BIG_ENDIAN #define __IEEE_BIG_ENDIAN
#endif #endif
#ifdef __FT32__
#define __IEEE_LITTLE_ENDIAN
#endif
#ifdef __mcore__ #ifdef __mcore__
#define __IEEE_BIG_ENDIAN #define __IEEE_BIG_ENDIAN
#endif #endif
@ -415,6 +419,10 @@
# endif # endif
#endif #endif
#ifdef __VISIUM__
#define __IEEE_BIG_ENDIAN
#endif
#if (defined(__XTENSA__)) #if (defined(__XTENSA__))
# ifdef __XTENSA_EB__ # ifdef __XTENSA_EB__
# define __IEEE_BIG_ENDIAN # define __IEEE_BIG_ENDIAN

View file

@ -92,6 +92,9 @@ _BEGIN_STD_C
# define _JBLEN (13 * 4) # define _JBLEN (13 * 4)
# elif defined(__unix__) || defined(__rtems__) # elif defined(__unix__) || defined(__rtems__)
# define _JBLEN 9 # define _JBLEN 9
# elif defined(__iamcu__)
/* Intel MCU jmp_buf only covers callee-saved registers. */
# define _JBLEN 6
# else # else
# include "setjmp-dj.h" # include "setjmp-dj.h"
# endif # endif
@ -250,6 +253,10 @@ _BEGIN_STD_C
#define _JBLEN 10 #define _JBLEN 10
#endif #endif
#ifdef __FT32__
#define _JBLEN 27
#endif
#ifdef __iq2000__ #ifdef __iq2000__
#define _JBLEN 32 #define _JBLEN 32
#endif #endif
@ -258,6 +265,10 @@ _BEGIN_STD_C
#define _JBLEN 16 #define _JBLEN 16
#endif #endif
#ifdef __arc__
#define _JBLEN 25 /* r13-r30,blink,lp_count,lp_start,lp_end,mlo,mhi,status32 */
#endif
#ifdef __MMIX__ #ifdef __MMIX__
/* Using a layout compatible with GCC's built-in. */ /* Using a layout compatible with GCC's built-in. */
#define _JBLEN 5 #define _JBLEN 5
@ -314,6 +325,10 @@ _BEGIN_STD_C
#define _JBLEN 18 #define _JBLEN 18
#endif #endif
#ifdef __ia64
#define _JBLEN 64
#endif
#ifdef __lm32__ #ifdef __lm32__
#define _JBLEN 19 #define _JBLEN 19
#endif #endif
@ -365,6 +380,11 @@ _BEGIN_STD_C
#define _JBLEN 0x44 #define _JBLEN 0x44
#endif #endif
#ifdef __VISIUM__
/* All call-saved GP registers: r11-r19,r21,r22,r23. */
#define _JBLEN 12
#endif
#ifdef _JBLEN #ifdef _JBLEN
#ifdef _JBTYPE #ifdef _JBTYPE
typedef _JBTYPE jmp_buf[_JBLEN]; typedef _JBTYPE jmp_buf[_JBLEN];
@ -403,6 +423,13 @@ typedef int sigjmp_buf[_JBLEN+1+(sizeof (sigset_t)/sizeof (int))];
#define __SIGMASK_FUNC sigprocmask #define __SIGMASK_FUNC sigprocmask
#endif #endif
#ifdef __CYGWIN__
/* Per POSIX, siglongjmp has to be implemented as function. Cygwin
provides functions for both, siglongjmp and sigsetjmp since 2.2.0. */
extern void siglongjmp (sigjmp_buf, int) __attribute__ ((__noreturn__));
extern int sigsetjmp (sigjmp_buf, int);
#endif
#if defined(__GNUC__) #if defined(__GNUC__)
#define sigsetjmp(env, savemask) \ #define sigsetjmp(env, savemask) \
@ -440,8 +467,8 @@ typedef int sigjmp_buf[_JBLEN+1+(sizeof (sigset_t)/sizeof (int))];
are equivalent to sigsetjmp/siglongjmp when not saving the signal mask. are equivalent to sigsetjmp/siglongjmp when not saving the signal mask.
New applications should use sigsetjmp/siglongjmp instead. */ New applications should use sigsetjmp/siglongjmp instead. */
#ifdef __CYGWIN__ #ifdef __CYGWIN__
extern void _longjmp(jmp_buf, int); extern void _longjmp (jmp_buf, int) __attribute__ ((__noreturn__));
extern int _setjmp(jmp_buf); extern int _setjmp (jmp_buf);
#else #else
#define _setjmp(env) sigsetjmp ((env), 0) #define _setjmp(env) sigsetjmp ((env), 0)
#define _longjmp(env, val) siglongjmp ((env), (val)) #define _longjmp(env, val) siglongjmp ((env), (val))

View file

@ -1,19 +1,15 @@
#ifndef _MACHTIME_H_ #ifndef _MACHTIME_H_
#define _MACHTIME_H_ #define _MACHTIME_H_
#if defined(__rtems__) #if defined(__rtems__) || defined(__VISIUM__)
#define _CLOCKS_PER_SEC_ sysconf(_SC_CLK_TCK) #define _CLOCKS_PER_SEC_ 1000000
#else /* !__rtems__ */ #elif defined(__aarch64__) || defined(__arm__) || defined(__thumb__)
#if defined(__aarch64__) || defined(__arm__) || defined(__thumb__)
#define _CLOCKS_PER_SEC_ 100 #define _CLOCKS_PER_SEC_ 100
#endif #endif
#endif /* !__rtems__ */
#ifdef __SPU__ #ifdef __SPU__
#include <sys/types.h> #include <sys/_timespec.h>
int nanosleep (const struct timespec *, struct timespec *); int nanosleep (const struct timespec *, struct timespec *);
#endif #endif
#endif /* _MACHTIME_H_ */ #endif /* _MACHTIME_H_ */

View file

@ -1,30 +1,7 @@
#ifndef _MACHTYPES_H_
#define _MACHTYPES_H_
/* /*
* The following section is RTEMS specific and is needed to more * Newlib targets may provide an own version of this file in their machine
* closely match the types defined in the BSD machine/types.h. * directory to add custom user types for <sys/types.h>.
* This is needed to let the RTEMS/BSD TCP/IP stack compile.
*/ */
#if defined(__rtems__) #ifndef _SYS_TYPES_H
#include <machine/_types.h> #error "must be included via <sys/types.h>"
#endif #endif /* !_SYS_TYPES_H */
#define _CLOCK_T_ unsigned long /* clock() */
#define _TIME_T_ long /* time() */
#define _CLOCKID_T_ unsigned long
#define _TIMER_T_ unsigned long
#ifndef _HAVE_SYSTYPES
typedef long int __off_t;
typedef int __pid_t;
#ifdef __GNUC__
__extension__ typedef long long int __loff_t;
#else
typedef long int __loff_t;
#endif
#endif
#endif /* _MACHTYPES_H_ */

View file

@ -3,34 +3,12 @@
#define _MATH_H_ #define _MATH_H_
#include <sys/reent.h> #include <sys/reent.h>
#include <sys/cdefs.h>
#include <machine/ieeefp.h> #include <machine/ieeefp.h>
#include "_ansi.h" #include "_ansi.h"
_BEGIN_STD_C _BEGIN_STD_C
/* __dmath, __fmath, and __ldmath are only here for backwards compatibility
* in case any code used them. They are no longer used by Newlib, itself,
* other than legacy. */
union __dmath
{
double d;
__ULong i[2];
};
union __fmath
{
float f;
__ULong i[1];
};
#if defined(_HAVE_LONG_DOUBLE)
union __ldmath
{
long double ld;
__ULong i[4];
};
#endif
/* Natural log of 2 */ /* Natural log of 2 */
#define _M_LN2 0.693147180559945309417 #define _M_LN2 0.693147180559945309417
@ -136,9 +114,26 @@ extern double fmod _PARAMS((double, double));
#endif /* ! defined (__math_68881) */ #endif /* ! defined (__math_68881) */
#endif /* ! defined (_REENT_ONLY) */ #endif /* ! defined (_REENT_ONLY) */
#if !defined(__STRICT_ANSI__) || defined(__cplusplus) || \ #if __MISC_VISIBLE
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) extern int finite _PARAMS((double));
extern int finitef _PARAMS((float));
extern int finitel _PARAMS((long double));
extern int isinff _PARAMS((float));
extern int isnanf _PARAMS((float));
#ifdef __CYGWIN__ /* not implemented in newlib yet */
extern int isinfl _PARAMS((long double));
extern int isnanl _PARAMS((long double));
#endif
#if !defined(__cplusplus) || __cplusplus < 201103L
extern int isinf _PARAMS((double));
#endif
#endif /* __MISC_VISIBLE */
#if (__MISC_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 600)) \
&& (!defined(__cplusplus) || __cplusplus < 201103L)
extern int isnan _PARAMS((double));
#endif
#if __ISO_C_VISIBLE >= 1999
/* ISO C99 types and macros. */ /* ISO C99 types and macros. */
/* FIXME: FLT_EVAL_METHOD should somehow be gotten from float.h (which is hard, /* FIXME: FLT_EVAL_METHOD should somehow be gotten from float.h (which is hard,
@ -180,10 +175,10 @@ extern double fmod _PARAMS((double, double));
#define FP_NORMAL 4 #define FP_NORMAL 4
#ifndef FP_ILOGB0 #ifndef FP_ILOGB0
# define FP_ILOGB0 (-INT_MAX) # define FP_ILOGB0 (-__INT_MAX__)
#endif #endif
#ifndef FP_ILOGBNAN #ifndef FP_ILOGBNAN
# define FP_ILOGBNAN INT_MAX # define FP_ILOGBNAN __INT_MAX__
#endif #endif
#ifndef MATH_ERRNO #ifndef MATH_ERRNO
@ -205,35 +200,70 @@ extern int __fpclassifyd (double x);
extern int __signbitf (float x); extern int __signbitf (float x);
extern int __signbitd (double x); extern int __signbitd (double x);
#define fpclassify(__x) \
((sizeof(__x) == sizeof(float)) ? __fpclassifyf(__x) : \
__fpclassifyd(__x))
#ifndef isfinite
#define isfinite(__y) \
(__extension__ ({int __cy = fpclassify(__y); \
__cy != FP_INFINITE && __cy != FP_NAN;}))
#endif
/* Note: isinf and isnan were once functions in newlib that took double /* Note: isinf and isnan were once functions in newlib that took double
* arguments. C99 specifies that these names are reserved for macros * arguments. C99 specifies that these names are reserved for macros
* supporting multiple floating point types. Thus, they are * supporting multiple floating point types. Thus, they are
* now defined as macros. Implementations of the old functions * now defined as macros. Implementations of the old functions
* taking double arguments still exist for compatibility purposes * taking double arguments still exist for compatibility purposes
* (prototypes for them are in <ieeefp.h>). */ * (prototypes for them are earlier in this header). */
#ifndef isinf
#define isinf(y) (fpclassify(y) == FP_INFINITE) #if __GNUC_PREREQ (4, 4)
#define fpclassify(__x) (__builtin_fpclassify (FP_NAN, FP_INFINITE, \
FP_NORMAL, FP_SUBNORMAL, \
FP_ZERO, __x))
#ifndef isfinite
#define isfinite(__x) (__builtin_isfinite (__x))
#endif
#ifndef isinf
#define isinf(__x) (__builtin_isinf_sign (__x))
#endif
#ifndef isnan
#define isnan(__x) (__builtin_isnan (__x))
#endif
#define isnormal(__x) (__builtin_isnormal (__x))
#else
#define fpclassify(__x) \
((sizeof(__x) == sizeof(float)) ? __fpclassifyf(__x) : \
__fpclassifyd(__x))
#ifndef isfinite
#define isfinite(__y) \
(__extension__ ({int __cy = fpclassify(__y); \
__cy != FP_INFINITE && __cy != FP_NAN;}))
#endif
#ifndef isinf
#define isinf(__x) (fpclassify(__x) == FP_INFINITE)
#endif
#ifndef isnan
#define isnan(__x) (fpclassify(__x) == FP_NAN)
#endif
#define isnormal(__x) (fpclassify(__x) == FP_NORMAL)
#endif #endif
#ifndef isnan #if __GNUC_PREREQ (4, 0)
#define isnan(y) (fpclassify(y) == FP_NAN) #if defined(_HAVE_LONG_DOUBLE)
#define signbit(__x) \
((sizeof(__x) == sizeof(float)) ? __builtin_signbitf(__x) : \
(sizeof(__x) == sizeof(double)) ? __builtin_signbit (__x) : \
__builtin_signbitl(__x))
#else
#define signbit(__x) \
((sizeof(__x) == sizeof(float)) ? __builtin_signbitf(__x) : \
__builtin_signbit (__x))
#endif
#else
#define signbit(__x) \
((sizeof(__x) == sizeof(float)) ? __signbitf(__x) : \
__signbitd(__x))
#endif #endif
#define isnormal(y) (fpclassify(y) == FP_NORMAL) #if __GNUC_PREREQ (2, 97)
#define signbit(__x) \ #define isgreater(__x,__y) (__builtin_isgreater (__x, __y))
((sizeof(__x) == sizeof(float)) ? __signbitf(__x) : \ #define isgreaterequal(__x,__y) (__builtin_isgreaterequal (__x, __y))
__signbitd(__x)) #define isless(__x,__y) (__builtin_isless (__x, __y))
#define islessequal(__x,__y) (__builtin_islessequal (__x, __y))
#define islessgreater(__x,__y) (__builtin_islessgreater (__x, __y))
#define isunordered(__x,__y) (__builtin_isunordered (__x, __y))
#else
#define isgreater(x,y) \ #define isgreater(x,y) \
(__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \ (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
!isunordered(__x,__y) && (__x > __y);})) !isunordered(__x,__y) && (__x > __y);}))
@ -253,12 +283,12 @@ extern int __signbitd (double x);
#define isunordered(a,b) \ #define isunordered(a,b) \
(__extension__ ({__typeof__(a) __a = (a); __typeof__(b) __b = (b); \ (__extension__ ({__typeof__(a) __a = (a); __typeof__(b) __b = (b); \
fpclassify(__a) == FP_NAN || fpclassify(__b) == FP_NAN;})) fpclassify(__a) == FP_NAN || fpclassify(__b) == FP_NAN;}))
#endif
/* Non ANSI double precision functions. */ /* Non ANSI double precision functions. */
extern double infinity _PARAMS((void)); extern double infinity _PARAMS((void));
extern double nan _PARAMS((const char *)); extern double nan _PARAMS((const char *));
extern int finite _PARAMS((double));
extern double copysign _PARAMS((double, double)); extern double copysign _PARAMS((double, double));
extern double logb _PARAMS((double)); extern double logb _PARAMS((double));
extern int ilogb _PARAMS((double)); extern int ilogb _PARAMS((double));
@ -357,7 +387,6 @@ extern float fmaf _PARAMS((float, float, float));
extern float infinityf _PARAMS((void)); extern float infinityf _PARAMS((void));
extern float nanf _PARAMS((const char *)); extern float nanf _PARAMS((const char *));
extern int finitef _PARAMS((float));
extern float copysignf _PARAMS((float, float)); extern float copysignf _PARAMS((float, float));
extern float logbf _PARAMS((float)); extern float logbf _PARAMS((float));
extern int ilogbf _PARAMS((float)); extern int ilogbf _PARAMS((float));
@ -382,8 +411,12 @@ extern float log2f _PARAMS((float));
extern float hypotf _PARAMS((float, float)); extern float hypotf _PARAMS((float, float));
#endif /* ! defined (_REENT_ONLY) */ #endif /* ! defined (_REENT_ONLY) */
/* On platforms where long double equals double. */ /* Newlib doesn't fully support long double math functions so far.
#ifdef _LDBL_EQ_DBL On platforms where long double equals double the long double functions
simply call the double functions. On Cygwin the long double functions
are implemented independently from newlib to be able to use optimized
assembler functions despite using the Microsoft x86_64 ABI. */
#if defined (_LDBL_EQ_DBL) || defined (__CYGWIN__)
/* Reentrant ANSI C functions. */ /* Reentrant ANSI C functions. */
#ifndef __math_68881 #ifndef __math_68881
extern long double atanl _PARAMS((long double)); extern long double atanl _PARAMS((long double));
@ -453,44 +486,56 @@ extern long double lgammal _PARAMS((long double));
extern long double erfl _PARAMS((long double)); extern long double erfl _PARAMS((long double));
extern long double erfcl _PARAMS((long double)); extern long double erfcl _PARAMS((long double));
#endif /* ! defined (_REENT_ONLY) */ #endif /* ! defined (_REENT_ONLY) */
#else /* !_LDBL_EQ_DBL */ #else /* !_LDBL_EQ_DBL && !__CYGWIN__ */
extern long double hypotl _PARAMS((long double, long double));
extern long double sqrtl _PARAMS((long double));
#ifdef __i386__ #ifdef __i386__
/* Other long double precision functions. */ /* Other long double precision functions. */
extern _LONG_DOUBLE rintl _PARAMS((_LONG_DOUBLE)); extern _LONG_DOUBLE rintl _PARAMS((_LONG_DOUBLE));
extern long int lrintl _PARAMS((_LONG_DOUBLE)); extern long int lrintl _PARAMS((_LONG_DOUBLE));
extern long long int llrintl _PARAMS((_LONG_DOUBLE)); extern long long int llrintl _PARAMS((_LONG_DOUBLE));
#endif /* __i386__ */ #endif /* __i386__ */
#endif /* !_LDBL_EQ_DBL */ #endif /* !_LDBL_EQ_DBL && !__CYGWIN__ */
#endif /* !defined (__STRICT_ANSI__) || defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) */ #endif /* __ISO_C_VISIBLE >= 1999 */
#if !defined (__STRICT_ANSI__) || defined(__cplusplus)
#if __MISC_VISIBLE
extern double drem _PARAMS((double, double)); extern double drem _PARAMS((double, double));
extern void sincos _PARAMS((double, double *, double *)); extern float dremf _PARAMS((float, float));
#ifdef __CYGWIN__
extern float dreml _PARAMS((long double, long double));
#endif /* __CYGWIN__ */
extern double gamma_r _PARAMS((double, int *)); extern double gamma_r _PARAMS((double, int *));
extern double lgamma_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 || __XSI_VISIBLE
extern double y0 _PARAMS((double)); extern double y0 _PARAMS((double));
extern double y1 _PARAMS((double)); extern double y1 _PARAMS((double));
extern double yn _PARAMS((int, double)); extern double yn _PARAMS((int, double));
extern double j0 _PARAMS((double)); extern double j0 _PARAMS((double));
extern double j1 _PARAMS((double)); extern double j1 _PARAMS((double));
extern double jn _PARAMS((int, double)); extern double jn _PARAMS((int, double));
#endif
extern float dremf _PARAMS((float, float)); #if __MISC_VISIBLE || __XSI_VISIBLE >= 600
extern void sincosf _PARAMS((float, float *, float *));
extern float gammaf_r _PARAMS((float, int *));
extern float lgammaf_r _PARAMS((float, int *));
extern float y0f _PARAMS((float)); extern float y0f _PARAMS((float));
extern float y1f _PARAMS((float)); extern float y1f _PARAMS((float));
extern float ynf _PARAMS((int, float)); extern float ynf _PARAMS((int, float));
extern float j0f _PARAMS((float)); extern float j0f _PARAMS((float));
extern float j1f _PARAMS((float)); extern float j1f _PARAMS((float));
extern float jnf _PARAMS((int, float)); extern float jnf _PARAMS((int, float));
#endif
/* GNU extensions */ /* GNU extensions */
#if __GNU_VISIBLE
extern void sincos _PARAMS((double, double *, double *));
extern void sincosf _PARAMS((float, float *, float *));
#ifdef __CYGWIN__
extern void sincosl _PARAMS((long double, long double *, long double *));
#endif /* __CYGWIN__ */
# ifndef exp10 # ifndef exp10
extern double exp10 _PARAMS((double)); extern double exp10 _PARAMS((double));
# endif # endif
@ -503,11 +548,17 @@ extern float exp10f _PARAMS((float));
# ifndef pow10f # ifndef pow10f
extern float pow10f _PARAMS((float)); extern float pow10f _PARAMS((float));
# endif # endif
#ifdef __CYGWIN__
# ifndef exp10l
extern float exp10l _PARAMS((float));
# endif
# ifndef pow10l
extern float pow10l _PARAMS((float));
# endif
#endif /* __CYGWIN__ */
#endif /* __GNU_VISIBLE */
#endif /* !defined (__STRICT_ANSI__) || defined(__cplusplus) */ #if __MISC_VISIBLE || __XSI_VISIBLE
#ifndef __STRICT_ANSI__
/* The gamma functions use a global variable, signgam. */ /* The gamma functions use a global variable, signgam. */
#ifndef _REENT_ONLY #ifndef _REENT_ONLY
#define signgam (*__signgam()) #define signgam (*__signgam())
@ -515,7 +566,9 @@ extern int *__signgam _PARAMS((void));
#endif /* ! defined (_REENT_ONLY) */ #endif /* ! defined (_REENT_ONLY) */
#define __signgam_r(ptr) _REENT_SIGNGAM(ptr) #define __signgam_r(ptr) _REENT_SIGNGAM(ptr)
#endif /* __MISC_VISIBLE || __XSI_VISIBLE */
#if __SVID_VISIBLE
/* The exception structure passed to the matherr routine. */ /* The exception structure passed to the matherr routine. */
/* We have a problem when using C++ since `exception' is a reserved /* We have a problem when using C++ since `exception' is a reserved
name in C++. */ name in C++. */
@ -548,11 +601,11 @@ extern int matherr _PARAMS((struct exception *e));
#define TLOSS 5 #define TLOSS 5
#define PLOSS 6 #define PLOSS 6
#endif /* ! defined (__STRICT_ANSI__) */ #endif /* __SVID_VISIBLE */
/* Useful constants. */ /* Useful constants. */
#if !defined(__STRICT_ANSI__) || ((_XOPEN_SOURCE - 0) >= 500) #if __BSD_VISIBLE || __XSI_VISIBLE
#define MAXFLOAT 3.40282347e+38F #define MAXFLOAT 3.40282347e+38F
@ -572,7 +625,7 @@ extern int matherr _PARAMS((struct exception *e));
#endif #endif
#ifndef __STRICT_ANSI__ #if __BSD_VISIBLE
#define M_TWOPI (M_PI * 2.0) #define M_TWOPI (M_PI * 2.0)
#define M_3PI_4 2.3561944901923448370E0 #define M_3PI_4 2.3561944901923448370E0
@ -604,7 +657,7 @@ extern __IMPORT _LIB_VERSION_TYPE _LIB_VERSION;
#define _XOPEN_ __fdlibm_xopen #define _XOPEN_ __fdlibm_xopen
#define _POSIX_ __fdlibm_posix #define _POSIX_ __fdlibm_posix
#endif /* ! defined (__STRICT_ANSI__) */ #endif /* __BSD_VISIBLE */
_END_STD_C _END_STD_C

View file

@ -0,0 +1,4 @@
#ifndef _MEMORY_H
#define _MEMORY_H
#include <string.h>
#endif /* !_MEMORY_H */

View file

@ -11,7 +11,7 @@
/* #undef _ELIX_LEVEL */ /* #undef _ELIX_LEVEL */
/* Newlib version */ /* Newlib version */
#define _NEWLIB_VERSION "2.2.0" #include <_newlib_version.h>
/* C99 formats support (such as %a, %zu, ...) in IO functions like /* C99 formats support (such as %a, %zu, ...) in IO functions like
* printf/scanf enabled */ * printf/scanf enabled */
@ -62,12 +62,6 @@
/* True if long double supported and it is equal to double. */ /* True if long double supported and it is equal to double. */
#define _LDBL_EQ_DBL 1 #define _LDBL_EQ_DBL 1
/* Define if uintptr_t is unsigned long on this architecture */
/* #undef _UINTPTR_EQ_ULONG */
/* Define if uintptr_t is unsigned long long on this architecture */
/* #undef _UINTPTR_EQ_ULONGLONG */
/* Define if ivo supported in streamio. */ /* Define if ivo supported in streamio. */
#define _FVWRITE_IN_STREAMIO 1 #define _FVWRITE_IN_STREAMIO 1
@ -86,9 +80,17 @@
/* Define if declare atexit data as global. */ /* Define if declare atexit data as global. */
/* #undef _REENT_GLOBAL_ATEXIT */ /* #undef _REENT_GLOBAL_ATEXIT */
/* Define to move the stdio stream FILE objects out of struct _reent and make
them global. The stdio stream pointers of struct _reent are initialized to
point to the global stdio FILE stream objects. */
/* #undef _WANT_REENT_GLOBAL_STDIO_STREAMS */
/* Define if small footprint nano-formatted-IO implementation used. */ /* Define if small footprint nano-formatted-IO implementation used. */
#define _NANO_FORMATTED_IO 1 #define _NANO_FORMATTED_IO 1
/* Define if using retargetable functions for default lock routines. */
/* #undef _RETARGETABLE_LOCKING */
/* /*
* Iconv encodings enabled ("to" direction) * Iconv encodings enabled ("to" direction)
*/ */

View file

@ -1,8 +1,7 @@
/* pthread.h /*
* Written by Joel Sherrill <joel.sherrill@OARcorp.com>.
* *
* Written by Joel Sherrill <joel@OARcorp.com>. * COPYRIGHT (c) 1989-2013, 2015.
*
* COPYRIGHT (c) 1989-2013.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
* *
* Permission to use, copy, modify, and distribute this software for any * Permission to use, copy, modify, and distribute this software for any
@ -14,8 +13,6 @@
* WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION * WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION
* OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS * OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS
* SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. * SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
*
* $Id$
*/ */
#ifndef __PTHREAD_h #ifndef __PTHREAD_h
@ -31,7 +28,7 @@ extern "C" {
#include <sys/types.h> #include <sys/types.h>
#include <time.h> #include <time.h>
#include <sys/sched.h> #include <sched.h>
#include <sys/cdefs.h> #include <sys/cdefs.h>
struct _pthread_cleanup_context { struct _pthread_cleanup_context {
@ -76,7 +73,7 @@ int _EXFUN(pthread_mutex_destroy, (pthread_mutex_t *__mutex));
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
*/ */
#define PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t) 0xFFFFFFFF) #define PTHREAD_MUTEX_INITIALIZER _PTHREAD_MUTEX_INITIALIZER
/* Locking and Unlocking a Mutex, P1003.1c/Draft 10, p. 93 /* Locking and Unlocking a Mutex, P1003.1c/Draft 10, p. 93
NOTE: P1003.4b/D8 adds pthread_mutex_timedlock(), p. 29 */ NOTE: P1003.4b/D8 adds pthread_mutex_timedlock(), p. 29 */
@ -96,6 +93,13 @@ int _EXFUN(pthread_mutex_timedlock,
int _EXFUN(pthread_condattr_init, (pthread_condattr_t *__attr)); int _EXFUN(pthread_condattr_init, (pthread_condattr_t *__attr));
int _EXFUN(pthread_condattr_destroy, (pthread_condattr_t *__attr)); int _EXFUN(pthread_condattr_destroy, (pthread_condattr_t *__attr));
int _EXFUN(pthread_condattr_getclock,
(const pthread_condattr_t *__restrict __attr,
clockid_t *__restrict __clock_id));
int _EXFUN(pthread_condattr_setclock,
(pthread_condattr_t *__attr, clockid_t __clock_id));
int _EXFUN(pthread_condattr_getpshared, int _EXFUN(pthread_condattr_getpshared,
(_CONST pthread_condattr_t *__attr, int *__pshared)); (_CONST pthread_condattr_t *__attr, int *__pshared));
int _EXFUN(pthread_condattr_setpshared, int _EXFUN(pthread_condattr_setpshared,
@ -112,7 +116,7 @@ int _EXFUN(pthread_cond_destroy, (pthread_cond_t *__mutex));
pthread_cond_t cond = PTHREAD_COND_INITIALIZER; pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
*/ */
#define PTHREAD_COND_INITIALIZER ((pthread_cond_t) 0xFFFFFFFF) #define PTHREAD_COND_INITIALIZER _PTHREAD_COND_INITIALIZER
/* Broadcasting and Signaling a Condition, P1003.1c/Draft 10, p. 101 */ /* Broadcasting and Signaling a Condition, P1003.1c/Draft 10, p. 101 */
@ -161,8 +165,17 @@ int _EXFUN(pthread_getschedparam,
int _EXFUN(pthread_setschedparam, int _EXFUN(pthread_setschedparam,
(pthread_t __pthread, int __policy, struct sched_param *__param)); (pthread_t __pthread, int __policy, struct sched_param *__param));
/* Set Scheduling Priority of a Thread */
int _EXFUN(pthread_setschedprio, (pthread_t thread, int prio));
#endif /* defined(_POSIX_THREAD_PRIORITY_SCHEDULING) */ #endif /* defined(_POSIX_THREAD_PRIORITY_SCHEDULING) */
#if __GNU_VISIBLE
int pthread_getname_np(pthread_t, char *, size_t) __nonnull(2);
int pthread_setname_np(pthread_t, const char *) __nonnull(2);
#endif
#if defined(_POSIX_THREAD_PRIO_INHERIT) || defined(_POSIX_THREAD_PRIO_PROTECT) #if defined(_POSIX_THREAD_PRIO_INHERIT) || defined(_POSIX_THREAD_PRIO_PROTECT)
/* Mutex Initialization Scheduling Attributes, P1003.1c/Draft 10, p. 128 */ /* Mutex Initialization Scheduling Attributes, P1003.1c/Draft 10, p. 128 */
@ -218,7 +231,7 @@ int _EXFUN(pthread_attr_setguardsize,
* in GNU/Linux. They may be provided by other OSes for * in GNU/Linux. They may be provided by other OSes for
* compatibility. * compatibility.
*/ */
#if defined(__GNU_VISIBLE) #if __GNU_VISIBLE
#if defined(__rtems__) #if defined(__rtems__)
int _EXFUN(pthread_attr_setaffinity_np, int _EXFUN(pthread_attr_setaffinity_np,
(pthread_attr_t *__attr, size_t __cpusetsize, (pthread_attr_t *__attr, size_t __cpusetsize,
@ -235,7 +248,7 @@ int _EXFUN(pthread_getaffinity_np,
int _EXFUN(pthread_getattr_np, int _EXFUN(pthread_getattr_np,
(pthread_t __id, pthread_attr_t *__attr)); (pthread_t __id, pthread_attr_t *__attr));
#endif /* defined(__rtems__) */ #endif /* defined(__rtems__) */
#endif /* defined(__GNU_VISIBLE) */ #endif /* __GNU_VISIBLE */
/* Thread Creation, P1003.1c/Draft 10, p. 144 */ /* Thread Creation, P1003.1c/Draft 10, p. 144 */
@ -253,7 +266,7 @@ int _EXFUN(pthread_detach, (pthread_t __pthread));
/* Thread Termination, p1003.1c/Draft 10, p. 150 */ /* Thread Termination, p1003.1c/Draft 10, p. 150 */
void _EXFUN(pthread_exit, (void *__value_ptr)); void _EXFUN(pthread_exit, (void *__value_ptr)) __dead2;
/* Get Calling Thread's ID, p1003.1c/Draft 10, p. XXX */ /* Get Calling Thread's ID, p1003.1c/Draft 10, p. XXX */
@ -263,6 +276,18 @@ pthread_t _EXFUN(pthread_self, (void));
int _EXFUN(pthread_equal, (pthread_t __t1, pthread_t __t2)); int _EXFUN(pthread_equal, (pthread_t __t1, pthread_t __t2));
/* Retrieve ID of a Thread's CPU Time Clock */
int _EXFUN(pthread_getcpuclockid,
(pthread_t thread, clockid_t *clock_id));
/* Get/Set Current Thread's Concurrency Level */
int _EXFUN(pthread_setconcurrency, (int new_level));
int _EXFUN(pthread_getconcurrency, (void));
#if __BSD_VISIBLE || __GNU_VISIBLE
void _EXFUN(pthread_yield, (void));
#endif
/* Dynamic Package Initialization */ /* Dynamic Package Initialization */
/* This is used to statically initialize a pthread_once_t. Example: /* This is used to statically initialize a pthread_once_t. Example:
@ -271,7 +296,7 @@ int _EXFUN(pthread_equal, (pthread_t __t1, pthread_t __t2));
NOTE: This is named inconsistently -- it should be INITIALIZER. */ NOTE: This is named inconsistently -- it should be INITIALIZER. */
#define PTHREAD_ONCE_INIT { 1, 0 } /* is initialized and not run */ #define PTHREAD_ONCE_INIT _PTHREAD_ONCE_INIT
int _EXFUN(pthread_once, int _EXFUN(pthread_once,
(pthread_once_t *__once_control, void (*__init_routine)(void))); (pthread_once_t *__once_control, void (*__init_routine)(void)));
@ -329,7 +354,7 @@ void _EXFUN(_pthread_cleanup_pop,
_pthread_cleanup_pop(&_pthread_clup_ctx, (_execute)); \ _pthread_cleanup_pop(&_pthread_clup_ctx, (_execute)); \
} while (0) } while (0)
#if defined(_GNU_SOURCE) #if __GNU_VISIBLE
void _EXFUN(_pthread_cleanup_push_defer, void _EXFUN(_pthread_cleanup_push_defer,
(struct _pthread_cleanup_context *_context, (struct _pthread_cleanup_context *_context,
void (*_routine)(void *), void *_arg)); void (*_routine)(void *), void *_arg));
@ -347,7 +372,7 @@ void _EXFUN(_pthread_cleanup_pop_restore,
#define pthread_cleanup_pop_restore_np(_execute) \ #define pthread_cleanup_pop_restore_np(_execute) \
_pthread_cleanup_pop_restore(&_pthread_clup_ctx, (_execute)); \ _pthread_cleanup_pop_restore(&_pthread_clup_ctx, (_execute)); \
} while (0) } while (0)
#endif /* defined(_GNU_SOURCE) */ #endif /* __GNU_VISIBLE */
#if defined(_POSIX_THREAD_CPUTIME) #if defined(_POSIX_THREAD_CPUTIME)
@ -398,7 +423,7 @@ int _EXFUN(pthread_spin_unlock, (pthread_spinlock_t *__spinlock));
pthread_mutex_t mutex = PTHREAD_RWLOCK_INITIALIZER; pthread_mutex_t mutex = PTHREAD_RWLOCK_INITIALIZER;
*/ */
#define PTHREAD_RWLOCK_INITIALIZER ((pthread_rwlock_t) 0xFFFFFFFF) #define PTHREAD_RWLOCK_INITIALIZER _PTHREAD_RWLOCK_INITIALIZER
int _EXFUN(pthread_rwlockattr_init, (pthread_rwlockattr_t *__attr)); int _EXFUN(pthread_rwlockattr_init, (pthread_rwlockattr_t *__attr));
int _EXFUN(pthread_rwlockattr_destroy, (pthread_rwlockattr_t *__attr)); int _EXFUN(pthread_rwlockattr_destroy, (pthread_rwlockattr_t *__attr));

View file

@ -63,14 +63,14 @@ struct passwd {
struct passwd *getpwuid (uid_t); struct passwd *getpwuid (uid_t);
struct passwd *getpwnam (const char *); struct passwd *getpwnam (const char *);
#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 500 #if __MISC_VISIBLE || __POSIX_VISIBLE
int getpwnam_r (const char *, struct passwd *, int getpwnam_r (const char *, struct passwd *,
char *, size_t , struct passwd **); char *, size_t , struct passwd **);
int getpwuid_r (uid_t, struct passwd *, char *, int getpwuid_r (uid_t, struct passwd *, char *,
size_t, struct passwd **); size_t, struct passwd **);
#endif #endif
#if __XSI_VISIBLE >= 500 #if __MISC_VISIBLE || __XSI_VISIBLE >= 4
struct passwd *getpwent (void); struct passwd *getpwent (void);
void setpwent (void); void setpwent (void);
void endpwent (void); void endpwent (void);

View file

@ -92,7 +92,6 @@ extern "C" {
#include <sys/reent.h> #include <sys/reent.h>
#include <sys/_types.h> #include <sys/_types.h>
#include <machine/types.h>
#define __need_size_t #define __need_size_t
#define __need_ptrdiff_t #define __need_ptrdiff_t

View file

@ -2,15 +2,18 @@
#define _SIGNAL_H_ #define _SIGNAL_H_
#include "_ansi.h" #include "_ansi.h"
#include <sys/cdefs.h>
#include <sys/signal.h> #include <sys/signal.h>
_BEGIN_STD_C _BEGIN_STD_C
typedef int sig_atomic_t; /* Atomic entity type (ANSI) */ typedef int sig_atomic_t; /* Atomic entity type (ANSI) */
#ifndef _POSIX_SOURCE #if __BSD_VISIBLE
typedef _sig_func_ptr sig_t; /* BSD naming */ typedef _sig_func_ptr sig_t; /* BSD naming */
#endif
#if __GNU_VISIBLE
typedef _sig_func_ptr sighandler_t; /* glibc naming */ typedef _sig_func_ptr sighandler_t; /* glibc naming */
#endif /* !_POSIX_SOURCE */ #endif
#define SIG_DFL ((_sig_func_ptr)0) /* Default action */ #define SIG_DFL ((_sig_func_ptr)0) /* Default action */
#define SIG_IGN ((_sig_func_ptr)1) /* Ignore action */ #define SIG_IGN ((_sig_func_ptr)1) /* Ignore action */

View file

@ -11,53 +11,30 @@
#include <machine/_default_types.h> #include <machine/_default_types.h>
#include <sys/_intsup.h> #include <sys/_intsup.h>
#include <sys/_stdint.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#ifdef ___int8_t_defined
typedef __int8_t int8_t ;
typedef __uint8_t uint8_t ;
#define __int8_t_defined 1
#endif
#ifdef ___int_least8_t_defined #ifdef ___int_least8_t_defined
typedef __int_least8_t int_least8_t; typedef __int_least8_t int_least8_t;
typedef __uint_least8_t uint_least8_t; typedef __uint_least8_t uint_least8_t;
#define __int_least8_t_defined 1 #define __int_least8_t_defined 1
#endif #endif
#ifdef ___int16_t_defined
typedef __int16_t int16_t ;
typedef __uint16_t uint16_t ;
#define __int16_t_defined 1
#endif
#ifdef ___int_least16_t_defined #ifdef ___int_least16_t_defined
typedef __int_least16_t int_least16_t; typedef __int_least16_t int_least16_t;
typedef __uint_least16_t uint_least16_t; typedef __uint_least16_t uint_least16_t;
#define __int_least16_t_defined 1 #define __int_least16_t_defined 1
#endif #endif
#ifdef ___int32_t_defined
typedef __int32_t int32_t ;
typedef __uint32_t uint32_t ;
#define __int32_t_defined 1
#endif
#ifdef ___int_least32_t_defined #ifdef ___int_least32_t_defined
typedef __int_least32_t int_least32_t; typedef __int_least32_t int_least32_t;
typedef __uint_least32_t uint_least32_t; typedef __uint_least32_t uint_least32_t;
#define __int_least32_t_defined 1 #define __int_least32_t_defined 1
#endif #endif
#ifdef ___int64_t_defined
typedef __int64_t int64_t ;
typedef __uint64_t uint64_t ;
#define __int64_t_defined 1
#endif
#ifdef ___int_least64_t_defined #ifdef ___int_least64_t_defined
typedef __int_least64_t int_least64_t; typedef __int_least64_t int_least64_t;
typedef __uint_least64_t uint_least64_t; typedef __uint_least64_t uint_least64_t;
@ -147,37 +124,15 @@ typedef __uint_least64_t uint_least64_t;
#endif #endif
#endif #endif
/* Greatest-width integer types */
/* Modern GCCs provide __INTMAX_TYPE__ */
#if defined(__INTMAX_TYPE__)
typedef __INTMAX_TYPE__ intmax_t;
#elif __have_longlong64
typedef signed long long intmax_t;
#else
typedef signed long intmax_t;
#endif
/* Modern GCCs provide __UINTMAX_TYPE__ */
#if defined(__UINTMAX_TYPE__)
typedef __UINTMAX_TYPE__ uintmax_t;
#elif __have_longlong64
typedef unsigned long long uintmax_t;
#else
typedef unsigned long uintmax_t;
#endif
typedef __intptr_t intptr_t;
typedef __uintptr_t uintptr_t;
#ifdef __INTPTR_TYPE__ #ifdef __INTPTR_TYPE__
#define INTPTR_MIN (-__INTPTR_MAX__ - 1) #define INTPTR_MIN (-__INTPTR_MAX__ - 1)
#define INTPTR_MAX __INTPTR_MAX__ #define INTPTR_MAX (__INTPTR_MAX__)
#define UINTPTR_MAX __UINTPTR_MAX__ #define UINTPTR_MAX (__UINTPTR_MAX__)
#elif defined(__PTRDIFF_TYPE__) #elif defined(__PTRDIFF_TYPE__)
#define INTPTR_MAX PTRDIFF_MAX #define INTPTR_MAX PTRDIFF_MAX
#define INTPTR_MIN PTRDIFF_MIN #define INTPTR_MIN PTRDIFF_MIN
#ifdef __UINTPTR_MAX__ #ifdef __UINTPTR_MAX__
#define UINTPTR_MAX __UINTPTR_MAX__ #define UINTPTR_MAX (__UINTPTR_MAX__)
#else #else
#define UINTPTR_MAX (2UL * PTRDIFF_MAX + 1) #define UINTPTR_MAX (2UL * PTRDIFF_MAX + 1)
#endif #endif
@ -186,7 +141,7 @@ typedef __uintptr_t uintptr_t;
* Fallback to hardcoded values, * Fallback to hardcoded values,
* should be valid on cpu's with 32bit int/32bit void* * should be valid on cpu's with 32bit int/32bit void*
*/ */
#define INTPTR_MAX __STDINT_EXP(LONG_MAX) #define INTPTR_MAX (__STDINT_EXP(LONG_MAX))
#define INTPTR_MIN (-__STDINT_EXP(LONG_MAX) - 1) #define INTPTR_MIN (-__STDINT_EXP(LONG_MAX) - 1)
#define UINTPTR_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1) #define UINTPTR_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)
#endif #endif
@ -195,77 +150,77 @@ typedef __uintptr_t uintptr_t;
#ifdef __INT8_MAX__ #ifdef __INT8_MAX__
#define INT8_MIN (-__INT8_MAX__ - 1) #define INT8_MIN (-__INT8_MAX__ - 1)
#define INT8_MAX __INT8_MAX__ #define INT8_MAX (__INT8_MAX__)
#define UINT8_MAX __UINT8_MAX__ #define UINT8_MAX (__UINT8_MAX__)
#elif defined(__int8_t_defined) #elif defined(__int8_t_defined)
#define INT8_MIN -128 #define INT8_MIN (-128)
#define INT8_MAX 127 #define INT8_MAX (127)
#define UINT8_MAX 255 #define UINT8_MAX (255)
#endif #endif
#ifdef __INT_LEAST8_MAX__ #ifdef __INT_LEAST8_MAX__
#define INT_LEAST8_MIN (-__INT_LEAST8_MAX__ - 1) #define INT_LEAST8_MIN (-__INT_LEAST8_MAX__ - 1)
#define INT_LEAST8_MAX __INT_LEAST8_MAX__ #define INT_LEAST8_MAX (__INT_LEAST8_MAX__)
#define UINT_LEAST8_MAX __UINT_LEAST8_MAX__ #define UINT_LEAST8_MAX (__UINT_LEAST8_MAX__)
#elif defined(__int_least8_t_defined) #elif defined(__int_least8_t_defined)
#define INT_LEAST8_MIN -128 #define INT_LEAST8_MIN (-128)
#define INT_LEAST8_MAX 127 #define INT_LEAST8_MAX (127)
#define UINT_LEAST8_MAX 255 #define UINT_LEAST8_MAX (255)
#else #else
#error required type int_least8_t missing #error required type int_least8_t missing
#endif #endif
#ifdef __INT16_MAX__ #ifdef __INT16_MAX__
#define INT16_MIN (-__INT16_MAX__ - 1) #define INT16_MIN (-__INT16_MAX__ - 1)
#define INT16_MAX __INT16_MAX__ #define INT16_MAX (__INT16_MAX__)
#define UINT16_MAX __UINT16_MAX__ #define UINT16_MAX (__UINT16_MAX__)
#elif defined(__int16_t_defined) #elif defined(__int16_t_defined)
#define INT16_MIN -32768 #define INT16_MIN (-32768)
#define INT16_MAX 32767 #define INT16_MAX (32767)
#define UINT16_MAX 65535 #define UINT16_MAX (65535)
#endif #endif
#ifdef __INT_LEAST16_MAX__ #ifdef __INT_LEAST16_MAX__
#define INT_LEAST16_MIN (-__INT_LEAST16_MAX__ - 1) #define INT_LEAST16_MIN (-__INT_LEAST16_MAX__ - 1)
#define INT_LEAST16_MAX __INT_LEAST16_MAX__ #define INT_LEAST16_MAX (__INT_LEAST16_MAX__)
#define UINT_LEAST16_MAX __UINT_LEAST16_MAX__ #define UINT_LEAST16_MAX (__UINT_LEAST16_MAX__)
#elif defined(__int_least16_t_defined) #elif defined(__int_least16_t_defined)
#define INT_LEAST16_MIN -32768 #define INT_LEAST16_MIN (-32768)
#define INT_LEAST16_MAX 32767 #define INT_LEAST16_MAX (32767)
#define UINT_LEAST16_MAX 65535 #define UINT_LEAST16_MAX (65535)
#else #else
#error required type int_least16_t missing #error required type int_least16_t missing
#endif #endif
#ifdef __INT32_MAX__ #ifdef __INT32_MAX__
#define INT32_MIN (-__INT32_MAX__ - 1) #define INT32_MIN (-__INT32_MAX__ - 1)
#define INT32_MAX __INT32_MAX__ #define INT32_MAX (__INT32_MAX__)
#define UINT32_MAX __UINT32_MAX__ #define UINT32_MAX (__UINT32_MAX__)
#elif defined(__int32_t_defined) #elif defined(__int32_t_defined)
#if __have_long32 #if defined (_INT32_EQ_LONG)
#define INT32_MIN (-2147483647L-1) #define INT32_MIN (-2147483647L-1)
#define INT32_MAX 2147483647L #define INT32_MAX (2147483647L)
#define UINT32_MAX 4294967295UL #define UINT32_MAX (4294967295UL)
#else #else
#define INT32_MIN (-2147483647-1) #define INT32_MIN (-2147483647-1)
#define INT32_MAX 2147483647 #define INT32_MAX (2147483647)
#define UINT32_MAX 4294967295U #define UINT32_MAX (4294967295U)
#endif #endif
#endif #endif
#ifdef __INT_LEAST32_MAX__ #ifdef __INT_LEAST32_MAX__
#define INT_LEAST32_MIN (-__INT_LEAST32_MAX__ - 1) #define INT_LEAST32_MIN (-__INT_LEAST32_MAX__ - 1)
#define INT_LEAST32_MAX __INT_LEAST32_MAX__ #define INT_LEAST32_MAX (__INT_LEAST32_MAX__)
#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__ #define UINT_LEAST32_MAX (__UINT_LEAST32_MAX__)
#elif defined(__int_least32_t_defined) #elif defined(__int_least32_t_defined)
#if __have_long32 #if defined (_INT32_EQ_LONG)
#define INT_LEAST32_MIN (-2147483647L-1) #define INT_LEAST32_MIN (-2147483647L-1)
#define INT_LEAST32_MAX 2147483647L #define INT_LEAST32_MAX (2147483647L)
#define UINT_LEAST32_MAX 4294967295UL #define UINT_LEAST32_MAX (4294967295UL)
#else #else
#define INT_LEAST32_MIN (-2147483647-1) #define INT_LEAST32_MIN (-2147483647-1)
#define INT_LEAST32_MAX 2147483647 #define INT_LEAST32_MAX (2147483647)
#define UINT_LEAST32_MAX 4294967295U #define UINT_LEAST32_MAX (4294967295U)
#endif #endif
#else #else
#error required type int_least32_t missing #error required type int_least32_t missing
@ -273,44 +228,44 @@ typedef __uintptr_t uintptr_t;
#ifdef __INT64_MAX__ #ifdef __INT64_MAX__
#define INT64_MIN (-__INT64_MAX__ - 1) #define INT64_MIN (-__INT64_MAX__ - 1)
#define INT64_MAX __INT64_MAX__ #define INT64_MAX (__INT64_MAX__)
#define UINT64_MAX __UINT64_MAX__ #define UINT64_MAX (__UINT64_MAX__)
#elif defined(__int64_t_defined) #elif defined(__int64_t_defined)
#if __have_long64 #if __have_long64
#define INT64_MIN (-9223372036854775807L-1L) #define INT64_MIN (-9223372036854775807L-1L)
#define INT64_MAX 9223372036854775807L #define INT64_MAX (9223372036854775807L)
#define UINT64_MAX 18446744073709551615U #define UINT64_MAX (18446744073709551615U)
#elif __have_longlong64 #elif __have_longlong64
#define INT64_MIN (-9223372036854775807LL-1LL) #define INT64_MIN (-9223372036854775807LL-1LL)
#define INT64_MAX 9223372036854775807LL #define INT64_MAX (9223372036854775807LL)
#define UINT64_MAX 18446744073709551615ULL #define UINT64_MAX (18446744073709551615ULL)
#endif #endif
#endif #endif
#ifdef __INT_LEAST64_MAX__ #ifdef __INT_LEAST64_MAX__
#define INT_LEAST64_MIN (-__INT_LEAST64_MAX__ - 1) #define INT_LEAST64_MIN (-__INT_LEAST64_MAX__ - 1)
#define INT_LEAST64_MAX __INT_LEAST64_MAX__ #define INT_LEAST64_MAX (__INT_LEAST64_MAX__)
#define UINT_LEAST64_MAX __UINT_LEAST64_MAX__ #define UINT_LEAST64_MAX (__UINT_LEAST64_MAX__)
#elif defined(__int_least64_t_defined) #elif defined(__int_least64_t_defined)
#if __have_long64 #if __have_long64
#define INT_LEAST64_MIN (-9223372036854775807L-1L) #define INT_LEAST64_MIN (-9223372036854775807L-1L)
#define INT_LEAST64_MAX 9223372036854775807L #define INT_LEAST64_MAX (9223372036854775807L)
#define UINT_LEAST64_MAX 18446744073709551615U #define UINT_LEAST64_MAX (18446744073709551615U)
#elif __have_longlong64 #elif __have_longlong64
#define INT_LEAST64_MIN (-9223372036854775807LL-1LL) #define INT_LEAST64_MIN (-9223372036854775807LL-1LL)
#define INT_LEAST64_MAX 9223372036854775807LL #define INT_LEAST64_MAX (9223372036854775807LL)
#define UINT_LEAST64_MAX 18446744073709551615ULL #define UINT_LEAST64_MAX (18446744073709551615ULL)
#endif #endif
#endif #endif
#ifdef __INT_FAST8_MAX__ #ifdef __INT_FAST8_MAX__
#define INT_FAST8_MIN (-__INT_FAST8_MAX__ - 1) #define INT_FAST8_MIN (-__INT_FAST8_MAX__ - 1)
#define INT_FAST8_MAX __INT_FAST8_MAX__ #define INT_FAST8_MAX (__INT_FAST8_MAX__)
#define UINT_FAST8_MAX __UINT_FAST8_MAX__ #define UINT_FAST8_MAX (__UINT_FAST8_MAX__)
#elif defined(__int_fast8_t_defined) #elif defined(__int_fast8_t_defined)
#if __STDINT_EXP(INT_MAX) >= 0x7f #if __STDINT_EXP(INT_MAX) >= 0x7f
#define INT_FAST8_MIN (-__STDINT_EXP(INT_MAX)-1) #define INT_FAST8_MIN (-__STDINT_EXP(INT_MAX)-1)
#define INT_FAST8_MAX __STDINT_EXP(INT_MAX) #define INT_FAST8_MAX (__STDINT_EXP(INT_MAX))
#define UINT_FAST8_MAX (__STDINT_EXP(INT_MAX)*2U+1U) #define UINT_FAST8_MAX (__STDINT_EXP(INT_MAX)*2U+1U)
#else #else
#define INT_FAST8_MIN INT_LEAST8_MIN #define INT_FAST8_MIN INT_LEAST8_MIN
@ -321,12 +276,12 @@ typedef __uintptr_t uintptr_t;
#ifdef __INT_FAST16_MAX__ #ifdef __INT_FAST16_MAX__
#define INT_FAST16_MIN (-__INT_FAST16_MAX__ - 1) #define INT_FAST16_MIN (-__INT_FAST16_MAX__ - 1)
#define INT_FAST16_MAX __INT_FAST16_MAX__ #define INT_FAST16_MAX (__INT_FAST16_MAX__)
#define UINT_FAST16_MAX __UINT_FAST16_MAX__ #define UINT_FAST16_MAX (__UINT_FAST16_MAX__)
#elif defined(__int_fast16_t_defined) #elif defined(__int_fast16_t_defined)
#if __STDINT_EXP(INT_MAX) >= 0x7fff #if __STDINT_EXP(INT_MAX) >= 0x7fff
#define INT_FAST16_MIN (-__STDINT_EXP(INT_MAX)-1) #define INT_FAST16_MIN (-__STDINT_EXP(INT_MAX)-1)
#define INT_FAST16_MAX __STDINT_EXP(INT_MAX) #define INT_FAST16_MAX (__STDINT_EXP(INT_MAX))
#define UINT_FAST16_MAX (__STDINT_EXP(INT_MAX)*2U+1U) #define UINT_FAST16_MAX (__STDINT_EXP(INT_MAX)*2U+1U)
#else #else
#define INT_FAST16_MIN INT_LEAST16_MIN #define INT_FAST16_MIN INT_LEAST16_MIN
@ -337,12 +292,12 @@ typedef __uintptr_t uintptr_t;
#ifdef __INT_FAST32_MAX__ #ifdef __INT_FAST32_MAX__
#define INT_FAST32_MIN (-__INT_FAST32_MAX__ - 1) #define INT_FAST32_MIN (-__INT_FAST32_MAX__ - 1)
#define INT_FAST32_MAX __INT_FAST32_MAX__ #define INT_FAST32_MAX (__INT_FAST32_MAX__)
#define UINT_FAST32_MAX __UINT_FAST32_MAX__ #define UINT_FAST32_MAX (__UINT_FAST32_MAX__)
#elif defined(__int_fast32_t_defined) #elif defined(__int_fast32_t_defined)
#if __STDINT_EXP(INT_MAX) >= 0x7fffffff #if __STDINT_EXP(INT_MAX) >= 0x7fffffff
#define INT_FAST32_MIN (-__STDINT_EXP(INT_MAX)-1) #define INT_FAST32_MIN (-__STDINT_EXP(INT_MAX)-1)
#define INT_FAST32_MAX __STDINT_EXP(INT_MAX) #define INT_FAST32_MAX (__STDINT_EXP(INT_MAX))
#define UINT_FAST32_MAX (__STDINT_EXP(INT_MAX)*2U+1U) #define UINT_FAST32_MAX (__STDINT_EXP(INT_MAX)*2U+1U)
#else #else
#define INT_FAST32_MIN INT_LEAST32_MIN #define INT_FAST32_MIN INT_LEAST32_MIN
@ -353,12 +308,12 @@ typedef __uintptr_t uintptr_t;
#ifdef __INT_FAST64_MAX__ #ifdef __INT_FAST64_MAX__
#define INT_FAST64_MIN (-__INT_FAST64_MAX__ - 1) #define INT_FAST64_MIN (-__INT_FAST64_MAX__ - 1)
#define INT_FAST64_MAX __INT_FAST64_MAX__ #define INT_FAST64_MAX (__INT_FAST64_MAX__)
#define UINT_FAST64_MAX __UINT_FAST64_MAX__ #define UINT_FAST64_MAX (__UINT_FAST64_MAX__)
#elif defined(__int_fast64_t_defined) #elif defined(__int_fast64_t_defined)
#if __STDINT_EXP(INT_MAX) > 0x7fffffff #if __STDINT_EXP(INT_MAX) > 0x7fffffff
#define INT_FAST64_MIN (-__STDINT_EXP(INT_MAX)-1) #define INT_FAST64_MIN (-__STDINT_EXP(INT_MAX)-1)
#define INT_FAST64_MAX __STDINT_EXP(INT_MAX) #define INT_FAST64_MAX (__STDINT_EXP(INT_MAX))
#define UINT_FAST64_MAX (__STDINT_EXP(INT_MAX)*2U+1U) #define UINT_FAST64_MAX (__STDINT_EXP(INT_MAX)*2U+1U)
#else #else
#define INT_FAST64_MIN INT_LEAST64_MIN #define INT_FAST64_MIN INT_LEAST64_MIN
@ -368,7 +323,7 @@ typedef __uintptr_t uintptr_t;
#endif #endif
#ifdef __INTMAX_MAX__ #ifdef __INTMAX_MAX__
#define INTMAX_MAX __INTMAX_MAX__ #define INTMAX_MAX (__INTMAX_MAX__)
#define INTMAX_MIN (-INTMAX_MAX - 1) #define INTMAX_MIN (-INTMAX_MAX - 1)
#elif defined(__INTMAX_TYPE__) #elif defined(__INTMAX_TYPE__)
/* All relevant GCC versions prefer long to long long for intmax_t. */ /* All relevant GCC versions prefer long to long long for intmax_t. */
@ -377,7 +332,7 @@ typedef __uintptr_t uintptr_t;
#endif #endif
#ifdef __UINTMAX_MAX__ #ifdef __UINTMAX_MAX__
#define UINTMAX_MAX __UINTMAX_MAX__ #define UINTMAX_MAX (__UINTMAX_MAX__)
#elif defined(__UINTMAX_TYPE__) #elif defined(__UINTMAX_TYPE__)
/* All relevant GCC versions prefer long to long long for intmax_t. */ /* All relevant GCC versions prefer long to long long for intmax_t. */
#define UINTMAX_MAX UINT64_MAX #define UINTMAX_MAX UINT64_MAX
@ -385,27 +340,27 @@ typedef __uintptr_t uintptr_t;
/* This must match size_t in stddef.h, currently long unsigned int */ /* This must match size_t in stddef.h, currently long unsigned int */
#ifdef __SIZE_MAX__ #ifdef __SIZE_MAX__
#define SIZE_MAX __SIZE_MAX__ #define SIZE_MAX (__SIZE_MAX__)
#else #else
#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1) #define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)
#endif #endif
/* This must match sig_atomic_t in <signal.h> (currently int) */ /* This must match sig_atomic_t in <signal.h> (currently int) */
#define SIG_ATOMIC_MIN (-__STDINT_EXP(INT_MAX) - 1) #define SIG_ATOMIC_MIN (-__STDINT_EXP(INT_MAX) - 1)
#define SIG_ATOMIC_MAX __STDINT_EXP(INT_MAX) #define SIG_ATOMIC_MAX (__STDINT_EXP(INT_MAX))
/* This must match ptrdiff_t in <stddef.h> (currently long int) */ /* This must match ptrdiff_t in <stddef.h> (currently long int) */
#ifdef __PTRDIFF_MAX__ #ifdef __PTRDIFF_MAX__
#define PTRDIFF_MAX __PTRDIFF_MAX__ #define PTRDIFF_MAX (__PTRDIFF_MAX__)
#else #else
#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX) #define PTRDIFF_MAX (__STDINT_EXP(LONG_MAX))
#endif #endif
#define PTRDIFF_MIN (-PTRDIFF_MAX - 1) #define PTRDIFF_MIN (-PTRDIFF_MAX - 1)
/* This must match definition in <wchar.h> */ /* This must match definition in <wchar.h> */
#ifndef WCHAR_MIN #ifndef WCHAR_MIN
#ifdef __WCHAR_MIN__ #ifdef __WCHAR_MIN__
#define WCHAR_MIN __WCHAR_MIN__ #define WCHAR_MIN (__WCHAR_MIN__)
#elif defined(__WCHAR_UNSIGNED__) || (L'\0' - 1 > 0) #elif defined(__WCHAR_UNSIGNED__) || (L'\0' - 1 > 0)
#define WCHAR_MIN (0 + L'\0') #define WCHAR_MIN (0 + L'\0')
#else #else
@ -416,7 +371,7 @@ typedef __uintptr_t uintptr_t;
/* This must match definition in <wchar.h> */ /* This must match definition in <wchar.h> */
#ifndef WCHAR_MAX #ifndef WCHAR_MAX
#ifdef __WCHAR_MAX__ #ifdef __WCHAR_MAX__
#define WCHAR_MAX __WCHAR_MAX__ #define WCHAR_MAX (__WCHAR_MAX__)
#elif defined(__WCHAR_UNSIGNED__) || (L'\0' - 1 > 0) #elif defined(__WCHAR_UNSIGNED__) || (L'\0' - 1 > 0)
#define WCHAR_MAX (0xffffffffu + L'\0') #define WCHAR_MAX (0xffffffffu + L'\0')
#else #else
@ -426,14 +381,14 @@ typedef __uintptr_t uintptr_t;
/* wint_t is unsigned int on almost all GCC targets. */ /* wint_t is unsigned int on almost all GCC targets. */
#ifdef __WINT_MAX__ #ifdef __WINT_MAX__
#define WINT_MAX __WINT_MAX__ #define WINT_MAX (__WINT_MAX__)
#else #else
#define WINT_MAX (__STDINT_EXP(INT_MAX) * 2U + 1U) #define WINT_MAX (__STDINT_EXP(INT_MAX) * 2U + 1U)
#endif #endif
#ifdef __WINT_MIN__ #ifdef __WINT_MIN__
#define WINT_MIN __WINT_MIN__ #define WINT_MIN (__WINT_MIN__)
#else #else
#define WINT_MIN 0U #define WINT_MIN (0U)
#endif #endif
/** Macros for minimum-width integer constant expressions */ /** Macros for minimum-width integer constant expressions */
@ -465,7 +420,7 @@ typedef __uintptr_t uintptr_t;
#define INT32_C(x) __INT32_C(x) #define INT32_C(x) __INT32_C(x)
#define UINT32_C(x) __UINT32_C(x) #define UINT32_C(x) __UINT32_C(x)
#else #else
#if __have_long32 #if defined (_INT32_EQ_LONG)
#define INT32_C(x) x##L #define INT32_C(x) x##L
#define UINT32_C(x) x##UL #define UINT32_C(x) x##UL
#else #else

View file

@ -35,9 +35,22 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#include <stddef.h> #include <stddef.h>
/* typedef only __gnuc_va_list, used throughout the header */
#define __need___va_list #define __need___va_list
#include <stdarg.h> #include <stdarg.h>
/* typedef va_list only when required */
#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE
#ifdef __GNUC__
#ifndef _VA_LIST_DEFINED
typedef __gnuc_va_list va_list;
#define _VA_LIST_DEFINED
#endif
#else /* !__GNUC__ */
#include <stdarg.h>
#endif
#endif /* __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE */
/* /*
* <sys/reent.h> defines __FILE, _fpos_t. * <sys/reent.h> defines __FILE, _fpos_t.
* They must be defined there because struct _reent needs them (and we don't * They must be defined there because struct _reent needs them (and we don't
@ -49,7 +62,10 @@
_BEGIN_STD_C _BEGIN_STD_C
#if !defined(__FILE_defined)
typedef __FILE FILE; typedef __FILE FILE;
# define __FILE_defined
#endif
#ifdef __CYGWIN__ #ifdef __CYGWIN__
typedef _fpos64_t fpos_t; typedef _fpos64_t fpos_t;
@ -125,7 +141,7 @@ typedef _fpos64_t fpos64_t;
#define L_tmpnam FILENAME_MAX #define L_tmpnam FILENAME_MAX
#endif #endif
#ifndef __STRICT_ANSI__ #if __BSD_VISIBLE || __XSI_VISIBLE
#define P_tmpdir "/tmp" #define P_tmpdir "/tmp"
#endif #endif
@ -161,6 +177,12 @@ typedef _fpos64_t fpos64_t;
#endif #endif
#endif #endif
#if __POSIX_VISIBLE
char * _EXFUN(ctermid, (char *));
#endif
#if __XSI_VISIBLE && __XSI_VISIBLE < 600
char * _EXFUN(cuserid, (char *));
#endif
FILE * _EXFUN(tmpfile, (void)); FILE * _EXFUN(tmpfile, (void));
char * _EXFUN(tmpnam, (char *)); char * _EXFUN(tmpnam, (char *));
#if __BSD_VISIBLE || __XSI_VISIBLE || __POSIX_VISIBLE >= 200112 #if __BSD_VISIBLE || __XSI_VISIBLE || __POSIX_VISIBLE >= 200112
@ -227,7 +249,7 @@ int _EXFUN(rename, (const char *, const char *));
int _EXFUN(_rename, (const char *, const char *)); int _EXFUN(_rename, (const char *, const char *));
#endif #endif
#endif #endif
#if !defined(__STRICT_ANSI__) || defined(__USE_XOPEN2K) #if __LARGEFILE_VISIBLE || __POSIX_VISIBLE >= 200112
#ifdef _COMPILING_NEWLIB #ifdef _COMPILING_NEWLIB
int _EXFUN(fseeko, (FILE *, _off_t, int)); int _EXFUN(fseeko, (FILE *, _off_t, int));
_off_t _EXFUN(ftello, ( FILE *)); _off_t _EXFUN(ftello, ( FILE *));
@ -239,16 +261,32 @@ off_t _EXFUN(ftello, ( FILE *));
#if __GNU_VISIBLE #if __GNU_VISIBLE
int _EXFUN(fcloseall, (_VOID)); int _EXFUN(fcloseall, (_VOID));
#endif #endif
#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) || (__cplusplus >= 201103L)
#ifndef _REENT_ONLY #ifndef _REENT_ONLY
#if __ISO_C_VISIBLE >= 1999
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 *, ...) int _EXFUN(asiprintf, (char **, const char *, ...)
_ATTRIBUTE ((__format__ (__printf__, 2, 3)))); _ATTRIBUTE ((__format__ (__printf__, 2, 3))));
char * _EXFUN(asniprintf, (char *, size_t *, const char *, ...) char * _EXFUN(asniprintf, (char *, size_t *, const char *, ...)
_ATTRIBUTE ((__format__ (__printf__, 3, 4)))); _ATTRIBUTE ((__format__ (__printf__, 3, 4))));
char * _EXFUN(asnprintf, (char *__restrict, size_t *__restrict, const char *__restrict, ...) char * _EXFUN(asnprintf, (char *__restrict, size_t *__restrict, const char *__restrict, ...)
_ATTRIBUTE ((__format__ (__printf__, 3, 4)))); _ATTRIBUTE ((__format__ (__printf__, 3, 4))));
int _EXFUN(asprintf, (char **__restrict, const char *__restrict, ...)
_ATTRIBUTE ((__format__ (__printf__, 2, 3))));
#ifndef diprintf #ifndef diprintf
int _EXFUN(diprintf, (int, const char *, ...) int _EXFUN(diprintf, (int, const char *, ...)
_ATTRIBUTE ((__format__ (__printf__, 2, 3)))); _ATTRIBUTE ((__format__ (__printf__, 2, 3))));
@ -265,8 +303,6 @@ int _EXFUN(siprintf, (char *, const char *, ...)
_ATTRIBUTE ((__format__ (__printf__, 2, 3)))); _ATTRIBUTE ((__format__ (__printf__, 2, 3))));
int _EXFUN(siscanf, (const char *, const char *, ...) int _EXFUN(siscanf, (const char *, const char *, ...)
_ATTRIBUTE ((__format__ (__scanf__, 2, 3)))); _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 *, ...) int _EXFUN(sniprintf, (char *, size_t, const char *, ...)
_ATTRIBUTE ((__format__ (__printf__, 3, 4)))); _ATTRIBUTE ((__format__ (__printf__, 3, 4))));
int _EXFUN(vasiprintf, (char **, const char *, __VALIST) int _EXFUN(vasiprintf, (char **, const char *, __VALIST)
@ -275,50 +311,50 @@ char * _EXFUN(vasniprintf, (char *, size_t *, const char *, __VALIST)
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); _ATTRIBUTE ((__format__ (__printf__, 3, 0))));
char * _EXFUN(vasnprintf, (char *, size_t *, const char *, __VALIST) char * _EXFUN(vasnprintf, (char *, size_t *, const char *, __VALIST)
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); _ATTRIBUTE ((__format__ (__printf__, 3, 0))));
int _EXFUN(vasprintf, (char **, const char *, __VALIST)
_ATTRIBUTE ((__format__ (__printf__, 2, 0))));
int _EXFUN(vdiprintf, (int, const char *, __VALIST) int _EXFUN(vdiprintf, (int, const char *, __VALIST)
_ATTRIBUTE ((__format__ (__printf__, 2, 0)))); _ATTRIBUTE ((__format__ (__printf__, 2, 0))));
int _EXFUN(vfiprintf, (FILE *, const char *, __VALIST) int _EXFUN(vfiprintf, (FILE *, const char *, __VALIST)
_ATTRIBUTE ((__format__ (__printf__, 2, 0)))); _ATTRIBUTE ((__format__ (__printf__, 2, 0))));
int _EXFUN(vfiscanf, (FILE *, const char *, __VALIST) int _EXFUN(vfiscanf, (FILE *, const char *, __VALIST)
_ATTRIBUTE ((__format__ (__scanf__, 2, 0)))); _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) int _EXFUN(viprintf, (const char *, __VALIST)
_ATTRIBUTE ((__format__ (__printf__, 1, 0)))); _ATTRIBUTE ((__format__ (__printf__, 1, 0))));
int _EXFUN(viscanf, (const char *, __VALIST) int _EXFUN(viscanf, (const char *, __VALIST)
_ATTRIBUTE ((__format__ (__scanf__, 1, 0)))); _ATTRIBUTE ((__format__ (__scanf__, 1, 0))));
int _EXFUN(vscanf, (const char *, __VALIST)
_ATTRIBUTE ((__format__ (__scanf__, 1, 0))));
int _EXFUN(vsiprintf, (char *, const char *, __VALIST) int _EXFUN(vsiprintf, (char *, const char *, __VALIST)
_ATTRIBUTE ((__format__ (__printf__, 2, 0)))); _ATTRIBUTE ((__format__ (__printf__, 2, 0))));
int _EXFUN(vsiscanf, (const char *, const char *, __VALIST) int _EXFUN(vsiscanf, (const char *, const char *, __VALIST)
_ATTRIBUTE ((__format__ (__scanf__, 2, 0)))); _ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
int _EXFUN(vsniprintf, (char *, size_t, const char *, __VALIST) int _EXFUN(vsniprintf, (char *, size_t, const char *, __VALIST)
_ATTRIBUTE ((__format__ (__printf__, 3, 0)))); _ATTRIBUTE ((__format__ (__printf__, 3, 0))));
int _EXFUN(vsnprintf, (char *__restrict, size_t, const char *__restrict, __VALIST) #endif /* __MISC_VISIBLE */
_ATTRIBUTE ((__format__ (__printf__, 3, 0))));
int _EXFUN(vsscanf, (const char *__restrict, const char *__restrict, __VALIST)
_ATTRIBUTE ((__format__ (__scanf__, 2, 0))));
#endif /* !_REENT_ONLY */ #endif /* !_REENT_ONLY */
#endif /* !__STRICT_ANSI__ */
/* /*
* Routines in POSIX 1003.1:2001. * Routines in POSIX 1003.1:2001.
*/ */
#ifndef __STRICT_ANSI__ #if __POSIX_VISIBLE
#ifndef _REENT_ONLY #ifndef _REENT_ONLY
FILE * _EXFUN(fdopen, (int, const char *)); FILE * _EXFUN(fdopen, (int, const char *));
#endif #endif
int _EXFUN(fileno, (FILE *)); int _EXFUN(fileno, (FILE *));
int _EXFUN(getw, (FILE *)); #endif
#if __MISC_VISIBLE || __POSIX_VISIBLE >= 199209
int _EXFUN(pclose, (FILE *)); int _EXFUN(pclose, (FILE *));
FILE * _EXFUN(popen, (const char *, const char *)); FILE * _EXFUN(popen, (const char *, const char *));
int _EXFUN(putw, (int, FILE *)); #endif
#if __BSD_VISIBLE
void _EXFUN(setbuffer, (FILE *, char *, int)); void _EXFUN(setbuffer, (FILE *, char *, int));
int _EXFUN(setlinebuf, (FILE *)); int _EXFUN(setlinebuf, (FILE *));
#endif
#if __MISC_VISIBLE || (__XSI_VISIBLE && __POSIX_VISIBLE < 200112)
int _EXFUN(getw, (FILE *));
int _EXFUN(putw, (int, FILE *));
#endif
#if __MISC_VISIBLE || __POSIX_VISIBLE
int _EXFUN(getc_unlocked, (FILE *)); int _EXFUN(getc_unlocked, (FILE *));
int _EXFUN(getchar_unlocked, (void)); int _EXFUN(getchar_unlocked, (void));
void _EXFUN(flockfile, (FILE *)); void _EXFUN(flockfile, (FILE *));
@ -326,13 +362,13 @@ int _EXFUN(ftrylockfile, (FILE *));
void _EXFUN(funlockfile, (FILE *)); void _EXFUN(funlockfile, (FILE *));
int _EXFUN(putc_unlocked, (int, FILE *)); int _EXFUN(putc_unlocked, (int, FILE *));
int _EXFUN(putchar_unlocked, (int)); int _EXFUN(putchar_unlocked, (int));
#endif /* ! __STRICT_ANSI__ */ #endif
/* /*
* Routines in POSIX 1003.1:200x. * Routines in POSIX 1003.1:200x.
*/ */
#ifndef __STRICT_ANSI__ #if __POSIX_VISIBLE >= 200809
# ifndef _REENT_ONLY # ifndef _REENT_ONLY
# ifndef dprintf # ifndef dprintf
int _EXFUN(dprintf, (int, const char *__restrict, ...) int _EXFUN(dprintf, (int, const char *__restrict, ...)
@ -342,13 +378,13 @@ FILE * _EXFUN(fmemopen, (void *__restrict, size_t, const char *__restrict));
/* getdelim - see __getdelim for now */ /* getdelim - see __getdelim for now */
/* getline - see __getline for now */ /* getline - see __getline for now */
FILE * _EXFUN(open_memstream, (char **, size_t *)); 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) int _EXFUN(vdprintf, (int, const char *__restrict, __VALIST)
_ATTRIBUTE ((__format__ (__printf__, 2, 0)))); _ATTRIBUTE ((__format__ (__printf__, 2, 0))));
# endif # endif
#endif #endif
#if __ATFILE_VISIBLE
int _EXFUN(renameat, (int, const char *, int, const char *));
#endif
/* /*
* Recursive versions of the above. * Recursive versions of the above.
@ -492,7 +528,7 @@ int _EXFUN(fpurge, (FILE *));
ssize_t _EXFUN(__getdelim, (char **, size_t *, int, FILE *)); ssize_t _EXFUN(__getdelim, (char **, size_t *, int, FILE *));
ssize_t _EXFUN(__getline, (char **, size_t *, FILE *)); ssize_t _EXFUN(__getline, (char **, size_t *, FILE *));
#if __BSD_VISIBLE #if __MISC_VISIBLE
void _EXFUN(clearerr_unlocked, (FILE *)); void _EXFUN(clearerr_unlocked, (FILE *));
int _EXFUN(feof_unlocked, (FILE *)); int _EXFUN(feof_unlocked, (FILE *));
int _EXFUN(ferror_unlocked, (FILE *)); int _EXFUN(ferror_unlocked, (FILE *));
@ -542,7 +578,7 @@ int _EXFUN(__swbuf_r, (struct _reent *, int, FILE *));
* Stdio function-access interface. * Stdio function-access interface.
*/ */
#ifndef __STRICT_ANSI__ #if __BSD_VISIBLE
# ifdef __LARGE64_FILES # ifdef __LARGE64_FILES
FILE *_EXFUN(funopen,(const _PTR __cookie, FILE *_EXFUN(funopen,(const _PTR __cookie,
int (*__readfn)(_PTR __c, char *__buf, int (*__readfn)(_PTR __c, char *__buf,
@ -579,7 +615,9 @@ FILE *_EXFUN(_funopen_r,(struct _reent *, const _PTR __cookie,
(fpos_t (*)())0, (int (*)())0) (fpos_t (*)())0, (int (*)())0)
# define fwopen(__cookie, __fn) funopen(__cookie, (int (*)())0, __fn, \ # define fwopen(__cookie, __fn) funopen(__cookie, (int (*)())0, __fn, \
(fpos_t (*)())0, (int (*)())0) (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_read_function_t(void *__cookie, char *__buf, size_t __n);
typedef ssize_t cookie_write_function_t(void *__cookie, const char *__buf, typedef ssize_t cookie_write_function_t(void *__cookie, const char *__buf,
size_t __n); size_t __n);
@ -603,7 +641,7 @@ FILE *_EXFUN(fopencookie,(void *__cookie,
const char *__mode, cookie_io_functions_t __functions)); const char *__mode, cookie_io_functions_t __functions));
FILE *_EXFUN(_fopencookie_r,(struct _reent *, void *__cookie, FILE *_EXFUN(_fopencookie_r,(struct _reent *, void *__cookie,
const char *__mode, cookie_io_functions_t __functions)); const char *__mode, cookie_io_functions_t __functions));
#endif /* ! __STRICT_ANSI__ */ #endif /* __GNU_VISIBLE */
#ifndef __CUSTOM_FILE_IO__ #ifndef __CUSTOM_FILE_IO__
/* /*
@ -642,10 +680,12 @@ _ELIDABLE_INLINE int __sgetc_r(struct _reent *__ptr, FILE *__p)
#define __sgetc_r(__ptr, __p) __sgetc_raw_r(__ptr, __p) #define __sgetc_r(__ptr, __p) __sgetc_raw_r(__ptr, __p)
#endif #endif
#ifdef _never /* __GNUC__ */ #ifdef __GNUC__
/* If this inline is actually used, then systems using coff debugging
info get hopelessly confused. 21sept93 rich@cygnus.com. */
_ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) { _ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
#ifdef __SCLE
if ((_p->_flags & __SCLE) && _c == '\n')
__sputc_r (_ptr, '\r', _p);
#endif
if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
return (*_p->_p++ = _c); return (*_p->_p++ = _c);
else else
@ -678,19 +718,20 @@ _ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF))) #define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
#define __sfileno(p) ((p)->_file) #define __sfileno(p) ((p)->_file)
#ifndef __cplusplus
#ifndef _REENT_SMALL #ifndef _REENT_SMALL
#define feof(p) __sfeof(p) #define feof(p) __sfeof(p)
#define ferror(p) __sferror(p) #define ferror(p) __sferror(p)
#define clearerr(p) __sclearerr(p) #define clearerr(p) __sclearerr(p)
#if __BSD_VISIBLE #if __MISC_VISIBLE
#define feof_unlocked(p) __sfeof(p) #define feof_unlocked(p) __sfeof(p)
#define ferror_unlocked(p) __sferror(p) #define ferror_unlocked(p) __sferror(p)
#define clearerr_unlocked(p) __sclearerr(p) #define clearerr_unlocked(p) __sclearerr(p)
#endif /* __BSD_VISIBLE */ #endif /* __MISC_VISIBLE */
#endif /* _REENT_SMALL */ #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) #define fileno(p) __sfileno(p)
#endif #endif
@ -700,16 +741,19 @@ _ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
#define putc(x, fp) __sputc_r(_REENT, x, fp) #define putc(x, fp) __sputc_r(_REENT, x, fp)
#endif /* lint */ #endif /* lint */
#endif /* __CYGWIN__ */ #endif /* __CYGWIN__ */
#endif /* __cplusplus */
#ifndef __STRICT_ANSI__ #if __MISC_VISIBLE
/* fast always-buffered version, true iff error */ /* fast always-buffered version, true iff error */
#define fast_putc(x,p) (--(p)->_w < 0 ? \ #define fast_putc(x,p) (--(p)->_w < 0 ? \
__swbuf_r(_REENT, (int)(x), p) == EOF : (*(p)->_p = (x), (p)->_p++, 0)) __swbuf_r(_REENT, (int)(x), p) == EOF : (*(p)->_p = (x), (p)->_p++, 0))
#define L_cuserid 9 /* posix says it goes in stdio.h :( */
#ifdef __CYGWIN__
#define L_ctermid 16
#endif #endif
#if __GNU_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 600)
#define L_cuserid 9 /* posix says it goes in stdio.h :( */
#endif
#if __POSIX_VISIBLE
#define L_ctermid 16
#endif #endif
#endif /* !__CUSTOM_FILE_IO__ */ #endif /* !__CUSTOM_FILE_IO__ */
@ -717,7 +761,7 @@ _ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
#define getchar() getc(stdin) #define getchar() getc(stdin)
#define putchar(x) putc(x, stdout) #define putchar(x) putc(x, stdout)
#ifndef __STRICT_ANSI__ #if __MISC_VISIBLE || __POSIX_VISIBLE
#define getchar_unlocked() getc_unlocked(stdin) #define getchar_unlocked() getc_unlocked(stdin)
#define putchar_unlocked(x) putc_unlocked(x, stdout) #define putchar_unlocked(x) putc_unlocked(x, stdout)
#endif #endif

View file

@ -26,6 +26,10 @@
#include <cygwin/stdlib.h> #include <cygwin/stdlib.h>
#endif #endif
#if __GNU_VISIBLE
#include <xlocale.h>
#endif
_BEGIN_STD_C _BEGIN_STD_C
typedef struct typedef struct
@ -40,9 +44,7 @@ typedef struct
long rem; /* remainder */ long rem; /* remainder */
} ldiv_t; } ldiv_t;
#if !defined(__STRICT_ANSI__) || \ #if __ISO_C_VISIBLE >= 1999
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
(defined(__cplusplus) && __cplusplus >= 201103L)
typedef struct typedef struct
{ {
long long int quot; /* quotient */ long long int quot; /* quotient */
@ -70,9 +72,14 @@ int _EXFUN(__locale_mb_cur_max,(_VOID));
_VOID _EXFUN(abort,(_VOID) _ATTRIBUTE ((__noreturn__))); _VOID _EXFUN(abort,(_VOID) _ATTRIBUTE ((__noreturn__)));
int _EXFUN(abs,(int)); int _EXFUN(abs,(int));
#if __BSD_VISIBLE
__uint32_t _EXFUN(arc4random, (void));
__uint32_t _EXFUN(arc4random_uniform, (__uint32_t));
void _EXFUN(arc4random_buf, (void *, size_t));
#endif
int _EXFUN(atexit,(_VOID (*__func)(_VOID))); int _EXFUN(atexit,(_VOID (*__func)(_VOID)));
double _EXFUN(atof,(const char *__nptr)); double _EXFUN(atof,(const char *__nptr));
#ifndef __STRICT_ANSI__ #if __MISC_VISIBLE
float _EXFUN(atoff,(const char *__nptr)); float _EXFUN(atoff,(const char *__nptr));
#endif #endif
int _EXFUN(atoi,(const char *__nptr)); int _EXFUN(atoi,(const char *__nptr));
@ -92,7 +99,7 @@ char * _EXFUN(getenv,(const char *__string));
char * _EXFUN(_getenv_r,(struct _reent *, const char *__string)); char * _EXFUN(_getenv_r,(struct _reent *, const char *__string));
char * _EXFUN(_findenv,(_CONST char *, int *)); char * _EXFUN(_findenv,(_CONST char *, int *));
char * _EXFUN(_findenv_r,(struct _reent *, _CONST char *, int *)); char * _EXFUN(_findenv_r,(struct _reent *, _CONST char *, int *));
#ifndef __STRICT_ANSI__ #if __POSIX_VISIBLE >= 200809
extern char *suboptarg; /* getsubopt(3) external variable */ extern char *suboptarg; /* getsubopt(3) external variable */
int _EXFUN(getsubopt,(char **, char * const *, char **)); int _EXFUN(getsubopt,(char **, char * const *, char **));
#endif #endif
@ -109,48 +116,64 @@ 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(_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,(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 *)); size_t _EXFUN(_wcstombs_r,(struct _reent *, char *__restrict, const wchar_t *__restrict, size_t, _mbstate_t *));
#ifndef __STRICT_ANSI__
#ifndef _REENT_ONLY #ifndef _REENT_ONLY
#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809
char * _EXFUN(mkdtemp,(char *)); char * _EXFUN(mkdtemp,(char *));
#endif
#if __GNU_VISIBLE
int _EXFUN(mkostemp,(char *, int)); int _EXFUN(mkostemp,(char *, int));
int _EXFUN(mkostemps,(char *, int, int)); int _EXFUN(mkostemps,(char *, int, int));
#endif
#if __MISC_VISIBLE || __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 4
int _EXFUN(mkstemp,(char *)); int _EXFUN(mkstemp,(char *));
#endif
#if __MISC_VISIBLE
int _EXFUN(mkstemps,(char *, int)); int _EXFUN(mkstemps,(char *, int));
#endif
#if (__GNUC__ < 4) || defined(__XTENSA__) #if (__GNUC__ < 4) || defined(__XTENSA__)
char * _EXFUN(mktemp,(char *)); char * _EXFUN(mktemp,(char *));
#else #else
char * _EXFUN(mktemp,(char *) _ATTRIBUTE ((__warning__ ("the use of `mktemp' is dangerous; use `mkstemp' instead")))); #if __BSD_VISIBLE || (__XSI_VISIBLE >= 4 && __POSIX_VISIBLE < 200112)
char * _EXFUN(mktemp,(char *) _ATTRIBUTE ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))));
#endif #endif
#endif #endif
#endif /* !_REENT_ONLY */
char * _EXFUN(_mkdtemp_r, (struct _reent *, char *)); char * _EXFUN(_mkdtemp_r, (struct _reent *, char *));
int _EXFUN(_mkostemp_r, (struct _reent *, char *, int)); int _EXFUN(_mkostemp_r, (struct _reent *, char *, int));
int _EXFUN(_mkostemps_r, (struct _reent *, char *, int, int)); int _EXFUN(_mkostemps_r, (struct _reent *, char *, int, int));
int _EXFUN(_mkstemp_r, (struct _reent *, char *)); int _EXFUN(_mkstemp_r, (struct _reent *, char *));
int _EXFUN(_mkstemps_r, (struct _reent *, char *, int)); int _EXFUN(_mkstemps_r, (struct _reent *, char *, int));
#if (__GNUC__ < 4) || defined(__XTENSA__) #if (__GNUC__ < 4) || defined(__XTENSA__)
char * _EXFUN(_mktemp_r, (struct _reent *, char *)); char * _EXFUN(_mktemp_r, (struct _reent *, char *));
#else #else
char * _EXFUN(_mktemp_r, (struct _reent *, char *) _ATTRIBUTE ((__warning__ ("the use of `mktemp' is dangerous; use `mkstemp' instead")))); char * _EXFUN(_mktemp_r, (struct _reent *, char *) _ATTRIBUTE ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead"))));
#endif
#endif #endif
_VOID _EXFUN(qsort,(_PTR __base, size_t __nmemb, size_t __size, __compar_fn_t _compar)); _VOID _EXFUN(qsort,(_PTR __base, size_t __nmemb, size_t __size, __compar_fn_t _compar));
int _EXFUN(rand,(_VOID)); int _EXFUN(rand,(_VOID));
_PTR _EXFUN_NOTHROW(realloc,(_PTR __r, size_t __size)); _PTR _EXFUN_NOTHROW(realloc,(_PTR __r, size_t __size));
#ifndef __STRICT_ANSI__ #if __BSD_VISIBLE
void *reallocarray(void *, size_t, size_t) __result_use_check __alloc_size(2)
__alloc_size(3);
_PTR _EXFUN(reallocf,(_PTR __r, size_t __size)); _PTR _EXFUN(reallocf,(_PTR __r, size_t __size));
#endif
#if __BSD_VISIBLE || __XSI_VISIBLE >= 4
char * _EXFUN(realpath, (const char *__restrict path, char *__restrict resolved_path)); char * _EXFUN(realpath, (const char *__restrict path, char *__restrict resolved_path));
#endif #endif
#if __BSD_VISIBLE
int _EXFUN(rpmatch, (const char *response));
#endif
#if __XSI_VISIBLE
_VOID _EXFUN(setkey, (const char *__key));
#endif
_VOID _EXFUN(srand,(unsigned __seed)); _VOID _EXFUN(srand,(unsigned __seed));
double _EXFUN(strtod,(const char *__restrict __n, char **__restrict __end_PTR)); 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)); double _EXFUN(_strtod_r,(struct _reent *,const char *__restrict __n, char **__restrict __end_PTR));
#if !defined(__STRICT_ANSI__) || \ #if __ISO_C_VISIBLE >= 1999
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
(defined(__cplusplus) && __cplusplus >= 201103L)
float _EXFUN(strtof,(const char *__restrict __n, char **__restrict __end_PTR)); float _EXFUN(strtof,(const char *__restrict __n, char **__restrict __end_PTR));
#endif #endif
#ifndef __STRICT_ANSI__ #if __MISC_VISIBLE
/* the following strtodf interface is deprecated...use strtof instead */ /* the following strtodf interface is deprecated...use strtof instead */
# ifndef strtodf # ifndef strtodf
# define strtodf strtof # define strtodf strtof
# endif # endif
#endif #endif
@ -159,26 +182,45 @@ long _EXFUN(_strtol_r,(struct _reent *,const char *__restrict __n, char **__rest
unsigned long _EXFUN(strtoul,(const char *__restrict __n, char **__restrict __end_PTR, int __base)); unsigned long _EXFUN(strtoul,(const char *__restrict __n, char **__restrict __end_PTR, int __base));
unsigned long _EXFUN(_strtoul_r,(struct _reent *,const char *__restrict __n, char **__restrict __end_PTR, int __base)); unsigned long _EXFUN(_strtoul_r,(struct _reent *,const char *__restrict __n, char **__restrict __end_PTR, int __base));
#if __GNU_VISIBLE
double strtod_l (const char *__restrict, char **__restrict, locale_t);
float strtof_l (const char *__restrict, char **__restrict, locale_t);
#ifdef _HAVE_LONG_DOUBLE
extern long double strtold_l (const char *__restrict, char **__restrict,
locale_t);
#endif /* _HAVE_LONG_DOUBLE */
long strtol_l (const char *__restrict, char **__restrict, int, locale_t);
unsigned long strtoul_l (const char *__restrict, char **__restrict, int,
locale_t __loc);
long long strtoll_l (const char *__restrict, char **__restrict, int, locale_t);
unsigned long long strtoull_l (const char *__restrict, char **__restrict, int,
locale_t __loc);
#endif
int _EXFUN(system,(const char *__string)); int _EXFUN(system,(const char *__string));
#ifndef __STRICT_ANSI__ #if __SVID_VISIBLE || __XSI_VISIBLE >= 4
long _EXFUN(a64l,(const char *__input)); long _EXFUN(a64l,(const char *__input));
char * _EXFUN(l64a,(long __input)); char * _EXFUN(l64a,(long __input));
char * _EXFUN(_l64a_r,(struct _reent *,long __input)); char * _EXFUN(_l64a_r,(struct _reent *,long __input));
#endif
#if __MISC_VISIBLE
int _EXFUN(on_exit,(_VOID (*__func)(int, _PTR),_PTR __arg)); int _EXFUN(on_exit,(_VOID (*__func)(int, _PTR),_PTR __arg));
#endif /* ! __STRICT_ANSI__ */ #endif
#if !defined(__STRICT_ANSI__) || \ #if __ISO_C_VISIBLE >= 1999
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
(defined(__cplusplus) && __cplusplus >= 201103L)
_VOID _EXFUN(_Exit,(int __status) _ATTRIBUTE ((__noreturn__))); _VOID _EXFUN(_Exit,(int __status) _ATTRIBUTE ((__noreturn__)));
#endif #endif
#ifndef __STRICT_ANSI__ #if __SVID_VISIBLE || __XSI_VISIBLE
int _EXFUN(putenv,(char *__string)); int _EXFUN(putenv,(char *__string));
#endif
int _EXFUN(_putenv_r,(struct _reent *, char *__string)); int _EXFUN(_putenv_r,(struct _reent *, char *__string));
_PTR _EXFUN(_reallocf_r,(struct _reent *, _PTR, size_t)); _PTR _EXFUN(_reallocf_r,(struct _reent *, _PTR, size_t));
#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112
int _EXFUN(setenv,(const char *__string, const char *__value, int __overwrite)); int _EXFUN(setenv,(const char *__string, const char *__value, int __overwrite));
#endif
int _EXFUN(_setenv_r,(struct _reent *, const char *__string, const char *__value, int __overwrite)); int _EXFUN(_setenv_r,(struct _reent *, const char *__string, const char *__value, int __overwrite));
#if __XSI_VISIBLE >= 4 && __POSIX_VISIBLE < 200112
char * _EXFUN(gcvt,(double,int,char *)); char * _EXFUN(gcvt,(double,int,char *));
char * _EXFUN(gcvtf,(float,int,char *)); char * _EXFUN(gcvtf,(float,int,char *));
char * _EXFUN(fcvt,(double,int,int *,int *)); char * _EXFUN(fcvt,(double,int,int *,int *));
@ -187,15 +229,18 @@ char * _EXFUN(ecvt,(double,int,int *,int *));
char * _EXFUN(ecvtbuf,(double, int, int*, int*, char *)); char * _EXFUN(ecvtbuf,(double, int, int*, int*, char *));
char * _EXFUN(fcvtbuf,(double, int, int*, int*, char *)); char * _EXFUN(fcvtbuf,(double, int, int*, int*, char *));
char * _EXFUN(ecvtf,(float,int,int *,int *)); char * _EXFUN(ecvtf,(float,int,int *,int *));
char * _EXFUN(dtoa,(double, int, int, int *, int*, char**));
#endif #endif
char * _EXFUN(__itoa,(int, char *, int)); char * _EXFUN(__itoa,(int, char *, int));
char * _EXFUN(__utoa,(unsigned, char *, int)); char * _EXFUN(__utoa,(unsigned, char *, int));
#ifndef __STRICT_ANSI__ #if __MISC_VISIBLE
char * _EXFUN(itoa,(int, char *, int)); char * _EXFUN(itoa,(int, char *, int));
char * _EXFUN(utoa,(unsigned, char *, int)); char * _EXFUN(utoa,(unsigned, char *, int));
#endif
#if __POSIX_VISIBLE
int _EXFUN(rand_r,(unsigned *__seed)); int _EXFUN(rand_r,(unsigned *__seed));
#endif
#if __SVID_VISIBLE || __XSI_VISIBLE
double _EXFUN(drand48,(_VOID)); double _EXFUN(drand48,(_VOID));
double _EXFUN(_drand48_r,(struct _reent *)); double _EXFUN(_drand48_r,(struct _reent *));
double _EXFUN(erand48,(unsigned short [3])); double _EXFUN(erand48,(unsigned short [3]));
@ -216,45 +261,42 @@ unsigned short *
_EXFUN(_seed48_r,(struct _reent *, unsigned short [3])); _EXFUN(_seed48_r,(struct _reent *, unsigned short [3]));
_VOID _EXFUN(srand48,(long)); _VOID _EXFUN(srand48,(long));
_VOID _EXFUN(_srand48_r,(struct _reent *, long)); _VOID _EXFUN(_srand48_r,(struct _reent *, long));
#endif /* ! __STRICT_ANSI__ */ #endif /* __SVID_VISIBLE || __XSI_VISIBLE */
#if !defined(__STRICT_ANSI__) || \ #if __SVID_VISIBLE || __XSI_VISIBLE >= 4 || __BSD_VISIBLE
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ char * _EXFUN(initstate,(unsigned, char *, size_t));
(defined(__cplusplus) && __cplusplus >= 201103L) long _EXFUN(random,(_VOID));
char * _EXFUN(setstate,(char *));
_VOID _EXFUN(srandom,(unsigned));
#endif
#if __ISO_C_VISIBLE >= 1999
long long _EXFUN(atoll,(const char *__nptr)); long long _EXFUN(atoll,(const char *__nptr));
#endif #endif
#ifndef __STRICT_ANSI__
long long _EXFUN(_atoll_r,(struct _reent *, const char *__nptr)); long long _EXFUN(_atoll_r,(struct _reent *, const char *__nptr));
#endif /* ! __STRICT_ANSI__ */ #if __ISO_C_VISIBLE >= 1999
#if !defined(__STRICT_ANSI__) || \
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
(defined(__cplusplus) && __cplusplus >= 201103L)
long long _EXFUN(llabs,(long long)); long long _EXFUN(llabs,(long long));
lldiv_t _EXFUN(lldiv,(long long __numer, long long __denom)); lldiv_t _EXFUN(lldiv,(long long __numer, long long __denom));
long long _EXFUN(strtoll,(const char *__restrict __n, char **__restrict __end_PTR, int __base)); long long _EXFUN(strtoll,(const char *__restrict __n, char **__restrict __end_PTR, int __base));
#endif #endif
#ifndef __STRICT_ANSI__
long long _EXFUN(_strtoll_r,(struct _reent *, const char *__restrict __n, char **__restrict __end_PTR, int __base)); long long _EXFUN(_strtoll_r,(struct _reent *, const char *__restrict __n, char **__restrict __end_PTR, int __base));
#endif /* ! __STRICT_ANSI__ */ #if __ISO_C_VISIBLE >= 1999
#if !defined(__STRICT_ANSI__) || \
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
(defined(__cplusplus) && __cplusplus >= 201103L)
unsigned long long _EXFUN(strtoull,(const char *__restrict __n, char **__restrict __end_PTR, int __base)); unsigned long long _EXFUN(strtoull,(const char *__restrict __n, char **__restrict __end_PTR, int __base));
#endif #endif
#ifndef __STRICT_ANSI__
unsigned long long _EXFUN(_strtoull_r,(struct _reent *, const char *__restrict __n, char **__restrict __end_PTR, int __base)); unsigned long long _EXFUN(_strtoull_r,(struct _reent *, const char *__restrict __n, char **__restrict __end_PTR, int __base));
#ifndef __CYGWIN__ #ifndef __CYGWIN__
#if __MISC_VISIBLE
_VOID _EXFUN(cfree,(_PTR)); _VOID _EXFUN(cfree,(_PTR));
#endif
#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112
int _EXFUN(unsetenv,(const char *__string)); int _EXFUN(unsetenv,(const char *__string));
#endif
int _EXFUN(_unsetenv_r,(struct _reent *, const char *__string)); int _EXFUN(_unsetenv_r,(struct _reent *, const char *__string));
#endif #endif /* !__CYGWIN__ */
#ifdef __rtems__ #if __POSIX_VISIBLE >= 200112
int _EXFUN(posix_memalign,(void **, size_t, size_t)); int _EXFUN(__nonnull (1) posix_memalign,(void **, size_t, size_t));
#endif #endif
#endif /* ! __STRICT_ANSI__ */
char * _EXFUN(_dtoa_r,(struct _reent *, double, int, int, int *, int*, char**)); char * _EXFUN(_dtoa_r,(struct _reent *, double, int, int, int *, int*, char**));
#ifndef __CYGWIN__ #ifndef __CYGWIN__
_PTR _EXFUN_NOTHROW(_malloc_r,(struct _reent *, size_t)); _PTR _EXFUN_NOTHROW(_malloc_r,(struct _reent *, size_t));
@ -271,7 +313,9 @@ _VOID _EXFUN(__eprintf,(const char *, const char *, unsigned int, const char *))
_BSD_SOURCE, you get the BSD version; otherwise you get the GNU _BSD_SOURCE, you get the BSD version; otherwise you get the GNU
version. We want that #undef qsort_r will still let you version. We want that #undef qsort_r will still let you
invoke the underlying function, but that requires gcc support. */ 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__ # ifdef __GNUC__
_VOID _EXFUN(qsort_r,(_PTR __base, size_t __nmemb, size_t __size, _PTR __thunk, int (*_compar)(_PTR, const _PTR, const _PTR))) _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")); __asm__ (__ASMNAME ("__bsd_qsort_r"));
@ -279,19 +323,27 @@ _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))); _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 # define qsort_r __bsd_qsort_r
# endif # 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 #endif
/* On platforms where long double equals double. */ /* On platforms where long double equals double. */
#ifdef _HAVE_LONG_DOUBLE #ifdef _HAVE_LONG_DOUBLE
#if !defined(__STRICT_ANSI__) || \ extern long double _strtold_r (struct _reent *, const char *__restrict, char **__restrict);
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ #if __ISO_C_VISIBLE >= 1999
(defined(__cplusplus) && __cplusplus >= 201103L)
extern long double strtold (const char *__restrict, char **__restrict); extern long double strtold (const char *__restrict, char **__restrict);
#endif #endif
#endif /* _HAVE_LONG_DOUBLE */ #endif /* _HAVE_LONG_DOUBLE */
/*
* If we're in a mode greater than C99, expose C11 functions.
*/
#if __ISO_C_VISIBLE >= 2011
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 */
_END_STD_C _END_STD_C
#endif /* _STDLIB_H_ */ #endif /* _STDLIB_H_ */

View file

@ -16,6 +16,14 @@
#define __need_NULL #define __need_NULL
#include <stddef.h> #include <stddef.h>
#if __POSIX_VISIBLE >= 200809
#include <xlocale.h>
#endif
#if __BSD_VISIBLE
#include <strings.h>
#endif
_BEGIN_STD_C _BEGIN_STD_C
_PTR _EXFUN(memchr,(const _PTR, int, size_t)); _PTR _EXFUN(memchr,(const _PTR, int, size_t));
@ -43,57 +51,43 @@ char *_EXFUN(strtok,(char *__restrict, const char *__restrict));
#endif #endif
size_t _EXFUN(strxfrm,(char *__restrict, const char *__restrict, size_t)); size_t _EXFUN(strxfrm,(char *__restrict, const char *__restrict, size_t));
#if __POSIX_VISIBLE #if __POSIX_VISIBLE >= 200809
int strcoll_l (const char *, const char *, locale_t);
char *strerror_l (int, locale_t);
size_t strxfrm_l (char *__restrict, const char *__restrict, size_t, locale_t);
#endif
#if __MISC_VISIBLE || __POSIX_VISIBLE
char *_EXFUN(strtok_r,(char *__restrict, const char *__restrict, char **__restrict)); char *_EXFUN(strtok_r,(char *__restrict, const char *__restrict, char **__restrict));
#endif #endif
#if __BSD_VISIBLE #if __BSD_VISIBLE
int _EXFUN(bcmp,(const void *, const void *, size_t)); int _EXFUN(timingsafe_bcmp,(const void *, const void *, size_t));
void _EXFUN(bcopy,(const void *, void *, size_t)); int _EXFUN(timingsafe_memcmp,(const void *, const void *, size_t));
void _EXFUN(bzero,(void *, size_t));
int _EXFUN(ffs,(int));
char *_EXFUN(index,(const char *, int));
#endif #endif
#if __BSD_VISIBLE || __XSI_VISIBLE #if __MISC_VISIBLE || __POSIX_VISIBLE
_PTR _EXFUN(memccpy,(_PTR __restrict, const _PTR __restrict, int, size_t)); _PTR _EXFUN(memccpy,(_PTR __restrict, const _PTR __restrict, int, size_t));
#endif #endif
#if __GNU_VISIBLE #if __GNU_VISIBLE
_PTR _EXFUN(mempcpy,(_PTR, const _PTR, size_t)); _PTR _EXFUN(mempcpy,(_PTR, const _PTR, size_t));
_PTR _EXFUN(memmem, (const _PTR, size_t, const _PTR, size_t)); _PTR _EXFUN(memmem, (const _PTR, size_t, const _PTR, size_t));
#endif
_PTR _EXFUN(memrchr,(const _PTR, int, size_t)); _PTR _EXFUN(memrchr,(const _PTR, int, size_t));
#if __GNU_VISIBLE
_PTR _EXFUN(rawmemchr,(const _PTR, int)); _PTR _EXFUN(rawmemchr,(const _PTR, int));
#endif #endif
#if __BSD_VISIBLE #if __POSIX_VISIBLE >= 200809
char *_EXFUN(rindex,(const char *, int));
#endif
char *_EXFUN(stpcpy,(char *__restrict, const char *__restrict)); char *_EXFUN(stpcpy,(char *__restrict, const char *__restrict));
char *_EXFUN(stpncpy,(char *__restrict, const char *__restrict, size_t)); char *_EXFUN(stpncpy,(char *__restrict, const char *__restrict, size_t));
#if __BSD_VISIBLE || __POSIX_VISIBLE
int _EXFUN(strcasecmp,(const char *, const char *));
#endif #endif
#if __GNU_VISIBLE #if __GNU_VISIBLE
char *_EXFUN(strcasestr,(const char *, const char *)); char *_EXFUN(strcasestr,(const char *, const char *));
char *_EXFUN(strchrnul,(const char *, int)); char *_EXFUN(strchrnul,(const char *, int));
#endif #endif
#if __XSI_VISIBLE >= 500 #if __MISC_VISIBLE || __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 4
char *_EXFUN(strdup,(const char *)); char *_EXFUN(strdup,(const char *));
#endif #endif
#ifndef __STRICT_ANSI__
char *_EXFUN(_strdup_r,(struct _reent *, const char *)); char *_EXFUN(_strdup_r,(struct _reent *, const char *));
#endif #if __POSIX_VISIBLE >= 200809
#if __XSI_VISIBLE >= 700
char *_EXFUN(strndup,(const char *, size_t)); char *_EXFUN(strndup,(const char *, size_t));
#endif #endif
#ifndef __STRICT_ANSI__
char *_EXFUN(_strndup_r,(struct _reent *, const char *, size_t)); char *_EXFUN(_strndup_r,(struct _reent *, const char *, size_t));
#endif
#if __GNU_VISIBLE
int _EXFUN(ffsl,(long));
int _EXFUN(ffsll, (long long));
#endif
/* There are two common strerror_r variants. If you request /* There are two common strerror_r variants. If you request
_GNU_SOURCE, you get the GNU version; otherwise you get the POSIX _GNU_SOURCE, you get the GNU version; otherwise you get the POSIX
@ -101,10 +95,13 @@ int _EXFUN(ffsll, (long long));
invoke the underlying function, but that requires gcc support. */ invoke the underlying function, but that requires gcc support. */
#if __GNU_VISIBLE #if __GNU_VISIBLE
char *_EXFUN(strerror_r,(int, char *, size_t)); char *_EXFUN(strerror_r,(int, char *, size_t));
#else #elif __POSIX_VISIBLE >= 200112
# ifdef __GNUC__ # ifdef __GNUC__
int _EXFUN(strerror_r,(int, char *, size_t)) int _EXFUN(strerror_r,(int, char *, size_t))
__asm__ (__ASMNAME ("__xpg_strerror_r")); #ifdef __ASMNAME
__asm__ (__ASMNAME ("__xpg_strerror_r"))
#endif
;
# else # else
int _EXFUN(__xpg_strerror_r,(int, char *, size_t)); int _EXFUN(__xpg_strerror_r,(int, char *, size_t));
# define strerror_r __xpg_strerror_r # define strerror_r __xpg_strerror_r
@ -118,22 +115,14 @@ char * _EXFUN(_strerror_r, (struct _reent *, int, int, int *));
size_t _EXFUN(strlcat,(char *, const char *, size_t)); size_t _EXFUN(strlcat,(char *, const char *, size_t));
size_t _EXFUN(strlcpy,(char *, const char *, size_t)); size_t _EXFUN(strlcpy,(char *, const char *, size_t));
#endif #endif
#if __BSD_VISIBLE || __POSIX_VISIBLE #if __POSIX_VISIBLE >= 200809
int _EXFUN(strncasecmp,(const char *, const char *, size_t));
#endif
#if !defined(__STRICT_ANSI__) || __POSIX_VISIBLE >= 200809 || \
__XSI_VISIBLE >= 700
size_t _EXFUN(strnlen,(const char *, size_t)); size_t _EXFUN(strnlen,(const char *, size_t));
#endif #endif
#if __BSD_VISIBLE #if __BSD_VISIBLE
char *_EXFUN(strsep,(char **, const char *)); char *_EXFUN(strsep,(char **, const char *));
#endif #endif
/* #if __MISC_VISIBLE
* 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__)
char *_EXFUN(strlwr,(char *)); char *_EXFUN(strlwr,(char *));
char *_EXFUN(strupr,(char *)); char *_EXFUN(strupr,(char *));
#endif #endif
@ -146,19 +135,39 @@ char *_EXFUN(strsignal, (int __signo));
int _EXFUN(strtosigno, (const char *__name)); int _EXFUN(strtosigno, (const char *__name));
#endif #endif
#if defined _GNU_SOURCE && defined __GNUC__ #if __GNU_VISIBLE
int _EXFUN(strverscmp,(const char *, const char *));
#endif
#if __GNU_VISIBLE && defined(__GNUC__)
#define strdupa(__s) \ #define strdupa(__s) \
(__extension__ ({const char *__in = (__s); \ (__extension__ ({const char *__sin = (__s); \
size_t __len = strlen (__in) + 1; \ size_t __len = strlen (__sin) + 1; \
char * __out = (char *) __builtin_alloca (__len); \ char * __sout = (char *) __builtin_alloca (__len); \
(char *) memcpy (__out, __in, __len);})) (char *) memcpy (__sout, __sin, __len);}))
#define strndupa(__s, __n) \ #define strndupa(__s, __n) \
(__extension__ ({const char *__in = (__s); \ (__extension__ ({const char *__sin = (__s); \
size_t __len = strnlen (__in, (__n)) + 1; \ size_t __len = strnlen (__sin, (__n)) + 1; \
char *__out = (char *) __builtin_alloca (__len); \ char *__sout = (char *) __builtin_alloca (__len); \
__out[__len-1] = '\0'; \ __sout[__len-1] = '\0'; \
(char *) memcpy (__out, __in, __len-1);})) (char *) memcpy (__sout, __sin, __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
#define _GNU_SOURCE
#include <string.h>
you get the GNU version. Otherwise you get the POSIX versionfor which you
should #include <libgen.h>i for the function prototype. POSIX requires that
#undef basename will still let you invoke the underlying function. However,
this also implies that the POSIX version is used in this case. That's made
sure here. */
#if __GNU_VISIBLE && !defined(basename)
# define basename basename
char *_EXFUN(__nonnull (1) basename,(const char *)) __asm__(__ASMNAME("__gnu_basename"));
#endif
#include <sys/string.h> #include <sys/string.h>

View file

@ -1,35 +1,76 @@
/* /*-
* strings.h * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
* All rights reserved.
* *
* Definitions for string operations. * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: head/include/strings.h 272673 2014-10-07 04:54:11Z delphij $
*/ */
#ifndef _STRINGS_H_ #ifndef _STRINGS_H_
#define _STRINGS_H_ #define _STRINGS_H_
#include "_ansi.h" #include <sys/cdefs.h>
#include <sys/reent.h> #include <sys/_types.h>
#include <sys/types.h> /* for size_t */ #if __POSIX_VISIBLE >= 200809
#include <xlocale.h>
#endif
_BEGIN_STD_C #ifndef _SIZE_T_DECLARED
typedef __size_t size_t;
#define _SIZE_T_DECLARED
#endif
#if !defined __STRICT_ANSI__ && _POSIX_VERSION < 200809L __BEGIN_DECLS
/* #if __BSD_VISIBLE || __POSIX_VISIBLE <= 200112
* Marked LEGACY in Open Group Base Specifications Issue 6/IEEE Std 1003.1-2004 int bcmp(const void *, const void *, size_t) __pure; /* LEGACY */
* Removed from Open Group Base Specifications Issue 7/IEEE Std 1003.1-2008 void bcopy(const void *, void *, size_t); /* LEGACY */
*/ void bzero(void *, size_t); /* LEGACY */
int _EXFUN(bcmp,(const void *, const void *, size_t)); #endif
void _EXFUN(bcopy,(const void *, void *, size_t)); #if __BSD_VISIBLE
void _EXFUN(bzero,(void *, size_t)); void explicit_bzero(void *, size_t);
char *_EXFUN(index,(const char *, int)); #endif
char *_EXFUN(rindex,(const char *, int)); #if __XSI_VISIBLE
#endif /* ! __STRICT_ANSI__ */ int ffs(int) __pure2;
#endif
#if __BSD_VISIBLE
int ffsl(long) __pure2;
int ffsll(long long) __pure2;
int fls(int) __pure2;
int flsl(long) __pure2;
int flsll(long long) __pure2;
#endif
#if __BSD_VISIBLE || __POSIX_VISIBLE <= 200112
char *index(const char *, int) __pure; /* LEGACY */
char *rindex(const char *, int) __pure; /* LEGACY */
#endif
int strcasecmp(const char *, const char *) __pure;
int strncasecmp(const char *, const char *, size_t) __pure;
int _EXFUN(ffs,(int)); #if __POSIX_VISIBLE >= 200809
int _EXFUN(strcasecmp,(const char *, const char *)); int strcasecmp_l (const char *, const char *, locale_t);
int _EXFUN(strncasecmp,(const char *, const char *, size_t)); int strncasecmp_l (const char *, const char *, size_t, locale_t);
#endif
_END_STD_C __END_DECLS
#endif /* _STRINGS_H_ */ #endif /* _STRINGS_H_ */

View file

@ -65,7 +65,7 @@ extern "C" {
#define O_SEARCH _FEXECSRCH #define O_SEARCH _FEXECSRCH
#endif #endif
#ifndef _POSIX_SOURCE #if __MISC_VISIBLE
/* /*
* Flags that work for fcntl(fd, F_SETFL, FXXXX) * Flags that work for fcntl(fd, F_SETFL, FXXXX)
@ -97,7 +97,11 @@ extern "C" {
#define FEXCL _FEXCL #define FEXCL _FEXCL
#define FNOCTTY _FNOCTTY #define FNOCTTY _FNOCTTY
#endif /* !_POSIX_SOURCE */ #endif /* __MISC_VISIBLE */
#if __BSD_VISIBLE
#define FNONBLOCK _FNONBLOCK
#endif /* __BSD_VISIBLE */
/* XXX close on exec request; must match UF_EXCLOSE in user.h */ /* XXX close on exec request; must match UF_EXCLOSE in user.h */
#define FD_CLOEXEC 1 /* posix */ #define FD_CLOEXEC 1 /* posix */
@ -108,20 +112,20 @@ extern "C" {
#define F_SETFD 2 /* Set fildes flags (close on exec) */ #define F_SETFD 2 /* Set fildes flags (close on exec) */
#define F_GETFL 3 /* Get file flags */ #define F_GETFL 3 /* Get file flags */
#define F_SETFL 4 /* Set file flags */ #define F_SETFL 4 /* Set file flags */
#ifndef _POSIX_SOURCE #if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112
#define F_GETOWN 5 /* Get owner - for ASYNC */ #define F_GETOWN 5 /* Get owner - for ASYNC */
#define F_SETOWN 6 /* Set owner - for ASYNC */ #define F_SETOWN 6 /* Set owner - for ASYNC */
#endif /* !_POSIX_SOURCE */ #endif /* __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 */
#define F_GETLK 7 /* Get record-locking information */ #define F_GETLK 7 /* Get record-locking information */
#define F_SETLK 8 /* Set or Clear a record-lock (Non-Blocking) */ #define F_SETLK 8 /* Set or Clear a record-lock (Non-Blocking) */
#define F_SETLKW 9 /* Set or Clear a record-lock (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_RGETLK 10 /* Test a remote lock to see if it is blocked */
#define F_RSETLK 11 /* Set or unlock a remote lock */ #define F_RSETLK 11 /* Set or unlock a remote lock */
#define F_CNVT 12 /* Convert a fhandle to an open fd */ #define F_CNVT 12 /* Convert a fhandle to an open fd */
#define F_RSETLKW 13 /* Set or Clear remote record-lock(Blocking) */ #define F_RSETLKW 13 /* Set or Clear remote record-lock(Blocking) */
#endif /* !_POSIX_SOURCE */ #endif /* __MISC_VISIBLE */
#ifdef __CYGWIN__ #if __POSIX_VISIBLE >= 200809
#define F_DUPFD_CLOEXEC 14 /* As F_DUPFD, but set close-on-exec flag */ #define F_DUPFD_CLOEXEC 14 /* As F_DUPFD, but set close-on-exec flag */
#endif #endif
@ -129,11 +133,11 @@ extern "C" {
#define F_RDLCK 1 /* read lock */ #define F_RDLCK 1 /* read lock */
#define F_WRLCK 2 /* write lock */ #define F_WRLCK 2 /* write lock */
#define F_UNLCK 3 /* remove lock(s) */ #define F_UNLCK 3 /* remove lock(s) */
#ifndef _POSIX_SOURCE #if __MISC_VISIBLE
#define F_UNLKSYS 4 /* remove remote locks for a given system */ #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 || __POSIX_VISIBLE >= 200809
/* Special descriptor value to denote the cwd in calls to openat(2) etc. */ /* Special descriptor value to denote the cwd in calls to openat(2) etc. */
#define AT_FDCWD -2 #define AT_FDCWD -2
@ -166,7 +170,7 @@ struct flock {
}; };
#endif /* __CYGWIN__ */ #endif /* __CYGWIN__ */
#ifndef _POSIX_SOURCE #if __MISC_VISIBLE
/* extended file segment locking set data type */ /* extended file segment locking set data type */
struct eflock { struct eflock {
short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */ short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */
@ -178,13 +182,13 @@ struct eflock {
long l_rpid; /* Remote process id wanting this lock */ long l_rpid; /* Remote process id wanting this lock */
long l_rsys; /* Remote system 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/types.h>
#include <sys/stat.h> /* sigh. for the mode bits for open/creat */ #include <sys/stat.h> /* sigh. for the mode bits for open/creat */
extern int open _PARAMS ((const char *, int, ...)); 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, ...)); extern int openat _PARAMS ((int, const char *, int, ...));
#endif #endif
extern int creat _PARAMS ((const char *, mode_t)); extern int creat _PARAMS ((const char *, mode_t));
@ -192,7 +196,7 @@ extern int fcntl _PARAMS ((int, int, ...));
#if __BSD_VISIBLE #if __BSD_VISIBLE
extern int flock _PARAMS ((int, int)); extern int flock _PARAMS ((int, int));
#endif #endif
#ifdef __CYGWIN__ #if __GNU_VISIBLE
#include <sys/time.h> #include <sys/time.h>
extern int futimesat _PARAMS ((int, const char *, const struct timeval *)); extern int futimesat _PARAMS ((int, const char *, const struct timeval *));
#endif #endif

View file

@ -0,0 +1,233 @@
/*
* Written by Joel Sherrill <joel.sherrill@OARcorp.com>.
*
* COPYRIGHT (c) 1989-2013, 2015.
* On-Line Applications Research Corporation (OAR).
*
* Permission to use, copy, modify, and distribute this software for any
* purpose without fee is hereby granted, provided that this entire notice
* is included in all copies of any software which is or includes a copy
* or modification of this software.
*
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION
* OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS
* SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
*/
#ifndef _SYS__PTHREADTYPES_H_
#define _SYS__PTHREADTYPES_H_
#if defined(_POSIX_THREADS) || __POSIX_VISIBLE >= 199506
#include <sys/sched.h>
/*
* 2.5 Primitive System Data Types, P1003.1c/D10, p. 19.
*/
#if defined(__XMK__)
typedef unsigned int pthread_t; /* identify a thread */
#else
typedef __uint32_t pthread_t; /* identify a thread */
#endif
/* P1003.1c/D10, p. 118-119 */
#define PTHREAD_SCOPE_PROCESS 0
#define PTHREAD_SCOPE_SYSTEM 1
/* P1003.1c/D10, p. 111 */
#define PTHREAD_INHERIT_SCHED 1 /* scheduling policy and associated */
/* attributes are inherited from */
/* the calling thread. */
#define PTHREAD_EXPLICIT_SCHED 2 /* set from provided attribute object */
/* P1003.1c/D10, p. 141 */
#define PTHREAD_CREATE_DETACHED 0
#define PTHREAD_CREATE_JOINABLE 1
#if defined(__XMK__)
typedef struct pthread_attr_s {
int contentionscope;
struct sched_param schedparam;
int detachstate;
void *stackaddr;
size_t stacksize;
} pthread_attr_t;
#define PTHREAD_STACK_MIN 200
#else /* !defined(__XMK__) */
typedef struct {
int is_initialized;
void *stackaddr;
int stacksize;
int contentionscope;
int inheritsched;
int schedpolicy;
struct sched_param schedparam;
/* P1003.4b/D8, p. 54 adds cputime_clock_allowed attribute. */
#if defined(_POSIX_THREAD_CPUTIME)
int cputime_clock_allowed; /* see time.h */
#endif
int detachstate;
} pthread_attr_t;
#endif /* !defined(__XMK__) */
#if defined(_POSIX_THREAD_PROCESS_SHARED)
/* NOTE: P1003.1c/D10, p. 81 defines following values for process_shared. */
#define PTHREAD_PROCESS_PRIVATE 0 /* visible within only the creating process */
#define PTHREAD_PROCESS_SHARED 1 /* visible too all processes with access to */
/* the memory where the resource is */
/* located */
#endif
#if defined(_POSIX_THREAD_PRIO_PROTECT)
/* Mutexes */
/* Values for blocking protocol. */
#define PTHREAD_PRIO_NONE 0
#define PTHREAD_PRIO_INHERIT 1
#define PTHREAD_PRIO_PROTECT 2
#endif
#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES)
/* Values for mutex type */
/* The following defines are part of the X/Open System Interface (XSI). */
/*
* This type of mutex does not detect deadlock. A thread attempting to
* relock this mutex without first unlocking it shall deadlock. Attempting
* to unlock a mutex locked by a different thread results in undefined
* behavior. Attempting to unlock an unlocked mutex results in undefined
* behavior.
*/
#define PTHREAD_MUTEX_NORMAL 0
/*
* A thread attempting to relock this mutex without first unlocking
* it shall succeed in locking the mutex. The relocking deadlock which
* can occur with mutexes of type PTHREAD_MUTEX_NORMAL cannot occur with
* this type of mutex. Multiple locks of this mutex shall require the
* same number of unlocks to release the mutex before another thread can
* acquire the mutex. A thread attempting to unlock a mutex which another
* thread has locked shall return with an error. A thread attempting to
* unlock an unlocked mutex shall return with an error.
*/
#define PTHREAD_MUTEX_RECURSIVE 1
/*
* This type of mutex provides error checking. A thread attempting
* to relock this mutex without first unlocking it shall return with an
* error. A thread attempting to unlock a mutex which another thread has
* locked shall return with an error. A thread attempting to unlock an
* unlocked mutex shall return with an error.
*/
#define PTHREAD_MUTEX_ERRORCHECK 2
/*
* Attempting to recursively lock a mutex of this type results
* in undefined behavior. Attempting to unlock a mutex of this type
* which was not locked by the calling thread results in undefined
* behavior. Attempting to unlock a mutex of this type which is not locked
* results in undefined behavior. An implementation may map this mutex to
* one of the other mutex types.
*/
#define PTHREAD_MUTEX_DEFAULT 3
#endif /* !defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES) */
#if defined(__XMK__)
typedef unsigned int pthread_mutex_t; /* identify a mutex */
typedef struct {
int type;
} pthread_mutexattr_t;
#else /* !defined(__XMK__) */
typedef __uint32_t pthread_mutex_t; /* identify a mutex */
typedef struct {
int is_initialized;
#if defined(_POSIX_THREAD_PROCESS_SHARED)
int process_shared; /* allow mutex to be shared amongst processes */
#endif
#if defined(_POSIX_THREAD_PRIO_PROTECT)
int prio_ceiling;
int protocol;
#endif
#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES)
int type;
#endif
int recursive;
} pthread_mutexattr_t;
#endif /* !defined(__XMK__) */
#define _PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t) 0xFFFFFFFF)
/* Condition Variables */
typedef __uint32_t pthread_cond_t; /* identify a condition variable */
#define _PTHREAD_COND_INITIALIZER ((pthread_cond_t) 0xFFFFFFFF)
typedef struct {
int is_initialized;
clock_t clock; /* specifiy clock for timeouts */
#if defined(_POSIX_THREAD_PROCESS_SHARED)
int process_shared; /* allow this to be shared amongst processes */
#endif
} pthread_condattr_t; /* a condition attribute object */
/* Keys */
typedef __uint32_t pthread_key_t; /* thread-specific data keys */
typedef struct {
int is_initialized; /* is this structure initialized? */
int init_executed; /* has the initialization routine been run? */
} pthread_once_t; /* dynamic package initialization */
#define _PTHREAD_ONCE_INIT { 1, 0 } /* is initialized and not run */
#endif /* defined(_POSIX_THREADS) || __POSIX_VISIBLE >= 199506 */
/* POSIX Barrier Types */
#if defined(_POSIX_BARRIERS)
typedef __uint32_t pthread_barrier_t; /* POSIX Barrier Object */
typedef struct {
int is_initialized; /* is this structure initialized? */
#if defined(_POSIX_THREAD_PROCESS_SHARED)
int process_shared; /* allow this to be shared amongst processes */
#endif
} pthread_barrierattr_t;
#endif /* defined(_POSIX_BARRIERS) */
/* POSIX Spin Lock Types */
#if defined(_POSIX_SPIN_LOCKS)
typedef __uint32_t pthread_spinlock_t; /* POSIX Spin Lock Object */
#endif /* defined(_POSIX_SPIN_LOCKS) */
/* POSIX Reader/Writer Lock Types */
#if defined(_POSIX_READER_WRITER_LOCKS)
typedef __uint32_t pthread_rwlock_t; /* POSIX RWLock Object */
#define _PTHREAD_RWLOCK_INITIALIZER ((pthread_rwlock_t) 0xFFFFFFFF)
typedef struct {
int is_initialized; /* is this structure initialized? */
#if defined(_POSIX_THREAD_PROCESS_SHARED)
int process_shared; /* allow this to be shared amongst processes */
#endif
} pthread_rwlockattr_t;
#endif /* defined(_POSIX_READER_WRITER_LOCKS) */
#endif /* ! _SYS__PTHREADTYPES_H_ */

View file

@ -0,0 +1,43 @@
/*-
* Copyright (c) 1982, 1986, 1989, 1991, 1993
* The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc.
* All or some portions of this file are derived from material licensed
* to the University of California by American Telephone and Telegraph
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
* the permission of UNIX System Laboratories, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)signal.h 8.4 (Berkeley) 5/4/95
* $FreeBSD$
*/
#ifndef _SYS__SIGSET_H_
#define _SYS__SIGSET_H_
typedef unsigned long __sigset_t;
#endif /* !_SYS__SIGSET_H_ */

View file

@ -0,0 +1,90 @@
/*
* Copyright (c) 2004, 2005 by
* Ralf Corsepius, Ulm/Germany. All rights reserved.
*
* Permission to use, copy, modify, and distribute this software
* is freely granted, provided that this notice is preserved.
*/
#ifndef _SYS__STDINT_H
#define _SYS__STDINT_H
#include <machine/_default_types.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef ___int8_t_defined
#ifndef _INT8_T_DECLARED
typedef __int8_t int8_t ;
#define _INT8_T_DECLARED
#endif
#ifndef _UINT8_T_DECLARED
typedef __uint8_t uint8_t ;
#define _UINT8_T_DECLARED
#endif
#define __int8_t_defined 1
#endif /* ___int8_t_defined */
#ifdef ___int16_t_defined
#ifndef _INT16_T_DECLARED
typedef __int16_t int16_t ;
#define _INT16_T_DECLARED
#endif
#ifndef _UINT16_T_DECLARED
typedef __uint16_t uint16_t ;
#define _UINT16_T_DECLARED
#endif
#define __int16_t_defined 1
#endif /* ___int16_t_defined */
#ifdef ___int32_t_defined
#ifndef _INT32_T_DECLARED
typedef __int32_t int32_t ;
#define _INT32_T_DECLARED
#endif
#ifndef _UINT32_T_DECLARED
typedef __uint32_t uint32_t ;
#define _UINT32_T_DECLARED
#endif
#define __int32_t_defined 1
#endif /* ___int32_t_defined */
#ifdef ___int64_t_defined
#ifndef _INT64_T_DECLARED
typedef __int64_t int64_t ;
#define _INT64_T_DECLARED
#endif
#ifndef _UINT64_T_DECLARED
typedef __uint64_t uint64_t ;
#define _UINT64_T_DECLARED
#endif
#define __int64_t_defined 1
#endif /* ___int64_t_defined */
#ifndef _INTMAX_T_DECLARED
typedef __intmax_t intmax_t;
#define _INTMAX_T_DECLARED
#endif
#ifndef _UINTMAX_T_DECLARED
typedef __uintmax_t uintmax_t;
#define _UINTMAX_T_DECLARED
#endif
#ifndef _INTPTR_T_DECLARED
typedef __intptr_t intptr_t;
#define _INTPTR_T_DECLARED
#endif
#ifndef _UINTPTR_T_DECLARED
typedef __uintptr_t uintptr_t;
#define _UINTPTR_T_DECLARED
#endif
#ifdef __cplusplus
}
#endif
#endif /* _SYS__STDINT_H */

View file

@ -0,0 +1,50 @@
/*-
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)time.h 8.5 (Berkeley) 5/4/95
* from: FreeBSD: src/sys/sys/time.h,v 1.43 2000/03/20 14:09:05 phk Exp
* $FreeBSD$
*/
#ifndef _SYS__TIMESPEC_H_
#define _SYS__TIMESPEC_H_
#include <sys/_types.h>
#if !defined(__time_t_defined) && !defined(_TIME_T_DECLARED)
typedef _TIME_T_ time_t;
#define __time_t_defined
#define _TIME_T_DECLARED
#endif
struct timespec {
time_t tv_sec; /* seconds */
long tv_nsec; /* and nanoseconds */
};
#endif /* !_SYS__TIMESPEC_H_ */

View file

@ -0,0 +1,89 @@
/*-
* Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _SYS__TIMEVAL_H_
#define _SYS__TIMEVAL_H_
#include <sys/_types.h>
#ifndef _SUSECONDS_T_DECLARED
typedef __suseconds_t suseconds_t;
#define _SUSECONDS_T_DECLARED
#endif
#if !defined(__time_t_defined) && !defined(_TIME_T_DECLARED)
typedef _TIME_T_ time_t;
#define __time_t_defined
#define _TIME_T_DECLARED
#endif
/* This define is also used outside of Newlib, e.g. in MinGW-w64 */
#ifndef _TIMEVAL_DEFINED
#define _TIMEVAL_DEFINED
/*
* Structure returned by gettimeofday(2) system call, and used in other calls.
*/
struct timeval {
time_t tv_sec; /* seconds */
suseconds_t tv_usec; /* and microseconds */
};
#if __BSD_VISIBLE
#ifndef _KERNEL /* NetBSD/OpenBSD compatible interfaces */
#define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
#define timercmp(tvp, uvp, cmp) \
(((tvp)->tv_sec == (uvp)->tv_sec) ? \
((tvp)->tv_usec cmp (uvp)->tv_usec) : \
((tvp)->tv_sec cmp (uvp)->tv_sec))
#define timeradd(tvp, uvp, vvp) \
do { \
(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
(vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
if ((vvp)->tv_usec >= 1000000) { \
(vvp)->tv_sec++; \
(vvp)->tv_usec -= 1000000; \
} \
} while (0)
#define timersub(tvp, uvp, vvp) \
do { \
(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
if ((vvp)->tv_usec < 0) { \
(vvp)->tv_sec--; \
(vvp)->tv_usec += 1000000; \
} \
} while (0)
#endif
#endif /* __BSD_VISIBLE */
#endif /* _TIMEVAL_DEFINED */
#endif /* !_SYS__TIMEVAL_H_ */

View file

@ -2,51 +2,141 @@
/* This file defines various typedefs needed by the system calls that support /* This file defines various typedefs needed by the system calls that support
the C library. Basically, they're just the POSIX versions with an '_' the C library. Basically, they're just the POSIX versions with an '_'
prepended. This file lives in the `sys' directory so targets can provide prepended. Targets shall use <machine/_types.h> to define their own
their own if desired (or they can put target dependant conditionals here). internal types if desired.
There are three define patterns used for type definitions. Lets assume
xyz_t is a user type.
The internal type definition uses __machine_xyz_t_defined. It is defined by
<machine/_types.h> to disable a default definition in <sys/_types.h>. It
must not be used in other files.
User type definitions are guarded by __xyz_t_defined in glibc and
_XYZ_T_DECLARED in BSD compatible systems.
*/ */
#ifndef _SYS__TYPES_H #ifndef _SYS__TYPES_H
#define _SYS__TYPES_H #define _SYS__TYPES_H
#include <newlib.h>
#include <sys/config.h>
#include <machine/_types.h> #include <machine/_types.h>
#include <sys/lock.h> #include <sys/lock.h>
#ifndef __off_t_defined #ifndef __machine_blkcnt_t_defined
typedef long __blkcnt_t;
#endif
#ifndef __machine_blksize_t_defined
typedef long __blksize_t;
#endif
#ifndef __machine_fsblkcnt_t_defined
typedef __uint64_t __fsblkcnt_t;
#endif
#ifndef __machine_fsfilcnt_t_defined
typedef __uint32_t __fsfilcnt_t;
#endif
#ifndef __machine_off_t_defined
typedef long _off_t; typedef long _off_t;
#endif #endif
#ifndef __dev_t_defined #if defined(__XMK__)
typedef signed char __pid_t;
#else
typedef int __pid_t;
#endif
#ifndef __machine_dev_t_defined
typedef short __dev_t; typedef short __dev_t;
#endif #endif
#ifndef __uid_t_defined #ifndef __machine_uid_t_defined
typedef unsigned short __uid_t; typedef unsigned short __uid_t;
#endif #endif
#ifndef __gid_t_defined #ifndef __machine_gid_t_defined
typedef unsigned short __gid_t; typedef unsigned short __gid_t;
#endif #endif
#ifndef __off64_t_defined #ifndef __machine_id_t_defined
typedef __uint32_t __id_t;
#endif
#ifndef __machine_ino_t_defined
#if (defined(__i386__) && (defined(GO32) || defined(__MSDOS__))) || \
defined(__sparc__) || defined(__SPU__)
typedef unsigned long __ino_t;
#else
typedef unsigned short __ino_t;
#endif
#endif
#ifndef __machine_mode_t_defined
#if defined(__i386__) && (defined(GO32) || defined(__MSDOS__))
typedef int __mode_t;
#else
#if defined(__sparc__) && !defined(__sparc_v9__)
#ifdef __svr4__
typedef unsigned long __mode_t;
#else
typedef unsigned short __mode_t;
#endif
#else
typedef __uint32_t __mode_t;
#endif
#endif
#endif
#ifndef __machine_off64_t_defined
__extension__ typedef long long _off64_t; __extension__ typedef long long _off64_t;
#endif #endif
#if defined(__CYGWIN__) && !defined(__LP64__)
typedef _off64_t __off_t;
#else
typedef _off_t __off_t;
#endif
typedef _off64_t __loff_t;
#ifndef __machine_key_t_defined
typedef long __key_t;
#endif
/* /*
* We need fpos_t for the following, but it doesn't have a leading "_", * We need fpos_t for the following, but it doesn't have a leading "_",
* so we use _fpos_t instead. * so we use _fpos_t instead.
*/ */
#ifndef __fpos_t_defined #ifndef __machine_fpos_t_defined
typedef long _fpos_t; /* XXX must match off_t in <sys/types.h> */ typedef long _fpos_t; /* XXX must match off_t in <sys/types.h> */
/* (and must be `long' for now) */ /* (and must be `long' for now) */
#endif #endif
#ifdef __LARGE64_FILES #ifdef __LARGE64_FILES
#ifndef __fpos64_t_defined #ifndef __machine_fpos64_t_defined
typedef _off64_t _fpos64_t; typedef _off64_t _fpos64_t;
#endif #endif
#endif #endif
#ifndef __ssize_t_defined /* Defined by GCC provided <stddef.h> */
#undef __size_t
#ifndef __machine_size_t_defined
#ifdef __SIZE_TYPE__
typedef __SIZE_TYPE__ __size_t;
#else
#if defined(__INT_MAX__) && __INT_MAX__ == 2147483647
typedef unsigned int __size_t;
#else
typedef unsigned long __size_t;
#endif
#endif
#endif
#ifndef __machine_ssize_t_defined
#ifdef __SIZE_TYPE__ #ifdef __SIZE_TYPE__
/* If __SIZE_TYPE__ is defined (gcc) we define ssize_t based on size_t. /* If __SIZE_TYPE__ is defined (gcc) we define ssize_t based on size_t.
We simply change "unsigned" to "signed" for this single definition We simply change "unsigned" to "signed" for this single definition
@ -63,10 +153,12 @@ typedef long _ssize_t;
#endif #endif
#endif #endif
typedef _ssize_t __ssize_t;
#define __need_wint_t #define __need_wint_t
#include <stddef.h> #include <stddef.h>
#ifndef __mbstate_t_defined #ifndef __machine_mbstate_t_defined
/* Conversion state information. */ /* Conversion state information. */
typedef struct typedef struct
{ {
@ -79,13 +171,43 @@ typedef struct
} _mbstate_t; } _mbstate_t;
#endif #endif
#ifndef __flock_t_defined #ifndef __machine_flock_t_defined
typedef _LOCK_RECURSIVE_T _flock_t; typedef _LOCK_RECURSIVE_T _flock_t;
#endif #endif
#ifndef __iconv_t_defined #ifndef __machine_iconv_t_defined
/* Iconv descriptor type */ /* Iconv descriptor type */
typedef void *_iconv_t; typedef void *_iconv_t;
#endif #endif
#define _CLOCK_T_ unsigned long /* clock() */
typedef _CLOCK_T_ __clock_t;
#define _TIME_T_ long /* time() */
typedef _TIME_T_ __time_t;
#define _CLOCKID_T_ unsigned long
typedef _CLOCKID_T_ __clockid_t;
#define _TIMER_T_ unsigned long
typedef _TIMER_T_ __timer_t;
#ifndef __machine_sa_family_t_defined
typedef __uint8_t __sa_family_t;
#endif
#ifndef __machine_socklen_t_defined
typedef __uint32_t __socklen_t;
#endif
typedef unsigned short __nlink_t;
typedef long __suseconds_t; /* microseconds (signed) */
typedef unsigned long __useconds_t; /* microseconds (unsigned) */
#ifdef __GNUCLIKE_BUILTIN_VARARGS
typedef __builtin_va_list __va_list;
#else
typedef char * __va_list;
#endif /* __GNUCLIKE_BUILTIN_VARARGS */
#endif /* _SYS__TYPES_H */ #endif /* _SYS__TYPES_H */

View file

@ -17,7 +17,7 @@
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* 4. Neither the name of the University nor the names of its contributors * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software * may be used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
@ -69,7 +69,9 @@
/* /*
* Testing against Clang-specific extensions. * Testing against Clang-specific extensions.
*/ */
#ifndef __has_attribute
#define __has_attribute(x) 0
#endif
#ifndef __has_extension #ifndef __has_extension
#define __has_extension __has_feature #define __has_extension __has_feature
#endif #endif
@ -100,33 +102,33 @@
#if defined(__GNUC__) || defined(__INTEL_COMPILER) #if defined(__GNUC__) || defined(__INTEL_COMPILER)
#if __GNUC__ >= 3 || defined(__INTEL_COMPILER) #if __GNUC__ >= 3 || defined(__INTEL_COMPILER)
#define __GNUCLIKE_ASM 3 #define __GNUCLIKE_ASM 3
#define __GNUCLIKE_MATH_BUILTIN_CONSTANTS #define __GNUCLIKE_MATH_BUILTIN_CONSTANTS
#else #else
#define __GNUCLIKE_ASM 2 #define __GNUCLIKE_ASM 2
#endif #endif
#define __GNUCLIKE___TYPEOF 1 #define __GNUCLIKE___TYPEOF 1
#define __GNUCLIKE___OFFSETOF 1 #define __GNUCLIKE___OFFSETOF 1
#define __GNUCLIKE___SECTION 1 #define __GNUCLIKE___SECTION 1
#ifndef __INTEL_COMPILER #ifndef __INTEL_COMPILER
# define __GNUCLIKE_CTOR_SECTION_HANDLING 1 #define __GNUCLIKE_CTOR_SECTION_HANDLING 1
#endif #endif
#define __GNUCLIKE_BUILTIN_CONSTANT_P 1 #define __GNUCLIKE_BUILTIN_CONSTANT_P 1
# if defined(__INTEL_COMPILER) && defined(__cplusplus) \ #if defined(__INTEL_COMPILER) && defined(__cplusplus) && \
&& __INTEL_COMPILER < 800 __INTEL_COMPILER < 800
# undef __GNUCLIKE_BUILTIN_CONSTANT_P #undef __GNUCLIKE_BUILTIN_CONSTANT_P
# endif #endif
#if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3) && !defined(__INTEL_COMPILER) #if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3)
# define __GNUCLIKE_BUILTIN_VARARGS 1 #define __GNUCLIKE_BUILTIN_VARARGS 1
# define __GNUCLIKE_BUILTIN_STDARG 1 #define __GNUCLIKE_BUILTIN_STDARG 1
# define __GNUCLIKE_BUILTIN_VAALIST 1 #define __GNUCLIKE_BUILTIN_VAALIST 1
#endif #endif
#if defined(__GNUC__) #if defined(__GNUC__)
# define __GNUC_VA_LIST_COMPATIBILITY 1 #define __GNUC_VA_LIST_COMPATIBILITY 1
#endif #endif
/* /*
@ -137,23 +139,23 @@
#endif #endif
#ifndef __INTEL_COMPILER #ifndef __INTEL_COMPILER
# define __GNUCLIKE_BUILTIN_NEXT_ARG 1 #define __GNUCLIKE_BUILTIN_NEXT_ARG 1
# define __GNUCLIKE_MATH_BUILTIN_RELOPS #define __GNUCLIKE_MATH_BUILTIN_RELOPS
#endif #endif
#define __GNUCLIKE_BUILTIN_MEMCPY 1 #define __GNUCLIKE_BUILTIN_MEMCPY 1
/* XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced */ /* XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced */
#define __CC_SUPPORTS_INLINE 1 #define __CC_SUPPORTS_INLINE 1
#define __CC_SUPPORTS___INLINE 1 #define __CC_SUPPORTS___INLINE 1
#define __CC_SUPPORTS___INLINE__ 1 #define __CC_SUPPORTS___INLINE__ 1
#define __CC_SUPPORTS___FUNC__ 1 #define __CC_SUPPORTS___FUNC__ 1
#define __CC_SUPPORTS_WARNING 1 #define __CC_SUPPORTS_WARNING 1
#define __CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */ #define __CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */
#define __CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1 #define __CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1
#endif /* __GNUC__ || __INTEL_COMPILER */ #endif /* __GNUC__ || __INTEL_COMPILER */
@ -229,8 +231,12 @@
#define __unused #define __unused
#define __packed #define __packed
#define __aligned(x) #define __aligned(x)
#define __alloc_align(x)
#define __alloc_size(x)
#define __section(x) #define __section(x)
#define __weak_symbol
#else #else
#define __weak_symbol __attribute__((__weak__))
#if !__GNUC_PREREQ__(2, 5) && !defined(__INTEL_COMPILER) #if !__GNUC_PREREQ__(2, 5) && !defined(__INTEL_COMPILER)
#define __dead2 #define __dead2
#define __pure2 #define __pure2
@ -242,7 +248,7 @@
#define __unused #define __unused
/* XXX Find out what to do for __packed, __aligned and __section */ /* XXX Find out what to do for __packed, __aligned and __section */
#endif #endif
#if __GNUC_PREREQ__(2, 7) #if __GNUC_PREREQ__(2, 7) || defined(__INTEL_COMPILER)
#define __dead2 __attribute__((__noreturn__)) #define __dead2 __attribute__((__noreturn__))
#define __pure2 __attribute__((__const__)) #define __pure2 __attribute__((__const__))
#define __unused __attribute__((__unused__)) #define __unused __attribute__((__unused__))
@ -251,16 +257,17 @@
#define __aligned(x) __attribute__((__aligned__(x))) #define __aligned(x) __attribute__((__aligned__(x)))
#define __section(x) __attribute__((__section__(x))) #define __section(x) __attribute__((__section__(x)))
#endif #endif
#if defined(__INTEL_COMPILER) #if __GNUC_PREREQ__(4, 3) || __has_attribute(__alloc_size__)
#define __dead2 __attribute__((__noreturn__)) #define __alloc_size(x) __attribute__((__alloc_size__(x)))
#define __pure2 __attribute__((__const__)) #else
#define __unused __attribute__((__unused__)) #define __alloc_size(x)
#define __used __attribute__((__used__))
#define __packed __attribute__((__packed__))
#define __aligned(x) __attribute__((__aligned__(x)))
#define __section(x) __attribute__((__section__(x)))
#endif #endif
#if __GNUC_PREREQ__(4, 9) || __has_attribute(__alloc_align__)
#define __alloc_align(x) __attribute__((__alloc_align__(x)))
#else
#define __alloc_align(x)
#endif #endif
#endif /* lint */
#if !__GNUC_PREREQ__(2, 95) #if !__GNUC_PREREQ__(2, 95)
#define __alignof(x) __offsetof(struct { char __a; x __b; }, __b) #define __alignof(x) __offsetof(struct { char __a; x __b; }, __b)
@ -270,7 +277,7 @@
* Keywords added in C11. * Keywords added in C11.
*/ */
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L || defined(lint)
#if !__has_extension(c_alignas) #if !__has_extension(c_alignas)
#if (defined(__cplusplus) && __cplusplus >= 201103L) || \ #if (defined(__cplusplus) && __cplusplus >= 201103L) || \
@ -288,7 +295,8 @@
#define _Alignof(x) __alignof(x) #define _Alignof(x) __alignof(x)
#endif #endif
#if !__has_extension(c_atomic) && !__has_extension(cxx_atomic) #if !defined(__cplusplus) && !__has_extension(c_atomic) && \
!__has_extension(cxx_atomic)
/* /*
* No native support for _Atomic(). Place object in structure to prevent * No native support for _Atomic(). Place object in structure to prevent
* most forms of direct non-atomic access. * most forms of direct non-atomic access.
@ -302,23 +310,28 @@
#define _Noreturn __dead2 #define _Noreturn __dead2
#endif #endif
#if __GNUC_PREREQ__(4, 6) && !defined(__cplusplus) #if !__has_extension(c_static_assert)
/* Do nothing: _Static_assert() works as per C11 */
#elif !__has_extension(c_static_assert)
#if (defined(__cplusplus) && __cplusplus >= 201103L) || \ #if (defined(__cplusplus) && __cplusplus >= 201103L) || \
__has_extension(cxx_static_assert) __has_extension(cxx_static_assert)
#define _Static_assert(x, y) static_assert(x, y) #define _Static_assert(x, y) static_assert(x, y)
#elif __GNUC_PREREQ__(4,6)
/* Nothing, gcc 4.6 and higher has _Static_assert built-in */
#elif defined(__COUNTER__) #elif defined(__COUNTER__)
#define _Static_assert(x, y) __Static_assert(x, __COUNTER__) #define _Static_assert(x, y) __Static_assert(x, __COUNTER__)
#define __Static_assert(x, y) ___Static_assert(x, y) #define __Static_assert(x, y) ___Static_assert(x, y)
#define ___Static_assert(x, y) typedef char __assert_ ## y[(x) ? 1 : -1] #define ___Static_assert(x, y) typedef char __assert_ ## y[(x) ? 1 : -1] \
__unused
#else #else
#define _Static_assert(x, y) struct __hack #define _Static_assert(x, y) struct __hack
#endif #endif
#endif #endif
#if !__has_extension(c_thread_local) #if !__has_extension(c_thread_local)
/* XXX: Change this to test against C++11 when clang in base supports it. */ /*
* XXX: Some compilers (Clang 3.3, GCC 4.7) falsely announce C++11 mode
* without actually supporting the thread_local keyword. Don't check for
* the presence of C++11 when defining _Thread_local.
*/
#if /* (defined(__cplusplus) && __cplusplus >= 201103L) || */ \ #if /* (defined(__cplusplus) && __cplusplus >= 201103L) || */ \
__has_extension(cxx_thread_local) __has_extension(cxx_thread_local)
#define _Thread_local thread_local #define _Thread_local thread_local
@ -338,7 +351,8 @@
* distinguish multiple cases. * distinguish multiple cases.
*/ */
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
__has_extension(c_generic_selections)
#define __generic(expr, t, yes, no) \ #define __generic(expr, t, yes, no) \
_Generic(expr, t: yes, default: no) _Generic(expr, t: yes, default: no)
#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus) #elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)
@ -347,6 +361,21 @@
__builtin_types_compatible_p(__typeof(expr), t), yes, no) __builtin_types_compatible_p(__typeof(expr), t), yes, no)
#endif #endif
/*
* C99 Static array indices in function parameter declarations. Syntax such as:
* void bar(int myArray[static 10]);
* is allowed in C99 but not in C++. Define __min_size appropriately so
* headers using it can be compiled in either language. Use like this:
* void bar(int myArray[__min_size(10)]);
*/
#if !defined(__cplusplus) && \
(defined(__clang__) || __GNUC_PREREQ__(4, 6)) && \
(!defined(__STDC_VERSION__) || (__STDC_VERSION__ >= 199901))
#define __min_size(x) static (x)
#else
#define __min_size(x) (x)
#endif
#if __GNUC_PREREQ__(2, 96) #if __GNUC_PREREQ__(2, 96)
#define __malloc_like __attribute__((__malloc__)) #define __malloc_like __attribute__((__malloc__))
#define __pure __attribute__((__pure__)) #define __pure __attribute__((__pure__))
@ -368,15 +397,19 @@
#endif #endif
#if __GNUC_PREREQ__(3, 3) #if __GNUC_PREREQ__(3, 3)
#define __nonnull(x) __attribute__((__nonnull__(x))) #define __nonnull(x) __attribute__((__nonnull__(x)))
#define __nonnull_all __attribute__((__nonnull__))
#else #else
#define __nonnull(x) #define __nonnull(x)
#define __nonnull_all
#endif #endif
#if __GNUC_PREREQ__(3, 4) #if __GNUC_PREREQ__(3, 4)
#define __fastcall __attribute__((__fastcall__)) #define __fastcall __attribute__((__fastcall__))
#define __result_use_check __attribute__((__warn_unused_result__))
#else #else
#define __fastcall #define __fastcall
#define __result_use_check
#endif #endif
#if __GNUC_PREREQ__(4, 1) #if __GNUC_PREREQ__(4, 1)
@ -385,6 +418,12 @@
#define __returns_twice #define __returns_twice
#endif #endif
#if __GNUC_PREREQ__(4, 6) || __has_builtin(__builtin_unreachable)
#define __unreachable() __builtin_unreachable()
#else
#define __unreachable() ((void)0)
#endif
/* XXX: should use `#if __STDC_VERSION__ < 199901'. */ /* XXX: should use `#if __STDC_VERSION__ < 199901'. */
#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER) #if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
#define __func__ NULL #define __func__ NULL
@ -433,19 +472,26 @@
* larger code. * larger code.
*/ */
#if __GNUC_PREREQ__(2, 96) #if __GNUC_PREREQ__(2, 96)
#define __predict_true(exp) __builtin_expect((exp), 1) #define __predict_true(exp) __builtin_expect((exp), 1)
#define __predict_false(exp) __builtin_expect((exp), 0) #define __predict_false(exp) __builtin_expect((exp), 0)
#else #else
#define __predict_true(exp) (exp) #define __predict_true(exp) (exp)
#define __predict_false(exp) (exp) #define __predict_false(exp) (exp)
#endif #endif
#if __GNUC_PREREQ__(4, 2) #if __GNUC_PREREQ__(4, 0)
#define __hidden __attribute__((__visibility__("hidden"))) #define __null_sentinel __attribute__((__sentinel__))
#define __exported __attribute__((__visibility__("default"))) #define __exported __attribute__((__visibility__("default")))
/* Only default visibility is supported on PE/COFF targets. */
#ifndef __CYGWIN__
#define __hidden __attribute__((__visibility__("hidden")))
#else #else
#define __hidden #define __hidden
#endif
#else
#define __null_sentinel
#define __exported #define __exported
#define __hidden
#endif #endif
#define __offsetof(type, field) offsetof(type, field) #define __offsetof(type, field) offsetof(type, field)
@ -460,7 +506,7 @@
*/ */
#if __GNUC_PREREQ__(3, 1) #if __GNUC_PREREQ__(3, 1)
#define __containerof(x, s, m) ({ \ #define __containerof(x, s, m) ({ \
const volatile __typeof__(((s *)0)->m) *__x = (x); \ const volatile __typeof(((s *)0)->m) *__x = (x); \
__DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));\ __DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));\
}) })
#else #else
@ -583,128 +629,94 @@
#define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var)) #define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var))
#endif #endif
/*- /*
* The following definitions are an extension of the behavior originally * Nullability qualifiers: currently only supported by Clang.
* implemented in <sys/_posix.h>, but with a different level of granularity.
* POSIX.1 requires that the macros we test be defined before any standard
* header file is included.
*
* Here's a quick run-down of the versions:
* defined(_POSIX_SOURCE) 1003.1-1988
* _POSIX_C_SOURCE == 1 1003.1-1990
* _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option
* _POSIX_C_SOURCE == 199309 1003.1b-1993
* _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995,
* and the omnibus ISO/IEC 9945-1: 1996
* _POSIX_C_SOURCE == 200112 1003.1-2001
* _POSIX_C_SOURCE == 200809 1003.1-2008
*
* In addition, the X/Open Portability Guide, which is now the Single UNIX
* Specification, defines a feature-test macro which indicates the version of
* that specification, and which subsumes _POSIX_C_SOURCE.
*
* Our macros begin with two underscores to avoid namespace screwage.
*/ */
#if !(defined(__clang__) && __has_feature(nullability))
/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */ #define _Nonnull
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1 #define _Nullable
#undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */ #define _Null_unspecified
#define _POSIX_C_SOURCE 199009 #define __NULLABILITY_PRAGMA_PUSH
#endif #define __NULLABILITY_PRAGMA_POP
#else
/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */ #define __NULLABILITY_PRAGMA_PUSH _Pragma("clang diagnostic push") \
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2 _Pragma("clang diagnostic ignored \"-Wnullability-completeness\"")
#undef _POSIX_C_SOURCE #define __NULLABILITY_PRAGMA_POP _Pragma("clang diagnostic pop")
#define _POSIX_C_SOURCE 199209
#endif
/* Deal with various X/Open Portability Guides and Single UNIX Spec. */
#ifdef _XOPEN_SOURCE
#if _XOPEN_SOURCE - 0 >= 700
#define __XSI_VISIBLE 700
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809
#elif _XOPEN_SOURCE - 0 >= 600
#define __XSI_VISIBLE 600
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200112
#elif _XOPEN_SOURCE - 0 >= 500
#define __XSI_VISIBLE 500
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 199506
#endif
#endif #endif
/* /*
* Deal with all versions of POSIX. The ordering relative to the tests above is * Type Safety Checking
* important.
*/
#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
#define _POSIX_C_SOURCE 198808
#endif
#ifdef _POSIX_C_SOURCE
#if _POSIX_C_SOURCE >= 200809
#define __POSIX_VISIBLE 200809
#define __ISO_C_VISIBLE 1999
#elif _POSIX_C_SOURCE >= 200112
#define __POSIX_VISIBLE 200112
#define __ISO_C_VISIBLE 1999
#elif _POSIX_C_SOURCE >= 199506
#define __POSIX_VISIBLE 199506
#define __ISO_C_VISIBLE 1990
#elif _POSIX_C_SOURCE >= 199309
#define __POSIX_VISIBLE 199309
#define __ISO_C_VISIBLE 1990
#elif _POSIX_C_SOURCE >= 199209
#define __POSIX_VISIBLE 199209
#define __ISO_C_VISIBLE 1990
#elif _POSIX_C_SOURCE >= 199009
#define __POSIX_VISIBLE 199009
#define __ISO_C_VISIBLE 1990
#else
#define __POSIX_VISIBLE 198808
#define __ISO_C_VISIBLE 0
#endif /* _POSIX_C_SOURCE */
#else
/*-
* Deal with _ANSI_SOURCE:
* If it is defined, and no other compilation environment is explicitly
* requested, then define our internal feature-test macros to zero. This
* makes no difference to the preprocessor (undefined symbols in preprocessing
* expressions are defined to have value zero), but makes it more convenient for
* a test program to print out the values.
* *
* If a program mistakenly defines _ANSI_SOURCE and some other macro such as * Clang provides additional attributes to enable checking type safety
* _POSIX_C_SOURCE, we will assume that it wants the broader compilation * properties that cannot be enforced by the C type system.
* environment (and in fact we will never get here).
*/ */
#if defined(_ANSI_SOURCE) /* Hide almost everything. */
#define __POSIX_VISIBLE 0 #if __has_attribute(__argument_with_type_tag__) && \
#define __XSI_VISIBLE 0 __has_attribute(__type_tag_for_datatype__) && !defined(lint)
#define __BSD_VISIBLE 0 #define __arg_type_tag(arg_kind, arg_idx, type_tag_idx) \
#define __ISO_C_VISIBLE 1990 __attribute__((__argument_with_type_tag__(arg_kind, arg_idx, type_tag_idx)))
#elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */ #define __datatype_type_tag(kind, type) \
#define __POSIX_VISIBLE 0 __attribute__((__type_tag_for_datatype__(kind, type)))
#define __XSI_VISIBLE 0 #else
#define __BSD_VISIBLE 0 #define __arg_type_tag(arg_kind, arg_idx, type_tag_idx)
#define __ISO_C_VISIBLE 1999 #define __datatype_type_tag(kind, type)
#elif defined(_C11_SOURCE) /* Localism to specify strict C11 env. */
#define __POSIX_VISIBLE 0
#define __XSI_VISIBLE 0
#define __BSD_VISIBLE 0
#define __ISO_C_VISIBLE 2011
#elif defined(_GNU_SOURCE) /* Everything and the kitchen sink. */
#define __POSIX_VISIBLE 200809
#define __XSI_VISIBLE 700
#define __BSD_VISIBLE 1
#define __ISO_C_VISIBLE 2011
#define __GNU_VISIBLE 1
#else /* Default: everything except __GNU_VISIBLE. */
#define __POSIX_VISIBLE 200809
#define __XSI_VISIBLE 700
#define __BSD_VISIBLE 1
#define __ISO_C_VISIBLE 2011
#endif
#endif #endif
/*
* Lock annotations.
*
* Clang provides support for doing basic thread-safety tests at
* compile-time, by marking which locks will/should be held when
* entering/leaving a functions.
*
* Furthermore, it is also possible to annotate variables and structure
* members to enforce that they are only accessed when certain locks are
* held.
*/
#if __has_extension(c_thread_safety_attributes)
#define __lock_annotate(x) __attribute__((x))
#else
#define __lock_annotate(x)
#endif
/* Structure implements a lock. */
#define __lockable __lock_annotate(lockable)
/* Function acquires an exclusive or shared lock. */
#define __locks_exclusive(...) \
__lock_annotate(exclusive_lock_function(__VA_ARGS__))
#define __locks_shared(...) \
__lock_annotate(shared_lock_function(__VA_ARGS__))
/* Function attempts to acquire an exclusive or shared lock. */
#define __trylocks_exclusive(...) \
__lock_annotate(exclusive_trylock_function(__VA_ARGS__))
#define __trylocks_shared(...) \
__lock_annotate(shared_trylock_function(__VA_ARGS__))
/* Function releases a lock. */
#define __unlocks(...) __lock_annotate(unlock_function(__VA_ARGS__))
/* Function asserts that an exclusive or shared lock is held. */
#define __asserts_exclusive(...) \
__lock_annotate(assert_exclusive_lock(__VA_ARGS__))
#define __asserts_shared(...) \
__lock_annotate(assert_shared_lock(__VA_ARGS__))
/* Function requires that an exclusive or shared lock is or is not held. */
#define __requires_exclusive(...) \
__lock_annotate(exclusive_locks_required(__VA_ARGS__))
#define __requires_shared(...) \
__lock_annotate(shared_locks_required(__VA_ARGS__))
#define __requires_unlocked(...) \
__lock_annotate(locks_excluded(__VA_ARGS__))
/* Function should not be analyzed. */
#define __no_lock_analysis __lock_annotate(no_thread_safety_analysis)
/* Guard variables and structure members by lock. */
#define __guarded_by(x) __lock_annotate(guarded_by(x))
#define __pt_guarded_by(x) __lock_annotate(pt_guarded_by(x))
#endif /* !_SYS_CDEFS_H_ */ #endif /* !_SYS_CDEFS_H_ */

View file

@ -92,7 +92,6 @@
/* we want the reentrancy structure to be returned by a function */ /* we want the reentrancy structure to be returned by a function */
#define __DYNAMIC_REENT__ #define __DYNAMIC_REENT__
#define HAVE_GETDATE #define HAVE_GETDATE
#define _HAVE_SYSTYPES
#define _READ_WRITE_RETURN_TYPE _ssize_t #define _READ_WRITE_RETURN_TYPE _ssize_t
#define __LARGE64_FILES 1 #define __LARGE64_FILES 1
/* we use some glibc header files so turn on glibc large file feature */ /* we use some glibc header files so turn on glibc large file feature */
@ -185,6 +184,10 @@
#define __CUSTOM_FILE_IO__ #define __CUSTOM_FILE_IO__
#endif #endif
#if defined(__or1k__) || defined(__or1knd__)
#define __DYNAMIC_REENT__
#endif
#ifdef __XTENSA__ #ifdef __XTENSA__
#include <xtensa/config/core-isa.h> #include <xtensa/config/core-isa.h>
#define MALLOC_ALIGNMENT ((XCHAL_DATA_WIDTH) < 16 ? 16 : (XCHAL_DATA_WIDTH)) #define MALLOC_ALIGNMENT ((XCHAL_DATA_WIDTH) < 16 ? 16 : (XCHAL_DATA_WIDTH))
@ -235,9 +238,6 @@
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
#include <cygwin/config.h> #include <cygwin/config.h>
#if !defined (__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L)
#define __USE_XOPEN2K 1
#endif
#endif #endif
#if defined(__rtems__) #if defined(__rtems__)
@ -245,6 +245,7 @@
#define _READ_WRITE_RETURN_TYPE _ssize_t #define _READ_WRITE_RETURN_TYPE _ssize_t
#define __DYNAMIC_REENT__ #define __DYNAMIC_REENT__
#define _REENT_GLOBAL_ATEXIT #define _REENT_GLOBAL_ATEXIT
#define _REENT_GLOBAL_STDIO_STREAMS
#endif #endif
#ifndef __EXPORT #ifndef __EXPORT
@ -282,6 +283,12 @@
#endif #endif
#endif #endif
#ifdef _WANT_REENT_GLOBAL_STDIO_STREAMS
#ifndef _REENT_GLOBAL_STDIO_STREAMS
#define _REENT_GLOBAL_STDIO_STREAMS
#endif
#endif
/* If _MB_EXTENDED_CHARSETS_ALL is set, we want all of the extended /* If _MB_EXTENDED_CHARSETS_ALL is set, we want all of the extended
charsets. The extended charsets add a few functions and a couple charsets. The extended charsets add a few functions and a couple
of tables of a few K each. */ of tables of a few K each. */

View file

@ -1,7 +1,7 @@
/* /*
* Written by Joel Sherrill <joel@OARcorp.com>. * Written by Joel Sherrill <joel@OARcorp.com>.
* *
* COPYRIGHT (c) 1989-2000. * COPYRIGHT (c) 1989-2014.
* *
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
* *
@ -25,11 +25,7 @@
extern "C" { extern "C" {
#endif #endif
/* Macros to determine that newlib is being used. Put in this header to #include <_newlib_version.h>
* be similar to where glibc stores its version of these macros.
*/
#define __NEWLIB__ 2
#define __NEWLIB_MINOR__ 1
/* Macro to test version of GCC. Returns 0 for non-GCC or too old GCC. */ /* Macro to test version of GCC. Returns 0 for non-GCC or too old GCC. */
#ifndef __GNUC_PREREQ #ifndef __GNUC_PREREQ
@ -43,6 +39,281 @@ extern "C" {
/* Version with trailing underscores for BSD compatibility. */ /* Version with trailing underscores for BSD compatibility. */
#define __GNUC_PREREQ__(ma, mi) __GNUC_PREREQ(ma, mi) #define __GNUC_PREREQ__(ma, mi) __GNUC_PREREQ(ma, mi)
/*
* Feature test macros control which symbols are exposed by the system
* headers. Any of these must be defined before including any headers.
*
* __STRICT_ANSI__ (defined by gcc -ansi, -std=c90, -std=c99, or -std=c11)
* ISO C
*
* _POSIX_SOURCE (deprecated by _POSIX_C_SOURCE=1)
* _POSIX_C_SOURCE >= 1
* POSIX.1-1990
*
* _POSIX_C_SOURCE >= 2
* POSIX.2-1992
*
* _POSIX_C_SOURCE >= 199309L
* POSIX.1b-1993 Real-time extensions
*
* _POSIX_C_SOURCE >= 199506L
* POSIX.1c-1995 Threads extensions
*
* _POSIX_C_SOURCE >= 200112L
* POSIX.1-2001 and C99
*
* _POSIX_C_SOURCE >= 200809L
* POSIX.1-2008
*
* _XOPEN_SOURCE
* POSIX.1-1990 and XPG4
*
* _XOPEN_SOURCE_EXTENDED
* SUSv1 (POSIX.2-1992 plus XPG4v2)
*
* _XOPEN_SOURCE >= 500
* SUSv2 (POSIX.1c-1995 plus XSI)
*
* _XOPEN_SOURCE >= 600
* SUSv3 (POSIX.1-2001 plus XSI) and C99
*
* _XOPEN_SOURCE >= 700
* SUSv4 (POSIX.1-2008 plus XSI)
*
* _ISOC99_SOURCE or gcc -std=c99 or g++
* ISO C99
*
* _ISOC11_SOURCE or gcc -std=c11 or g++ -std=c++11
* ISO C11
*
* _ATFILE_SOURCE (implied by _POSIX_C_SOURCE >= 200809L)
* "at" functions
*
* _LARGEFILE_SOURCE (deprecated by _XOPEN_SOURCE >= 500)
* fseeko, ftello
*
* _GNU_SOURCE
* All of the above plus GNU extensions
*
* _BSD_SOURCE (deprecated by _DEFAULT_SOURCE)
* _SVID_SOURCE (deprecated by _DEFAULT_SOURCE)
* _DEFAULT_SOURCE (or none of the above)
* POSIX-1.2008 with BSD and SVr4 extensions
*/
#ifdef _GNU_SOURCE
#undef _ATFILE_SOURCE
#define _ATFILE_SOURCE 1
#undef _DEFAULT_SOURCE
#define _DEFAULT_SOURCE 1
#undef _ISOC99_SOURCE
#define _ISOC99_SOURCE 1
#undef _ISOC11_SOURCE
#define _ISOC11_SOURCE 1
#undef _POSIX_SOURCE
#define _POSIX_SOURCE 1
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#undef _XOPEN_SOURCE
#define _XOPEN_SOURCE 700
#undef _XOPEN_SOURCE_EXTENDED
#define _XOPEN_SOURCE_EXTENDED 1
#endif /* _GNU_SOURCE */
#if defined(_BSD_SOURCE) || defined(_SVID_SOURCE) || \
(!defined(__STRICT_ANSI__) && !defined(_ANSI_SOURCE) && \
!defined(_ISOC99_SOURCE) && !defined(_POSIX_SOURCE) && \
!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE))
#undef _DEFAULT_SOURCE
#define _DEFAULT_SOURCE 1
#endif
#if defined(_DEFAULT_SOURCE)
#undef _POSIX_SOURCE
#define _POSIX_SOURCE 1
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif
#if !defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) && \
((!defined(__STRICT_ANSI__) && !defined(_ANSI_SOURCE)) || \
(_XOPEN_SOURCE - 0) >= 500)
#define _POSIX_SOURCE 1
#if !defined(_XOPEN_SOURCE) || (_XOPEN_SOURCE - 0) >= 700
#define _POSIX_C_SOURCE 200809L
#elif (_XOPEN_SOURCE - 0) >= 600
#define _POSIX_C_SOURCE 200112L
#elif (_XOPEN_SOURCE - 0) >= 500
#define _POSIX_C_SOURCE 199506L
#elif (_XOPEN_SOURCE - 0) < 500
#define _POSIX_C_SOURCE 2
#endif
#endif
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200809
#undef _ATFILE_SOURCE
#define _ATFILE_SOURCE 1
#endif
/*
* The following private macros are used throughout the headers to control
* which symbols should be exposed. They are for internal use only, as
* indicated by the leading double underscore, and must never be used outside
* of these headers.
*
* __POSIX_VISIBLE
* any version of POSIX.1; enabled by default, or with _POSIX_SOURCE,
* any value of _POSIX_C_SOURCE, or _XOPEN_SOURCE >= 500.
*
* __POSIX_VISIBLE >= 2
* POSIX.2-1992; enabled by default, with _POSIX_C_SOURCE >= 2,
* or _XOPEN_SOURCE >= 500.
*
* __POSIX_VISIBLE >= 199309
* POSIX.1b-1993; enabled by default, with _POSIX_C_SOURCE >= 199309L,
* or _XOPEN_SOURCE >= 500.
*
* __POSIX_VISIBLE >= 199506
* POSIX.1c-1995; enabled by default, with _POSIX_C_SOURCE >= 199506L,
* or _XOPEN_SOURCE >= 500.
*
* __POSIX_VISIBLE >= 200112
* POSIX.1-2001; enabled by default, with _POSIX_C_SOURCE >= 200112L,
* or _XOPEN_SOURCE >= 600.
*
* __POSIX_VISIBLE >= 200809
* POSIX.1-2008; enabled by default, with _POSIX_C_SOURCE >= 200809L,
* or _XOPEN_SOURCE >= 700.
*
* __XSI_VISIBLE
* XPG4 XSI extensions; enabled with any version of _XOPEN_SOURCE.
*
* __XSI_VISIBLE >= 4
* SUSv1 XSI extensions; enabled with both _XOPEN_SOURCE and
* _XOPEN_SOURCE_EXTENDED together.
*
* __XSI_VISIBLE >= 500
* SUSv2 XSI extensions; enabled with _XOPEN_SOURCE >= 500.
*
* __XSI_VISIBLE >= 600
* SUSv3 XSI extensions; enabled with _XOPEN_SOURCE >= 600.
*
* __XSI_VISIBLE >= 700
* SUSv4 XSI extensions; enabled with _XOPEN_SOURCE >= 700.
*
* __ISO_C_VISIBLE >= 1999
* ISO C99; enabled with gcc -std=c99 or newer (on by default since GCC 5),
* any version of C++, or with _ISOC99_SOURCE, _POSIX_C_SOURCE >= 200112L,
* or _XOPEN_SOURCE >= 600.
*
* __ISO_C_VISIBLE >= 2011
* ISO C11; enabled with gcc -std=c11 or newer (on by default since GCC 5),
* g++ -std=c++11 or newer (on by default since GCC 6), or with
* _ISOC11_SOURCE.
*
* __ATFILE_VISIBLE
* "at" functions; enabled by default, with _ATFILE_SOURCE,
* _POSIX_C_SOURCE >= 200809L, or _XOPEN_SOURCE >= 700.
*
* __LARGEFILE_VISIBLE
* fseeko, ftello; enabled with _LARGEFILE_SOURCE or _XOPEN_SOURCE >= 500.
*
* __BSD_VISIBLE
* BSD extensions; enabled by default, or with _BSD_SOURCE.
*
* __SVID_VISIBLE
* SVr4 extensions; enabled by default, or with _SVID_SOURCE.
*
* __MISC_VISIBLE
* Extensions found in both BSD and SVr4 (shorthand for
* (__BSD_VISIBLE || __SVID_VISIBLE)), or newlib-specific
* extensions; enabled by default.
*
* __GNU_VISIBLE
* GNU extensions; enabled with _GNU_SOURCE.
*
* In all cases above, "enabled by default" means either by defining
* _DEFAULT_SOURCE, or by not defining any of the public feature test macros.
* Defining _GNU_SOURCE makes all of the above avaliable.
*/
#ifdef _ATFILE_SOURCE
#define __ATFILE_VISIBLE 1
#else
#define __ATFILE_VISIBLE 0
#endif
#ifdef _DEFAULT_SOURCE
#define __BSD_VISIBLE 1
#else
#define __BSD_VISIBLE 0
#endif
#ifdef _GNU_SOURCE
#define __GNU_VISIBLE 1
#else
#define __GNU_VISIBLE 0
#endif
#if defined(_ISOC11_SOURCE) || \
(__STDC_VERSION__ - 0) >= 201112L || (__cplusplus - 0) >= 201103L
#define __ISO_C_VISIBLE 2011
#elif defined(_ISOC99_SOURCE) || (_POSIX_C_SOURCE - 0) >= 200112L || \
(__STDC_VERSION__ - 0) >= 199901L || defined(__cplusplus)
#define __ISO_C_VISIBLE 1999
#else
#define __ISO_C_VISIBLE 1990
#endif
#if defined(_LARGEFILE_SOURCE) || (_XOPEN_SOURCE - 0) >= 500
#define __LARGEFILE_VISIBLE 1
#else
#define __LARGEFILE_VISIBLE 0
#endif
#ifdef _DEFAULT_SOURCE
#define __MISC_VISIBLE 1
#else
#define __MISC_VISIBLE 0
#endif
#if (_POSIX_C_SOURCE - 0) >= 200809L
#define __POSIX_VISIBLE 200809
#elif (_POSIX_C_SOURCE - 0) >= 200112L
#define __POSIX_VISIBLE 200112
#elif (_POSIX_C_SOURCE - 0) >= 199506L
#define __POSIX_VISIBLE 199506
#elif (_POSIX_C_SOURCE - 0) >= 199309L
#define __POSIX_VISIBLE 199309
#elif (_POSIX_C_SOURCE - 0) >= 2 || defined(_XOPEN_SOURCE)
#define __POSIX_VISIBLE 199209
#elif defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE)
#define __POSIX_VISIBLE 199009
#else
#define __POSIX_VISIBLE 0
#endif
#ifdef _DEFAULT_SOURCE
#define __SVID_VISIBLE 1
#else
#define __SVID_VISIBLE 0
#endif
#if (_XOPEN_SOURCE - 0) >= 700
#define __XSI_VISIBLE 700
#elif (_XOPEN_SOURCE - 0) >= 600
#define __XSI_VISIBLE 600
#elif (_XOPEN_SOURCE - 0) >= 500
#define __XSI_VISIBLE 500
#elif defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)
#define __XSI_VISIBLE 4
#elif defined(_XOPEN_SOURCE)
#define __XSI_VISIBLE 1
#else
#define __XSI_VISIBLE 0
#endif
/* RTEMS adheres to POSIX -- 1003.1b with some features from annexes. */ /* RTEMS adheres to POSIX -- 1003.1b with some features from annexes. */
#ifdef __rtems__ #ifdef __rtems__
@ -57,11 +328,12 @@ extern "C" {
#define _POSIX_MEMORY_PROTECTION 1 #define _POSIX_MEMORY_PROTECTION 1
#define _POSIX_MESSAGE_PASSING 1 #define _POSIX_MESSAGE_PASSING 1
#define _POSIX_MONOTONIC_CLOCK 200112L #define _POSIX_MONOTONIC_CLOCK 200112L
#define _POSIX_CLOCK_SELECTION 200112L
#define _POSIX_PRIORITIZED_IO 1 #define _POSIX_PRIORITIZED_IO 1
#define _POSIX_PRIORITY_SCHEDULING 1 #define _POSIX_PRIORITY_SCHEDULING 1
#define _POSIX_REALTIME_SIGNALS 1 #define _POSIX_REALTIME_SIGNALS 1
#define _POSIX_SEMAPHORES 1 #define _POSIX_SEMAPHORES 1
/* #define _POSIX_SHARED_MEMORY_OBJECTS 1 */ #define _POSIX_SHARED_MEMORY_OBJECTS 1
#define _POSIX_SYNCHRONIZED_IO 1 #define _POSIX_SYNCHRONIZED_IO 1
#define _POSIX_TIMERS 1 #define _POSIX_TIMERS 1
#define _POSIX_BARRIERS 200112L #define _POSIX_BARRIERS 200112L
@ -94,6 +366,9 @@ extern "C" {
/* UNIX98 added some new pthread mutex attributes */ /* UNIX98 added some new pthread mutex attributes */
#define _UNIX98_THREAD_MUTEX_ATTRIBUTES 1 #define _UNIX98_THREAD_MUTEX_ATTRIBUTES 1
/* POSIX 1003.26-2003 defined device control method */
#define _POSIX_26_VERSION 200312L
#endif #endif
/* XMK loosely adheres to POSIX -- 1003.1 */ /* XMK loosely adheres to POSIX -- 1003.1 */
@ -111,62 +386,82 @@ extern "C" {
#ifdef __CYGWIN__ #ifdef __CYGWIN__
#if !defined(__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L #if __POSIX_VISIBLE >= 200809
#define _POSIX_VERSION 200809L
#define _POSIX2_VERSION 200809L
#elif __POSIX_VISIBLE >= 200112
#define _POSIX_VERSION 200112L #define _POSIX_VERSION 200112L
#define _POSIX2_VERSION 200112L #define _POSIX2_VERSION 200112L
#define _XOPEN_VERSION 600 #elif __POSIX_VISIBLE >= 199506
#define _POSIX_VERSION 199506L
#define _POSIX2_VERSION 199506L
#elif __POSIX_VISIBLE >= 199309
#define _POSIX_VERSION 199309L
#define _POSIX2_VERSION 199209L
#elif __POSIX_VISIBLE >= 199209
#define _POSIX_VERSION 199009L
#define _POSIX2_VERSION 199209L
#elif __POSIX_VISIBLE
#define _POSIX_VERSION 199009L
#endif
#if __XSI_VISIBLE >= 4
#define _XOPEN_VERSION __XSI_VISIBLE
#endif
#define _POSIX_ADVISORY_INFO 200112L #define _POSIX_ADVISORY_INFO 200809L
/* #define _POSIX_ASYNCHRONOUS_IO -1 */ /* #define _POSIX_ASYNCHRONOUS_IO -1 */
/* #define _POSIX_BARRIERS -1 */ #define _POSIX_BARRIERS 200809L
#define _POSIX_CHOWN_RESTRICTED 1 #define _POSIX_CHOWN_RESTRICTED 1
#define _POSIX_CLOCK_SELECTION 200112L #define _POSIX_CLOCK_SELECTION 200809L
#define _POSIX_CPUTIME 200112L #define _POSIX_CPUTIME 200809L
#define _POSIX_FSYNC 200112L #define _POSIX_FSYNC 200809L
#define _POSIX_IPV6 200112L #define _POSIX_IPV6 200809L
#define _POSIX_JOB_CONTROL 1 #define _POSIX_JOB_CONTROL 1
#define _POSIX_MAPPED_FILES 200112L #define _POSIX_MAPPED_FILES 200809L
/* #define _POSIX_MEMLOCK -1 */ /* #define _POSIX_MEMLOCK -1 */
#define _POSIX_MEMLOCK_RANGE 200112L #define _POSIX_MEMLOCK_RANGE 200809L
#define _POSIX_MEMORY_PROTECTION 200112L #define _POSIX_MEMORY_PROTECTION 200809L
#define _POSIX_MESSAGE_PASSING 200112L #define _POSIX_MESSAGE_PASSING 200809L
#define _POSIX_MONOTONIC_CLOCK 200112L #define _POSIX_MONOTONIC_CLOCK 200809L
#define _POSIX_NO_TRUNC 1 #define _POSIX_NO_TRUNC 1
/* #define _POSIX_PRIORITIZED_IO -1 */ /* #define _POSIX_PRIORITIZED_IO -1 */
#define _POSIX_PRIORITY_SCHEDULING 200112L #define _POSIX_PRIORITY_SCHEDULING 200809L
#define _POSIX_RAW_SOCKETS 200112L #define _POSIX_RAW_SOCKETS 200809L
#define _POSIX_READER_WRITER_LOCKS 200112L #define _POSIX_READER_WRITER_LOCKS 200809L
#define _POSIX_REALTIME_SIGNALS 200112L #define _POSIX_REALTIME_SIGNALS 200809L
#define _POSIX_REGEXP 1 #define _POSIX_REGEXP 1
#define _POSIX_SAVED_IDS 1 #define _POSIX_SAVED_IDS 1
#define _POSIX_SEMAPHORES 200112L #define _POSIX_SEMAPHORES 200809L
#define _POSIX_SHARED_MEMORY_OBJECTS 200112L #define _POSIX_SHARED_MEMORY_OBJECTS 200809L
#define _POSIX_SHELL 1 #define _POSIX_SHELL 1
/* #define _POSIX_SPAWN -1 */ #define _POSIX_SPAWN 200809L
#define _POSIX_SPIN_LOCKS 200112L #define _POSIX_SPIN_LOCKS 200809L
/* #define _POSIX_SPORADIC_SERVER -1 */ /* #define _POSIX_SPORADIC_SERVER -1 */
#define _POSIX_SYNCHRONIZED_IO 200112L #define _POSIX_SYNCHRONIZED_IO 200809L
#define _POSIX_THREAD_ATTR_STACKADDR 200112L #define _POSIX_THREAD_ATTR_STACKADDR 200809L
#define _POSIX_THREAD_ATTR_STACKSIZE 200112L #define _POSIX_THREAD_ATTR_STACKSIZE 200809L
#define _POSIX_THREAD_CPUTIME 200112L #define _POSIX_THREAD_CPUTIME 200809L
/* #define _POSIX_THREAD_PRIO_INHERIT -1 */ /* #define _POSIX_THREAD_PRIO_INHERIT -1 */
/* #define _POSIX_THREAD_PRIO_PROTECT -1 */ /* #define _POSIX_THREAD_PRIO_PROTECT -1 */
#define _POSIX_THREAD_PRIORITY_SCHEDULING 200112L #define _POSIX_THREAD_PRIORITY_SCHEDULING 200809L
#define _POSIX_THREAD_PROCESS_SHARED 200112L #define _POSIX_THREAD_PROCESS_SHARED 200809L
#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L #define _POSIX_THREAD_SAFE_FUNCTIONS 200809L
/* #define _POSIX_THREAD_SPORADIC_SERVER -1 */ /* #define _POSIX_THREAD_SPORADIC_SERVER -1 */
#define _POSIX_THREADS 200112L #define _POSIX_THREADS 200809L
/* #define _POSIX_TIMEOUTS -1 */ /* #define _POSIX_TIMEOUTS -1 */
#define _POSIX_TIMERS 1 #define _POSIX_TIMERS 200809L
/* #define _POSIX_TRACE -1 */ /* #define _POSIX_TRACE -1 */
/* #define _POSIX_TRACE_EVENT_FILTER -1 */ /* #define _POSIX_TRACE_EVENT_FILTER -1 */
/* #define _POSIX_TRACE_INHERIT -1 */ /* #define _POSIX_TRACE_INHERIT -1 */
/* #define _POSIX_TRACE_LOG -1 */ /* #define _POSIX_TRACE_LOG -1 */
/* #define _POSIX_TYPED_MEMORY_OBJECTS -1 */ /* #define _POSIX_TYPED_MEMORY_OBJECTS -1 */
#define _POSIX_VDISABLE '\0' #define _POSIX_VDISABLE '\0'
#define _POSIX2_C_BIND 200112L
#define _POSIX2_C_DEV 200112L #if __POSIX_VISIBLE >= 2
#define _POSIX2_CHAR_TERM 200112L #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_DEV -1 */
/* #define _POSIX2_FORT_RUN -1 */ /* #define _POSIX2_FORT_RUN -1 */
/* #define _POSIX2_LOCALEDEF -1 */ /* #define _POSIX2_LOCALEDEF -1 */
@ -176,8 +471,10 @@ extern "C" {
/* #define _POSIX2_PBS_LOCATE -1 */ /* #define _POSIX2_PBS_LOCATE -1 */
/* #define _POSIX2_PBS_MESSAGE -1 */ /* #define _POSIX2_PBS_MESSAGE -1 */
/* #define _POSIX2_PBS_TRACK -1 */ /* #define _POSIX2_PBS_TRACK -1 */
#define _POSIX2_SW_DEV 200112L #define _POSIX2_SW_DEV _POSIX2_VERSION
#define _POSIX2_UPE 200112L #define _POSIX2_UPE _POSIX2_VERSION
#endif /* __POSIX_VISIBLE >= 2 */
#define _POSIX_V6_ILP32_OFF32 -1 #define _POSIX_V6_ILP32_OFF32 -1
#ifdef __LP64__ #ifdef __LP64__
#define _POSIX_V6_ILP32_OFFBIG -1 #define _POSIX_V6_ILP32_OFFBIG -1
@ -188,10 +485,16 @@ extern "C" {
#define _POSIX_V6_LP64_OFF64 -1 #define _POSIX_V6_LP64_OFF64 -1
#define _POSIX_V6_LPBIG_OFFBIG -1 #define _POSIX_V6_LPBIG_OFFBIG -1
#endif #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_OFF32 _POSIX_V6_ILP32_OFF32
#define _XBS5_ILP32_OFFBIG _POSIX_V6_ILP32_OFFBIG #define _XBS5_ILP32_OFFBIG _POSIX_V6_ILP32_OFFBIG
#define _XBS5_LP64_OFF64 _POSIX_V6_LP64_OFF64 #define _XBS5_LP64_OFF64 _POSIX_V6_LP64_OFF64
#define _XBS5_LPBIG_OFFBIG _POSIX_V6_LPBIG_OFFBIG #define _XBS5_LPBIG_OFFBIG _POSIX_V6_LPBIG_OFFBIG
#if __XSI_VISIBLE
#define _XOPEN_CRYPT 1 #define _XOPEN_CRYPT 1
#define _XOPEN_ENH_I18N 1 #define _XOPEN_ENH_I18N 1
/* #define _XOPEN_LEGACY -1 */ /* #define _XOPEN_LEGACY -1 */
@ -200,8 +503,7 @@ extern "C" {
#define _XOPEN_SHM 1 #define _XOPEN_SHM 1
/* #define _XOPEN_STREAMS -1 */ /* #define _XOPEN_STREAMS -1 */
/* #define _XOPEN_UNIX -1 */ /* #define _XOPEN_UNIX -1 */
#endif /* __XSI_VISIBLE */
#endif /* !__STRICT_ANSI__ || __cplusplus || __STDC_VERSION__ >= 199901L */
/* The value corresponds to UNICODE version 4.0, which is the version /* 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 supported by XP. Newlib supports 5.2 (2011) but so far Cygwin needs
@ -210,25 +512,6 @@ extern "C" {
#endif /* __CYGWIN__ */ #endif /* __CYGWIN__ */
/* Per the permission given in POSIX.1-2008 section 2.2.1, define
* _POSIX_C_SOURCE if _XOPEN_SOURCE is defined and _POSIX_C_SOURCE is not.
* (_XOPEN_SOURCE indicates that XSI extensions are desired by an application.)
* This permission is first granted in 2008, but use it for older ones, also.
* Allow for _XOPEN_SOURCE to be empty (from the earliest form of it, before it
* was required to have specific values).
*/
#if !defined(_POSIX_C_SOURCE) && defined(_XOPEN_SOURCE)
#if (_XOPEN_SOURCE - 0) == 700 /* POSIX.1-2008 */
#define _POSIX_C_SOURCE 200809L
#elif (_XOPEN_SOURCE - 0) == 600 /* POSIX.1-2001 or 2004 */
#define _POSIX_C_SOURCE 200112L
#elif (_XOPEN_SOURCE - 0) == 500 /* POSIX.1-1995 */
#define _POSIX_C_SOURCE 199506L
#elif (_XOPEN_SOURCE - 0) < 500 /* really old */
#define _POSIX_C_SOURCE 2
#endif
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -10,6 +10,9 @@
#include <machine/endian.h> #include <machine/endian.h>
#include <machine/param.h> #include <machine/param.h>
#ifndef NBBY
# define NBBY 8 /* number of bits in a byte */
#endif
#ifndef HZ #ifndef HZ
# define HZ (60) # define HZ (60)
#endif #endif
@ -25,4 +28,8 @@
#define MAX(a,b) ((a) > (b) ? (a) : (b)) #define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b)) #define MIN(a,b) ((a) < (b) ? (a) : (b))
#ifndef howmany
#define howmany(x, y) (((x)+((y)-1))/(y))
#endif
#endif #endif

View file

@ -10,7 +10,7 @@
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* 4. Neither the name of the University nor the names of its contributors * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software * may be used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
@ -76,11 +76,17 @@
* *
* For details on the use of these macros, see the queue(3) manual page. * For details on the use of these macros, see the queue(3) manual page.
* *
* Below is a summary of implemented functions where:
* + means the macro is available
* - means the macro is not available
* s means the macro is available but is slow (runs in O(n) time)
* *
* SLIST LIST STAILQ TAILQ * SLIST LIST STAILQ TAILQ
* _HEAD + + + + * _HEAD + + + +
* _CLASS_HEAD + + + +
* _HEAD_INITIALIZER + + + + * _HEAD_INITIALIZER + + + +
* _ENTRY + + + + * _ENTRY + + + +
* _CLASS_ENTRY + + + +
* _INIT + + + + * _INIT + + + +
* _EMPTY + + + + * _EMPTY + + + +
* _FIRST + + + + * _FIRST + + + +
@ -88,21 +94,31 @@
* _PREV - + - + * _PREV - + - +
* _LAST - - + + * _LAST - - + +
* _FOREACH + + + + * _FOREACH + + + +
* _FOREACH_FROM + + + +
* _FOREACH_SAFE + + + + * _FOREACH_SAFE + + + +
* _FOREACH_FROM_SAFE + + + +
* _FOREACH_REVERSE - - - + * _FOREACH_REVERSE - - - +
* _FOREACH_REVERSE_FROM - - - +
* _FOREACH_REVERSE_SAFE - - - + * _FOREACH_REVERSE_SAFE - - - +
* _FOREACH_REVERSE_FROM_SAFE - - - +
* _INSERT_HEAD + + + + * _INSERT_HEAD + + + +
* _INSERT_BEFORE - + - + * _INSERT_BEFORE - + - +
* _INSERT_AFTER + + + + * _INSERT_AFTER + + + +
* _INSERT_TAIL - - + + * _INSERT_TAIL - - + +
* _CONCAT - - + + * _CONCAT s s + +
* _REMOVE_AFTER + - + - * _REMOVE_AFTER + - + -
* _REMOVE_HEAD + - + - * _REMOVE_HEAD + - + -
* _REMOVE + + + + * _REMOVE s + s +
* _SWAP + + + + * _SWAP + + + +
* *
*/ */
#ifdef QUEUE_MACRO_DEBUG #ifdef QUEUE_MACRO_DEBUG
#warn Use QUEUE_MACRO_DEBUG_TRACE and/or QUEUE_MACRO_DEBUG_TRASH
#define QUEUE_MACRO_DEBUG_TRACE
#define QUEUE_MACRO_DEBUG_TRASH
#endif
#ifdef QUEUE_MACRO_DEBUG_TRACE
/* Store the last 2 places the queue element or head was altered */ /* Store the last 2 places the queue element or head was altered */
struct qm_trace { struct qm_trace {
unsigned long lastline; unsigned long lastline;
@ -112,9 +128,7 @@ struct qm_trace {
}; };
#define TRACEBUF struct qm_trace trace; #define TRACEBUF struct qm_trace trace;
#define TRACEBUF_INITIALIZER { __FILE__, __LINE__, NULL, 0 } , #define TRACEBUF_INITIALIZER { __LINE__, 0, __FILE__, NULL } ,
#define TRASHIT(x) do {(x) = (void *)-1;} while (0)
#define QMD_SAVELINK(name, link) void **name = (void *)&(link)
#define QMD_TRACE_HEAD(head) do { \ #define QMD_TRACE_HEAD(head) do { \
(head)->trace.prevline = (head)->trace.lastline; \ (head)->trace.prevline = (head)->trace.lastline; \
@ -130,14 +144,35 @@ struct qm_trace {
(elem)->trace.lastfile = __FILE__; \ (elem)->trace.lastfile = __FILE__; \
} while (0) } while (0)
#else #else /* !QUEUE_MACRO_DEBUG_TRACE */
#define QMD_TRACE_ELEM(elem) #define QMD_TRACE_ELEM(elem)
#define QMD_TRACE_HEAD(head) #define QMD_TRACE_HEAD(head)
#define QMD_SAVELINK(name, link)
#define TRACEBUF #define TRACEBUF
#define TRACEBUF_INITIALIZER #define TRACEBUF_INITIALIZER
#endif /* QUEUE_MACRO_DEBUG_TRACE */
#ifdef QUEUE_MACRO_DEBUG_TRASH
#define TRASHIT(x) do {(x) = (void *)-1;} while (0)
#define QMD_IS_TRASHED(x) ((x) == (void *)(intptr_t)-1)
#else /* !QUEUE_MACRO_DEBUG_TRASH */
#define TRASHIT(x) #define TRASHIT(x)
#endif /* QUEUE_MACRO_DEBUG */ #define QMD_IS_TRASHED(x) 0
#endif /* QUEUE_MACRO_DEBUG_TRASH */
#if defined(QUEUE_MACRO_DEBUG_TRACE) || defined(QUEUE_MACRO_DEBUG_TRASH)
#define QMD_SAVELINK(name, link) void **name = (void *)&(link)
#else /* !QUEUE_MACRO_DEBUG_TRACE && !QUEUE_MACRO_DEBUG_TRASH */
#define QMD_SAVELINK(name, link)
#endif /* QUEUE_MACRO_DEBUG_TRACE || QUEUE_MACRO_DEBUG_TRASH */
#ifdef __cplusplus
/*
* In C++ there can be structure lists and class lists:
*/
#define QUEUE_TYPEOF(type) type
#else
#define QUEUE_TYPEOF(type) struct type
#endif
/* /*
* Singly-linked List declarations. * Singly-linked List declarations.
@ -147,6 +182,11 @@ struct name { \
struct type *slh_first; /* first element */ \ struct type *slh_first; /* first element */ \
} }
#define SLIST_CLASS_HEAD(name, type) \
struct name { \
class type *slh_first; /* first element */ \
}
#define SLIST_HEAD_INITIALIZER(head) \ #define SLIST_HEAD_INITIALIZER(head) \
{ NULL } { NULL }
@ -155,9 +195,37 @@ struct { \
struct type *sle_next; /* next element */ \ struct type *sle_next; /* next element */ \
} }
#define SLIST_CLASS_ENTRY(type) \
struct { \
class type *sle_next; /* next element */ \
}
/* /*
* Singly-linked List functions. * Singly-linked List functions.
*/ */
#if (defined(_KERNEL) && defined(INVARIANTS))
#define QMD_SLIST_CHECK_PREVPTR(prevp, elm) do { \
if (*(prevp) != (elm)) \
panic("Bad prevptr *(%p) == %p != %p", \
(prevp), *(prevp), (elm)); \
} while (0)
#else
#define QMD_SLIST_CHECK_PREVPTR(prevp, elm)
#endif
#define SLIST_CONCAT(head1, head2, type, field) do { \
QUEUE_TYPEOF(type) *curelm = SLIST_FIRST(head1); \
if (curelm == NULL) { \
if ((SLIST_FIRST(head1) = SLIST_FIRST(head2)) != NULL) \
SLIST_INIT(head2); \
} else if (SLIST_FIRST(head2) != NULL) { \
while (SLIST_NEXT(curelm, field) != NULL) \
curelm = SLIST_NEXT(curelm, field); \
SLIST_NEXT(curelm, field) = SLIST_FIRST(head2); \
SLIST_INIT(head2); \
} \
} while (0)
#define SLIST_EMPTY(head) ((head)->slh_first == NULL) #define SLIST_EMPTY(head) ((head)->slh_first == NULL)
#define SLIST_FIRST(head) ((head)->slh_first) #define SLIST_FIRST(head) ((head)->slh_first)
@ -167,11 +235,21 @@ struct { \
(var); \ (var); \
(var) = SLIST_NEXT((var), field)) (var) = SLIST_NEXT((var), field))
#define SLIST_FOREACH_FROM(var, head, field) \
for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \
(var); \
(var) = SLIST_NEXT((var), field))
#define SLIST_FOREACH_SAFE(var, head, field, tvar) \ #define SLIST_FOREACH_SAFE(var, head, field, tvar) \
for ((var) = SLIST_FIRST((head)); \ for ((var) = SLIST_FIRST((head)); \
(var) && ((tvar) = SLIST_NEXT((var), field), 1); \ (var) && ((tvar) = SLIST_NEXT((var), field), 1); \
(var) = (tvar)) (var) = (tvar))
#define SLIST_FOREACH_FROM_SAFE(var, head, field, tvar) \
for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \
(var) && ((tvar) = SLIST_NEXT((var), field), 1); \
(var) = (tvar))
#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \ #define SLIST_FOREACH_PREVPTR(var, varp, head, field) \
for ((varp) = &SLIST_FIRST((head)); \ for ((varp) = &SLIST_FIRST((head)); \
((var) = *(varp)) != NULL; \ ((var) = *(varp)) != NULL; \
@ -199,7 +277,7 @@ struct { \
SLIST_REMOVE_HEAD((head), field); \ SLIST_REMOVE_HEAD((head), field); \
} \ } \
else { \ else { \
struct type *curelm = SLIST_FIRST((head)); \ QUEUE_TYPEOF(type) *curelm = SLIST_FIRST(head); \
while (SLIST_NEXT(curelm, field) != (elm)) \ while (SLIST_NEXT(curelm, field) != (elm)) \
curelm = SLIST_NEXT(curelm, field); \ curelm = SLIST_NEXT(curelm, field); \
SLIST_REMOVE_AFTER(curelm, field); \ SLIST_REMOVE_AFTER(curelm, field); \
@ -216,8 +294,14 @@ struct { \
SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \ SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \
} while (0) } while (0)
#define SLIST_REMOVE_PREVPTR(prevp, elm, field) do { \
QMD_SLIST_CHECK_PREVPTR(prevp, elm); \
*(prevp) = SLIST_NEXT(elm, field); \
TRASHIT((elm)->field.sle_next); \
} while (0)
#define SLIST_SWAP(head1, head2, type) do { \ #define SLIST_SWAP(head1, head2, type) do { \
struct type *swap_first = SLIST_FIRST(head1); \ QUEUE_TYPEOF(type) *swap_first = SLIST_FIRST(head1); \
SLIST_FIRST(head1) = SLIST_FIRST(head2); \ SLIST_FIRST(head1) = SLIST_FIRST(head2); \
SLIST_FIRST(head2) = swap_first; \ SLIST_FIRST(head2) = swap_first; \
} while (0) } while (0)
@ -231,6 +315,12 @@ struct name { \
struct type **stqh_last;/* addr of last next element */ \ struct type **stqh_last;/* addr of last next element */ \
} }
#define STAILQ_CLASS_HEAD(name, type) \
struct name { \
class type *stqh_first; /* first element */ \
class type **stqh_last; /* addr of last next element */ \
}
#define STAILQ_HEAD_INITIALIZER(head) \ #define STAILQ_HEAD_INITIALIZER(head) \
{ NULL, &(head).stqh_first } { NULL, &(head).stqh_first }
@ -239,6 +329,11 @@ struct { \
struct type *stqe_next; /* next element */ \ struct type *stqe_next; /* next element */ \
} }
#define STAILQ_CLASS_ENTRY(type) \
struct { \
class type *stqe_next; /* next element */ \
}
/* /*
* Singly-linked Tail queue functions. * Singly-linked Tail queue functions.
*/ */
@ -259,12 +354,21 @@ struct { \
(var); \ (var); \
(var) = STAILQ_NEXT((var), field)) (var) = STAILQ_NEXT((var), field))
#define STAILQ_FOREACH_FROM(var, head, field) \
for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \
(var); \
(var) = STAILQ_NEXT((var), field))
#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \ #define STAILQ_FOREACH_SAFE(var, head, field, tvar) \
for ((var) = STAILQ_FIRST((head)); \ for ((var) = STAILQ_FIRST((head)); \
(var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \
(var) = (tvar)) (var) = (tvar))
#define STAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \
for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \
(var) && ((tvar) = STAILQ_NEXT((var), field), 1); \
(var) = (tvar))
#define STAILQ_INIT(head) do { \ #define STAILQ_INIT(head) do { \
STAILQ_FIRST((head)) = NULL; \ STAILQ_FIRST((head)) = NULL; \
(head)->stqh_last = &STAILQ_FIRST((head)); \ (head)->stqh_last = &STAILQ_FIRST((head)); \
@ -288,9 +392,10 @@ struct { \
(head)->stqh_last = &STAILQ_NEXT((elm), field); \ (head)->stqh_last = &STAILQ_NEXT((elm), field); \
} while (0) } while (0)
#define STAILQ_LAST(head, type, field) \ #define STAILQ_LAST(head, type, field) \
(STAILQ_EMPTY((head)) ? NULL : \ (STAILQ_EMPTY((head)) ? NULL : \
__containerof((head)->stqh_last, struct type, field.stqe_next)) __containerof((head)->stqh_last, \
QUEUE_TYPEOF(type), field.stqe_next))
#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) #define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
@ -300,7 +405,7 @@ struct { \
STAILQ_REMOVE_HEAD((head), field); \ STAILQ_REMOVE_HEAD((head), field); \
} \ } \
else { \ else { \
struct type *curelm = STAILQ_FIRST((head)); \ QUEUE_TYPEOF(type) *curelm = STAILQ_FIRST(head); \
while (STAILQ_NEXT(curelm, field) != (elm)) \ while (STAILQ_NEXT(curelm, field) != (elm)) \
curelm = STAILQ_NEXT(curelm, field); \ curelm = STAILQ_NEXT(curelm, field); \
STAILQ_REMOVE_AFTER(head, curelm, field); \ STAILQ_REMOVE_AFTER(head, curelm, field); \
@ -326,8 +431,8 @@ struct { \
} while (0) } while (0)
#define STAILQ_SWAP(head1, head2, type) do { \ #define STAILQ_SWAP(head1, head2, type) do { \
struct type *swap_first = STAILQ_FIRST(head1); \ QUEUE_TYPEOF(type) *swap_first = STAILQ_FIRST(head1); \
struct type **swap_last = (head1)->stqh_last; \ QUEUE_TYPEOF(type) **swap_last = (head1)->stqh_last; \
STAILQ_FIRST(head1) = STAILQ_FIRST(head2); \ STAILQ_FIRST(head1) = STAILQ_FIRST(head2); \
(head1)->stqh_last = (head2)->stqh_last; \ (head1)->stqh_last = (head2)->stqh_last; \
STAILQ_FIRST(head2) = swap_first; \ STAILQ_FIRST(head2) = swap_first; \
@ -347,6 +452,11 @@ struct name { \
struct type *lh_first; /* first element */ \ struct type *lh_first; /* first element */ \
} }
#define LIST_CLASS_HEAD(name, type) \
struct name { \
class type *lh_first; /* first element */ \
}
#define LIST_HEAD_INITIALIZER(head) \ #define LIST_HEAD_INITIALIZER(head) \
{ NULL } { NULL }
@ -356,11 +466,23 @@ struct { \
struct type **le_prev; /* address of previous next element */ \ struct type **le_prev; /* address of previous next element */ \
} }
#define LIST_CLASS_ENTRY(type) \
struct { \
class type *le_next; /* next element */ \
class type **le_prev; /* address of previous next element */ \
}
/* /*
* List functions. * List functions.
*/ */
#if (defined(_KERNEL) && defined(INVARIANTS)) #if (defined(_KERNEL) && defined(INVARIANTS))
/*
* QMD_LIST_CHECK_HEAD(LIST_HEAD *head, LIST_ENTRY NAME)
*
* If the list is non-empty, validates that the first element of the list
* points back at 'head.'
*/
#define QMD_LIST_CHECK_HEAD(head, field) do { \ #define QMD_LIST_CHECK_HEAD(head, field) do { \
if (LIST_FIRST((head)) != NULL && \ if (LIST_FIRST((head)) != NULL && \
LIST_FIRST((head))->field.le_prev != \ LIST_FIRST((head))->field.le_prev != \
@ -368,6 +490,12 @@ struct { \
panic("Bad list head %p first->prev != head", (head)); \ panic("Bad list head %p first->prev != head", (head)); \
} while (0) } while (0)
/*
* QMD_LIST_CHECK_NEXT(TYPE *elm, LIST_ENTRY NAME)
*
* If an element follows 'elm' in the list, validates that the next element
* points back at 'elm.'
*/
#define QMD_LIST_CHECK_NEXT(elm, field) do { \ #define QMD_LIST_CHECK_NEXT(elm, field) do { \
if (LIST_NEXT((elm), field) != NULL && \ if (LIST_NEXT((elm), field) != NULL && \
LIST_NEXT((elm), field)->field.le_prev != \ LIST_NEXT((elm), field)->field.le_prev != \
@ -375,6 +503,11 @@ struct { \
panic("Bad link elm %p next->prev != elm", (elm)); \ panic("Bad link elm %p next->prev != elm", (elm)); \
} while (0) } while (0)
/*
* QMD_LIST_CHECK_PREV(TYPE *elm, LIST_ENTRY NAME)
*
* Validates that the previous element (or head of the list) points to 'elm.'
*/
#define QMD_LIST_CHECK_PREV(elm, field) do { \ #define QMD_LIST_CHECK_PREV(elm, field) do { \
if (*(elm)->field.le_prev != (elm)) \ if (*(elm)->field.le_prev != (elm)) \
panic("Bad link elm %p prev->next != elm", (elm)); \ panic("Bad link elm %p prev->next != elm", (elm)); \
@ -385,6 +518,23 @@ struct { \
#define QMD_LIST_CHECK_PREV(elm, field) #define QMD_LIST_CHECK_PREV(elm, field)
#endif /* (_KERNEL && INVARIANTS) */ #endif /* (_KERNEL && INVARIANTS) */
#define LIST_CONCAT(head1, head2, type, field) do { \
QUEUE_TYPEOF(type) *curelm = LIST_FIRST(head1); \
if (curelm == NULL) { \
if ((LIST_FIRST(head1) = LIST_FIRST(head2)) != NULL) { \
LIST_FIRST(head2)->field.le_prev = \
&LIST_FIRST((head1)); \
LIST_INIT(head2); \
} \
} else if (LIST_FIRST(head2) != NULL) { \
while (LIST_NEXT(curelm, field) != NULL) \
curelm = LIST_NEXT(curelm, field); \
LIST_NEXT(curelm, field) = LIST_FIRST(head2); \
LIST_FIRST(head2)->field.le_prev = &LIST_NEXT(curelm, field); \
LIST_INIT(head2); \
} \
} while (0)
#define LIST_EMPTY(head) ((head)->lh_first == NULL) #define LIST_EMPTY(head) ((head)->lh_first == NULL)
#define LIST_FIRST(head) ((head)->lh_first) #define LIST_FIRST(head) ((head)->lh_first)
@ -394,11 +544,21 @@ struct { \
(var); \ (var); \
(var) = LIST_NEXT((var), field)) (var) = LIST_NEXT((var), field))
#define LIST_FOREACH_FROM(var, head, field) \
for ((var) = ((var) ? (var) : LIST_FIRST((head))); \
(var); \
(var) = LIST_NEXT((var), field))
#define LIST_FOREACH_SAFE(var, head, field, tvar) \ #define LIST_FOREACH_SAFE(var, head, field, tvar) \
for ((var) = LIST_FIRST((head)); \ for ((var) = LIST_FIRST((head)); \
(var) && ((tvar) = LIST_NEXT((var), field), 1); \ (var) && ((tvar) = LIST_NEXT((var), field), 1); \
(var) = (tvar)) (var) = (tvar))
#define LIST_FOREACH_FROM_SAFE(var, head, field, tvar) \
for ((var) = ((var) ? (var) : LIST_FIRST((head))); \
(var) && ((tvar) = LIST_NEXT((var), field), 1); \
(var) = (tvar))
#define LIST_INIT(head) do { \ #define LIST_INIT(head) do { \
LIST_FIRST((head)) = NULL; \ LIST_FIRST((head)) = NULL; \
} while (0) } while (0)
@ -430,9 +590,10 @@ struct { \
#define LIST_NEXT(elm, field) ((elm)->field.le_next) #define LIST_NEXT(elm, field) ((elm)->field.le_next)
#define LIST_PREV(elm, head, type, field) \ #define LIST_PREV(elm, head, type, field) \
((elm)->field.le_prev == &LIST_FIRST((head)) ? NULL : \ ((elm)->field.le_prev == &LIST_FIRST((head)) ? NULL : \
__containerof((elm)->field.le_prev, struct type, field.le_next)) __containerof((elm)->field.le_prev, \
QUEUE_TYPEOF(type), field.le_next))
#define LIST_REMOVE(elm, field) do { \ #define LIST_REMOVE(elm, field) do { \
QMD_SAVELINK(oldnext, (elm)->field.le_next); \ QMD_SAVELINK(oldnext, (elm)->field.le_next); \
@ -448,7 +609,7 @@ struct { \
} while (0) } while (0)
#define LIST_SWAP(head1, head2, type, field) do { \ #define LIST_SWAP(head1, head2, type, field) do { \
struct type *swap_tmp = LIST_FIRST((head1)); \ QUEUE_TYPEOF(type) *swap_tmp = LIST_FIRST(head1); \
LIST_FIRST((head1)) = LIST_FIRST((head2)); \ LIST_FIRST((head1)) = LIST_FIRST((head2)); \
LIST_FIRST((head2)) = swap_tmp; \ LIST_FIRST((head2)) = swap_tmp; \
if ((swap_tmp = LIST_FIRST((head1))) != NULL) \ if ((swap_tmp = LIST_FIRST((head1))) != NULL) \
@ -467,6 +628,13 @@ struct name { \
TRACEBUF \ TRACEBUF \
} }
#define TAILQ_CLASS_HEAD(name, type) \
struct name { \
class type *tqh_first; /* first element */ \
class type **tqh_last; /* addr of last next element */ \
TRACEBUF \
}
#define TAILQ_HEAD_INITIALIZER(head) \ #define TAILQ_HEAD_INITIALIZER(head) \
{ NULL, &(head).tqh_first, TRACEBUF_INITIALIZER } { NULL, &(head).tqh_first, TRACEBUF_INITIALIZER }
@ -477,10 +645,23 @@ struct { \
TRACEBUF \ TRACEBUF \
} }
#define TAILQ_CLASS_ENTRY(type) \
struct { \
class type *tqe_next; /* next element */ \
class type **tqe_prev; /* address of previous next element */ \
TRACEBUF \
}
/* /*
* Tail queue functions. * Tail queue functions.
*/ */
#if (defined(_KERNEL) && defined(INVARIANTS)) #if (defined(_KERNEL) && defined(INVARIANTS))
/*
* QMD_TAILQ_CHECK_HEAD(TAILQ_HEAD *head, TAILQ_ENTRY NAME)
*
* If the tailq is non-empty, validates that the first element of the tailq
* points back at 'head.'
*/
#define QMD_TAILQ_CHECK_HEAD(head, field) do { \ #define QMD_TAILQ_CHECK_HEAD(head, field) do { \
if (!TAILQ_EMPTY(head) && \ if (!TAILQ_EMPTY(head) && \
TAILQ_FIRST((head))->field.tqe_prev != \ TAILQ_FIRST((head))->field.tqe_prev != \
@ -488,11 +669,22 @@ struct { \
panic("Bad tailq head %p first->prev != head", (head)); \ panic("Bad tailq head %p first->prev != head", (head)); \
} while (0) } while (0)
/*
* QMD_TAILQ_CHECK_TAIL(TAILQ_HEAD *head, TAILQ_ENTRY NAME)
*
* Validates that the tail of the tailq is a pointer to pointer to NULL.
*/
#define QMD_TAILQ_CHECK_TAIL(head, field) do { \ #define QMD_TAILQ_CHECK_TAIL(head, field) do { \
if (*(head)->tqh_last != NULL) \ if (*(head)->tqh_last != NULL) \
panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head)); \ panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head)); \
} while (0) } while (0)
/*
* QMD_TAILQ_CHECK_NEXT(TYPE *elm, TAILQ_ENTRY NAME)
*
* If an element follows 'elm' in the tailq, validates that the next element
* points back at 'elm.'
*/
#define QMD_TAILQ_CHECK_NEXT(elm, field) do { \ #define QMD_TAILQ_CHECK_NEXT(elm, field) do { \
if (TAILQ_NEXT((elm), field) != NULL && \ if (TAILQ_NEXT((elm), field) != NULL && \
TAILQ_NEXT((elm), field)->field.tqe_prev != \ TAILQ_NEXT((elm), field)->field.tqe_prev != \
@ -500,6 +692,11 @@ struct { \
panic("Bad link elm %p next->prev != elm", (elm)); \ panic("Bad link elm %p next->prev != elm", (elm)); \
} while (0) } while (0)
/*
* QMD_TAILQ_CHECK_PREV(TYPE *elm, TAILQ_ENTRY NAME)
*
* Validates that the previous element (or head of the tailq) points to 'elm.'
*/
#define QMD_TAILQ_CHECK_PREV(elm, field) do { \ #define QMD_TAILQ_CHECK_PREV(elm, field) do { \
if (*(elm)->field.tqe_prev != (elm)) \ if (*(elm)->field.tqe_prev != (elm)) \
panic("Bad link elm %p prev->next != elm", (elm)); \ panic("Bad link elm %p prev->next != elm", (elm)); \
@ -531,21 +728,41 @@ struct { \
(var); \ (var); \
(var) = TAILQ_NEXT((var), field)) (var) = TAILQ_NEXT((var), field))
#define TAILQ_FOREACH_FROM(var, head, field) \
for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \
(var); \
(var) = TAILQ_NEXT((var), field))
#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \ #define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
for ((var) = TAILQ_FIRST((head)); \ for ((var) = TAILQ_FIRST((head)); \
(var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
(var) = (tvar)) (var) = (tvar))
#define TAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \
for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \
(var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
(var) = (tvar))
#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ #define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
for ((var) = TAILQ_LAST((head), headname); \ for ((var) = TAILQ_LAST((head), headname); \
(var); \ (var); \
(var) = TAILQ_PREV((var), headname, field)) (var) = TAILQ_PREV((var), headname, field))
#define TAILQ_FOREACH_REVERSE_FROM(var, head, headname, field) \
for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \
(var); \
(var) = TAILQ_PREV((var), headname, field))
#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \ #define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \
for ((var) = TAILQ_LAST((head), headname); \ for ((var) = TAILQ_LAST((head), headname); \
(var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \ (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \
(var) = (tvar)) (var) = (tvar))
#define TAILQ_FOREACH_REVERSE_FROM_SAFE(var, head, headname, field, tvar) \
for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \
(var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \
(var) = (tvar))
#define TAILQ_INIT(head) do { \ #define TAILQ_INIT(head) do { \
TAILQ_FIRST((head)) = NULL; \ TAILQ_FIRST((head)) = NULL; \
(head)->tqh_last = &TAILQ_FIRST((head)); \ (head)->tqh_last = &TAILQ_FIRST((head)); \
@ -564,7 +781,7 @@ struct { \
TAILQ_NEXT((listelm), field) = (elm); \ TAILQ_NEXT((listelm), field) = (elm); \
(elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \ (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \
QMD_TRACE_ELEM(&(elm)->field); \ QMD_TRACE_ELEM(&(elm)->field); \
QMD_TRACE_ELEM(&listelm->field); \ QMD_TRACE_ELEM(&(listelm)->field); \
} while (0) } while (0)
#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ #define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
@ -574,7 +791,7 @@ struct { \
*(listelm)->field.tqe_prev = (elm); \ *(listelm)->field.tqe_prev = (elm); \
(listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \ (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \
QMD_TRACE_ELEM(&(elm)->field); \ QMD_TRACE_ELEM(&(elm)->field); \
QMD_TRACE_ELEM(&listelm->field); \ QMD_TRACE_ELEM(&(listelm)->field); \
} while (0) } while (0)
#define TAILQ_INSERT_HEAD(head, elm, field) do { \ #define TAILQ_INSERT_HEAD(head, elm, field) do { \
@ -627,8 +844,8 @@ struct { \
} while (0) } while (0)
#define TAILQ_SWAP(head1, head2, type, field) do { \ #define TAILQ_SWAP(head1, head2, type, field) do { \
struct type *swap_first = (head1)->tqh_first; \ QUEUE_TYPEOF(type) *swap_first = (head1)->tqh_first; \
struct type **swap_last = (head1)->tqh_last; \ QUEUE_TYPEOF(type) **swap_last = (head1)->tqh_last; \
(head1)->tqh_first = (head2)->tqh_first; \ (head1)->tqh_first = (head2)->tqh_first; \
(head1)->tqh_last = (head2)->tqh_last; \ (head1)->tqh_last = (head2)->tqh_last; \
(head2)->tqh_first = swap_first; \ (head2)->tqh_first = swap_first; \

View file

@ -37,6 +37,8 @@ typedef __uint32_t __ULong;
struct _reent; struct _reent;
struct __locale_t;
/* /*
* If _REENT_SMALL is defined, we make struct _reent as small as possible, * If _REENT_SMALL is defined, we make struct _reent as small as possible,
* by having nearly everything possible allocated at first use. * by having nearly everything possible allocated at first use.
@ -384,8 +386,8 @@ struct _reent
int __sdidinit; /* 1 means stdio has been init'd */ int __sdidinit; /* 1 means stdio has been init'd */
int _current_category; /* unused */ int _unspecified_locale_info; /* unused, reserved for locale stuff */
_CONST char *_current_locale; /* unused */ struct __locale_t *_locale;/* per-thread locale */
struct _mprec *_mp; struct _mprec *_mp;
@ -429,7 +431,7 @@ extern const struct __sFILE_fake __sf_fake_stderr;
_NULL, \ _NULL, \
0, \ 0, \
0, \ 0, \
"C", \ _NULL, \
_NULL, \ _NULL, \
_NULL, \ _NULL, \
0, \ 0, \
@ -446,16 +448,14 @@ extern const struct __sFILE_fake __sf_fake_stderr;
_NULL \ _NULL \
} }
#define _REENT_INIT_PTR(var) \ #define _REENT_INIT_PTR_ZEROED(var) \
{ memset((var), 0, sizeof(*(var))); \ { (var)->_stdin = (__FILE *)&__sf_fake_stdin; \
(var)->_stdin = (__FILE *)&__sf_fake_stdin; \
(var)->_stdout = (__FILE *)&__sf_fake_stdout; \ (var)->_stdout = (__FILE *)&__sf_fake_stdout; \
(var)->_stderr = (__FILE *)&__sf_fake_stderr; \ (var)->_stderr = (__FILE *)&__sf_fake_stderr; \
(var)->_current_locale = "C"; \
} }
/* Only built the assert() calls if we are built with debugging. */ /* Only add assert() calls if we are specified to debug. */
#if DEBUG #ifdef _REENT_CHECK_DEBUG
#include <assert.h> #include <assert.h>
#define __reent_assert(x) assert(x) #define __reent_assert(x) assert(x)
#else #else
@ -578,8 +578,9 @@ struct _reent
int _inc; /* used by tmpnam */ int _inc; /* used by tmpnam */
char _emergency[_REENT_EMERGENCY_SIZE]; char _emergency[_REENT_EMERGENCY_SIZE];
int _current_category; /* used by setlocale */ /* TODO */
_CONST char *_current_locale; int _unspecified_locale_info; /* unused, reserved for locale stuff */
struct __locale_t *_locale;/* per-thread locale */
int __sdidinit; /* 1 means stdio has been init'd */ int __sdidinit; /* 1 means stdio has been init'd */
@ -643,18 +644,27 @@ struct _reent
of the above members (on the off chance that future binary compatibility of the above members (on the off chance that future binary compatibility
would be broken otherwise). */ would be broken otherwise). */
struct _glue __sglue; /* root of glue chain */ struct _glue __sglue; /* root of glue chain */
# ifndef _REENT_GLOBAL_STDIO_STREAMS
__FILE __sf[3]; /* first three file descriptors */ __FILE __sf[3]; /* first three file descriptors */
# endif
}; };
#ifdef _REENT_GLOBAL_STDIO_STREAMS
extern __FILE __sf[3];
#define _REENT_STDIO_STREAM(var, index) &__sf[index]
#else
#define _REENT_STDIO_STREAM(var, index) &(var)->__sf[index]
#endif
#define _REENT_INIT(var) \ #define _REENT_INIT(var) \
{ 0, \ { 0, \
&(var).__sf[0], \ _REENT_STDIO_STREAM(&(var), 0), \
&(var).__sf[1], \ _REENT_STDIO_STREAM(&(var), 1), \
&(var).__sf[2], \ _REENT_STDIO_STREAM(&(var), 2), \
0, \ 0, \
"", \ "", \
0, \ 0, \
"C", \ _NULL, \
0, \ 0, \
_NULL, \ _NULL, \
_NULL, \ _NULL, \
@ -694,12 +704,10 @@ struct _reent
{_NULL, 0, _NULL} \ {_NULL, 0, _NULL} \
} }
#define _REENT_INIT_PTR(var) \ #define _REENT_INIT_PTR_ZEROED(var) \
{ memset((var), 0, sizeof(*(var))); \ { (var)->_stdin = _REENT_STDIO_STREAM(var, 0); \
(var)->_stdin = &(var)->__sf[0]; \ (var)->_stdout = _REENT_STDIO_STREAM(var, 1); \
(var)->_stdout = &(var)->__sf[1]; \ (var)->_stderr = _REENT_STDIO_STREAM(var, 2); \
(var)->_stderr = &(var)->__sf[2]; \
(var)->_current_locale = "C"; \
(var)->_new._reent._rand_next = 1; \ (var)->_new._reent._rand_next = 1; \
(var)->_new._reent._r48._seed[0] = _RAND48_SEED_0; \ (var)->_new._reent._r48._seed[0] = _RAND48_SEED_0; \
(var)->_new._reent._r48._seed[1] = _RAND48_SEED_1; \ (var)->_new._reent._r48._seed[1] = _RAND48_SEED_1; \
@ -745,6 +753,11 @@ struct _reent
#endif /* !_REENT_SMALL */ #endif /* !_REENT_SMALL */
#define _REENT_INIT_PTR(var) \
{ memset((var), 0, sizeof(*(var))); \
_REENT_INIT_PTR_ZEROED(var); \
}
/* This value is used in stdlib/misc.c. reent/reent.c has to know it /* This value is used in stdlib/misc.c. reent/reent.c has to know it
as well to make sure the freelist is correctly free'd. Therefore as well to make sure the freelist is correctly free'd. Therefore
we define it here, rather than in stdlib/misc.c, as before. */ we define it here, rather than in stdlib/misc.c, as before. */

View file

@ -21,6 +21,8 @@
#ifndef _SYS_SCHED_H_ #ifndef _SYS_SCHED_H_
#define _SYS_SCHED_H_ #define _SYS_SCHED_H_
#include <sys/_timespec.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View file

@ -0,0 +1,87 @@
/* select.h
Copyright 1998, 1999, 2000, 2001, 2005, 2009 Red Hat, Inc.
Written by Geoffrey Noer <noer@cygnus.com>
This file is part of Cygwin.
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#ifndef _SYS_SELECT_H
#define _SYS_SELECT_H
/* We don't define fd_set and friends if we are compiling POSIX
source, or if we have included (or may include as indicated
by __USE_W32_SOCKETS) the W32api winsock[2].h header which
defines Windows versions of them. Note that a program which
includes the W32api winsock[2].h header must know what it is doing;
it must not call the Cygwin select function.
*/
# 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>
#if !defined(_SIGSET_T_DECLARED)
#define _SIGSET_T_DECLARED
typedef __sigset_t sigset_t;
#endif
# define _SYS_TYPES_FD_SET
/*
* Select uses bit masks of file descriptors in longs.
* These macros manipulate such bit fields (the filesystem macros use chars).
* FD_SETSIZE may be defined by the user, but the default here
* should be >= NOFILE (param.h).
*/
# ifndef FD_SETSIZE
# define FD_SETSIZE 64
# endif
typedef unsigned long fd_mask;
# define NFDBITS (sizeof (fd_mask) * 8) /* bits per mask */
# ifndef _howmany
# define _howmany(x,y) (((x)+((y)-1))/(y))
# endif
/* We use a macro for fd_set so that including Sockets.h afterwards
can work. */
typedef struct _types_fd_set {
fd_mask fds_bits[_howmany(FD_SETSIZE, NFDBITS)];
} _types_fd_set;
#define fd_set _types_fd_set
# define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS)))
# define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS)))
# define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS)))
# define FD_ZERO(p) (__extension__ (void)({ \
size_t __i; \
char *__tmp = (char *)p; \
for (__i = 0; __i < sizeof (*(p)); ++__i) \
*__tmp++ = 0; \
}))
#if !defined (__INSIDE_CYGWIN_NET__)
__BEGIN_DECLS
int select __P ((int __n, fd_set *__readfds, fd_set *__writefds,
fd_set *__exceptfds, struct timeval *__timeout));
#if __POSIX_VISIBLE >= 200112
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 /* !__INSIDE_CYGWIN_NET__ */
#endif /* !(_WINSOCK_H || _WINSOCKAPI_ || __USE_W32_SOCKETS) */
#endif /* sys/select.h */

View file

@ -7,19 +7,22 @@ extern "C" {
#endif #endif
#include "_ansi.h" #include "_ansi.h"
#include <sys/cdefs.h>
#include <sys/features.h> #include <sys/features.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/_sigset.h>
#include <sys/_timespec.h>
/* #ifndef __STRICT_ANSI__*/ #if !defined(_SIGSET_T_DECLARED)
#define _SIGSET_T_DECLARED
/* Cygwin defines it's own sigset_t in include/cygwin/signal.h */ typedef __sigset_t sigset_t;
#ifndef __CYGWIN__
typedef unsigned long sigset_t;
#endif #endif
#if defined(__rtems__) #if defined(__CYGWIN__)
#include <cygwin/signal.h>
#else
#if defined(_POSIX_REALTIME_SIGNALS) #if defined(_POSIX_REALTIME_SIGNALS) || __POSIX_VISIBLE >= 199309
/* sigev_notify values /* sigev_notify values
NOTE: P1003.1c/D10, p. 34 adds SIGEV_THREAD. */ NOTE: P1003.1c/D10, p. 34 adds SIGEV_THREAD. */
@ -67,14 +70,16 @@ typedef struct {
int si_code; /* Cause of the signal */ int si_code; /* Cause of the signal */
union sigval si_value; /* Signal value */ union sigval si_value; /* Signal value */
} siginfo_t; } siginfo_t;
#endif #endif /* defined(_POSIX_REALTIME_SIGNALS) || __POSIX_VISIBLE >= 199309 */
#if defined(__rtems__)
/* 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76 */ /* 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76 */
#define SA_NOCLDSTOP 0x1 /* Do not generate SIGCHLD when children stop */ #define SA_NOCLDSTOP 0x1 /* Do not generate SIGCHLD when children stop */
#define SA_SIGINFO 0x2 /* Invoke the signal catching function with */ #define SA_SIGINFO 0x2 /* Invoke the signal catching function with */
/* three arguments instead of one. */ /* three arguments instead of one. */
#if __BSD_VISIBLE || __XSI_VISIBLE || __POSIX_VISIBLE >= 200112 #if __BSD_VISIBLE || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809
#define SA_ONSTACK 0x4 /* Signal delivery will be on a separate stack. */ #define SA_ONSTACK 0x4 /* Signal delivery will be on a separate stack. */
#endif #endif
@ -107,7 +112,22 @@ struct sigaction {
#define sa_sigaction _signal_handlers._sigaction #define sa_sigaction _signal_handlers._sigaction
#endif #endif
#if __BSD_VISIBLE || __XSI_VISIBLE || __POSIX_VISIBLE >= 200112 #else /* defined(__rtems__) */
#define SA_NOCLDSTOP 1 /* only value supported now for sa_flags */
typedef void (*_sig_func_ptr)(int);
struct sigaction
{
_sig_func_ptr sa_handler;
sigset_t sa_mask;
int sa_flags;
};
#endif /* defined(__rtems__) */
#endif /* defined(__CYGWIN__) */
#if __BSD_VISIBLE || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809
/* /*
* Minimum and default signal stack constants. Allow for target overrides * Minimum and default signal stack constants. Allow for target overrides
* from <sys/features.h>. * from <sys/features.h>.
@ -125,6 +145,8 @@ struct sigaction {
#define SS_ONSTACK 0x1 #define SS_ONSTACK 0x1
#define SS_DISABLE 0x2 #define SS_DISABLE 0x2
#endif
/* /*
* Structure used in sigaltstack call. * Structure used in sigaltstack call.
*/ */
@ -133,58 +155,33 @@ typedef struct sigaltstack {
int ss_flags; /* Flags. */ int ss_flags; /* Flags. */
size_t ss_size; /* Stack size. */ size_t ss_size; /* Stack size. */
} stack_t; } stack_t;
#endif
#elif defined(__CYGWIN__)
#include <cygwin/signal.h>
#else
#define SA_NOCLDSTOP 1 /* only value supported now for sa_flags */
typedef void (*_sig_func_ptr)(int);
struct sigaction
{
_sig_func_ptr sa_handler;
sigset_t sa_mask;
int sa_flags;
};
#endif /* defined(__rtems__) */
#if __POSIX_VISIBLE
#define SIG_SETMASK 0 /* set mask with sigprocmask() */ #define SIG_SETMASK 0 /* set mask with sigprocmask() */
#define SIG_BLOCK 1 /* set of signals to block */ #define SIG_BLOCK 1 /* set of signals to block */
#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */ #define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
/* These depend upon the type of sigset_t, which right now
is always a long.. They're in the POSIX namespace, but
are not ANSI. */
#define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0)
#define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0)
#define sigemptyset(what) (*(what) = 0, 0)
#define sigfillset(what) (*(what) = ~(0), 0)
#define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
int _EXFUN(sigprocmask, (int how, const sigset_t *set, sigset_t *oset)); int _EXFUN(sigprocmask, (int how, const sigset_t *set, sigset_t *oset));
#endif
#if defined(_POSIX_THREADS) #if __POSIX_VISIBLE >= 199506
int _EXFUN(pthread_sigmask, (int how, const sigset_t *set, sigset_t *oset)); int _EXFUN(pthread_sigmask, (int how, const sigset_t *set, sigset_t *oset));
#endif #endif
#if defined(__CYGWIN__) || defined(__rtems__) #if defined(__CYGWIN__) || defined(__rtems__)
#undef sigaddset
#undef sigdelset
#undef sigemptyset
#undef sigfillset
#undef sigismember
#ifdef _COMPILING_NEWLIB #ifdef _COMPILING_NEWLIB
int _EXFUN(_kill, (pid_t, int)); int _EXFUN(_kill, (pid_t, int));
#endif /* _COMPILING_NEWLIB */ #endif /* _COMPILING_NEWLIB */
#endif /* __CYGWIN__ || __rtems__ */ #endif /* __CYGWIN__ || __rtems__ */
#if defined(__CYGWIN__) || defined(__rtems__) || defined(__SPU__)
#if __POSIX_VISIBLE
int _EXFUN(kill, (pid_t, int)); int _EXFUN(kill, (pid_t, int));
#endif /* __CYGWIN__ || __rtems__ || __SPU__ */ #endif
#if defined(__CYGWIN__) || defined(__rtems__)
#if __BSD_VISIBLE || __XSI_VISIBLE >= 4
int _EXFUN(killpg, (pid_t, int)); int _EXFUN(killpg, (pid_t, int));
#endif
#if __POSIX_VISIBLE
int _EXFUN(sigaction, (int, const struct sigaction *, struct sigaction *)); int _EXFUN(sigaction, (int, const struct sigaction *, struct sigaction *));
int _EXFUN(sigaddset, (sigset_t *, const int)); int _EXFUN(sigaddset, (sigset_t *, const int));
int _EXFUN(sigdelset, (sigset_t *, const int)); int _EXFUN(sigdelset, (sigset_t *, const int));
@ -193,24 +190,45 @@ int _EXFUN(sigfillset, (sigset_t *));
int _EXFUN(sigemptyset, (sigset_t *)); int _EXFUN(sigemptyset, (sigset_t *));
int _EXFUN(sigpending, (sigset_t *)); int _EXFUN(sigpending, (sigset_t *));
int _EXFUN(sigsuspend, (const sigset_t *)); int _EXFUN(sigsuspend, (const sigset_t *));
int _EXFUN(sigpause, (int)); int _EXFUN(sigwait, (const sigset_t *set, int *sig));
#ifdef __rtems__ #if !defined(__CYGWIN__) && !defined(__rtems__)
#if __BSD_VISIBLE || __XSI_VISIBLE || __POSIX_VISIBLE >= 200112 /* These depend upon the type of sigset_t, which right now
is always a long.. They're in the POSIX namespace, but
are not ANSI. */
#define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0)
#define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0)
#define sigemptyset(what) (*(what) = 0, 0)
#define sigfillset(what) (*(what) = ~(0), 0)
#define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
#endif /* !__CYGWIN__ && !__rtems__ */
#endif /* __POSIX_VISIBLE */
/* There are two common sigpause variants, both of which take an int argument.
If you request _XOPEN_SOURCE or _GNU_SOURCE, you get the System V version,
which removes the given signal from the process's signal mask; otherwise
you get the BSD version, which sets the process's signal mask to the given
value. */
#if __XSI_VISIBLE && !defined(__INSIDE_CYGWIN__)
# ifdef __GNUC__
int _EXFUN(sigpause, (int)) __asm__ (__ASMNAME ("__xpg_sigpause"));
# else
int _EXFUN(__xpg_sigpause, (int));
# define sigpause __xpg_sigpause
# endif
#elif __BSD_VISIBLE
int _EXFUN(sigpause, (int));
#endif
#if __BSD_VISIBLE || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809
int _EXFUN(sigaltstack, (const stack_t *__restrict, stack_t *__restrict)); int _EXFUN(sigaltstack, (const stack_t *__restrict, stack_t *__restrict));
#endif #endif
#endif
#if defined(_POSIX_THREADS) #if __POSIX_VISIBLE >= 199506
#ifdef __CYGWIN__
# ifndef _CYGWIN_TYPES_H
# error You need the winsup sources or a cygwin installation to compile the cygwin version of newlib.
# endif
#endif
int _EXFUN(pthread_kill, (pthread_t thread, int sig)); int _EXFUN(pthread_kill, (pthread_t thread, int sig));
#endif #endif
#if defined(_POSIX_REALTIME_SIGNALS) #if __POSIX_VISIBLE >= 199309
/* 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76 /* 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76
NOTE: P1003.1c/D10, p. 39 adds sigwait(). */ NOTE: P1003.1c/D10, p. 39 adds sigwait(). */
@ -219,16 +237,10 @@ int _EXFUN(sigwaitinfo, (const sigset_t *set, siginfo_t *info));
int _EXFUN(sigtimedwait, int _EXFUN(sigtimedwait,
(const sigset_t *set, siginfo_t *info, const struct timespec *timeout) (const sigset_t *set, siginfo_t *info, const struct timespec *timeout)
); );
int _EXFUN(sigwait, (const sigset_t *set, int *sig));
/* 3.3.9 Queue a Signal to a Process, P1003.1b-1993, p. 78 */ /* 3.3.9 Queue a Signal to a Process, P1003.1b-1993, p. 78 */
int _EXFUN(sigqueue, (pid_t pid, int signo, const union sigval value)); int _EXFUN(sigqueue, (pid_t pid, int signo, const union sigval value));
#endif /* defined(_POSIX_REALTIME_SIGNALS) */ #endif /* __POSIX_VISIBLE >= 199309 */
#endif /* defined(__CYGWIN__) || defined(__rtems__) */
/* #endif __STRICT_ANSI__ */
#if defined(___AM29K__) #if defined(___AM29K__)
/* These all need to be defined for ANSI C, but I don't think they are /* These all need to be defined for ANSI C, but I don't think they are
@ -349,6 +361,12 @@ int _EXFUN(sigqueue, (pid_t pid, int signo, const union sigval value));
} }
#endif #endif
#if defined(__CYGWIN__)
#if __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809
#include <sys/ucontext.h>
#endif
#endif
#ifndef _SIGNAL_H_ #ifndef _SIGNAL_H_
/* Some applications take advantage of the fact that <sys/signal.h> /* Some applications take advantage of the fact that <sys/signal.h>
* and <signal.h> are equivalent in glibc. Allow for that here. */ * and <signal.h> are equivalent in glibc. Allow for that here. */

View file

@ -9,6 +9,7 @@ extern "C" {
#include <time.h> #include <time.h>
#include <sys/cdefs.h> #include <sys/cdefs.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/_timespec.h>
/* dj's stat defines _STAT_H_ */ /* dj's stat defines _STAT_H_ */
#ifndef _STAT_H_ #ifndef _STAT_H_
@ -52,8 +53,8 @@ struct stat
long st_spare2; long st_spare2;
time_t st_ctime; time_t st_ctime;
long st_spare3; long st_spare3;
long st_blksize; blksize_t st_blksize;
long st_blocks; blkcnt_t st_blocks;
long st_spare4[2]; long st_spare4[2];
#endif #endif
#endif #endif
@ -81,12 +82,12 @@ struct stat
#define S_ISUID 0004000 /* set user id on execution */ #define S_ISUID 0004000 /* set user id on execution */
#define S_ISGID 0002000 /* set group id on execution */ #define S_ISGID 0002000 /* set group id on execution */
#define S_ISVTX 0001000 /* save swapped text even after use */ #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_IREAD 0000400 /* read permission, owner */
#define S_IWRITE 0000200 /* write permission, owner */ #define S_IWRITE 0000200 /* write permission, owner */
#define S_IEXEC 0000100 /* execute/search permission, owner */ #define S_IEXEC 0000100 /* execute/search permission, owner */
#define S_ENFMT 0002000 /* enforcement-mode locking */ #define S_ENFMT 0002000 /* enforcement-mode locking */
#endif /* !_POSIX_SOURCE */ #endif /* !_BSD_VISIBLE */
#define S_IFMT _IFMT #define S_IFMT _IFMT
#define S_IFDIR _IFDIR #define S_IFDIR _IFDIR
@ -123,7 +124,7 @@ struct stat
#define S_IWOTH 0000002 /* write permission, other */ #define S_IWOTH 0000002 /* write permission, other */
#define S_IXOTH 0000001/* execute/search 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 ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) /* 0777 */
#define ALLPERMS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) /* 07777 */ #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 */ #define DEFFILEMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) /* 0666 */
@ -156,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 )); int _EXFUN(mknod,( const char *__path, mode_t __mode, dev_t __dev ));
#endif #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)); 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(fstatat, (int, const char *__restrict , struct stat *__restrict, int));
int _EXFUN(mkdirat, (int, const char *, mode_t)); int _EXFUN(mkdirat, (int, const char *, mode_t));
int _EXFUN(mkfifoat, (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)); 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)); int _EXFUN(utimensat, (int, const char *, const struct timespec *, int));
#endif
#if __POSIX_VISIBLE >= 200809 && !defined(__INSIDE_CYGWIN__)
int _EXFUN(futimens, (int, const struct timespec *)); int _EXFUN(futimens, (int, const struct timespec *));
#endif #endif

View file

@ -2,90 +2,301 @@
Written by Geoffrey Noer <noer@cygnus.com> Written by Geoffrey Noer <noer@cygnus.com>
Public domain; no rights reserved. */ Public domain; no rights reserved. */
/*-
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)time.h 8.5 (Berkeley) 5/4/95
* $FreeBSD$
*/
#ifndef _SYS_TIME_H_ #ifndef _SYS_TIME_H_
#define _SYS_TIME_H_ #define _SYS_TIME_H_
#include <_ansi.h> #include <_ansi.h>
#include <sys/cdefs.h>
#include <sys/_timeval.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/timespec.h>
#ifdef __cplusplus #if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
extern "C" { #include <sys/select.h>
#endif #endif
#ifndef _TIMEVAL_DEFINED
#define _TIMEVAL_DEFINED
struct timeval {
time_t tv_sec;
suseconds_t tv_usec;
};
/* BSD time macros used by RTEMS code */
#if defined (__rtems__) || defined (__CYGWIN__)
/* Convenience macros for operations on timevals.
NOTE: `timercmp' does not work for >= or <=. */
#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
#define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
#define timercmp(a, b, CMP) \
(((a)->tv_sec == (b)->tv_sec) ? \
((a)->tv_usec CMP (b)->tv_usec) : \
((a)->tv_sec CMP (b)->tv_sec))
#define timeradd(a, b, result) \
do { \
(result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \
(result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \
if ((result)->tv_usec >= 1000000) \
{ \
++(result)->tv_sec; \
(result)->tv_usec -= 1000000; \
} \
} while (0)
#define timersub(a, b, result) \
do { \
(result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
(result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
if ((result)->tv_usec < 0) { \
--(result)->tv_sec; \
(result)->tv_usec += 1000000; \
} \
} while (0)
#endif /* defined (__rtems__) || defined (__CYGWIN__) */
#endif /* !_TIMEVAL_DEFINED */
struct timezone { struct timezone {
int tz_minuteswest; int tz_minuteswest; /* minutes west of Greenwich */
int tz_dsttime; int tz_dsttime; /* type of dst correction */
};
#define DST_NONE 0 /* not on dst */
#define DST_USA 1 /* USA style dst */
#define DST_AUST 2 /* Australian style dst */
#define DST_WET 3 /* Western European dst */
#define DST_MET 4 /* Middle European dst */
#define DST_EET 5 /* Eastern European dst */
#define DST_CAN 6 /* Canada */
#if __BSD_VISIBLE
struct bintime {
time_t sec;
uint64_t frac;
}; };
#ifdef __CYGWIN__ static __inline void
#include <cygwin/sys_time.h> bintime_addx(struct bintime *_bt, uint64_t _x)
#endif /* __CYGWIN__ */ {
uint64_t _u;
#define ITIMER_REAL 0 _u = _bt->frac;
#define ITIMER_VIRTUAL 1 _bt->frac += _x;
#define ITIMER_PROF 2 if (_u > _bt->frac)
_bt->sec++;
}
struct itimerval { static __inline void
struct timeval it_interval; bintime_add(struct bintime *_bt, const struct bintime *_bt2)
struct timeval it_value; {
uint64_t _u;
_u = _bt->frac;
_bt->frac += _bt2->frac;
if (_u > _bt->frac)
_bt->sec++;
_bt->sec += _bt2->sec;
}
static __inline void
bintime_sub(struct bintime *_bt, const struct bintime *_bt2)
{
uint64_t _u;
_u = _bt->frac;
_bt->frac -= _bt2->frac;
if (_u < _bt->frac)
_bt->sec--;
_bt->sec -= _bt2->sec;
}
static __inline void
bintime_mul(struct bintime *_bt, u_int _x)
{
uint64_t _p1, _p2;
_p1 = (_bt->frac & 0xffffffffull) * _x;
_p2 = (_bt->frac >> 32) * _x + (_p1 >> 32);
_bt->sec *= _x;
_bt->sec += (_p2 >> 32);
_bt->frac = (_p2 << 32) | (_p1 & 0xffffffffull);
}
static __inline void
bintime_shift(struct bintime *_bt, int _exp)
{
if (_exp > 0) {
_bt->sec <<= _exp;
_bt->sec |= _bt->frac >> (64 - _exp);
_bt->frac <<= _exp;
} else if (_exp < 0) {
_bt->frac >>= -_exp;
_bt->frac |= (uint64_t)_bt->sec << (64 + _exp);
_bt->sec >>= -_exp;
}
}
#define bintime_clear(a) ((a)->sec = (a)->frac = 0)
#define bintime_isset(a) ((a)->sec || (a)->frac)
#define bintime_cmp(a, b, cmp) \
(((a)->sec == (b)->sec) ? \
((a)->frac cmp (b)->frac) : \
((a)->sec cmp (b)->sec))
#define SBT_1S ((sbintime_t)1 << 32)
#define SBT_1M (SBT_1S * 60)
#define SBT_1MS (SBT_1S / 1000)
#define SBT_1US (SBT_1S / 1000000)
#define SBT_1NS (SBT_1S / 1000000000)
#define SBT_MAX 0x7fffffffffffffffLL
static __inline int
sbintime_getsec(sbintime_t _sbt)
{
return (_sbt >> 32);
}
static __inline sbintime_t
bttosbt(const struct bintime _bt)
{
return (((sbintime_t)_bt.sec << 32) + (_bt.frac >> 32));
}
static __inline struct bintime
sbttobt(sbintime_t _sbt)
{
struct bintime _bt;
_bt.sec = _sbt >> 32;
_bt.frac = _sbt << 32;
return (_bt);
}
/*-
* Background information:
*
* When converting between timestamps on parallel timescales of differing
* resolutions it is historical and scientific practice to round down rather
* than doing 4/5 rounding.
*
* The date changes at midnight, not at noon.
*
* Even at 15:59:59.999999999 it's not four'o'clock.
*
* time_second ticks after N.999999999 not after N.4999999999
*/
static __inline void
bintime2timespec(const struct bintime *_bt, struct timespec *_ts)
{
_ts->tv_sec = _bt->sec;
_ts->tv_nsec = ((uint64_t)1000000000 *
(uint32_t)(_bt->frac >> 32)) >> 32;
}
static __inline void
timespec2bintime(const struct timespec *_ts, struct bintime *_bt)
{
_bt->sec = _ts->tv_sec;
/* 18446744073 = int(2^64 / 1000000000) */
_bt->frac = _ts->tv_nsec * (uint64_t)18446744073LL;
}
static __inline void
bintime2timeval(const struct bintime *_bt, struct timeval *_tv)
{
_tv->tv_sec = _bt->sec;
_tv->tv_usec = ((uint64_t)1000000 * (uint32_t)(_bt->frac >> 32)) >> 32;
}
static __inline void
timeval2bintime(const struct timeval *_tv, struct bintime *_bt)
{
_bt->sec = _tv->tv_sec;
/* 18446744073709 = int(2^64 / 1000000) */
_bt->frac = _tv->tv_usec * (uint64_t)18446744073709LL;
}
static __inline struct timespec
sbttots(sbintime_t _sbt)
{
struct timespec _ts;
_ts.tv_sec = _sbt >> 32;
_ts.tv_nsec = ((uint64_t)1000000000 * (uint32_t)_sbt) >> 32;
return (_ts);
}
static __inline sbintime_t
tstosbt(struct timespec _ts)
{
return (((sbintime_t)_ts.tv_sec << 32) +
(_ts.tv_nsec * (((uint64_t)1 << 63) / 500000000) >> 32));
}
static __inline struct timeval
sbttotv(sbintime_t _sbt)
{
struct timeval _tv;
_tv.tv_sec = _sbt >> 32;
_tv.tv_usec = ((uint64_t)1000000 * (uint32_t)_sbt) >> 32;
return (_tv);
}
static __inline sbintime_t
tvtosbt(struct timeval _tv)
{
return (((sbintime_t)_tv.tv_sec << 32) +
(_tv.tv_usec * (((uint64_t)1 << 63) / 500000) >> 32));
}
#endif /* __BSD_VISIBLE */
/*
* Names of the interval timers, and structure
* defining a timer setting.
*/
#define ITIMER_REAL 0
#define ITIMER_VIRTUAL 1
#define ITIMER_PROF 2
struct itimerval {
struct timeval it_interval; /* timer interval */
struct timeval it_value; /* current value */
}; };
#ifndef _KERNEL
#include <time.h>
__BEGIN_DECLS
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(lutimes, (const char *, const struct timeval *));
int _EXFUN(settimeofday, (const struct timeval *, const struct timezone *));
#endif
#if __MISC_VISIBLE || __XSI_VISIBLE
int _EXFUN(getitimer, (int __which, struct itimerval *__value));
int _EXFUN(setitimer, (int __which, const struct itimerval *__restrict __value,
struct itimerval *__restrict __ovalue));
#endif
int _EXFUN(gettimeofday, (struct timeval *__restrict __p,
void *__restrict __tz));
#if __GNU_VISIBLE
int _EXFUN(futimesat, (int, const char *, const struct timeval [2]));
#endif
#ifdef _COMPILING_NEWLIB #ifdef _COMPILING_NEWLIB
int _EXFUN(_gettimeofday, (struct timeval *__p, void *__tz)); int _EXFUN(_gettimeofday, (struct timeval *__p, void *__tz));
#endif #endif
int _EXFUN(gettimeofday, (struct timeval *__restrict __p, __END_DECLS
void *__restrict __tz));
#if __BSD_VISIBLE
int _EXFUN(settimeofday, (const struct timeval *, const struct timezone *));
int _EXFUN(adjtime, (const struct timeval *, struct timeval *));
#endif
int _EXFUN(utimes, (const char *__path, const struct timeval *__tvp));
int _EXFUN(getitimer, (int __which, struct itimerval *__value));
int _EXFUN(setitimer, (int __which, const struct itimerval *__restrict __value,
struct itimerval *__restrict __ovalue));
#ifdef __cplusplus #endif /* !_KERNEL */
} #include <machine/_time.h>
#endif
#endif /* _SYS_TIME_H_ */ #endif /* !_SYS_TIME_H_ */

View file

@ -15,11 +15,12 @@ extern "C" {
#define _SYS_TIMEB_H #define _SYS_TIMEB_H
#include <_ansi.h> #include <_ansi.h>
#include <machine/types.h> #include <sys/_types.h>
#ifndef __time_t_defined #if !defined(__time_t_defined) && !defined(_TIME_T_DECLARED)
typedef _TIME_T_ time_t; typedef _TIME_T_ time_t;
#define __time_t_defined #define __time_t_defined
#define _TIME_T_DECLARED
#endif #endif
struct timeb struct timeb

View file

@ -5,11 +5,12 @@ extern "C" {
#define _SYS_TIMES_H #define _SYS_TIMES_H
#include <_ansi.h> #include <_ansi.h>
#include <machine/types.h> #include <sys/_types.h>
#ifndef __clock_t_defined #if !defined(__clock_t_defined) && !defined(_CLOCK_T_DECLARED)
typedef _CLOCK_T_ clock_t; typedef _CLOCK_T_ clock_t;
#define __clock_t_defined #define __clock_t_defined
#define _CLOCK_T_DECLARED
#endif #endif
/* Get Process Times, P1003.1b-1993, p. 92 */ /* Get Process Times, P1003.1b-1993, p. 92 */

View file

@ -0,0 +1,63 @@
/*-
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)time.h 8.5 (Berkeley) 5/4/95
* from: FreeBSD: src/sys/sys/time.h,v 1.43 2000/03/20 14:09:05 phk Exp
* $FreeBSD$
*/
#ifndef _SYS_TIMESPEC_H_
#define _SYS_TIMESPEC_H_
#include <sys/cdefs.h>
#include <sys/_timespec.h>
#if __BSD_VISIBLE
#define TIMEVAL_TO_TIMESPEC(tv, ts) \
do { \
(ts)->tv_sec = (tv)->tv_sec; \
(ts)->tv_nsec = (tv)->tv_usec * 1000; \
} while (0)
#define TIMESPEC_TO_TIMEVAL(tv, ts) \
do { \
(tv)->tv_sec = (ts)->tv_sec; \
(tv)->tv_usec = (ts)->tv_nsec / 1000; \
} while (0)
#endif /* __BSD_VISIBLE */
/*
* Structure defined by POSIX.1b to be like a itimerval, but with
* timespecs. Used in the timer_*() system calls.
*/
struct itimerspec {
struct timespec it_interval;
struct timespec it_value;
};
#endif /* _SYS_TIMESPEC_H_ */

View file

@ -0,0 +1,801 @@
/* $NetBSD: tree.h,v 1.8 2004/03/28 19:38:30 provos Exp $ */
/* $OpenBSD: tree.h,v 1.7 2002/10/17 21:51:54 art Exp $ */
/* $FreeBSD$ */
/*-
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _SYS_TREE_H_
#define _SYS_TREE_H_
#include <sys/cdefs.h>
/*
* This file defines data structures for different types of trees:
* splay trees and red-black trees.
*
* A splay tree is a self-organizing data structure. Every operation
* on the tree causes a splay to happen. The splay moves the requested
* node to the root of the tree and partly rebalances it.
*
* This has the benefit that request locality causes faster lookups as
* the requested nodes move to the top of the tree. On the other hand,
* every lookup causes memory writes.
*
* The Balance Theorem bounds the total access time for m operations
* and n inserts on an initially empty tree as O((m + n)lg n). The
* amortized cost for a sequence of m accesses to a splay tree is O(lg n);
*
* A red-black tree is a binary search tree with the node color as an
* extra attribute. It fulfills a set of conditions:
* - every search path from the root to a leaf consists of the
* same number of black nodes,
* - each red node (except for the root) has a black parent,
* - each leaf node is black.
*
* Every operation on a red-black tree is bounded as O(lg n).
* The maximum height of a red-black tree is 2lg (n+1).
*/
#define SPLAY_HEAD(name, type) \
struct name { \
struct type *sph_root; /* root of the tree */ \
}
#define SPLAY_INITIALIZER(root) \
{ NULL }
#define SPLAY_INIT(root) do { \
(root)->sph_root = NULL; \
} while (/*CONSTCOND*/ 0)
#define SPLAY_ENTRY(type) \
struct { \
struct type *spe_left; /* left element */ \
struct type *spe_right; /* right element */ \
}
#define SPLAY_LEFT(elm, field) (elm)->field.spe_left
#define SPLAY_RIGHT(elm, field) (elm)->field.spe_right
#define SPLAY_ROOT(head) (head)->sph_root
#define SPLAY_EMPTY(head) (SPLAY_ROOT(head) == NULL)
/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */
#define SPLAY_ROTATE_RIGHT(head, tmp, field) do { \
SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \
SPLAY_RIGHT(tmp, field) = (head)->sph_root; \
(head)->sph_root = tmp; \
} while (/*CONSTCOND*/ 0)
#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \
SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \
SPLAY_LEFT(tmp, field) = (head)->sph_root; \
(head)->sph_root = tmp; \
} while (/*CONSTCOND*/ 0)
#define SPLAY_LINKLEFT(head, tmp, field) do { \
SPLAY_LEFT(tmp, field) = (head)->sph_root; \
tmp = (head)->sph_root; \
(head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \
} while (/*CONSTCOND*/ 0)
#define SPLAY_LINKRIGHT(head, tmp, field) do { \
SPLAY_RIGHT(tmp, field) = (head)->sph_root; \
tmp = (head)->sph_root; \
(head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \
} while (/*CONSTCOND*/ 0)
#define SPLAY_ASSEMBLE(head, node, left, right, field) do { \
SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field); \
SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field);\
SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field); \
SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field); \
} while (/*CONSTCOND*/ 0)
/* Generates prototypes and inline functions */
#define SPLAY_PROTOTYPE(name, type, field, cmp) \
void name##_SPLAY(struct name *, struct type *); \
void name##_SPLAY_MINMAX(struct name *, int); \
struct type *name##_SPLAY_INSERT(struct name *, struct type *); \
struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \
\
/* Finds the node with the same key as elm */ \
static __inline struct type * \
name##_SPLAY_FIND(struct name *head, struct type *elm) \
{ \
if (SPLAY_EMPTY(head)) \
return(NULL); \
name##_SPLAY(head, elm); \
if ((cmp)(elm, (head)->sph_root) == 0) \
return (head->sph_root); \
return (NULL); \
} \
\
static __inline struct type * \
name##_SPLAY_NEXT(struct name *head, struct type *elm) \
{ \
name##_SPLAY(head, elm); \
if (SPLAY_RIGHT(elm, field) != NULL) { \
elm = SPLAY_RIGHT(elm, field); \
while (SPLAY_LEFT(elm, field) != NULL) { \
elm = SPLAY_LEFT(elm, field); \
} \
} else \
elm = NULL; \
return (elm); \
} \
\
static __inline struct type * \
name##_SPLAY_MIN_MAX(struct name *head, int val) \
{ \
name##_SPLAY_MINMAX(head, val); \
return (SPLAY_ROOT(head)); \
}
/* Main splay operation.
* Moves node close to the key of elm to top
*/
#define SPLAY_GENERATE(name, type, field, cmp) \
struct type * \
name##_SPLAY_INSERT(struct name *head, struct type *elm) \
{ \
if (SPLAY_EMPTY(head)) { \
SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \
} else { \
int __comp; \
name##_SPLAY(head, elm); \
__comp = (cmp)(elm, (head)->sph_root); \
if(__comp < 0) { \
SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field);\
SPLAY_RIGHT(elm, field) = (head)->sph_root; \
SPLAY_LEFT((head)->sph_root, field) = NULL; \
} else if (__comp > 0) { \
SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field);\
SPLAY_LEFT(elm, field) = (head)->sph_root; \
SPLAY_RIGHT((head)->sph_root, field) = NULL; \
} else \
return ((head)->sph_root); \
} \
(head)->sph_root = (elm); \
return (NULL); \
} \
\
struct type * \
name##_SPLAY_REMOVE(struct name *head, struct type *elm) \
{ \
struct type *__tmp; \
if (SPLAY_EMPTY(head)) \
return (NULL); \
name##_SPLAY(head, elm); \
if ((cmp)(elm, (head)->sph_root) == 0) { \
if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \
(head)->sph_root = SPLAY_RIGHT((head)->sph_root, field);\
} else { \
__tmp = SPLAY_RIGHT((head)->sph_root, field); \
(head)->sph_root = SPLAY_LEFT((head)->sph_root, field);\
name##_SPLAY(head, elm); \
SPLAY_RIGHT((head)->sph_root, field) = __tmp; \
} \
return (elm); \
} \
return (NULL); \
} \
\
void \
name##_SPLAY(struct name *head, struct type *elm) \
{ \
struct type __node, *__left, *__right, *__tmp; \
int __comp; \
\
SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\
__left = __right = &__node; \
\
while ((__comp = (cmp)(elm, (head)->sph_root)) != 0) { \
if (__comp < 0) { \
__tmp = SPLAY_LEFT((head)->sph_root, field); \
if (__tmp == NULL) \
break; \
if ((cmp)(elm, __tmp) < 0){ \
SPLAY_ROTATE_RIGHT(head, __tmp, field); \
if (SPLAY_LEFT((head)->sph_root, field) == NULL)\
break; \
} \
SPLAY_LINKLEFT(head, __right, field); \
} else if (__comp > 0) { \
__tmp = SPLAY_RIGHT((head)->sph_root, field); \
if (__tmp == NULL) \
break; \
if ((cmp)(elm, __tmp) > 0){ \
SPLAY_ROTATE_LEFT(head, __tmp, field); \
if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\
break; \
} \
SPLAY_LINKRIGHT(head, __left, field); \
} \
} \
SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \
} \
\
/* Splay with either the minimum or the maximum element \
* Used to find minimum or maximum element in tree. \
*/ \
void name##_SPLAY_MINMAX(struct name *head, int __comp) \
{ \
struct type __node, *__left, *__right, *__tmp; \
\
SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\
__left = __right = &__node; \
\
while (1) { \
if (__comp < 0) { \
__tmp = SPLAY_LEFT((head)->sph_root, field); \
if (__tmp == NULL) \
break; \
if (__comp < 0){ \
SPLAY_ROTATE_RIGHT(head, __tmp, field); \
if (SPLAY_LEFT((head)->sph_root, field) == NULL)\
break; \
} \
SPLAY_LINKLEFT(head, __right, field); \
} else if (__comp > 0) { \
__tmp = SPLAY_RIGHT((head)->sph_root, field); \
if (__tmp == NULL) \
break; \
if (__comp > 0) { \
SPLAY_ROTATE_LEFT(head, __tmp, field); \
if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\
break; \
} \
SPLAY_LINKRIGHT(head, __left, field); \
} \
} \
SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \
}
#define SPLAY_NEGINF -1
#define SPLAY_INF 1
#define SPLAY_INSERT(name, x, y) name##_SPLAY_INSERT(x, y)
#define SPLAY_REMOVE(name, x, y) name##_SPLAY_REMOVE(x, y)
#define SPLAY_FIND(name, x, y) name##_SPLAY_FIND(x, y)
#define SPLAY_NEXT(name, x, y) name##_SPLAY_NEXT(x, y)
#define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ? NULL \
: name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF))
#define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ? NULL \
: name##_SPLAY_MIN_MAX(x, SPLAY_INF))
#define SPLAY_FOREACH(x, name, head) \
for ((x) = SPLAY_MIN(name, head); \
(x) != NULL; \
(x) = SPLAY_NEXT(name, head, x))
/* Macros that define a red-black tree */
#define RB_HEAD(name, type) \
struct name { \
struct type *rbh_root; /* root of the tree */ \
}
#define RB_INITIALIZER(root) \
{ NULL }
#define RB_INIT(root) do { \
(root)->rbh_root = NULL; \
} while (/*CONSTCOND*/ 0)
#define RB_BLACK 0
#define RB_RED 1
#define RB_ENTRY(type) \
struct { \
struct type *rbe_left; /* left element */ \
struct type *rbe_right; /* right element */ \
struct type *rbe_parent; /* parent element */ \
int rbe_color; /* node color */ \
}
#define RB_LEFT(elm, field) (elm)->field.rbe_left
#define RB_RIGHT(elm, field) (elm)->field.rbe_right
#define RB_PARENT(elm, field) (elm)->field.rbe_parent
#define RB_COLOR(elm, field) (elm)->field.rbe_color
#define RB_ROOT(head) (head)->rbh_root
#define RB_EMPTY(head) (RB_ROOT(head) == NULL)
#define RB_SET(elm, parent, field) do { \
RB_PARENT(elm, field) = parent; \
RB_LEFT(elm, field) = RB_RIGHT(elm, field) = NULL; \
RB_COLOR(elm, field) = RB_RED; \
} while (/*CONSTCOND*/ 0)
#define RB_SET_BLACKRED(black, red, field) do { \
RB_COLOR(black, field) = RB_BLACK; \
RB_COLOR(red, field) = RB_RED; \
} while (/*CONSTCOND*/ 0)
#ifndef RB_AUGMENT
#define RB_AUGMENT(x) do {} while (0)
#endif
#define RB_ROTATE_LEFT(head, elm, tmp, field) do { \
(tmp) = RB_RIGHT(elm, field); \
if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field)) != NULL) { \
RB_PARENT(RB_LEFT(tmp, field), field) = (elm); \
} \
RB_AUGMENT(elm); \
if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \
if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \
RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \
else \
RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \
} else \
(head)->rbh_root = (tmp); \
RB_LEFT(tmp, field) = (elm); \
RB_PARENT(elm, field) = (tmp); \
RB_AUGMENT(tmp); \
if ((RB_PARENT(tmp, field))) \
RB_AUGMENT(RB_PARENT(tmp, field)); \
} while (/*CONSTCOND*/ 0)
#define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \
(tmp) = RB_LEFT(elm, field); \
if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field)) != NULL) { \
RB_PARENT(RB_RIGHT(tmp, field), field) = (elm); \
} \
RB_AUGMENT(elm); \
if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \
if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \
RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \
else \
RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \
} else \
(head)->rbh_root = (tmp); \
RB_RIGHT(tmp, field) = (elm); \
RB_PARENT(elm, field) = (tmp); \
RB_AUGMENT(tmp); \
if ((RB_PARENT(tmp, field))) \
RB_AUGMENT(RB_PARENT(tmp, field)); \
} while (/*CONSTCOND*/ 0)
/* Generates prototypes and inline functions */
#define RB_PROTOTYPE(name, type, field, cmp) \
RB_PROTOTYPE_INTERNAL(name, type, field, cmp,)
#define RB_PROTOTYPE_STATIC(name, type, field, cmp) \
RB_PROTOTYPE_INTERNAL(name, type, field, cmp, __unused static)
#define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr) \
RB_PROTOTYPE_INSERT_COLOR(name, type, attr); \
RB_PROTOTYPE_REMOVE_COLOR(name, type, attr); \
RB_PROTOTYPE_INSERT(name, type, attr); \
RB_PROTOTYPE_REMOVE(name, type, attr); \
RB_PROTOTYPE_FIND(name, type, attr); \
RB_PROTOTYPE_NFIND(name, type, attr); \
RB_PROTOTYPE_NEXT(name, type, attr); \
RB_PROTOTYPE_PREV(name, type, attr); \
RB_PROTOTYPE_MINMAX(name, type, attr);
#define RB_PROTOTYPE_INSERT_COLOR(name, type, attr) \
attr void name##_RB_INSERT_COLOR(struct name *, struct type *)
#define RB_PROTOTYPE_REMOVE_COLOR(name, type, attr) \
attr void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *)
#define RB_PROTOTYPE_REMOVE(name, type, attr) \
attr struct type *name##_RB_REMOVE(struct name *, struct type *)
#define RB_PROTOTYPE_INSERT(name, type, attr) \
attr struct type *name##_RB_INSERT(struct name *, struct type *)
#define RB_PROTOTYPE_FIND(name, type, attr) \
attr struct type *name##_RB_FIND(struct name *, struct type *)
#define RB_PROTOTYPE_NFIND(name, type, attr) \
attr struct type *name##_RB_NFIND(struct name *, struct type *)
#define RB_PROTOTYPE_NEXT(name, type, attr) \
attr struct type *name##_RB_NEXT(struct type *)
#define RB_PROTOTYPE_PREV(name, type, attr) \
attr struct type *name##_RB_PREV(struct type *)
#define RB_PROTOTYPE_MINMAX(name, type, attr) \
attr struct type *name##_RB_MINMAX(struct name *, int)
/* Main rb operation.
* Moves node close to the key of elm to top
*/
#define RB_GENERATE(name, type, field, cmp) \
RB_GENERATE_INTERNAL(name, type, field, cmp,)
#define RB_GENERATE_STATIC(name, type, field, cmp) \
RB_GENERATE_INTERNAL(name, type, field, cmp, __unused static)
#define RB_GENERATE_INTERNAL(name, type, field, cmp, attr) \
RB_GENERATE_INSERT_COLOR(name, type, field, attr) \
RB_GENERATE_REMOVE_COLOR(name, type, field, attr) \
RB_GENERATE_INSERT(name, type, field, cmp, attr) \
RB_GENERATE_REMOVE(name, type, field, attr) \
RB_GENERATE_FIND(name, type, field, cmp, attr) \
RB_GENERATE_NFIND(name, type, field, cmp, attr) \
RB_GENERATE_NEXT(name, type, field, attr) \
RB_GENERATE_PREV(name, type, field, attr) \
RB_GENERATE_MINMAX(name, type, field, attr)
#define RB_GENERATE_INSERT_COLOR(name, type, field, attr) \
attr void \
name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \
{ \
struct type *parent, *gparent, *tmp; \
while ((parent = RB_PARENT(elm, field)) != NULL && \
RB_COLOR(parent, field) == RB_RED) { \
gparent = RB_PARENT(parent, field); \
if (parent == RB_LEFT(gparent, field)) { \
tmp = RB_RIGHT(gparent, field); \
if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
RB_COLOR(tmp, field) = RB_BLACK; \
RB_SET_BLACKRED(parent, gparent, field);\
elm = gparent; \
continue; \
} \
if (RB_RIGHT(parent, field) == elm) { \
RB_ROTATE_LEFT(head, parent, tmp, field);\
tmp = parent; \
parent = elm; \
elm = tmp; \
} \
RB_SET_BLACKRED(parent, gparent, field); \
RB_ROTATE_RIGHT(head, gparent, tmp, field); \
} else { \
tmp = RB_LEFT(gparent, field); \
if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
RB_COLOR(tmp, field) = RB_BLACK; \
RB_SET_BLACKRED(parent, gparent, field);\
elm = gparent; \
continue; \
} \
if (RB_LEFT(parent, field) == elm) { \
RB_ROTATE_RIGHT(head, parent, tmp, field);\
tmp = parent; \
parent = elm; \
elm = tmp; \
} \
RB_SET_BLACKRED(parent, gparent, field); \
RB_ROTATE_LEFT(head, gparent, tmp, field); \
} \
} \
RB_COLOR(head->rbh_root, field) = RB_BLACK; \
}
#define RB_GENERATE_REMOVE_COLOR(name, type, field, attr) \
attr void \
name##_RB_REMOVE_COLOR(struct name *head, struct type *parent, struct type *elm) \
{ \
struct type *tmp; \
while ((elm == NULL || RB_COLOR(elm, field) == RB_BLACK) && \
elm != RB_ROOT(head)) { \
if (RB_LEFT(parent, field) == elm) { \
tmp = RB_RIGHT(parent, field); \
if (RB_COLOR(tmp, field) == RB_RED) { \
RB_SET_BLACKRED(tmp, parent, field); \
RB_ROTATE_LEFT(head, parent, tmp, field);\
tmp = RB_RIGHT(parent, field); \
} \
if ((RB_LEFT(tmp, field) == NULL || \
RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\
(RB_RIGHT(tmp, field) == NULL || \
RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\
RB_COLOR(tmp, field) = RB_RED; \
elm = parent; \
parent = RB_PARENT(elm, field); \
} else { \
if (RB_RIGHT(tmp, field) == NULL || \
RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK) {\
struct type *oleft; \
if ((oleft = RB_LEFT(tmp, field)) \
!= NULL) \
RB_COLOR(oleft, field) = RB_BLACK;\
RB_COLOR(tmp, field) = RB_RED; \
RB_ROTATE_RIGHT(head, tmp, oleft, field);\
tmp = RB_RIGHT(parent, field); \
} \
RB_COLOR(tmp, field) = RB_COLOR(parent, field);\
RB_COLOR(parent, field) = RB_BLACK; \
if (RB_RIGHT(tmp, field)) \
RB_COLOR(RB_RIGHT(tmp, field), field) = RB_BLACK;\
RB_ROTATE_LEFT(head, parent, tmp, field);\
elm = RB_ROOT(head); \
break; \
} \
} else { \
tmp = RB_LEFT(parent, field); \
if (RB_COLOR(tmp, field) == RB_RED) { \
RB_SET_BLACKRED(tmp, parent, field); \
RB_ROTATE_RIGHT(head, parent, tmp, field);\
tmp = RB_LEFT(parent, field); \
} \
if ((RB_LEFT(tmp, field) == NULL || \
RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\
(RB_RIGHT(tmp, field) == NULL || \
RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\
RB_COLOR(tmp, field) = RB_RED; \
elm = parent; \
parent = RB_PARENT(elm, field); \
} else { \
if (RB_LEFT(tmp, field) == NULL || \
RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) {\
struct type *oright; \
if ((oright = RB_RIGHT(tmp, field)) \
!= NULL) \
RB_COLOR(oright, field) = RB_BLACK;\
RB_COLOR(tmp, field) = RB_RED; \
RB_ROTATE_LEFT(head, tmp, oright, field);\
tmp = RB_LEFT(parent, field); \
} \
RB_COLOR(tmp, field) = RB_COLOR(parent, field);\
RB_COLOR(parent, field) = RB_BLACK; \
if (RB_LEFT(tmp, field)) \
RB_COLOR(RB_LEFT(tmp, field), field) = RB_BLACK;\
RB_ROTATE_RIGHT(head, parent, tmp, field);\
elm = RB_ROOT(head); \
break; \
} \
} \
} \
if (elm) \
RB_COLOR(elm, field) = RB_BLACK; \
}
#define RB_GENERATE_REMOVE(name, type, field, attr) \
attr struct type * \
name##_RB_REMOVE(struct name *head, struct type *elm) \
{ \
struct type *child, *parent, *old = elm; \
int color; \
if (RB_LEFT(elm, field) == NULL) \
child = RB_RIGHT(elm, field); \
else if (RB_RIGHT(elm, field) == NULL) \
child = RB_LEFT(elm, field); \
else { \
struct type *left; \
elm = RB_RIGHT(elm, field); \
while ((left = RB_LEFT(elm, field)) != NULL) \
elm = left; \
child = RB_RIGHT(elm, field); \
parent = RB_PARENT(elm, field); \
color = RB_COLOR(elm, field); \
if (child) \
RB_PARENT(child, field) = parent; \
if (parent) { \
if (RB_LEFT(parent, field) == elm) \
RB_LEFT(parent, field) = child; \
else \
RB_RIGHT(parent, field) = child; \
RB_AUGMENT(parent); \
} else \
RB_ROOT(head) = child; \
if (RB_PARENT(elm, field) == old) \
parent = elm; \
(elm)->field = (old)->field; \
if (RB_PARENT(old, field)) { \
if (RB_LEFT(RB_PARENT(old, field), field) == old)\
RB_LEFT(RB_PARENT(old, field), field) = elm;\
else \
RB_RIGHT(RB_PARENT(old, field), field) = elm;\
RB_AUGMENT(RB_PARENT(old, field)); \
} else \
RB_ROOT(head) = elm; \
RB_PARENT(RB_LEFT(old, field), field) = elm; \
if (RB_RIGHT(old, field)) \
RB_PARENT(RB_RIGHT(old, field), field) = elm; \
if (parent) { \
left = parent; \
do { \
RB_AUGMENT(left); \
} while ((left = RB_PARENT(left, field)) != NULL); \
} \
goto color; \
} \
parent = RB_PARENT(elm, field); \
color = RB_COLOR(elm, field); \
if (child) \
RB_PARENT(child, field) = parent; \
if (parent) { \
if (RB_LEFT(parent, field) == elm) \
RB_LEFT(parent, field) = child; \
else \
RB_RIGHT(parent, field) = child; \
RB_AUGMENT(parent); \
} else \
RB_ROOT(head) = child; \
color: \
if (color == RB_BLACK) \
name##_RB_REMOVE_COLOR(head, parent, child); \
return (old); \
} \
#define RB_GENERATE_INSERT(name, type, field, cmp, attr) \
/* Inserts a node into the RB tree */ \
attr struct type * \
name##_RB_INSERT(struct name *head, struct type *elm) \
{ \
struct type *tmp; \
struct type *parent = NULL; \
int comp = 0; \
tmp = RB_ROOT(head); \
while (tmp) { \
parent = tmp; \
comp = (cmp)(elm, parent); \
if (comp < 0) \
tmp = RB_LEFT(tmp, field); \
else if (comp > 0) \
tmp = RB_RIGHT(tmp, field); \
else \
return (tmp); \
} \
RB_SET(elm, parent, field); \
if (parent != NULL) { \
if (comp < 0) \
RB_LEFT(parent, field) = elm; \
else \
RB_RIGHT(parent, field) = elm; \
RB_AUGMENT(parent); \
} else \
RB_ROOT(head) = elm; \
name##_RB_INSERT_COLOR(head, elm); \
return (NULL); \
}
#define RB_GENERATE_FIND(name, type, field, cmp, attr) \
/* Finds the node with the same key as elm */ \
attr struct type * \
name##_RB_FIND(struct name *head, struct type *elm) \
{ \
struct type *tmp = RB_ROOT(head); \
int comp; \
while (tmp) { \
comp = cmp(elm, tmp); \
if (comp < 0) \
tmp = RB_LEFT(tmp, field); \
else if (comp > 0) \
tmp = RB_RIGHT(tmp, field); \
else \
return (tmp); \
} \
return (NULL); \
}
#define RB_GENERATE_NFIND(name, type, field, cmp, attr) \
/* Finds the first node greater than or equal to the search key */ \
attr struct type * \
name##_RB_NFIND(struct name *head, struct type *elm) \
{ \
struct type *tmp = RB_ROOT(head); \
struct type *res = NULL; \
int comp; \
while (tmp) { \
comp = cmp(elm, tmp); \
if (comp < 0) { \
res = tmp; \
tmp = RB_LEFT(tmp, field); \
} \
else if (comp > 0) \
tmp = RB_RIGHT(tmp, field); \
else \
return (tmp); \
} \
return (res); \
}
#define RB_GENERATE_NEXT(name, type, field, attr) \
/* ARGSUSED */ \
attr struct type * \
name##_RB_NEXT(struct type *elm) \
{ \
if (RB_RIGHT(elm, field)) { \
elm = RB_RIGHT(elm, field); \
while (RB_LEFT(elm, field)) \
elm = RB_LEFT(elm, field); \
} else { \
if (RB_PARENT(elm, field) && \
(elm == RB_LEFT(RB_PARENT(elm, field), field))) \
elm = RB_PARENT(elm, field); \
else { \
while (RB_PARENT(elm, field) && \
(elm == RB_RIGHT(RB_PARENT(elm, field), field)))\
elm = RB_PARENT(elm, field); \
elm = RB_PARENT(elm, field); \
} \
} \
return (elm); \
}
#define RB_GENERATE_PREV(name, type, field, attr) \
/* ARGSUSED */ \
attr struct type * \
name##_RB_PREV(struct type *elm) \
{ \
if (RB_LEFT(elm, field)) { \
elm = RB_LEFT(elm, field); \
while (RB_RIGHT(elm, field)) \
elm = RB_RIGHT(elm, field); \
} else { \
if (RB_PARENT(elm, field) && \
(elm == RB_RIGHT(RB_PARENT(elm, field), field))) \
elm = RB_PARENT(elm, field); \
else { \
while (RB_PARENT(elm, field) && \
(elm == RB_LEFT(RB_PARENT(elm, field), field)))\
elm = RB_PARENT(elm, field); \
elm = RB_PARENT(elm, field); \
} \
} \
return (elm); \
}
#define RB_GENERATE_MINMAX(name, type, field, attr) \
attr struct type * \
name##_RB_MINMAX(struct name *head, int val) \
{ \
struct type *tmp = RB_ROOT(head); \
struct type *parent = NULL; \
while (tmp) { \
parent = tmp; \
if (val < 0) \
tmp = RB_LEFT(tmp, field); \
else \
tmp = RB_RIGHT(tmp, field); \
} \
return (parent); \
}
#define RB_NEGINF -1
#define RB_INF 1
#define RB_INSERT(name, x, y) name##_RB_INSERT(x, y)
#define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y)
#define RB_FIND(name, x, y) name##_RB_FIND(x, y)
#define RB_NFIND(name, x, y) name##_RB_NFIND(x, y)
#define RB_NEXT(name, x, y) name##_RB_NEXT(y)
#define RB_PREV(name, x, y) name##_RB_PREV(y)
#define RB_MIN(name, x) name##_RB_MINMAX(x, RB_NEGINF)
#define RB_MAX(name, x) name##_RB_MINMAX(x, RB_INF)
#define RB_FOREACH(x, name, head) \
for ((x) = RB_MIN(name, head); \
(x) != NULL; \
(x) = name##_RB_NEXT(x))
#define RB_FOREACH_FROM(x, name, y) \
for ((x) = (y); \
((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \
(x) = (y))
#define RB_FOREACH_SAFE(x, name, head, y) \
for ((x) = RB_MIN(name, head); \
((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \
(x) = (y))
#define RB_FOREACH_REVERSE(x, name, head) \
for ((x) = RB_MAX(name, head); \
(x) != NULL; \
(x) = name##_RB_PREV(x))
#define RB_FOREACH_REVERSE_FROM(x, name, y) \
for ((x) = (y); \
((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \
(x) = (y))
#define RB_FOREACH_REVERSE_SAFE(x, name, head, y) \
for ((x) = RB_MAX(name, head); \
((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \
(x) = (y))
#endif /* _SYS_TREE_H_ */

View file

@ -18,20 +18,12 @@
#ifndef _SYS_TYPES_H #ifndef _SYS_TYPES_H
#include <_ansi.h> #include <_ansi.h>
#include <sys/cdefs.h>
#ifndef __INTTYPES_DEFINED__
#define __INTTYPES_DEFINED__
#include <machine/_types.h> #include <machine/_types.h>
#if defined(__rtems__) || defined(__XMK__) /* BSD types permitted by POSIX and always exposed as in Glibc. Only provided
/* for backward compatibility with BSD code. The uintN_t standard types should
* The following section is RTEMS specific and is needed to more be preferred in new code. */
* closely match the types defined in the BSD sys/types.h.
* This is needed to let the RTEMS/BSD TCP/IP stack compile.
*/
/* deprecated */
#if ___int8_t_defined #if ___int8_t_defined
typedef __uint8_t u_int8_t; typedef __uint8_t u_int8_t;
#endif #endif
@ -41,52 +33,54 @@ typedef __uint16_t u_int16_t;
#if ___int32_t_defined #if ___int32_t_defined
typedef __uint32_t u_int32_t; typedef __uint32_t u_int32_t;
#endif #endif
#if ___int64_t_defined #if ___int64_t_defined
typedef __uint64_t u_int64_t; typedef __uint64_t u_int64_t;
#endif
typedef int register_t;
#define __BIT_TYPES_DEFINED__ 1
#if defined(__rtems__) || defined(__XMK__)
/*
* The following section is RTEMS specific and is needed to more
* closely match the types defined in the BSD sys/types.h.
* This is needed to let the RTEMS/BSD TCP/IP stack compile.
*/
/* deprecated */ /* deprecated */
#if ___int64_t_defined
typedef __uint64_t u_quad_t; typedef __uint64_t u_quad_t;
typedef __int64_t quad_t; typedef __int64_t quad_t;
typedef quad_t * qaddr_t; typedef quad_t * qaddr_t;
#endif #endif
#endif #endif /* __rtems__ || __XMK__ */
#endif /* ! __INTTYPES_DEFINED */
#ifndef __need_inttypes #ifndef __need_inttypes
#define _SYS_TYPES_H #define _SYS_TYPES_H
/* <stddef.h> must be before <sys/_types.h> for __size_t considerations */
#include <stddef.h>
#include <sys/_types.h> #include <sys/_types.h>
#include <sys/_stdint.h>
#ifdef __i386__ #if __BSD_VISIBLE
#if defined (GO32) || defined (__MSDOS__) #include <machine/endian.h>
#define __MS_types__ #include <sys/select.h>
#endif
#endif
# include <stddef.h>
# include <machine/types.h>
/* To ensure the stat struct's layout doesn't change when sizeof(int), etc.
changes, we assume sizeof short and long never change and have all types
used to define struct stat use them and not int where possible.
Where not possible, _ST_INTxx are used. It would be preferable to not have
such assumptions, but until the extra fluff is necessary, it's avoided.
No 64 bit targets use stat yet. What to do about them is postponed
until necessary. */
#ifdef __GNUC__
#define _ST_INT32 __attribute__ ((__mode__ (__SI__)))
#else
#define _ST_INT32
#endif
# ifndef _POSIX_SOURCE
# define physadr physadr_t # define physadr physadr_t
# define quad quad_t # define quad quad_t
#ifndef _IN_ADDR_T_DECLARED
typedef __uint32_t in_addr_t; /* base type for internet address */
#define _IN_ADDR_T_DECLARED
#endif
#ifndef _IN_PORT_T_DECLARED
typedef __uint16_t in_port_t;
#define _IN_PORT_T_DECLARED
#endif
#endif /* __BSD_VISIBLE */
#if __MISC_VISIBLE
#ifndef _BSDTYPES_DEFINED #ifndef _BSDTYPES_DEFINED
/* also defined in mingw/gmon.h and in w32api/winsock[2].h */ /* also defined in mingw/gmon.h and in w32api/winsock[2].h */
#ifndef __u_char_defined #ifndef __u_char_defined
@ -107,36 +101,35 @@ typedef unsigned long u_long;
#endif #endif
#define _BSDTYPES_DEFINED #define _BSDTYPES_DEFINED
#endif #endif
#endif /*__BSD_VISIBLE || __CYGWIN__ */
#if __MISC_VISIBLE
typedef unsigned short ushort; /* System V compatibility */ typedef unsigned short ushort; /* System V compatibility */
typedef unsigned int uint; /* System V compatibility */ typedef unsigned int uint; /* System V compatibility */
typedef unsigned long ulong; /* System V compatibility */ typedef unsigned long ulong; /* System V compatibility */
# endif /*!_POSIX_SOURCE */
#ifndef __clock_t_defined
typedef _CLOCK_T_ clock_t;
#define __clock_t_defined
#endif #endif
#ifndef __time_t_defined #ifndef _BLKCNT_T_DECLARED
typedef _TIME_T_ time_t; typedef __blkcnt_t blkcnt_t;
#define __time_t_defined #define _BLKCNT_T_DECLARED
#endif #endif
#ifndef __timespec_defined #ifndef _BLKSIZE_T_DECLARED
#define __timespec_defined typedef __blksize_t blksize_t;
/* Time Value Specification Structures, P1003.1b-1993, p. 261 */ #define _BLKSIZE_T_DECLARED
struct timespec {
time_t tv_sec; /* Seconds */
long tv_nsec; /* Nanoseconds */
};
#endif #endif
struct itimerspec { #if !defined(__clock_t_defined) && !defined(_CLOCK_T_DECLARED)
struct timespec it_interval; /* Timer period */ typedef _CLOCK_T_ clock_t;
struct timespec it_value; /* Timer expiration */ #define __clock_t_defined
}; #define _CLOCK_T_DECLARED
#endif
#if !defined(__time_t_defined) && !defined(_TIME_T_DECLARED)
typedef _TIME_T_ time_t;
#define __time_t_defined
#define _TIME_T_DECLARED
#endif
#ifndef __daddr_t_defined #ifndef __daddr_t_defined
typedef long daddr_t; typedef long daddr_t;
@ -147,31 +140,27 @@ typedef char * caddr_t;
#define __caddr_t_defined #define __caddr_t_defined
#endif #endif
#ifndef __CYGWIN__ #ifndef _FSBLKCNT_T_DECLARED /* for statvfs() */
#if defined(__MS_types__) || defined(__rtems__) || \ typedef __fsblkcnt_t fsblkcnt_t;
defined(__sparc__) || defined(__SPU__) typedef __fsfilcnt_t fsfilcnt_t;
typedef unsigned long ino_t; #define _FSBLKCNT_T_DECLARED
#else
typedef unsigned short ino_t;
#endif #endif
#endif /*__CYGWIN__*/
#ifdef __MS_types__ #ifndef _ID_T_DECLARED
typedef __id_t id_t; /* can hold a uid_t or pid_t */
#define _ID_T_DECLARED
#endif
#ifndef _INO_T_DECLARED
typedef __ino_t ino_t; /* inode number */
#define _INO_T_DECLARED
#endif
#if defined(__i386__) && (defined(GO32) || defined(__MSDOS__))
typedef char * addr_t;
typedef unsigned long vm_offset_t; typedef unsigned long vm_offset_t;
typedef unsigned long vm_size_t; typedef unsigned long vm_size_t;
#endif /* __i386__ && (GO32 || __MSDOS__) */
#define __BIT_TYPES_DEFINED__
typedef signed char int8_t;
typedef unsigned char u_int8_t;
typedef short int16_t;
typedef unsigned short u_int16_t;
typedef int int32_t;
typedef unsigned int u_int32_t;
typedef long long int64_t;
typedef unsigned long long u_int64_t;
typedef int32_t register_t;
#endif /* __MS_types__ */
/* /*
* All these should be machine specific - right now they are all broken. * All these should be machine specific - right now they are all broken.
@ -180,339 +169,75 @@ typedef int32_t register_t;
* how the file was compiled (e.g. -mint16 vs -mint32, etc.). * how the file was compiled (e.g. -mint16 vs -mint32, etc.).
*/ */
#ifndef __CYGWIN__ /* which defines these types in it's own types.h. */ #ifndef _OFF_T_DECLARED
typedef _off_t off_t; typedef __off_t off_t; /* file offset */
typedef __dev_t dev_t; #define _OFF_T_DECLARED
typedef __uid_t uid_t; #endif
typedef __gid_t gid_t; #ifndef _DEV_T_DECLARED
typedef __dev_t dev_t; /* device number or struct cdev */
#define _DEV_T_DECLARED
#endif
#ifndef _UID_T_DECLARED
typedef __uid_t uid_t; /* user id */
#define _UID_T_DECLARED
#endif
#ifndef _GID_T_DECLARED
typedef __gid_t gid_t; /* group id */
#define _GID_T_DECLARED
#endif #endif
#if defined(__XMK__) #ifndef _PID_T_DECLARED
typedef signed char pid_t; typedef __pid_t pid_t; /* process id */
#else #define _PID_T_DECLARED
typedef int pid_t;
#endif #endif
#if defined(__rtems__) #ifndef _KEY_T_DECLARED
typedef _mode_t mode_t; typedef __key_t key_t; /* IPC key */
#define _KEY_T_DECLARED
#endif #endif
#ifndef __CYGWIN__ #ifndef _SSIZE_T_DECLARED
typedef long key_t;
#endif
typedef _ssize_t ssize_t; typedef _ssize_t ssize_t;
#define _SSIZE_T_DECLARED
#if !defined(__CYGWIN__) && !defined(__rtems__)
#ifdef __MS_types__
typedef char * addr_t;
typedef int mode_t;
#else
#if defined (__sparc__) && !defined (__sparc_v9__)
#ifdef __svr4__
typedef unsigned long mode_t;
#else
typedef unsigned short mode_t;
#endif
#else
typedef unsigned int mode_t _ST_INT32;
#endif
#endif /* ! __MS_types__ */
#endif /*__CYGWIN__*/
typedef unsigned short nlink_t;
/* We don't define fd_set and friends if we are compiling POSIX
source, or if we have included (or may include as indicated
by __USE_W32_SOCKETS) the W32api winsock[2].h header which
defines Windows versions of them. Note that a program which
includes the W32api winsock[2].h header must know what it is doing;
it must not call the cygwin32 select function.
*/
# if !(defined (_POSIX_SOURCE) || defined (_WINSOCK_H) || defined (_WINSOCKAPI_) || defined (__USE_W32_SOCKETS))
# define _SYS_TYPES_FD_SET
# define NBBY 8 /* number of bits in a byte */
/*
* Select uses bit masks of file descriptors in longs.
* These macros manipulate such bit fields (the filesystem macros use chars).
* FD_SETSIZE may be defined by the user, but the default here
* should be >= NOFILE (param.h).
*/
# ifndef FD_SETSIZE
# define FD_SETSIZE 64
# endif
typedef long fd_mask;
# define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */
# ifndef howmany
# define howmany(x,y) (((x)+((y)-1))/(y))
# endif
/* We use a macro for fd_set so that including Sockets.h afterwards
can work. */
typedef struct _types_fd_set {
fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
} _types_fd_set;
#define fd_set _types_fd_set
# define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS)))
# define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS)))
# define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS)))
# define FD_ZERO(p) (__extension__ (void)({ \
size_t __i; \
char *__tmp = (char *)p; \
for (__i = 0; __i < sizeof (*(p)); ++__i) \
*__tmp++ = 0; \
}))
# endif /* !(defined (_POSIX_SOURCE) || defined (_WINSOCK_H) || defined (_WINSOCKAPI_) || defined (__USE_W32_SOCKETS)) */
#undef __MS_types__
#undef _ST_INT32
#ifndef __clockid_t_defined
typedef _CLOCKID_T_ clockid_t;
#define __clockid_t_defined
#endif #endif
#ifndef __timer_t_defined #ifndef _MODE_T_DECLARED
typedef _TIMER_T_ timer_t; typedef __mode_t mode_t; /* permissions */
#define __timer_t_defined #define _MODE_T_DECLARED
#endif #endif
typedef unsigned long useconds_t; #ifndef _NLINK_T_DECLARED
typedef long suseconds_t; typedef __nlink_t nlink_t; /* link count */
#define _NLINK_T_DECLARED
#endif
#if !defined(__clockid_t_defined) && !defined(_CLOCKID_T_DECLARED)
typedef __clockid_t clockid_t;
#define __clockid_t_defined
#define _CLOCKID_T_DECLARED
#endif
#if !defined(__timer_t_defined) && !defined(_TIMER_T_DECLARED)
typedef __timer_t timer_t;
#define __timer_t_defined
#define _TIMER_T_DECLARED
#endif
#ifndef _USECONDS_T_DECLARED
typedef __useconds_t useconds_t; /* microseconds (unsigned) */
#define _USECONDS_T_DECLARED
#endif
#ifndef _SUSECONDS_T_DECLARED
typedef __suseconds_t suseconds_t;
#define _SUSECONDS_T_DECLARED
#endif
typedef __int64_t sbintime_t;
#include <sys/features.h> #include <sys/features.h>
#include <sys/_pthreadtypes.h>
#include <machine/types.h>
/* Cygwin will probably never have full posix compliance due to little things
* like an inability to set the stackaddress. Cygwin is also using void *
* pointers rather than structs to ensure maximum binary compatability with
* previous releases.
* This means that we don't use the types defined here, but rather in
* <cygwin/types.h>
*/
#if defined(_POSIX_THREADS) && !defined(__CYGWIN__)
#include <sys/sched.h>
/*
* 2.5 Primitive System Data Types, P1003.1c/D10, p. 19.
*/
#if defined(__XMK__)
typedef unsigned int pthread_t; /* identify a thread */
#else
typedef __uint32_t pthread_t; /* identify a thread */
#endif
/* P1003.1c/D10, p. 118-119 */
#define PTHREAD_SCOPE_PROCESS 0
#define PTHREAD_SCOPE_SYSTEM 1
/* P1003.1c/D10, p. 111 */
#define PTHREAD_INHERIT_SCHED 1 /* scheduling policy and associated */
/* attributes are inherited from */
/* the calling thread. */
#define PTHREAD_EXPLICIT_SCHED 2 /* set from provided attribute object */
/* P1003.1c/D10, p. 141 */
#define PTHREAD_CREATE_DETACHED 0
#define PTHREAD_CREATE_JOINABLE 1
#if defined(__rtems__)
#include <sys/cpuset.h>
#endif
#if defined(__XMK__)
typedef struct pthread_attr_s {
int contentionscope;
struct sched_param schedparam;
int detachstate;
void *stackaddr;
size_t stacksize;
} pthread_attr_t;
#define PTHREAD_STACK_MIN 200
#else /* !defined(__XMK__) */
typedef struct {
int is_initialized;
void *stackaddr;
int stacksize;
int contentionscope;
int inheritsched;
int schedpolicy;
struct sched_param schedparam;
#if defined(__rtems__)
size_t guardsize;
#endif
/* P1003.4b/D8, p. 54 adds cputime_clock_allowed attribute. */
#if defined(_POSIX_THREAD_CPUTIME)
int cputime_clock_allowed; /* see time.h */
#endif
int detachstate;
#if defined(__rtems__)
size_t affinitysetsize;
cpu_set_t *affinityset;
cpu_set_t affinitysetpreallocated;
#endif
} pthread_attr_t;
#endif /* !defined(__XMK__) */
#if defined(_POSIX_THREAD_PROCESS_SHARED)
/* NOTE: P1003.1c/D10, p. 81 defines following values for process_shared. */
#define PTHREAD_PROCESS_PRIVATE 0 /* visible within only the creating process */
#define PTHREAD_PROCESS_SHARED 1 /* visible too all processes with access to */
/* the memory where the resource is */
/* located */
#endif
#if defined(_POSIX_THREAD_PRIO_PROTECT)
/* Mutexes */
/* Values for blocking protocol. */
#define PTHREAD_PRIO_NONE 0
#define PTHREAD_PRIO_INHERIT 1
#define PTHREAD_PRIO_PROTECT 2
#endif
#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES)
/* Values for mutex type */
/* The following defines are part of the X/Open System Interface (XSI). */
/*
* This type of mutex does not detect deadlock. A thread attempting to
* relock this mutex without first unlocking it shall deadlock. Attempting
* to unlock a mutex locked by a different thread results in undefined
* behavior. Attempting to unlock an unlocked mutex results in undefined
* behavior.
*/
#define PTHREAD_MUTEX_NORMAL 0
/*
* A thread attempting to relock this mutex without first unlocking
* it shall succeed in locking the mutex. The relocking deadlock which
* can occur with mutexes of type PTHREAD_MUTEX_NORMAL cannot occur with
* this type of mutex. Multiple locks of this mutex shall require the
* same number of unlocks to release the mutex before another thread can
* acquire the mutex. A thread attempting to unlock a mutex which another
* thread has locked shall return with an error. A thread attempting to
* unlock an unlocked mutex shall return with an error.
*/
#define PTHREAD_MUTEX_RECURSIVE 1
/*
* This type of mutex provides error checking. A thread attempting
* to relock this mutex without first unlocking it shall return with an
* error. A thread attempting to unlock a mutex which another thread has
* locked shall return with an error. A thread attempting to unlock an
* unlocked mutex shall return with an error.
*/
#define PTHREAD_MUTEX_ERRORCHECK 2
/*
* Attempting to recursively lock a mutex of this type results
* in undefined behavior. Attempting to unlock a mutex of this type
* which was not locked by the calling thread results in undefined
* behavior. Attempting to unlock a mutex of this type which is not locked
* results in undefined behavior. An implementation may map this mutex to
* one of the other mutex types.
*/
#define PTHREAD_MUTEX_DEFAULT 3
#endif /* !defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES) */
#if defined(__XMK__)
typedef unsigned int pthread_mutex_t; /* identify a mutex */
typedef struct {
int type;
} pthread_mutexattr_t;
#else /* !defined(__XMK__) */
typedef __uint32_t pthread_mutex_t; /* identify a mutex */
typedef struct {
int is_initialized;
#if defined(_POSIX_THREAD_PROCESS_SHARED)
int process_shared; /* allow mutex to be shared amongst processes */
#endif
#if defined(_POSIX_THREAD_PRIO_PROTECT)
int prio_ceiling;
int protocol;
#endif
#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES)
int type;
#endif
int recursive;
} pthread_mutexattr_t;
#endif /* !defined(__XMK__) */
/* Condition Variables */
typedef __uint32_t pthread_cond_t; /* identify a condition variable */
typedef struct {
int is_initialized;
#if defined(_POSIX_THREAD_PROCESS_SHARED)
int process_shared; /* allow this to be shared amongst processes */
#endif
} pthread_condattr_t; /* a condition attribute object */
/* Keys */
typedef __uint32_t pthread_key_t; /* thread-specific data keys */
typedef struct {
int is_initialized; /* is this structure initialized? */
int init_executed; /* has the initialization routine been run? */
} pthread_once_t; /* dynamic package initialization */
#else
#if defined (__CYGWIN__)
#include <cygwin/types.h>
#endif
#endif /* defined(_POSIX_THREADS) */
/* POSIX Barrier Types */
#if defined(_POSIX_BARRIERS)
typedef __uint32_t pthread_barrier_t; /* POSIX Barrier Object */
typedef struct {
int is_initialized; /* is this structure initialized? */
#if defined(_POSIX_THREAD_PROCESS_SHARED)
int process_shared; /* allow this to be shared amongst processes */
#endif
} pthread_barrierattr_t;
#endif /* defined(_POSIX_BARRIERS) */
/* POSIX Spin Lock Types */
#if !defined (__CYGWIN__)
#if defined(_POSIX_SPIN_LOCKS)
typedef __uint32_t pthread_spinlock_t; /* POSIX Spin Lock Object */
#endif /* defined(_POSIX_SPIN_LOCKS) */
/* POSIX Reader/Writer Lock Types */
#if defined(_POSIX_READER_WRITER_LOCKS)
typedef __uint32_t pthread_rwlock_t; /* POSIX RWLock Object */
typedef struct {
int is_initialized; /* is this structure initialized? */
#if defined(_POSIX_THREAD_PROCESS_SHARED)
int process_shared; /* allow this to be shared amongst processes */
#endif
} pthread_rwlockattr_t;
#endif /* defined(_POSIX_READER_WRITER_LOCKS) */
#endif /* __CYGWIN__ */
#endif /* !__need_inttypes */ #endif /* !__need_inttypes */

View file

@ -24,72 +24,89 @@ int _EXFUN(chmod, (const char *__path, mode_t __mode ));
#if !defined(__INSIDE_CYGWIN__) #if !defined(__INSIDE_CYGWIN__)
int _EXFUN(chown, (const char *__path, uid_t __owner, gid_t __group )); int _EXFUN(chown, (const char *__path, uid_t __owner, gid_t __group ));
#endif #endif
#if defined(__CYGWIN__) || defined(__rtems__) #if __BSD_VISIBLE || (__XSI_VISIBLE >= 4 && __POSIX_VISIBLE < 200112)
int _EXFUN(chroot, (const char *__path )); int _EXFUN(chroot, (const char *__path ));
#endif #endif
int _EXFUN(close, (int __fildes )); int _EXFUN(close, (int __fildes ));
#if defined(__CYGWIN__) #if __POSIX_VISIBLE >= 199209
size_t _EXFUN(confstr, (int __name, char *__buf, size_t __len)); size_t _EXFUN(confstr, (int __name, char *__buf, size_t __len));
#endif #endif
#if __XSI_VISIBLE
char * _EXFUN(crypt, (const char *__key, const char *__salt));
#endif
#if __XSI_VISIBLE && __XSI_VISIBLE < 700
char * _EXFUN(ctermid, (char *__s )); char * _EXFUN(ctermid, (char *__s ));
#endif
#if __XSI_VISIBLE && __XSI_VISIBLE < 600
char * _EXFUN(cuserid, (char *__s )); char * _EXFUN(cuserid, (char *__s ));
#if defined(__CYGWIN__) #endif
#if __BSD_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 500)
int _EXFUN(daemon, (int nochdir, int noclose)); int _EXFUN(daemon, (int nochdir, int noclose));
#endif #endif
int _EXFUN(dup, (int __fildes )); int _EXFUN(dup, (int __fildes ));
int _EXFUN(dup2, (int __fildes, int __fildes2 )); int _EXFUN(dup2, (int __fildes, int __fildes2 ));
#if defined(__CYGWIN__) #if __GNU_VISIBLE
int _EXFUN(dup3, (int __fildes, int __fildes2, int flags)); int _EXFUN(dup3, (int __fildes, int __fildes2, int flags));
int _EXFUN(eaccess, (const char *__path, int __mode)); int _EXFUN(eaccess, (const char *__path, int __mode));
#endif
#if __XSI_VISIBLE
void _EXFUN(encrypt, (char *__block, int __edflag));
#endif
#if __BSD_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 500)
void _EXFUN(endusershell, (void)); void _EXFUN(endusershell, (void));
#endif
#if __GNU_VISIBLE
int _EXFUN(euidaccess, (const char *__path, int __mode)); int _EXFUN(euidaccess, (const char *__path, int __mode));
#endif #endif
int _EXFUN(execl, (const char *__path, const char *, ... )); int _EXFUN(execl, (const char *__path, const char *, ... ));
int _EXFUN(execle, (const char *__path, const char *, ... )); int _EXFUN(execle, (const char *__path, const char *, ... ));
int _EXFUN(execlp, (const char *__file, const char *, ... )); int _EXFUN(execlp, (const char *__file, const char *, ... ));
#if defined(__CYGWIN__) #if __MISC_VISIBLE
int _EXFUN(execlpe, (const char *__file, const char *, ... )); int _EXFUN(execlpe, (const char *__file, const char *, ... ));
#endif #endif
int _EXFUN(execv, (const char *__path, char * const __argv[] )); int _EXFUN(execv, (const char *__path, char * const __argv[] ));
int _EXFUN(execve, (const char *__path, char * const __argv[], char * const __envp[] )); int _EXFUN(execve, (const char *__path, char * const __argv[], char * const __envp[] ));
int _EXFUN(execvp, (const char *__file, char * const __argv[] )); 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[] )); int _EXFUN(execvpe, (const char *__file, char * const __argv[], char * const __envp[] ));
#endif #endif
#if __POSIX_VISIBLE >= 200809 || __BSD_VISIBLE || defined(__CYGWIN__) #if __ATFILE_VISIBLE
int _EXFUN(faccessat, (int __dirfd, const char *__path, int __mode, int __flags)); int _EXFUN(faccessat, (int __dirfd, const char *__path, int __mode, int __flags));
#endif #endif
#if defined(__CYGWIN__) || defined(__rtems__) || defined(__SPU__) #if __BSD_VISIBLE || __XSI_VISIBLE >= 4
int _EXFUN(fchdir, (int __fildes)); int _EXFUN(fchdir, (int __fildes));
#endif #endif
int _EXFUN(fchmod, (int __fildes, mode_t __mode )); int _EXFUN(fchmod, (int __fildes, mode_t __mode ));
#if !defined(__INSIDE_CYGWIN__) #if !defined(__INSIDE_CYGWIN__)
int _EXFUN(fchown, (int __fildes, uid_t __owner, gid_t __group )); int _EXFUN(fchown, (int __fildes, uid_t __owner, gid_t __group ));
#endif #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)); int _EXFUN(fchownat, (int __dirfd, const char *__path, uid_t __owner, gid_t __group, int __flags));
#endif #endif
#if defined(__CYGWIN__) #if __POSIX_VISIBLE >= 200809
int _EXFUN(fexecve, (int __fd, char * const __argv[], char * const __envp[] )); int _EXFUN(fexecve, (int __fd, char * const __argv[], char * const __envp[] ));
#endif #endif
pid_t _EXFUN(fork, (void )); pid_t _EXFUN(fork, (void ));
long _EXFUN(fpathconf, (int __fd, int __name )); long _EXFUN(fpathconf, (int __fd, int __name ));
int _EXFUN(fsync, (int __fd)); int _EXFUN(fsync, (int __fd));
int _EXFUN(fdatasync, (int __fd)); int _EXFUN(fdatasync, (int __fd));
#if defined(__CYGWIN__) #if __GNU_VISIBLE
char * _EXFUN(get_current_dir_name, (void)); char * _EXFUN(get_current_dir_name, (void));
#endif #endif
char * _EXFUN(getcwd, (char *__buf, size_t __size )); char * _EXFUN(getcwd, (char *__buf, size_t __size ));
#if defined(__CYGWIN__) #if __BSD_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 500)
int _EXFUN(getdomainname ,(char *__name, size_t __len)); int _EXFUN(getdomainname ,(char *__name, size_t __len));
#endif #endif
#if __BSD_VISIBLE
int _EXFUN(getentropy, (void *, size_t));
#endif
#if !defined(__INSIDE_CYGWIN__) #if !defined(__INSIDE_CYGWIN__)
gid_t _EXFUN(getegid, (void )); gid_t _EXFUN(getegid, (void ));
uid_t _EXFUN(geteuid, (void )); uid_t _EXFUN(geteuid, (void ));
gid_t _EXFUN(getgid, (void )); gid_t _EXFUN(getgid, (void ));
#endif #endif
int _EXFUN(getgroups, (int __gidsetsize, gid_t __grouplist[] )); int _EXFUN(getgroups, (int __gidsetsize, gid_t __grouplist[] ));
#if defined(__CYGWIN__) #if __BSD_VISIBLE || __XSI_VISIBLE >= 4
long _EXFUN(gethostid, (void)); long _EXFUN(gethostid, (void));
#endif #endif
char * _EXFUN(getlogin, (void )); char * _EXFUN(getlogin, (void ));
@ -98,37 +115,44 @@ int _EXFUN(getlogin_r, (char *name, size_t namesize) );
#endif #endif
char * _EXFUN(getpass, (const char *__prompt)); char * _EXFUN(getpass, (const char *__prompt));
int _EXFUN(getpagesize, (void)); int _EXFUN(getpagesize, (void));
#if defined(__CYGWIN__) #if __BSD_VISIBLE
int _EXFUN(getpeereid, (int, uid_t *, gid_t *)); int _EXFUN(getpeereid, (int, uid_t *, gid_t *));
#endif #endif
pid_t _EXFUN(getpgid, (pid_t)); pid_t _EXFUN(getpgid, (pid_t));
pid_t _EXFUN(getpgrp, (void )); pid_t _EXFUN(getpgrp, (void ));
pid_t _EXFUN(getpid, (void )); pid_t _EXFUN(getpid, (void ));
pid_t _EXFUN(getppid, (void )); pid_t _EXFUN(getppid, (void ));
#if defined(__CYGWIN__) || defined(__rtems__) #if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 4
pid_t _EXFUN(getsid, (pid_t)); pid_t _EXFUN(getsid, (pid_t));
#endif #endif
#if !defined(__INSIDE_CYGWIN__) #if !defined(__INSIDE_CYGWIN__)
uid_t _EXFUN(getuid, (void )); uid_t _EXFUN(getuid, (void ));
#endif #endif
#ifdef __CYGWIN__ #if __BSD_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 500)
char * _EXFUN(getusershell, (void)); char * _EXFUN(getusershell, (void));
#endif
#if __BSD_VISIBLE || (__XSI_VISIBLE >= 4 && __POSIX_VISIBLE < 200809)
char * _EXFUN(getwd, (char *__buf )); char * _EXFUN(getwd, (char *__buf ));
#endif
#if __BSD_VISIBLE
int _EXFUN(iruserok, (unsigned long raddr, int superuser, const char *ruser, const char *luser)); int _EXFUN(iruserok, (unsigned long raddr, int superuser, const char *ruser, const char *luser));
#endif #endif
int _EXFUN(isatty, (int __fildes )); int _EXFUN(isatty, (int __fildes ));
#if __BSD_VISIBLE
int _EXFUN(issetugid, (void));
#endif
#if !defined(__INSIDE_CYGWIN__) #if !defined(__INSIDE_CYGWIN__)
int _EXFUN(lchown, (const char *__path, uid_t __owner, gid_t __group )); int _EXFUN(lchown, (const char *__path, uid_t __owner, gid_t __group ));
#endif #endif
int _EXFUN(link, (const char *__path1, const char *__path2 )); 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 )); int _EXFUN(linkat, (int __dirfd1, const char *__path1, int __dirfd2, const char *__path2, int __flags ));
#endif #endif
int _EXFUN(nice, (int __nice_value )); int _EXFUN(nice, (int __nice_value ));
#if !defined(__INSIDE_CYGWIN__) #if !defined(__INSIDE_CYGWIN__)
off_t _EXFUN(lseek, (int __fildes, off_t __offset, int __whence )); off_t _EXFUN(lseek, (int __fildes, off_t __offset, int __whence ));
#endif #endif
#if defined(__SPU__) || defined(__CYGWIN__) #if __MISC_VISIBLE || __XSI_VISIBLE >= 4
#define F_ULOCK 0 #define F_ULOCK 0
#define F_LOCK 1 #define F_LOCK 1
#define F_TLOCK 2 #define F_TLOCK 2
@ -137,41 +161,41 @@ int _EXFUN(lockf, (int __fd, int __cmd, off_t __len));
#endif #endif
long _EXFUN(pathconf, (const char *__path, int __name )); long _EXFUN(pathconf, (const char *__path, int __name ));
int _EXFUN(pause, (void )); int _EXFUN(pause, (void ));
#ifdef __CYGWIN__ #if __POSIX_VISIBLE >= 199506
int _EXFUN(pthread_atfork, (void (*)(void), void (*)(void), void (*)(void))); int _EXFUN(pthread_atfork, (void (*)(void), void (*)(void), void (*)(void)));
#endif #endif
int _EXFUN(pipe, (int __fildes[2] )); int _EXFUN(pipe, (int __fildes[2] ));
#ifdef __CYGWIN__ #if __GNU_VISIBLE
int _EXFUN(pipe2, (int __fildes[2], int flags)); int _EXFUN(pipe2, (int __fildes[2], int flags));
#endif #endif
ssize_t _EXFUN(pread, (int __fd, void *__buf, size_t __nbytes, off_t __offset)); 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)); 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 )); _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(rresvport, (int *__alport));
int _EXFUN(revoke, (char *__path)); int _EXFUN(revoke, (char *__path));
#endif #endif
int _EXFUN(rmdir, (const char *__path )); 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)); int _EXFUN(ruserok, (const char *rhost, int superuser, const char *ruser, const char *luser));
#endif #endif
void * _EXFUN(sbrk, (ptrdiff_t __incr)); void * _EXFUN(sbrk, (ptrdiff_t __incr));
#if !defined(__INSIDE_CYGWIN__) #if !defined(__INSIDE_CYGWIN__)
#if defined(__CYGWIN__) || defined(__rtems__) #if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112
int _EXFUN(setegid, (gid_t __gid )); int _EXFUN(setegid, (gid_t __gid ));
int _EXFUN(seteuid, (uid_t __uid )); int _EXFUN(seteuid, (uid_t __uid ));
#endif #endif
int _EXFUN(setgid, (gid_t __gid )); int _EXFUN(setgid, (gid_t __gid ));
#endif #endif
#if defined(__CYGWIN__) #if __BSD_VISIBLE
int _EXFUN(setgroups, (int ngroups, const gid_t *grouplist )); int _EXFUN(setgroups, (int ngroups, const gid_t *grouplist ));
#endif #endif
#if __BSD_VISIBLE || (defined(_XOPEN_SOURCE) && __XSI_VISIBLE < 500) #if __BSD_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 500)
int _EXFUN(sethostname, (const char *, size_t)); int _EXFUN(sethostname, (const char *, size_t));
#endif #endif
int _EXFUN(setpgid, (pid_t __pid, pid_t __pgid )); int _EXFUN(setpgid, (pid_t __pid, pid_t __pgid ));
int _EXFUN(setpgrp, (void )); int _EXFUN(setpgrp, (void ));
#if defined(__CYGWIN__) && !defined(__INSIDE_CYGWIN__) #if (__BSD_VISIBLE || __XSI_VISIBLE >= 4) && !defined(__INSIDE_CYGWIN__)
int _EXFUN(setregid, (gid_t __rgid, gid_t __egid)); int _EXFUN(setregid, (gid_t __rgid, gid_t __egid));
int _EXFUN(setreuid, (uid_t __ruid, uid_t __euid)); int _EXFUN(setreuid, (uid_t __ruid, uid_t __euid));
#endif #endif
@ -179,21 +203,25 @@ pid_t _EXFUN(setsid, (void ));
#if !defined(__INSIDE_CYGWIN__) #if !defined(__INSIDE_CYGWIN__)
int _EXFUN(setuid, (uid_t __uid )); int _EXFUN(setuid, (uid_t __uid ));
#endif #endif
#if defined(__CYGWIN__) #if __BSD_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 500)
void _EXFUN(setusershell, (void)); void _EXFUN(setusershell, (void));
#endif #endif
unsigned _EXFUN(sleep, (unsigned int __seconds )); unsigned _EXFUN(sleep, (unsigned int __seconds ));
#if __XSI_VISIBLE
void _EXFUN(swab, (const void *__restrict, void *__restrict, ssize_t)); void _EXFUN(swab, (const void *__restrict, void *__restrict, ssize_t));
#endif
long _EXFUN(sysconf, (int __name )); long _EXFUN(sysconf, (int __name ));
pid_t _EXFUN(tcgetpgrp, (int __fildes )); pid_t _EXFUN(tcgetpgrp, (int __fildes ));
int _EXFUN(tcsetpgrp, (int __fildes, pid_t __pgrp_id )); int _EXFUN(tcsetpgrp, (int __fildes, pid_t __pgrp_id ));
char * _EXFUN(ttyname, (int __fildes )); char * _EXFUN(ttyname, (int __fildes ));
#if defined(__CYGWIN__) || defined(__rtems__) int _EXFUN(ttyname_r, (int, char *, size_t));
int _EXFUN(ttyname_r, (int, char *, size_t));
#endif
int _EXFUN(unlink, (const char *__path )); int _EXFUN(unlink, (const char *__path ));
#if __XSI_VISIBLE >= 500 && __POSIX_VISIBLE < 200809 || __BSD_VISIBLE
int _EXFUN(usleep, (useconds_t __useconds)); int _EXFUN(usleep, (useconds_t __useconds));
#endif
#if __BSD_VISIBLE
int _EXFUN(vhangup, (void )); int _EXFUN(vhangup, (void ));
#endif
_READ_WRITE_RETURN_TYPE _EXFUN(write, (int __fd, const void *__buf, size_t __nbyte )); _READ_WRITE_RETURN_TYPE _EXFUN(write, (int __fd, const void *__buf, size_t __nbyte ));
#ifdef __CYGWIN__ #ifdef __CYGWIN__
@ -207,9 +235,9 @@ int getopt(int, char * const [], const char *);
extern int optreset; /* getopt(3) external variable */ extern int optreset; /* getopt(3) external variable */
#endif #endif
#ifndef _POSIX_SOURCE #if __BSD_VISIBLE || (__XSI_VISIBLE >= 4 && __POSIX_VISIBLE < 200809)
pid_t _EXFUN(vfork, (void )); pid_t _EXFUN(vfork, (void ));
#endif /* _POSIX_SOURCE */ #endif
#ifdef _COMPILING_NEWLIB #ifdef _COMPILING_NEWLIB
/* Provide prototypes for most of the _<systemcall> names that are /* Provide prototypes for most of the _<systemcall> names that are
@ -230,36 +258,45 @@ _READ_WRITE_RETURN_TYPE _EXFUN(_write, (int __fd, const void *__buf, size_t __nb
int _EXFUN(_execve, (const char *__path, char * const __argv[], char * const __envp[] )); int _EXFUN(_execve, (const char *__path, char * const __argv[], char * const __envp[] ));
#endif #endif
#if defined(__CYGWIN__) || defined(__rtems__) || defined(__aarch64__) || defined (__arm__) || defined(__sh__) || defined(__SPU__)
#if !defined(__INSIDE_CYGWIN__) #if !defined(__INSIDE_CYGWIN__)
#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 500
int _EXFUN(ftruncate, (int __fd, off_t __length)); int _EXFUN(ftruncate, (int __fd, off_t __length));
#endif
#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 500
int _EXFUN(truncate, (const char *, off_t __length)); int _EXFUN(truncate, (const char *, off_t __length));
#endif #endif
#endif #endif
#if defined(__CYGWIN__) || defined(__rtems__) #if __BSD_VISIBLE || __POSIX_VISIBLE < 200112
int _EXFUN(getdtablesize, (void)); int _EXFUN(getdtablesize, (void));
int _EXFUN(setdtablesize, (int)); #endif
#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 500
useconds_t _EXFUN(ualarm, (useconds_t __useconds, useconds_t __interval)); useconds_t _EXFUN(ualarm, (useconds_t __useconds, useconds_t __interval));
#endif
#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 500
#if !(defined (_WINSOCK_H) || defined (_WINSOCKAPI_) || defined (__USE_W32_SOCKETS)) #if !(defined (_WINSOCK_H) || defined (_WINSOCKAPI_) || defined (__USE_W32_SOCKETS))
/* winsock[2].h defines as __stdcall, and with int as 2nd arg */ /* winsock[2].h defines as __stdcall, and with int as 2nd arg */
int _EXFUN(gethostname, (char *__name, size_t __len)); int _EXFUN(gethostname, (char *__name, size_t __len));
#endif #endif
char * _EXFUN(mktemp, (char *));
#endif #endif
#if defined(__CYGWIN__) || defined(__SPU__) || defined(__rtems__) #if __MISC_VISIBLE
int _EXFUN(setdtablesize, (int));
#endif
#if __BSD_VISIBLE || __XSI_VISIBLE >= 500
void _EXFUN(sync, (void)); void _EXFUN(sync, (void));
#endif #endif
#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 4
ssize_t _EXFUN(readlink, (const char *__restrict __path, ssize_t _EXFUN(readlink, (const char *__restrict __path,
char *__restrict __buf, size_t __buflen)); 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, ssize_t _EXFUN(readlinkat, (int __dirfd1, const char *__restrict __path,
char *__restrict __buf, size_t __buflen)); 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(symlinkat, (const char *, int, const char *));
int _EXFUN(unlinkat, (int, const char *, int)); int _EXFUN(unlinkat, (int, const char *, int));
#endif #endif
@ -422,6 +459,22 @@ int _EXFUN(unlinkat, (int, const char *, int));
#define _SC_THREAD_ROBUST_PRIO_INHERIT 122 #define _SC_THREAD_ROBUST_PRIO_INHERIT 122
#define _SC_THREAD_ROBUST_PRIO_PROTECT 123 #define _SC_THREAD_ROBUST_PRIO_PROTECT 123
#define _SC_XOPEN_UUCP 124 #define _SC_XOPEN_UUCP 124
#define _SC_LEVEL1_ICACHE_SIZE 125
#define _SC_LEVEL1_ICACHE_ASSOC 126
#define _SC_LEVEL1_ICACHE_LINESIZE 127
#define _SC_LEVEL1_DCACHE_SIZE 128
#define _SC_LEVEL1_DCACHE_ASSOC 129
#define _SC_LEVEL1_DCACHE_LINESIZE 130
#define _SC_LEVEL2_CACHE_SIZE 131
#define _SC_LEVEL2_CACHE_ASSOC 132
#define _SC_LEVEL2_CACHE_LINESIZE 133
#define _SC_LEVEL3_CACHE_SIZE 134
#define _SC_LEVEL3_CACHE_ASSOC 135
#define _SC_LEVEL3_CACHE_LINESIZE 136
#define _SC_LEVEL4_CACHE_SIZE 137
#define _SC_LEVEL4_CACHE_ASSOC 138
#define _SC_LEVEL4_CACHE_LINESIZE 139
#define _SC_POSIX_26_VERSION 140
/* /*
* pathconf values per IEEE Std 1003.1, 2008 Edition * pathconf values per IEEE Std 1003.1, 2008 Edition
@ -453,6 +506,7 @@ int _EXFUN(unlinkat, (int, const char *, int));
#define _PC_POSIX_PERMISSIONS 90 #define _PC_POSIX_PERMISSIONS 90
/* Ask for full POSIX permission support including uid/gid settings. */ /* Ask for full POSIX permission support including uid/gid settings. */
#define _PC_POSIX_SECURITY 91 #define _PC_POSIX_SECURITY 91
#define _PC_CASE_INSENSITIVE 92
#endif #endif
/* /*

View file

@ -11,7 +11,7 @@ extern "C" {
#define WUNTRACED 2 #define WUNTRACED 2
/* A status looks like: /* A status looks like:
<2 bytes info> <2 bytes code> <1 byte info> <1 byte code>
<code> == 0, child has exited, info is the exit value <code> == 0, child has exited, info is the exit value
<code> == 1..7e, child has exited, info is the signal number. <code> == 1..7e, child has exited, info is the signal number.

View file

@ -5,6 +5,8 @@
#ifndef _TAR_H #ifndef _TAR_H
#define _TAR_H #define _TAR_H
#include <sys/features.h>
/* General definitions */ /* General definitions */
#define TMAGIC "ustar" /* ustar plus null byte. */ #define TMAGIC "ustar" /* ustar plus null byte. */
#define TMAGLEN 6 /* Length of the above. */ #define TMAGLEN 6 /* Length of the above. */
@ -25,7 +27,9 @@
/* Mode field bit definitions (octal) */ /* Mode field bit definitions (octal) */
#define TSUID 04000 /* Set UID on execution. */ #define TSUID 04000 /* Set UID on execution. */
#define TSGID 02000 /* Set GID on execution. */ #define TSGID 02000 /* Set GID on execution. */
#if __XSI_VISIBLE || __POSIX_VISIBLE < 200112
#define TSVTX 01000 /* On directories, restricted deletion flag. */ #define TSVTX 01000 /* On directories, restricted deletion flag. */
#endif
#define TUREAD 00400 /* Read by owner. */ #define TUREAD 00400 /* Read by owner. */
#define TUWRITE 00200 /* Write by owner. */ #define TUWRITE 00200 /* Write by owner. */
#define TUEXEC 00100 /* Execute/search by owner. */ #define TUEXEC 00100 /* Execute/search by owner. */

View file

@ -79,7 +79,7 @@
__tg_type3(__e1, __e2, __e3, long double _Complex) || \ __tg_type3(__e1, __e2, __e3, long double _Complex) || \
__tg_type3(__e1, __e2, __e3, __typeof__(_Complex_I))) __tg_type3(__e1, __e2, __e3, __typeof__(_Complex_I)))
#ifdef _LDBL_EQ_DBL #if defined (_LDBL_EQ_DBL) || defined (__CYGWIN__)
#define __tg_impl_simple(x, y, z, fn, fnf, fnl, ...) \ #define __tg_impl_simple(x, y, z, fn, fnf, fnl, ...) \
__builtin_choose_expr(__tg_type_corr(x, y, z, long double), \ __builtin_choose_expr(__tg_type_corr(x, y, z, long double), \
fnl(__VA_ARGS__), __builtin_choose_expr( \ fnl(__VA_ARGS__), __builtin_choose_expr( \
@ -161,9 +161,10 @@
#define lround(__x) __tg_simple(__x, lround) #define lround(__x) __tg_simple(__x, lround)
#define nearbyint(__x) __tg_simple(__x, nearbyint) #define nearbyint(__x) __tg_simple(__x, nearbyint)
#define nextafter(__x, __y) __tg_simple2(__x, __y, nextafter) #define nextafter(__x, __y) __tg_simple2(__x, __y, nextafter)
/* not yet implemented even for _LDBL_EQ_DBL platforms /* not yet implemented even for _LDBL_EQ_DBL platforms */
#ifdef __CYGWIN__
#define nexttoward(__x, __y) __tg_simplev(__x, nexttoward, __x, __y) #define nexttoward(__x, __y) __tg_simplev(__x, nexttoward, __x, __y)
*/ #endif
#define remainder(__x, __y) __tg_simple2(__x, __y, remainder) #define remainder(__x, __y) __tg_simple2(__x, __y, remainder)
#define remquo(__x, __y, __z) __tg_impl_simple(__x, __x, __y, remquo, remquof, \ #define remquo(__x, __y, __z) __tg_impl_simple(__x, __x, __y, remquo, remquof, \
remquol, __x, __y, __z) remquol, __x, __y, __z)

View file

@ -0,0 +1,93 @@
/*-
* Copyright (c) 2011 Ed Schouten <ed@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _THREADS_H_
#define _THREADS_H_
#include <machine/_threads.h>
#include <time.h>
typedef void (*tss_dtor_t)(void *);
typedef int (*thrd_start_t)(void *);
enum {
mtx_plain = 0x1,
mtx_recursive = 0x2,
mtx_timed = 0x4
};
enum {
thrd_busy = 1,
thrd_error = 2,
thrd_nomem = 3,
thrd_success = 4,
thrd_timedout = 5
};
#if !defined(__cplusplus) || __cplusplus < 201103L
#define thread_local _Thread_local
#endif
__BEGIN_DECLS
void call_once(once_flag *, void (*)(void));
int cnd_broadcast(cnd_t *);
void cnd_destroy(cnd_t *);
int cnd_init(cnd_t *);
int cnd_signal(cnd_t *);
int cnd_timedwait(cnd_t *__restrict, mtx_t *__restrict __mtx,
const struct timespec *__restrict)
__requires_exclusive(*__mtx);
int cnd_wait(cnd_t *, mtx_t *__mtx)
__requires_exclusive(*__mtx);
void mtx_destroy(mtx_t *__mtx)
__requires_unlocked(*__mtx);
int mtx_init(mtx_t *__mtx, int)
__requires_unlocked(*__mtx);
int mtx_lock(mtx_t *__mtx)
__locks_exclusive(*__mtx);
int mtx_timedlock(mtx_t *__restrict __mtx,
const struct timespec *__restrict)
__trylocks_exclusive(thrd_success, *__mtx);
int mtx_trylock(mtx_t *__mtx)
__trylocks_exclusive(thrd_success, *__mtx);
int mtx_unlock(mtx_t *__mtx)
__unlocks(*__mtx);
int thrd_create(thrd_t *, thrd_start_t, void *);
thrd_t thrd_current(void);
int thrd_detach(thrd_t);
int thrd_equal(thrd_t, thrd_t);
_Noreturn void
thrd_exit(int);
int thrd_join(thrd_t, int *);
int thrd_sleep(const struct timespec *, struct timespec *);
void thrd_yield(void);
int tss_create(tss_t *, tss_dtor_t);
void tss_delete(tss_t);
void * tss_get(tss_t);
int tss_set(tss_t, void *);
__END_DECLS
#endif /* !_THREADS_H_ */

View file

@ -8,6 +8,7 @@
#define _TIME_H_ #define _TIME_H_
#include "_ansi.h" #include "_ansi.h"
#include <sys/cdefs.h>
#include <sys/reent.h> #include <sys/reent.h>
#define __need_size_t #define __need_size_t
@ -25,6 +26,11 @@
#define CLK_TCK CLOCKS_PER_SEC #define CLK_TCK CLOCKS_PER_SEC
#include <sys/types.h> #include <sys/types.h>
#include <sys/timespec.h>
#if __POSIX_VISIBLE >= 200809
#include <xlocale.h>
#endif
_BEGIN_STD_C _BEGIN_STD_C
@ -61,6 +67,12 @@ size_t _EXFUN(strftime, (char *__restrict _s,
size_t _maxsize, const char *__restrict _fmt, size_t _maxsize, const char *__restrict _fmt,
const struct tm *__restrict _t)); const struct tm *__restrict _t));
#if __POSIX_VISIBLE >= 200809
extern size_t strftime_l (char *__restrict _s, size_t _maxsize,
const char *__restrict _fmt,
const struct tm *__restrict _t, locale_t _l);
#endif
char *_EXFUN(asctime_r, (const struct tm *__restrict, char *_EXFUN(asctime_r, (const struct tm *__restrict,
char *__restrict)); char *__restrict));
char *_EXFUN(ctime_r, (const time_t *, char *)); char *_EXFUN(ctime_r, (const time_t *, char *));
@ -75,11 +87,19 @@ _END_STD_C
extern "C" { extern "C" {
#endif #endif
#ifndef __STRICT_ANSI__ #if __XSI_VISIBLE
char *_EXFUN(strptime, (const char *__restrict, char *_EXFUN(strptime, (const char *__restrict,
const char *__restrict, const char *__restrict,
struct tm *__restrict)); struct tm *__restrict));
#endif
#if __GNU_VISIBLE
char *strptime_l (const char *__restrict, const char *__restrict,
struct tm *__restrict, locale_t);
#endif
#if __POSIX_VISIBLE
_VOID _EXFUN(tzset, (_VOID)); _VOID _EXFUN(tzset, (_VOID));
#endif
_VOID _EXFUN(_tzset_r, (struct _reent *)); _VOID _EXFUN(_tzset_r, (struct _reent *));
typedef struct __tzrule_struct typedef struct __tzrule_struct
@ -105,6 +125,7 @@ __tzinfo_type *_EXFUN (__gettzinfo, (_VOID));
/* getdate functions */ /* getdate functions */
#ifdef HAVE_GETDATE #ifdef HAVE_GETDATE
#if __XSI_VISIBLE >= 4
#ifndef _REENT_ONLY #ifndef _REENT_ONLY
#define getdate_err (*__getdate_err()) #define getdate_err (*__getdate_err())
int *_EXFUN(__getdate_err,(_VOID)); int *_EXFUN(__getdate_err,(_VOID));
@ -120,21 +141,27 @@ struct tm * _EXFUN(getdate, (const char *));
7 there is no line in the template that matches the input, 7 there is no line in the template that matches the input,
8 invalid input specification */ 8 invalid input specification */
#endif /* !_REENT_ONLY */ #endif /* !_REENT_ONLY */
#endif /* __XSI_VISIBLE >= 4 */
#if __GNU_VISIBLE
/* getdate_r returns the error code as above */ /* getdate_r returns the error code as above */
int _EXFUN(getdate_r, (const char *, struct tm *)); int _EXFUN(getdate_r, (const char *, struct tm *));
#endif /* __GNU_VISIBLE */
#endif /* HAVE_GETDATE */ #endif /* HAVE_GETDATE */
/* defines for the opengroup specifications Derived from Issue 1 of the SVID. */ /* defines for the opengroup specifications Derived from Issue 1 of the SVID. */
#if __SVID_VISIBLE || __XSI_VISIBLE
extern __IMPORT long _timezone; extern __IMPORT long _timezone;
extern __IMPORT int _daylight; extern __IMPORT int _daylight;
#endif
#if __POSIX_VISIBLE
extern __IMPORT char *_tzname[2]; extern __IMPORT char *_tzname[2];
/* POSIX defines the external tzname being defined in time.h */ /* POSIX defines the external tzname being defined in time.h */
#ifndef tzname #ifndef tzname
#define tzname _tzname #define tzname _tzname
#endif #endif
#endif /* !__STRICT_ANSI__ */ #endif /* __POSIX_VISIBLE */
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -11,15 +11,32 @@
#define __need_NULL #define __need_NULL
#include <stddef.h> #include <stddef.h>
#define __need___va_list
#include <stdarg.h>
/* For _mbstate_t definition. */ /* For _mbstate_t definition. */
#include <sys/_types.h> #include <sys/_types.h>
#include <sys/cdefs.h> #include <sys/cdefs.h>
/* For __STDC_ISO_10646__ */ /* For __STDC_ISO_10646__ */
#include <sys/features.h> #include <sys/features.h>
/* typedef only __gnuc_va_list, used throughout the header */
#define __need___va_list
#include <stdarg.h>
/* typedef va_list only when required */
#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE
#ifdef __GNUC__
#ifndef _VA_LIST_DEFINED
typedef __gnuc_va_list va_list;
#define _VA_LIST_DEFINED
#endif
#else /* !__GNUC__ */
#include <stdarg.h>
#endif
#endif /* __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE */
#if __XSI_VISIBLE /* && __XSI_VISIBLE < 800 */ && !__GNU_VISIBLE
#include <wctype.h>
#endif
#ifndef WEOF #ifndef WEOF
# define WEOF ((wint_t)-1) # define WEOF ((wint_t)-1)
#endif #endif
@ -46,10 +63,19 @@
#endif #endif
#endif #endif
#if __POSIX_VISIBLE >= 200809
#include <xlocale.h>
#endif
_BEGIN_STD_C _BEGIN_STD_C
#if __POSIX_VISIBLE >= 200809 || _XSI_VISIBLE
/* As in stdio.h, <sys/reent.h> defines __FILE. */ /* As in stdio.h, <sys/reent.h> defines __FILE. */
#if !defined(__FILE_defined)
typedef __FILE FILE; typedef __FILE FILE;
# define __FILE_defined
#endif
#endif
/* As required by POSIX.1-2008, declare tm as incomplete type. /* As required by POSIX.1-2008, declare tm as incomplete type.
The actual definition is in time.h. */ The actual definition is in time.h. */
@ -68,8 +94,10 @@ size_t _EXFUN(mbrtowc, (wchar_t *__restrict, const char *__restrict, size_t,
size_t _EXFUN(_mbrtowc_r, (struct _reent *, wchar_t * , const char * , size_t _EXFUN(_mbrtowc_r, (struct _reent *, wchar_t * , const char * ,
size_t, mbstate_t *)); size_t, mbstate_t *));
int _EXFUN(mbsinit, (const mbstate_t *)); int _EXFUN(mbsinit, (const mbstate_t *));
#if __POSIX_VISIBLE >= 200809
size_t _EXFUN(mbsnrtowcs, (wchar_t *__restrict, const char **__restrict, size_t _EXFUN(mbsnrtowcs, (wchar_t *__restrict, const char **__restrict,
size_t, size_t, mbstate_t *__restrict)); size_t, size_t, mbstate_t *__restrict));
#endif
size_t _EXFUN(_mbsnrtowcs_r, (struct _reent *, wchar_t * , const char ** , size_t _EXFUN(_mbsnrtowcs_r, (struct _reent *, wchar_t * , const char ** ,
size_t, size_t, mbstate_t *)); size_t, size_t, mbstate_t *));
size_t _EXFUN(mbsrtowcs, (wchar_t *__restrict, const char **__restrict, size_t, size_t _EXFUN(mbsrtowcs, (wchar_t *__restrict, const char **__restrict, size_t,
@ -77,39 +105,53 @@ size_t _EXFUN(mbsrtowcs, (wchar_t *__restrict, const char **__restrict, size_t,
size_t _EXFUN(_mbsrtowcs_r, (struct _reent *, wchar_t * , const char ** , size_t, mbstate_t *)); size_t _EXFUN(_mbsrtowcs_r, (struct _reent *, wchar_t * , const char ** , size_t, mbstate_t *));
size_t _EXFUN(wcrtomb, (char *__restrict, wchar_t, mbstate_t *__restrict)); size_t _EXFUN(wcrtomb, (char *__restrict, wchar_t, mbstate_t *__restrict));
size_t _EXFUN(_wcrtomb_r, (struct _reent *, char * , wchar_t, mbstate_t *)); size_t _EXFUN(_wcrtomb_r, (struct _reent *, char * , wchar_t, mbstate_t *));
#if __POSIX_VISIBLE >= 200809
size_t _EXFUN(wcsnrtombs, (char *__restrict, const wchar_t **__restrict, size_t _EXFUN(wcsnrtombs, (char *__restrict, const wchar_t **__restrict,
size_t, size_t, mbstate_t *__restrict)); size_t, size_t, mbstate_t *__restrict));
#endif
size_t _EXFUN(_wcsnrtombs_r, (struct _reent *, char * , const wchar_t ** , size_t _EXFUN(_wcsnrtombs_r, (struct _reent *, char * , const wchar_t ** ,
size_t, size_t, mbstate_t *)); size_t, size_t, mbstate_t *));
size_t _EXFUN(wcsrtombs, (char *__restrict, const wchar_t **__restrict, size_t _EXFUN(wcsrtombs, (char *__restrict, const wchar_t **__restrict,
size_t, mbstate_t *__restrict)); size_t, mbstate_t *__restrict));
size_t _EXFUN(_wcsrtombs_r, (struct _reent *, char * , const wchar_t ** , size_t _EXFUN(_wcsrtombs_r, (struct _reent *, char * , const wchar_t ** ,
size_t, mbstate_t *)); size_t, mbstate_t *));
#if __POSIX_VISIBLE >= 200809
int _EXFUN(wcscasecmp, (const wchar_t *, const wchar_t *)); int _EXFUN(wcscasecmp, (const wchar_t *, const wchar_t *));
#endif
wchar_t *_EXFUN(wcscat, (wchar_t *__restrict, const wchar_t *__restrict)); wchar_t *_EXFUN(wcscat, (wchar_t *__restrict, const wchar_t *__restrict));
wchar_t *_EXFUN(wcschr, (const wchar_t *, wchar_t)); wchar_t *_EXFUN(wcschr, (const wchar_t *, wchar_t));
int _EXFUN(wcscmp, (const wchar_t *, const wchar_t *)); int _EXFUN(wcscmp, (const wchar_t *, const wchar_t *));
int _EXFUN(wcscoll, (const wchar_t *, const wchar_t *)); int _EXFUN(wcscoll, (const wchar_t *, const wchar_t *));
wchar_t *_EXFUN(wcscpy, (wchar_t *__restrict, const wchar_t *__restrict)); wchar_t *_EXFUN(wcscpy, (wchar_t *__restrict, const wchar_t *__restrict));
#if __POSIX_VISIBLE >= 200809
wchar_t *_EXFUN(wcpcpy, (wchar_t *__restrict, wchar_t *_EXFUN(wcpcpy, (wchar_t *__restrict,
const wchar_t *__restrict)); const wchar_t *__restrict));
wchar_t *_EXFUN(wcsdup, (const wchar_t *)); wchar_t *_EXFUN(wcsdup, (const wchar_t *));
#endif
wchar_t *_EXFUN(_wcsdup_r, (struct _reent *, const wchar_t * )); wchar_t *_EXFUN(_wcsdup_r, (struct _reent *, const wchar_t * ));
size_t _EXFUN(wcscspn, (const wchar_t *, const wchar_t *)); size_t _EXFUN(wcscspn, (const wchar_t *, const wchar_t *));
size_t _EXFUN(wcsftime, (wchar_t *__restrict, size_t, size_t _EXFUN(wcsftime, (wchar_t *__restrict, size_t,
const wchar_t *__restrict, const struct tm *__restrict)); const wchar_t *__restrict, const struct tm *__restrict));
#if __GNU_VISIBLE
size_t wcsftime_l (wchar_t *__restrict, size_t, const wchar_t *__restrict,
const struct tm *__restrict, locale_t);
#endif
size_t _EXFUN(wcslcat, (wchar_t *, const wchar_t *, size_t)); size_t _EXFUN(wcslcat, (wchar_t *, const wchar_t *, size_t));
size_t _EXFUN(wcslcpy, (wchar_t *, const wchar_t *, size_t)); size_t _EXFUN(wcslcpy, (wchar_t *, const wchar_t *, size_t));
size_t _EXFUN(wcslen, (const wchar_t *)); size_t _EXFUN(wcslen, (const wchar_t *));
#if __POSIX_VISIBLE >= 200809
int _EXFUN(wcsncasecmp, (const wchar_t *, const wchar_t *, size_t)); int _EXFUN(wcsncasecmp, (const wchar_t *, const wchar_t *, size_t));
#endif
wchar_t *_EXFUN(wcsncat, (wchar_t *__restrict, wchar_t *_EXFUN(wcsncat, (wchar_t *__restrict,
const wchar_t *__restrict, size_t)); const wchar_t *__restrict, size_t));
int _EXFUN(wcsncmp, (const wchar_t *, const wchar_t *, size_t)); int _EXFUN(wcsncmp, (const wchar_t *, const wchar_t *, size_t));
wchar_t *_EXFUN(wcsncpy, (wchar_t *__restrict, wchar_t *_EXFUN(wcsncpy, (wchar_t *__restrict,
const wchar_t *__restrict, size_t)); const wchar_t *__restrict, size_t));
#if __POSIX_VISIBLE >= 200809
wchar_t *_EXFUN(wcpncpy, (wchar_t *__restrict, wchar_t *_EXFUN(wcpncpy, (wchar_t *__restrict,
const wchar_t *__restrict, size_t)); const wchar_t *__restrict, size_t));
size_t _EXFUN(wcsnlen, (const wchar_t *, size_t)); size_t _EXFUN(wcsnlen, (const wchar_t *, size_t));
#endif
wchar_t *_EXFUN(wcspbrk, (const wchar_t *, const wchar_t *)); wchar_t *_EXFUN(wcspbrk, (const wchar_t *, const wchar_t *));
wchar_t *_EXFUN(wcsrchr, (const wchar_t *, wchar_t)); wchar_t *_EXFUN(wcsrchr, (const wchar_t *, wchar_t));
size_t _EXFUN(wcsspn, (const wchar_t *, const wchar_t *)); size_t _EXFUN(wcsspn, (const wchar_t *, const wchar_t *));
@ -119,15 +161,29 @@ wchar_t *_EXFUN(wcstok, (wchar_t *__restrict, const wchar_t *__restrict,
wchar_t **__restrict)); wchar_t **__restrict));
double _EXFUN(wcstod, (const wchar_t *__restrict, wchar_t **__restrict)); double _EXFUN(wcstod, (const wchar_t *__restrict, wchar_t **__restrict));
double _EXFUN(_wcstod_r, (struct _reent *, const wchar_t *, wchar_t **)); double _EXFUN(_wcstod_r, (struct _reent *, const wchar_t *, wchar_t **));
#if __ISO_C_VISIBLE >= 1999
float _EXFUN(wcstof, (const wchar_t *__restrict, wchar_t **__restrict)); float _EXFUN(wcstof, (const wchar_t *__restrict, wchar_t **__restrict));
#endif
float _EXFUN(_wcstof_r, (struct _reent *, const wchar_t *, wchar_t **)); float _EXFUN(_wcstof_r, (struct _reent *, const wchar_t *, wchar_t **));
#ifdef _LDBL_EQ_DBL #ifdef _LDBL_EQ_DBL
long double _EXFUN(wcstold, (const wchar_t *, wchar_t **)); long double _EXFUN(wcstold, (const wchar_t *, wchar_t **));
#endif /* _LDBL_EQ_DBL */ #endif /* _LDBL_EQ_DBL */
#if __XSI_VISIBLE
int _EXFUN(wcswidth, (const wchar_t *, size_t)); int _EXFUN(wcswidth, (const wchar_t *, size_t));
#endif
size_t _EXFUN(wcsxfrm, (wchar_t *__restrict, const wchar_t *__restrict, size_t _EXFUN(wcsxfrm, (wchar_t *__restrict, const wchar_t *__restrict,
size_t)); size_t));
#if __POSIX_VISIBLE >= 200809
extern int wcscasecmp_l (const wchar_t *, const wchar_t *, locale_t);
extern int wcsncasecmp_l (const wchar_t *, const wchar_t *, size_t, locale_t);
extern int wcscoll_l (const wchar_t *, const wchar_t *, locale_t);
extern size_t wcsxfrm_l (wchar_t *__restrict, const wchar_t *__restrict, size_t,
locale_t);
#endif
#if __XSI_VISIBLE
int _EXFUN(wcwidth, (const wchar_t)); int _EXFUN(wcwidth, (const wchar_t));
#endif
wchar_t *_EXFUN(wmemchr, (const wchar_t *, wchar_t, size_t)); wchar_t *_EXFUN(wmemchr, (const wchar_t *, wchar_t, size_t));
int _EXFUN(wmemcmp, (const wchar_t *, const wchar_t *, size_t)); int _EXFUN(wmemcmp, (const wchar_t *, const wchar_t *, size_t));
wchar_t *_EXFUN(wmemcpy, (wchar_t *__restrict, const wchar_t *__restrict, wchar_t *_EXFUN(wmemcpy, (wchar_t *__restrict, const wchar_t *__restrict,
@ -136,26 +192,44 @@ wchar_t *_EXFUN(wmemmove, (wchar_t *, const wchar_t *, size_t));
wchar_t *_EXFUN(wmemset, (wchar_t *, wchar_t, size_t)); wchar_t *_EXFUN(wmemset, (wchar_t *, wchar_t, size_t));
long _EXFUN(wcstol, (const wchar_t *__restrict, wchar_t **__restrict, int)); long _EXFUN(wcstol, (const wchar_t *__restrict, wchar_t **__restrict, int));
#if __ISO_C_VISIBLE >= 1999
long long _EXFUN(wcstoll, (const wchar_t *__restrict, wchar_t **__restrict, long long _EXFUN(wcstoll, (const wchar_t *__restrict, wchar_t **__restrict,
int)); int));
#endif
unsigned long _EXFUN(wcstoul, (const wchar_t *__restrict, wchar_t **__restrict, unsigned long _EXFUN(wcstoul, (const wchar_t *__restrict, wchar_t **__restrict,
int)); int));
#if __ISO_C_VISIBLE >= 1999
unsigned long long _EXFUN(wcstoull, (const wchar_t *__restrict, unsigned long long _EXFUN(wcstoull, (const wchar_t *__restrict,
wchar_t **__restrict, int)); wchar_t **__restrict, int));
#endif
long _EXFUN(_wcstol_r, (struct _reent *, const wchar_t *, wchar_t **, int)); long _EXFUN(_wcstol_r, (struct _reent *, const wchar_t *, wchar_t **, int));
long long _EXFUN(_wcstoll_r, (struct _reent *, const wchar_t *, wchar_t **, int)); long long _EXFUN(_wcstoll_r, (struct _reent *, const wchar_t *, wchar_t **, int));
unsigned long _EXFUN(_wcstoul_r, (struct _reent *, const wchar_t *, wchar_t **, int)); unsigned long _EXFUN(_wcstoul_r, (struct _reent *, const wchar_t *, wchar_t **, int));
unsigned long long _EXFUN(_wcstoull_r, (struct _reent *, const wchar_t *, wchar_t **, int)); unsigned long long _EXFUN(_wcstoull_r, (struct _reent *, const wchar_t *, wchar_t **, int));
/* On platforms where long double equals double. */ #if __ISO_C_VISIBLE >= 1999
#ifdef _LDBL_EQ_DBL
long double _EXFUN(wcstold, (const wchar_t *, wchar_t **)); long double _EXFUN(wcstold, (const wchar_t *, wchar_t **));
#endif /* _LDBL_EQ_DBL */ #endif
#if __GNU_VISIBLE
long wcstol_l (const wchar_t *__restrict, wchar_t **__restrict, int, locale_t);
long long wcstoll_l (const wchar_t *__restrict, wchar_t **__restrict, int,
locale_t);
unsigned long wcstoul_l (const wchar_t *__restrict, wchar_t **__restrict, int,
locale_t);
unsigned long long wcstoull_l (const wchar_t *__restrict, wchar_t **__restrict,
int, locale_t);
double wcstod_l (const wchar_t *, wchar_t **, locale_t);
float wcstof_l (const wchar_t *, wchar_t **, locale_t);
long double wcstold_l (const wchar_t *, wchar_t **, locale_t);
#endif
wint_t _EXFUN(fgetwc, (__FILE *)); wint_t _EXFUN(fgetwc, (__FILE *));
wchar_t *_EXFUN(fgetws, (wchar_t *__restrict, int, __FILE *__restrict)); wchar_t *_EXFUN(fgetws, (wchar_t *__restrict, int, __FILE *__restrict));
wint_t _EXFUN(fputwc, (wchar_t, __FILE *)); wint_t _EXFUN(fputwc, (wchar_t, __FILE *));
int _EXFUN(fputws, (const wchar_t *__restrict, __FILE *__restrict)); int _EXFUN(fputws, (const wchar_t *__restrict, __FILE *__restrict));
#if __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE >= 500
int _EXFUN (fwide, (__FILE *, int)); int _EXFUN (fwide, (__FILE *, int));
#endif
wint_t _EXFUN (getwc, (__FILE *)); wint_t _EXFUN (getwc, (__FILE *));
wint_t _EXFUN (getwchar, (void)); wint_t _EXFUN (getwchar, (void));
wint_t _EXFUN(putwc, (wchar_t, __FILE *)); wint_t _EXFUN(putwc, (wchar_t, __FILE *));
@ -192,7 +266,9 @@ wint_t _EXFUN(putwc_unlocked, (wchar_t, __FILE *));
wint_t _EXFUN(putwchar_unlocked, (wchar_t)); wint_t _EXFUN(putwchar_unlocked, (wchar_t));
#endif #endif
#if __POSIX_VISIBLE >= 200809
__FILE *_EXFUN (open_wmemstream, (wchar_t **, size_t *)); __FILE *_EXFUN (open_wmemstream, (wchar_t **, size_t *));
#endif
__FILE *_EXFUN (_open_wmemstream_r, (struct _reent *, wchar_t **, size_t *)); __FILE *_EXFUN (_open_wmemstream_r, (struct _reent *, wchar_t **, size_t *));
#ifndef __VALIST #ifndef __VALIST
@ -203,6 +279,7 @@ __FILE *_EXFUN (_open_wmemstream_r, (struct _reent *, wchar_t **, size_t *));
#endif #endif
#endif #endif
#if __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE >= 500
int _EXFUN(fwprintf, (__FILE *__restrict, const wchar_t *__restrict, ...)); int _EXFUN(fwprintf, (__FILE *__restrict, const wchar_t *__restrict, ...));
int _EXFUN(swprintf, (wchar_t *__restrict, size_t, int _EXFUN(swprintf, (wchar_t *__restrict, size_t,
const wchar_t *__restrict, ...)); const wchar_t *__restrict, ...));
@ -212,6 +289,7 @@ int _EXFUN(vswprintf, (wchar_t *__restrict, size_t,
const wchar_t *__restrict, __VALIST)); const wchar_t *__restrict, __VALIST));
int _EXFUN(vwprintf, (const wchar_t *__restrict, __VALIST)); int _EXFUN(vwprintf, (const wchar_t *__restrict, __VALIST));
int _EXFUN(wprintf, (const wchar_t *__restrict, ...)); int _EXFUN(wprintf, (const wchar_t *__restrict, ...));
#endif
int _EXFUN(_fwprintf_r, (struct _reent *, __FILE *, const wchar_t *, ...)); int _EXFUN(_fwprintf_r, (struct _reent *, __FILE *, const wchar_t *, ...));
int _EXFUN(_swprintf_r, (struct _reent *, wchar_t *, size_t, const wchar_t *, ...)); int _EXFUN(_swprintf_r, (struct _reent *, wchar_t *, size_t, const wchar_t *, ...));
@ -220,6 +298,7 @@ int _EXFUN(_vswprintf_r, (struct _reent *, wchar_t *, size_t, const wchar_t *, _
int _EXFUN(_vwprintf_r, (struct _reent *, const wchar_t *, __VALIST)); int _EXFUN(_vwprintf_r, (struct _reent *, const wchar_t *, __VALIST));
int _EXFUN(_wprintf_r, (struct _reent *, const wchar_t *, ...)); int _EXFUN(_wprintf_r, (struct _reent *, const wchar_t *, ...));
#if __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE >= 500
int _EXFUN(fwscanf, (__FILE *__restrict, const wchar_t *__restrict, ...)); int _EXFUN(fwscanf, (__FILE *__restrict, const wchar_t *__restrict, ...));
int _EXFUN(swscanf, (const wchar_t *__restrict, int _EXFUN(swscanf, (const wchar_t *__restrict,
const wchar_t *__restrict, ...)); const wchar_t *__restrict, ...));
@ -229,6 +308,7 @@ int _EXFUN(vswscanf, (const wchar_t *__restrict, const wchar_t *__restrict,
__VALIST)); __VALIST));
int _EXFUN(vwscanf, (const wchar_t *__restrict, __VALIST)); int _EXFUN(vwscanf, (const wchar_t *__restrict, __VALIST));
int _EXFUN(wscanf, (const wchar_t *__restrict, ...)); int _EXFUN(wscanf, (const wchar_t *__restrict, ...));
#endif
int _EXFUN(_fwscanf_r, (struct _reent *, __FILE *, const wchar_t *, ...)); int _EXFUN(_fwscanf_r, (struct _reent *, __FILE *, const wchar_t *, ...));
int _EXFUN(_swscanf_r, (struct _reent *, const wchar_t *, const wchar_t *, ...)); int _EXFUN(_swscanf_r, (struct _reent *, const wchar_t *, const wchar_t *, ...));

View file

@ -7,6 +7,10 @@
#define __need_wint_t #define __need_wint_t
#include <stddef.h> #include <stddef.h>
#if __POSIX_VISIBLE >= 200809
#include <xlocale.h>
#endif
#ifndef WEOF #ifndef WEOF
# define WEOF ((wint_t)-1) # define WEOF ((wint_t)-1)
#endif #endif
@ -25,7 +29,9 @@ typedef int wctrans_t;
int _EXFUN(iswalpha, (wint_t)); int _EXFUN(iswalpha, (wint_t));
int _EXFUN(iswalnum, (wint_t)); int _EXFUN(iswalnum, (wint_t));
#if __ISO_C_VISIBLE >= 1999
int _EXFUN(iswblank, (wint_t)); int _EXFUN(iswblank, (wint_t));
#endif
int _EXFUN(iswcntrl, (wint_t)); int _EXFUN(iswcntrl, (wint_t));
int _EXFUN(iswctype, (wint_t, wctype_t)); int _EXFUN(iswctype, (wint_t, wctype_t));
int _EXFUN(iswdigit, (wint_t)); int _EXFUN(iswdigit, (wint_t));
@ -42,6 +48,27 @@ wint_t _EXFUN(towlower, (wint_t));
wctrans_t _EXFUN(wctrans, (const char *)); wctrans_t _EXFUN(wctrans, (const char *));
wctype_t _EXFUN(wctype, (const char *)); wctype_t _EXFUN(wctype, (const char *));
#if __POSIX_VISIBLE >= 200809
extern int iswalpha_l (wint_t, locale_t);
extern int iswalnum_l (wint_t, locale_t);
extern int iswblank_l (wint_t, locale_t);
extern int iswcntrl_l (wint_t, locale_t);
extern int iswctype_l (wint_t, wctype_t, locale_t);
extern int iswdigit_l (wint_t, locale_t);
extern int iswgraph_l (wint_t, locale_t);
extern int iswlower_l (wint_t, locale_t);
extern int iswprint_l (wint_t, locale_t);
extern int iswpunct_l (wint_t, locale_t);
extern int iswspace_l (wint_t, locale_t);
extern int iswupper_l (wint_t, locale_t);
extern int iswxdigit_l (wint_t, locale_t);
extern wint_t towctrans_l (wint_t, wctrans_t, locale_t);
extern wint_t towupper_l (wint_t, locale_t);
extern wint_t towlower_l (wint_t, locale_t);
extern wctrans_t wctrans_l (const char *, locale_t);
extern wctype_t wctype_l (const char *, locale_t);
#endif
_END_STD_C _END_STD_C
#endif /* _WCTYPE_H_ */ #endif /* _WCTYPE_H_ */

View file

@ -0,0 +1,12 @@
/* Definition of opaque POSIX-1.2008 type locale_t for userspace. */
#ifndef _XLOCALE_H
#define _XLOCALE_H
#include <newlib.h>
#include <sys/config.h>
struct __locale_t;
typedef struct __locale_t *locale_t;
#endif /* _XLOCALE_H */

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -90,7 +90,7 @@ C_CXX_FLAGS ?= -Wall -Wl,-EL -nostdlib $(EXTRA_C_CXX_FLAGS)
# Flags for C only # Flags for C only
CFLAGS ?= $(C_CXX_FLAGS) -std=gnu99 $(EXTRA_CFLAGS) CFLAGS ?= $(C_CXX_FLAGS) -std=gnu99 $(EXTRA_CFLAGS)
# Flags for C++ only # Flags for C++ only
CXXFLAGS ?= $(C_CXX_FLAGS) -fno-exceptions -fno-rtti $(EXTRA_CXXFLAGS) CXXFLAGS ?= $(C_CXX_FLAGS) -std=c++0x -fno-exceptions -fno-rtti $(EXTRA_CXXFLAGS)
# these aren't all technically preprocesor args, but used by all 3 of C, C++, assembler # these aren't all technically preprocesor args, but used by all 3 of C, C++, assembler
CPPFLAGS += -mlongcalls -mtext-section-literals CPPFLAGS += -mlongcalls -mtext-section-literals