libc: update to a recent newlib version.
This commit is contained in:
parent
cd23acaa4a
commit
af4ac44cb5
77 changed files with 4496 additions and 9989 deletions
|
@ -65,7 +65,7 @@ extern "C" {
|
|||
#define O_SEARCH _FEXECSRCH
|
||||
#endif
|
||||
|
||||
#ifndef _POSIX_SOURCE
|
||||
#if __MISC_VISIBLE
|
||||
|
||||
/*
|
||||
* Flags that work for fcntl(fd, F_SETFL, FXXXX)
|
||||
|
@ -97,7 +97,11 @@ extern "C" {
|
|||
#define FEXCL _FEXCL
|
||||
#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 */
|
||||
#define FD_CLOEXEC 1 /* posix */
|
||||
|
@ -108,20 +112,20 @@ extern "C" {
|
|||
#define F_SETFD 2 /* Set fildes flags (close on exec) */
|
||||
#define F_GETFL 3 /* Get file flags */
|
||||
#define F_SETFL 4 /* Set file flags */
|
||||
#ifndef _POSIX_SOURCE
|
||||
#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112
|
||||
#define F_GETOWN 5 /* Get 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_SETLK 8 /* Set or Clear a record-lock (Non-Blocking) */
|
||||
#define F_SETLKW 9 /* Set or Clear a record-lock (Blocking) */
|
||||
#ifndef _POSIX_SOURCE
|
||||
#if __MISC_VISIBLE
|
||||
#define F_RGETLK 10 /* Test a remote lock to see if it is blocked */
|
||||
#define F_RSETLK 11 /* Set or unlock a remote lock */
|
||||
#define F_CNVT 12 /* Convert a fhandle to an open fd */
|
||||
#define F_RSETLKW 13 /* Set or Clear remote record-lock(Blocking) */
|
||||
#endif /* !_POSIX_SOURCE */
|
||||
#ifdef __CYGWIN__
|
||||
#endif /* __MISC_VISIBLE */
|
||||
#if __POSIX_VISIBLE >= 200809
|
||||
#define F_DUPFD_CLOEXEC 14 /* As F_DUPFD, but set close-on-exec flag */
|
||||
#endif
|
||||
|
||||
|
@ -129,11 +133,11 @@ extern "C" {
|
|||
#define F_RDLCK 1 /* read lock */
|
||||
#define F_WRLCK 2 /* write lock */
|
||||
#define F_UNLCK 3 /* remove lock(s) */
|
||||
#ifndef _POSIX_SOURCE
|
||||
#if __MISC_VISIBLE
|
||||
#define F_UNLKSYS 4 /* remove remote locks for a given system */
|
||||
#endif /* !_POSIX_SOURCE */
|
||||
#endif /* __MISC_VISIBLE */
|
||||
|
||||
#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809 || defined(__CYGWIN__)
|
||||
#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809
|
||||
/* Special descriptor value to denote the cwd in calls to openat(2) etc. */
|
||||
#define AT_FDCWD -2
|
||||
|
||||
|
@ -166,7 +170,7 @@ struct flock {
|
|||
};
|
||||
#endif /* __CYGWIN__ */
|
||||
|
||||
#ifndef _POSIX_SOURCE
|
||||
#if __MISC_VISIBLE
|
||||
/* extended file segment locking set data type */
|
||||
struct eflock {
|
||||
short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */
|
||||
|
@ -178,13 +182,13 @@ struct eflock {
|
|||
long l_rpid; /* Remote process id wanting this lock */
|
||||
long l_rsys; /* Remote system id wanting this lock */
|
||||
};
|
||||
#endif /* !_POSIX_SOURCE */
|
||||
#endif /* __MISC_VISIBLE */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h> /* sigh. for the mode bits for open/creat */
|
||||
|
||||
extern int open _PARAMS ((const char *, int, ...));
|
||||
#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809 || defined(__CYGWIN__)
|
||||
#if __ATFILE_VISIBLE
|
||||
extern int openat _PARAMS ((int, const char *, int, ...));
|
||||
#endif
|
||||
extern int creat _PARAMS ((const char *, mode_t));
|
||||
|
@ -192,7 +196,7 @@ extern int fcntl _PARAMS ((int, int, ...));
|
|||
#if __BSD_VISIBLE
|
||||
extern int flock _PARAMS ((int, int));
|
||||
#endif
|
||||
#ifdef __CYGWIN__
|
||||
#if __GNU_VISIBLE
|
||||
#include <sys/time.h>
|
||||
extern int futimesat _PARAMS ((int, const char *, const struct timeval *));
|
||||
#endif
|
||||
|
|
233
libc/xtensa-lx106-elf/include/sys/_pthreadtypes.h
Normal file
233
libc/xtensa-lx106-elf/include/sys/_pthreadtypes.h
Normal 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_ */
|
43
libc/xtensa-lx106-elf/include/sys/_sigset.h
Normal file
43
libc/xtensa-lx106-elf/include/sys/_sigset.h
Normal 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_ */
|
90
libc/xtensa-lx106-elf/include/sys/_stdint.h
Normal file
90
libc/xtensa-lx106-elf/include/sys/_stdint.h
Normal 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 */
|
50
libc/xtensa-lx106-elf/include/sys/_timespec.h
Normal file
50
libc/xtensa-lx106-elf/include/sys/_timespec.h
Normal 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_ */
|
89
libc/xtensa-lx106-elf/include/sys/_timeval.h
Normal file
89
libc/xtensa-lx106-elf/include/sys/_timeval.h
Normal 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_ */
|
|
@ -2,51 +2,141 @@
|
|||
|
||||
/* This file defines various typedefs needed by the system calls that support
|
||||
the C library. Basically, they're just the POSIX versions with an '_'
|
||||
prepended. This file lives in the `sys' directory so targets can provide
|
||||
their own if desired (or they can put target dependant conditionals here).
|
||||
prepended. Targets shall use <machine/_types.h> to define their own
|
||||
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
|
||||
#define _SYS__TYPES_H
|
||||
|
||||
#include <newlib.h>
|
||||
#include <sys/config.h>
|
||||
#include <machine/_types.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;
|
||||
#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;
|
||||
#endif
|
||||
|
||||
#ifndef __uid_t_defined
|
||||
#ifndef __machine_uid_t_defined
|
||||
typedef unsigned short __uid_t;
|
||||
#endif
|
||||
#ifndef __gid_t_defined
|
||||
#ifndef __machine_gid_t_defined
|
||||
typedef unsigned short __gid_t;
|
||||
#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;
|
||||
#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 "_",
|
||||
* 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> */
|
||||
/* (and must be `long' for now) */
|
||||
#endif
|
||||
|
||||
#ifdef __LARGE64_FILES
|
||||
#ifndef __fpos64_t_defined
|
||||
#ifndef __machine_fpos64_t_defined
|
||||
typedef _off64_t _fpos64_t;
|
||||
#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__
|
||||
/* If __SIZE_TYPE__ is defined (gcc) we define ssize_t based on size_t.
|
||||
We simply change "unsigned" to "signed" for this single definition
|
||||
|
@ -63,10 +153,12 @@ typedef long _ssize_t;
|
|||
#endif
|
||||
#endif
|
||||
|
||||
typedef _ssize_t __ssize_t;
|
||||
|
||||
#define __need_wint_t
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef __mbstate_t_defined
|
||||
#ifndef __machine_mbstate_t_defined
|
||||
/* Conversion state information. */
|
||||
typedef struct
|
||||
{
|
||||
|
@ -79,13 +171,43 @@ typedef struct
|
|||
} _mbstate_t;
|
||||
#endif
|
||||
|
||||
#ifndef __flock_t_defined
|
||||
#ifndef __machine_flock_t_defined
|
||||
typedef _LOCK_RECURSIVE_T _flock_t;
|
||||
#endif
|
||||
|
||||
#ifndef __iconv_t_defined
|
||||
#ifndef __machine_iconv_t_defined
|
||||
/* Iconv descriptor type */
|
||||
typedef void *_iconv_t;
|
||||
#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 */
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* 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
|
||||
* 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
|
||||
* without specific prior written permission.
|
||||
*
|
||||
|
@ -69,7 +69,9 @@
|
|||
/*
|
||||
* Testing against Clang-specific extensions.
|
||||
*/
|
||||
|
||||
#ifndef __has_attribute
|
||||
#define __has_attribute(x) 0
|
||||
#endif
|
||||
#ifndef __has_extension
|
||||
#define __has_extension __has_feature
|
||||
#endif
|
||||
|
@ -100,33 +102,33 @@
|
|||
#if defined(__GNUC__) || defined(__INTEL_COMPILER)
|
||||
|
||||
#if __GNUC__ >= 3 || defined(__INTEL_COMPILER)
|
||||
#define __GNUCLIKE_ASM 3
|
||||
#define __GNUCLIKE_MATH_BUILTIN_CONSTANTS
|
||||
#define __GNUCLIKE_ASM 3
|
||||
#define __GNUCLIKE_MATH_BUILTIN_CONSTANTS
|
||||
#else
|
||||
#define __GNUCLIKE_ASM 2
|
||||
#define __GNUCLIKE_ASM 2
|
||||
#endif
|
||||
#define __GNUCLIKE___TYPEOF 1
|
||||
#define __GNUCLIKE___OFFSETOF 1
|
||||
#define __GNUCLIKE___SECTION 1
|
||||
#define __GNUCLIKE___TYPEOF 1
|
||||
#define __GNUCLIKE___OFFSETOF 1
|
||||
#define __GNUCLIKE___SECTION 1
|
||||
|
||||
#ifndef __INTEL_COMPILER
|
||||
# define __GNUCLIKE_CTOR_SECTION_HANDLING 1
|
||||
#define __GNUCLIKE_CTOR_SECTION_HANDLING 1
|
||||
#endif
|
||||
|
||||
#define __GNUCLIKE_BUILTIN_CONSTANT_P 1
|
||||
# if defined(__INTEL_COMPILER) && defined(__cplusplus) \
|
||||
&& __INTEL_COMPILER < 800
|
||||
# undef __GNUCLIKE_BUILTIN_CONSTANT_P
|
||||
# endif
|
||||
#define __GNUCLIKE_BUILTIN_CONSTANT_P 1
|
||||
#if defined(__INTEL_COMPILER) && defined(__cplusplus) && \
|
||||
__INTEL_COMPILER < 800
|
||||
#undef __GNUCLIKE_BUILTIN_CONSTANT_P
|
||||
#endif
|
||||
|
||||
#if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3) && !defined(__INTEL_COMPILER)
|
||||
# define __GNUCLIKE_BUILTIN_VARARGS 1
|
||||
# define __GNUCLIKE_BUILTIN_STDARG 1
|
||||
# define __GNUCLIKE_BUILTIN_VAALIST 1
|
||||
#if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3)
|
||||
#define __GNUCLIKE_BUILTIN_VARARGS 1
|
||||
#define __GNUCLIKE_BUILTIN_STDARG 1
|
||||
#define __GNUCLIKE_BUILTIN_VAALIST 1
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
# define __GNUC_VA_LIST_COMPATIBILITY 1
|
||||
#define __GNUC_VA_LIST_COMPATIBILITY 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -137,23 +139,23 @@
|
|||
#endif
|
||||
|
||||
#ifndef __INTEL_COMPILER
|
||||
# define __GNUCLIKE_BUILTIN_NEXT_ARG 1
|
||||
# define __GNUCLIKE_MATH_BUILTIN_RELOPS
|
||||
#define __GNUCLIKE_BUILTIN_NEXT_ARG 1
|
||||
#define __GNUCLIKE_MATH_BUILTIN_RELOPS
|
||||
#endif
|
||||
|
||||
#define __GNUCLIKE_BUILTIN_MEMCPY 1
|
||||
#define __GNUCLIKE_BUILTIN_MEMCPY 1
|
||||
|
||||
/* 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_WARNING 1
|
||||
#define __CC_SUPPORTS___FUNC__ 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 */
|
||||
|
||||
|
@ -229,8 +231,12 @@
|
|||
#define __unused
|
||||
#define __packed
|
||||
#define __aligned(x)
|
||||
#define __alloc_align(x)
|
||||
#define __alloc_size(x)
|
||||
#define __section(x)
|
||||
#define __weak_symbol
|
||||
#else
|
||||
#define __weak_symbol __attribute__((__weak__))
|
||||
#if !__GNUC_PREREQ__(2, 5) && !defined(__INTEL_COMPILER)
|
||||
#define __dead2
|
||||
#define __pure2
|
||||
|
@ -242,7 +248,7 @@
|
|||
#define __unused
|
||||
/* XXX Find out what to do for __packed, __aligned and __section */
|
||||
#endif
|
||||
#if __GNUC_PREREQ__(2, 7)
|
||||
#if __GNUC_PREREQ__(2, 7) || defined(__INTEL_COMPILER)
|
||||
#define __dead2 __attribute__((__noreturn__))
|
||||
#define __pure2 __attribute__((__const__))
|
||||
#define __unused __attribute__((__unused__))
|
||||
|
@ -251,16 +257,17 @@
|
|||
#define __aligned(x) __attribute__((__aligned__(x)))
|
||||
#define __section(x) __attribute__((__section__(x)))
|
||||
#endif
|
||||
#if defined(__INTEL_COMPILER)
|
||||
#define __dead2 __attribute__((__noreturn__))
|
||||
#define __pure2 __attribute__((__const__))
|
||||
#define __unused __attribute__((__unused__))
|
||||
#define __used __attribute__((__used__))
|
||||
#define __packed __attribute__((__packed__))
|
||||
#define __aligned(x) __attribute__((__aligned__(x)))
|
||||
#define __section(x) __attribute__((__section__(x)))
|
||||
#if __GNUC_PREREQ__(4, 3) || __has_attribute(__alloc_size__)
|
||||
#define __alloc_size(x) __attribute__((__alloc_size__(x)))
|
||||
#else
|
||||
#define __alloc_size(x)
|
||||
#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 /* lint */
|
||||
|
||||
#if !__GNUC_PREREQ__(2, 95)
|
||||
#define __alignof(x) __offsetof(struct { char __a; x __b; }, __b)
|
||||
|
@ -270,7 +277,7 @@
|
|||
* 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 (defined(__cplusplus) && __cplusplus >= 201103L) || \
|
||||
|
@ -288,7 +295,8 @@
|
|||
#define _Alignof(x) __alignof(x)
|
||||
#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
|
||||
* most forms of direct non-atomic access.
|
||||
|
@ -302,23 +310,28 @@
|
|||
#define _Noreturn __dead2
|
||||
#endif
|
||||
|
||||
#if __GNUC_PREREQ__(4, 6) && !defined(__cplusplus)
|
||||
/* Do nothing: _Static_assert() works as per C11 */
|
||||
#elif !__has_extension(c_static_assert)
|
||||
#if !__has_extension(c_static_assert)
|
||||
#if (defined(__cplusplus) && __cplusplus >= 201103L) || \
|
||||
__has_extension(cxx_static_assert)
|
||||
#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__)
|
||||
#define _Static_assert(x, y) __Static_assert(x, __COUNTER__)
|
||||
#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
|
||||
#define _Static_assert(x, y) struct __hack
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#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) || */ \
|
||||
__has_extension(cxx_thread_local)
|
||||
#define _Thread_local thread_local
|
||||
|
@ -338,7 +351,8 @@
|
|||
* 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) \
|
||||
_Generic(expr, t: yes, default: no)
|
||||
#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)
|
||||
|
@ -347,6 +361,21 @@
|
|||
__builtin_types_compatible_p(__typeof(expr), t), yes, no)
|
||||
#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)
|
||||
#define __malloc_like __attribute__((__malloc__))
|
||||
#define __pure __attribute__((__pure__))
|
||||
|
@ -368,15 +397,19 @@
|
|||
#endif
|
||||
|
||||
#if __GNUC_PREREQ__(3, 3)
|
||||
#define __nonnull(x) __attribute__((__nonnull__(x)))
|
||||
#define __nonnull(x) __attribute__((__nonnull__(x)))
|
||||
#define __nonnull_all __attribute__((__nonnull__))
|
||||
#else
|
||||
#define __nonnull(x)
|
||||
#define __nonnull(x)
|
||||
#define __nonnull_all
|
||||
#endif
|
||||
|
||||
#if __GNUC_PREREQ__(3, 4)
|
||||
#define __fastcall __attribute__((__fastcall__))
|
||||
#define __result_use_check __attribute__((__warn_unused_result__))
|
||||
#else
|
||||
#define __fastcall
|
||||
#define __result_use_check
|
||||
#endif
|
||||
|
||||
#if __GNUC_PREREQ__(4, 1)
|
||||
|
@ -385,6 +418,12 @@
|
|||
#define __returns_twice
|
||||
#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'. */
|
||||
#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
|
||||
#define __func__ NULL
|
||||
|
@ -433,19 +472,26 @@
|
|||
* larger code.
|
||||
*/
|
||||
#if __GNUC_PREREQ__(2, 96)
|
||||
#define __predict_true(exp) __builtin_expect((exp), 1)
|
||||
#define __predict_false(exp) __builtin_expect((exp), 0)
|
||||
#define __predict_true(exp) __builtin_expect((exp), 1)
|
||||
#define __predict_false(exp) __builtin_expect((exp), 0)
|
||||
#else
|
||||
#define __predict_true(exp) (exp)
|
||||
#define __predict_false(exp) (exp)
|
||||
#define __predict_true(exp) (exp)
|
||||
#define __predict_false(exp) (exp)
|
||||
#endif
|
||||
|
||||
#if __GNUC_PREREQ__(4, 2)
|
||||
#define __hidden __attribute__((__visibility__("hidden")))
|
||||
#if __GNUC_PREREQ__(4, 0)
|
||||
#define __null_sentinel __attribute__((__sentinel__))
|
||||
#define __exported __attribute__((__visibility__("default")))
|
||||
/* Only default visibility is supported on PE/COFF targets. */
|
||||
#ifndef __CYGWIN__
|
||||
#define __hidden __attribute__((__visibility__("hidden")))
|
||||
#else
|
||||
#define __hidden
|
||||
#endif
|
||||
#else
|
||||
#define __null_sentinel
|
||||
#define __exported
|
||||
#define __hidden
|
||||
#endif
|
||||
|
||||
#define __offsetof(type, field) offsetof(type, field)
|
||||
|
@ -460,7 +506,7 @@
|
|||
*/
|
||||
#if __GNUC_PREREQ__(3, 1)
|
||||
#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));\
|
||||
})
|
||||
#else
|
||||
|
@ -583,128 +629,94 @@
|
|||
#define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var))
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* The following definitions are an extension of the behavior originally
|
||||
* 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.
|
||||
/*
|
||||
* Nullability qualifiers: currently only supported by Clang.
|
||||
*/
|
||||
|
||||
/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */
|
||||
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1
|
||||
#undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */
|
||||
#define _POSIX_C_SOURCE 199009
|
||||
#endif
|
||||
|
||||
/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */
|
||||
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2
|
||||
#undef _POSIX_C_SOURCE
|
||||
#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
|
||||
#if !(defined(__clang__) && __has_feature(nullability))
|
||||
#define _Nonnull
|
||||
#define _Nullable
|
||||
#define _Null_unspecified
|
||||
#define __NULLABILITY_PRAGMA_PUSH
|
||||
#define __NULLABILITY_PRAGMA_POP
|
||||
#else
|
||||
#define __NULLABILITY_PRAGMA_PUSH _Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic ignored \"-Wnullability-completeness\"")
|
||||
#define __NULLABILITY_PRAGMA_POP _Pragma("clang diagnostic pop")
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Deal with all versions of POSIX. The ordering relative to the tests above is
|
||||
* 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.
|
||||
* Type Safety Checking
|
||||
*
|
||||
* If a program mistakenly defines _ANSI_SOURCE and some other macro such as
|
||||
* _POSIX_C_SOURCE, we will assume that it wants the broader compilation
|
||||
* environment (and in fact we will never get here).
|
||||
* Clang provides additional attributes to enable checking type safety
|
||||
* properties that cannot be enforced by the C type system.
|
||||
*/
|
||||
#if defined(_ANSI_SOURCE) /* Hide almost everything. */
|
||||
#define __POSIX_VISIBLE 0
|
||||
#define __XSI_VISIBLE 0
|
||||
#define __BSD_VISIBLE 0
|
||||
#define __ISO_C_VISIBLE 1990
|
||||
#elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */
|
||||
#define __POSIX_VISIBLE 0
|
||||
#define __XSI_VISIBLE 0
|
||||
#define __BSD_VISIBLE 0
|
||||
#define __ISO_C_VISIBLE 1999
|
||||
#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
|
||||
|
||||
#if __has_attribute(__argument_with_type_tag__) && \
|
||||
__has_attribute(__type_tag_for_datatype__) && !defined(lint)
|
||||
#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx) \
|
||||
__attribute__((__argument_with_type_tag__(arg_kind, arg_idx, type_tag_idx)))
|
||||
#define __datatype_type_tag(kind, type) \
|
||||
__attribute__((__type_tag_for_datatype__(kind, type)))
|
||||
#else
|
||||
#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx)
|
||||
#define __datatype_type_tag(kind, type)
|
||||
#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_ */
|
||||
|
|
|
@ -92,7 +92,6 @@
|
|||
/* we want the reentrancy structure to be returned by a function */
|
||||
#define __DYNAMIC_REENT__
|
||||
#define HAVE_GETDATE
|
||||
#define _HAVE_SYSTYPES
|
||||
#define _READ_WRITE_RETURN_TYPE _ssize_t
|
||||
#define __LARGE64_FILES 1
|
||||
/* we use some glibc header files so turn on glibc large file feature */
|
||||
|
@ -185,6 +184,10 @@
|
|||
#define __CUSTOM_FILE_IO__
|
||||
#endif
|
||||
|
||||
#if defined(__or1k__) || defined(__or1knd__)
|
||||
#define __DYNAMIC_REENT__
|
||||
#endif
|
||||
|
||||
#ifdef __XTENSA__
|
||||
#include <xtensa/config/core-isa.h>
|
||||
#define MALLOC_ALIGNMENT ((XCHAL_DATA_WIDTH) < 16 ? 16 : (XCHAL_DATA_WIDTH))
|
||||
|
@ -235,9 +238,6 @@
|
|||
|
||||
#if defined(__CYGWIN__)
|
||||
#include <cygwin/config.h>
|
||||
#if !defined (__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L)
|
||||
#define __USE_XOPEN2K 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__rtems__)
|
||||
|
@ -245,6 +245,7 @@
|
|||
#define _READ_WRITE_RETURN_TYPE _ssize_t
|
||||
#define __DYNAMIC_REENT__
|
||||
#define _REENT_GLOBAL_ATEXIT
|
||||
#define _REENT_GLOBAL_STDIO_STREAMS
|
||||
#endif
|
||||
|
||||
#ifndef __EXPORT
|
||||
|
@ -282,6 +283,12 @@
|
|||
#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
|
||||
charsets. The extended charsets add a few functions and a couple
|
||||
of tables of a few K each. */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Written by Joel Sherrill <joel@OARcorp.com>.
|
||||
*
|
||||
* COPYRIGHT (c) 1989-2000.
|
||||
* COPYRIGHT (c) 1989-2014.
|
||||
*
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
|
@ -25,11 +25,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Macros to determine that newlib is being used. Put in this header to
|
||||
* be similar to where glibc stores its version of these macros.
|
||||
*/
|
||||
#define __NEWLIB__ 2
|
||||
#define __NEWLIB_MINOR__ 1
|
||||
#include <_newlib_version.h>
|
||||
|
||||
/* Macro to test version of GCC. Returns 0 for non-GCC or too old GCC. */
|
||||
#ifndef __GNUC_PREREQ
|
||||
|
@ -43,6 +39,281 @@ extern "C" {
|
|||
/* Version with trailing underscores for BSD compatibility. */
|
||||
#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. */
|
||||
|
||||
#ifdef __rtems__
|
||||
|
@ -57,11 +328,12 @@ extern "C" {
|
|||
#define _POSIX_MEMORY_PROTECTION 1
|
||||
#define _POSIX_MESSAGE_PASSING 1
|
||||
#define _POSIX_MONOTONIC_CLOCK 200112L
|
||||
#define _POSIX_CLOCK_SELECTION 200112L
|
||||
#define _POSIX_PRIORITIZED_IO 1
|
||||
#define _POSIX_PRIORITY_SCHEDULING 1
|
||||
#define _POSIX_REALTIME_SIGNALS 1
|
||||
#define _POSIX_SEMAPHORES 1
|
||||
/* #define _POSIX_SHARED_MEMORY_OBJECTS 1 */
|
||||
#define _POSIX_SHARED_MEMORY_OBJECTS 1
|
||||
#define _POSIX_SYNCHRONIZED_IO 1
|
||||
#define _POSIX_TIMERS 1
|
||||
#define _POSIX_BARRIERS 200112L
|
||||
|
@ -94,6 +366,9 @@ extern "C" {
|
|||
/* UNIX98 added some new pthread mutex attributes */
|
||||
#define _UNIX98_THREAD_MUTEX_ATTRIBUTES 1
|
||||
|
||||
/* POSIX 1003.26-2003 defined device control method */
|
||||
#define _POSIX_26_VERSION 200312L
|
||||
|
||||
#endif
|
||||
|
||||
/* XMK loosely adheres to POSIX -- 1003.1 */
|
||||
|
@ -111,62 +386,82 @@ extern "C" {
|
|||
|
||||
#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 _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_BARRIERS -1 */
|
||||
#define _POSIX_BARRIERS 200809L
|
||||
#define _POSIX_CHOWN_RESTRICTED 1
|
||||
#define _POSIX_CLOCK_SELECTION 200112L
|
||||
#define _POSIX_CPUTIME 200112L
|
||||
#define _POSIX_FSYNC 200112L
|
||||
#define _POSIX_IPV6 200112L
|
||||
#define _POSIX_CLOCK_SELECTION 200809L
|
||||
#define _POSIX_CPUTIME 200809L
|
||||
#define _POSIX_FSYNC 200809L
|
||||
#define _POSIX_IPV6 200809L
|
||||
#define _POSIX_JOB_CONTROL 1
|
||||
#define _POSIX_MAPPED_FILES 200112L
|
||||
#define _POSIX_MAPPED_FILES 200809L
|
||||
/* #define _POSIX_MEMLOCK -1 */
|
||||
#define _POSIX_MEMLOCK_RANGE 200112L
|
||||
#define _POSIX_MEMORY_PROTECTION 200112L
|
||||
#define _POSIX_MESSAGE_PASSING 200112L
|
||||
#define _POSIX_MONOTONIC_CLOCK 200112L
|
||||
#define _POSIX_MEMLOCK_RANGE 200809L
|
||||
#define _POSIX_MEMORY_PROTECTION 200809L
|
||||
#define _POSIX_MESSAGE_PASSING 200809L
|
||||
#define _POSIX_MONOTONIC_CLOCK 200809L
|
||||
#define _POSIX_NO_TRUNC 1
|
||||
/* #define _POSIX_PRIORITIZED_IO -1 */
|
||||
#define _POSIX_PRIORITY_SCHEDULING 200112L
|
||||
#define _POSIX_RAW_SOCKETS 200112L
|
||||
#define _POSIX_READER_WRITER_LOCKS 200112L
|
||||
#define _POSIX_REALTIME_SIGNALS 200112L
|
||||
#define _POSIX_PRIORITY_SCHEDULING 200809L
|
||||
#define _POSIX_RAW_SOCKETS 200809L
|
||||
#define _POSIX_READER_WRITER_LOCKS 200809L
|
||||
#define _POSIX_REALTIME_SIGNALS 200809L
|
||||
#define _POSIX_REGEXP 1
|
||||
#define _POSIX_SAVED_IDS 1
|
||||
#define _POSIX_SEMAPHORES 200112L
|
||||
#define _POSIX_SHARED_MEMORY_OBJECTS 200112L
|
||||
#define _POSIX_SEMAPHORES 200809L
|
||||
#define _POSIX_SHARED_MEMORY_OBJECTS 200809L
|
||||
#define _POSIX_SHELL 1
|
||||
/* #define _POSIX_SPAWN -1 */
|
||||
#define _POSIX_SPIN_LOCKS 200112L
|
||||
#define _POSIX_SPAWN 200809L
|
||||
#define _POSIX_SPIN_LOCKS 200809L
|
||||
/* #define _POSIX_SPORADIC_SERVER -1 */
|
||||
#define _POSIX_SYNCHRONIZED_IO 200112L
|
||||
#define _POSIX_THREAD_ATTR_STACKADDR 200112L
|
||||
#define _POSIX_THREAD_ATTR_STACKSIZE 200112L
|
||||
#define _POSIX_THREAD_CPUTIME 200112L
|
||||
#define _POSIX_SYNCHRONIZED_IO 200809L
|
||||
#define _POSIX_THREAD_ATTR_STACKADDR 200809L
|
||||
#define _POSIX_THREAD_ATTR_STACKSIZE 200809L
|
||||
#define _POSIX_THREAD_CPUTIME 200809L
|
||||
/* #define _POSIX_THREAD_PRIO_INHERIT -1 */
|
||||
/* #define _POSIX_THREAD_PRIO_PROTECT -1 */
|
||||
#define _POSIX_THREAD_PRIORITY_SCHEDULING 200112L
|
||||
#define _POSIX_THREAD_PROCESS_SHARED 200112L
|
||||
#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L
|
||||
#define _POSIX_THREAD_PRIORITY_SCHEDULING 200809L
|
||||
#define _POSIX_THREAD_PROCESS_SHARED 200809L
|
||||
#define _POSIX_THREAD_SAFE_FUNCTIONS 200809L
|
||||
/* #define _POSIX_THREAD_SPORADIC_SERVER -1 */
|
||||
#define _POSIX_THREADS 200112L
|
||||
#define _POSIX_THREADS 200809L
|
||||
/* #define _POSIX_TIMEOUTS -1 */
|
||||
#define _POSIX_TIMERS 1
|
||||
#define _POSIX_TIMERS 200809L
|
||||
/* #define _POSIX_TRACE -1 */
|
||||
/* #define _POSIX_TRACE_EVENT_FILTER -1 */
|
||||
/* #define _POSIX_TRACE_INHERIT -1 */
|
||||
/* #define _POSIX_TRACE_LOG -1 */
|
||||
/* #define _POSIX_TYPED_MEMORY_OBJECTS -1 */
|
||||
#define _POSIX_VDISABLE '\0'
|
||||
#define _POSIX2_C_BIND 200112L
|
||||
#define _POSIX2_C_DEV 200112L
|
||||
#define _POSIX2_CHAR_TERM 200112L
|
||||
|
||||
#if __POSIX_VISIBLE >= 2
|
||||
#define _POSIX2_C_VERSION _POSIX2_VERSION
|
||||
#define _POSIX2_C_BIND _POSIX2_VERSION
|
||||
#define _POSIX2_C_DEV _POSIX2_VERSION
|
||||
#define _POSIX2_CHAR_TERM _POSIX2_VERSION
|
||||
/* #define _POSIX2_FORT_DEV -1 */
|
||||
/* #define _POSIX2_FORT_RUN -1 */
|
||||
/* #define _POSIX2_LOCALEDEF -1 */
|
||||
|
@ -176,8 +471,10 @@ extern "C" {
|
|||
/* #define _POSIX2_PBS_LOCATE -1 */
|
||||
/* #define _POSIX2_PBS_MESSAGE -1 */
|
||||
/* #define _POSIX2_PBS_TRACK -1 */
|
||||
#define _POSIX2_SW_DEV 200112L
|
||||
#define _POSIX2_UPE 200112L
|
||||
#define _POSIX2_SW_DEV _POSIX2_VERSION
|
||||
#define _POSIX2_UPE _POSIX2_VERSION
|
||||
#endif /* __POSIX_VISIBLE >= 2 */
|
||||
|
||||
#define _POSIX_V6_ILP32_OFF32 -1
|
||||
#ifdef __LP64__
|
||||
#define _POSIX_V6_ILP32_OFFBIG -1
|
||||
|
@ -188,10 +485,16 @@ extern "C" {
|
|||
#define _POSIX_V6_LP64_OFF64 -1
|
||||
#define _POSIX_V6_LPBIG_OFFBIG -1
|
||||
#endif
|
||||
#define _POSIX_V7_ILP32_OFF32 _POSIX_V6_ILP32_OFF32
|
||||
#define _POSIX_V7_ILP32_OFFBIG _POSIX_V6_ILP32_OFFBIG
|
||||
#define _POSIX_V7_LP64_OFF64 _POSIX_V6_LP64_OFF64
|
||||
#define _POSIX_V7_LPBIG_OFFBIG _POSIX_V6_LPBIG_OFFBIG
|
||||
#define _XBS5_ILP32_OFF32 _POSIX_V6_ILP32_OFF32
|
||||
#define _XBS5_ILP32_OFFBIG _POSIX_V6_ILP32_OFFBIG
|
||||
#define _XBS5_LP64_OFF64 _POSIX_V6_LP64_OFF64
|
||||
#define _XBS5_LPBIG_OFFBIG _POSIX_V6_LPBIG_OFFBIG
|
||||
|
||||
#if __XSI_VISIBLE
|
||||
#define _XOPEN_CRYPT 1
|
||||
#define _XOPEN_ENH_I18N 1
|
||||
/* #define _XOPEN_LEGACY -1 */
|
||||
|
@ -200,8 +503,7 @@ extern "C" {
|
|||
#define _XOPEN_SHM 1
|
||||
/* #define _XOPEN_STREAMS -1 */
|
||||
/* #define _XOPEN_UNIX -1 */
|
||||
|
||||
#endif /* !__STRICT_ANSI__ || __cplusplus || __STDC_VERSION__ >= 199901L */
|
||||
#endif /* __XSI_VISIBLE */
|
||||
|
||||
/* The value corresponds to UNICODE version 4.0, which is the version
|
||||
supported by XP. Newlib supports 5.2 (2011) but so far Cygwin needs
|
||||
|
@ -210,25 +512,6 @@ extern "C" {
|
|||
|
||||
#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
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
#include <machine/endian.h>
|
||||
#include <machine/param.h>
|
||||
|
||||
#ifndef NBBY
|
||||
# define NBBY 8 /* number of bits in a byte */
|
||||
#endif
|
||||
#ifndef HZ
|
||||
# define HZ (60)
|
||||
#endif
|
||||
|
@ -25,4 +28,8 @@
|
|||
#define MAX(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
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
* 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
|
||||
* 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
|
||||
* without specific prior written permission.
|
||||
*
|
||||
|
@ -76,11 +76,17 @@
|
|||
*
|
||||
* 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
|
||||
* _HEAD + + + +
|
||||
* _CLASS_HEAD + + + +
|
||||
* _HEAD_INITIALIZER + + + +
|
||||
* _ENTRY + + + +
|
||||
* _CLASS_ENTRY + + + +
|
||||
* _INIT + + + +
|
||||
* _EMPTY + + + +
|
||||
* _FIRST + + + +
|
||||
|
@ -88,21 +94,31 @@
|
|||
* _PREV - + - +
|
||||
* _LAST - - + +
|
||||
* _FOREACH + + + +
|
||||
* _FOREACH_FROM + + + +
|
||||
* _FOREACH_SAFE + + + +
|
||||
* _FOREACH_FROM_SAFE + + + +
|
||||
* _FOREACH_REVERSE - - - +
|
||||
* _FOREACH_REVERSE_FROM - - - +
|
||||
* _FOREACH_REVERSE_SAFE - - - +
|
||||
* _FOREACH_REVERSE_FROM_SAFE - - - +
|
||||
* _INSERT_HEAD + + + +
|
||||
* _INSERT_BEFORE - + - +
|
||||
* _INSERT_AFTER + + + +
|
||||
* _INSERT_TAIL - - + +
|
||||
* _CONCAT - - + +
|
||||
* _CONCAT s s + +
|
||||
* _REMOVE_AFTER + - + -
|
||||
* _REMOVE_HEAD + - + -
|
||||
* _REMOVE + + + +
|
||||
* _REMOVE s + s +
|
||||
* _SWAP + + + +
|
||||
*
|
||||
*/
|
||||
#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 */
|
||||
struct qm_trace {
|
||||
unsigned long lastline;
|
||||
|
@ -112,9 +128,7 @@ struct qm_trace {
|
|||
};
|
||||
|
||||
#define TRACEBUF struct qm_trace trace;
|
||||
#define TRACEBUF_INITIALIZER { __FILE__, __LINE__, NULL, 0 } ,
|
||||
#define TRASHIT(x) do {(x) = (void *)-1;} while (0)
|
||||
#define QMD_SAVELINK(name, link) void **name = (void *)&(link)
|
||||
#define TRACEBUF_INITIALIZER { __LINE__, 0, __FILE__, NULL } ,
|
||||
|
||||
#define QMD_TRACE_HEAD(head) do { \
|
||||
(head)->trace.prevline = (head)->trace.lastline; \
|
||||
|
@ -130,14 +144,35 @@ struct qm_trace {
|
|||
(elem)->trace.lastfile = __FILE__; \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
#else /* !QUEUE_MACRO_DEBUG_TRACE */
|
||||
#define QMD_TRACE_ELEM(elem)
|
||||
#define QMD_TRACE_HEAD(head)
|
||||
#define QMD_SAVELINK(name, link)
|
||||
#define TRACEBUF
|
||||
#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)
|
||||
#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.
|
||||
|
@ -147,6 +182,11 @@ struct name { \
|
|||
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) \
|
||||
{ NULL }
|
||||
|
||||
|
@ -155,9 +195,37 @@ struct { \
|
|||
struct type *sle_next; /* next element */ \
|
||||
}
|
||||
|
||||
#define SLIST_CLASS_ENTRY(type) \
|
||||
struct { \
|
||||
class type *sle_next; /* next element */ \
|
||||
}
|
||||
|
||||
/*
|
||||
* 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_FIRST(head) ((head)->slh_first)
|
||||
|
@ -167,11 +235,21 @@ struct { \
|
|||
(var); \
|
||||
(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) \
|
||||
for ((var) = SLIST_FIRST((head)); \
|
||||
(var) && ((tvar) = SLIST_NEXT((var), field), 1); \
|
||||
(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) \
|
||||
for ((varp) = &SLIST_FIRST((head)); \
|
||||
((var) = *(varp)) != NULL; \
|
||||
|
@ -199,7 +277,7 @@ struct { \
|
|||
SLIST_REMOVE_HEAD((head), field); \
|
||||
} \
|
||||
else { \
|
||||
struct type *curelm = SLIST_FIRST((head)); \
|
||||
QUEUE_TYPEOF(type) *curelm = SLIST_FIRST(head); \
|
||||
while (SLIST_NEXT(curelm, field) != (elm)) \
|
||||
curelm = SLIST_NEXT(curelm, field); \
|
||||
SLIST_REMOVE_AFTER(curelm, field); \
|
||||
|
@ -216,8 +294,14 @@ struct { \
|
|||
SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \
|
||||
} 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 { \
|
||||
struct type *swap_first = SLIST_FIRST(head1); \
|
||||
QUEUE_TYPEOF(type) *swap_first = SLIST_FIRST(head1); \
|
||||
SLIST_FIRST(head1) = SLIST_FIRST(head2); \
|
||||
SLIST_FIRST(head2) = swap_first; \
|
||||
} while (0)
|
||||
|
@ -231,6 +315,12 @@ struct name { \
|
|||
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) \
|
||||
{ NULL, &(head).stqh_first }
|
||||
|
||||
|
@ -239,6 +329,11 @@ struct { \
|
|||
struct type *stqe_next; /* next element */ \
|
||||
}
|
||||
|
||||
#define STAILQ_CLASS_ENTRY(type) \
|
||||
struct { \
|
||||
class type *stqe_next; /* next element */ \
|
||||
}
|
||||
|
||||
/*
|
||||
* Singly-linked Tail queue functions.
|
||||
*/
|
||||
|
@ -259,12 +354,21 @@ struct { \
|
|||
(var); \
|
||||
(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) \
|
||||
for ((var) = STAILQ_FIRST((head)); \
|
||||
(var) && ((tvar) = STAILQ_NEXT((var), field), 1); \
|
||||
(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 { \
|
||||
STAILQ_FIRST((head)) = NULL; \
|
||||
(head)->stqh_last = &STAILQ_FIRST((head)); \
|
||||
|
@ -288,9 +392,10 @@ struct { \
|
|||
(head)->stqh_last = &STAILQ_NEXT((elm), field); \
|
||||
} while (0)
|
||||
|
||||
#define STAILQ_LAST(head, type, field) \
|
||||
(STAILQ_EMPTY((head)) ? NULL : \
|
||||
__containerof((head)->stqh_last, struct type, field.stqe_next))
|
||||
#define STAILQ_LAST(head, type, field) \
|
||||
(STAILQ_EMPTY((head)) ? NULL : \
|
||||
__containerof((head)->stqh_last, \
|
||||
QUEUE_TYPEOF(type), field.stqe_next))
|
||||
|
||||
#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
|
||||
|
||||
|
@ -300,7 +405,7 @@ struct { \
|
|||
STAILQ_REMOVE_HEAD((head), field); \
|
||||
} \
|
||||
else { \
|
||||
struct type *curelm = STAILQ_FIRST((head)); \
|
||||
QUEUE_TYPEOF(type) *curelm = STAILQ_FIRST(head); \
|
||||
while (STAILQ_NEXT(curelm, field) != (elm)) \
|
||||
curelm = STAILQ_NEXT(curelm, field); \
|
||||
STAILQ_REMOVE_AFTER(head, curelm, field); \
|
||||
|
@ -326,8 +431,8 @@ struct { \
|
|||
} while (0)
|
||||
|
||||
#define STAILQ_SWAP(head1, head2, type) do { \
|
||||
struct type *swap_first = STAILQ_FIRST(head1); \
|
||||
struct type **swap_last = (head1)->stqh_last; \
|
||||
QUEUE_TYPEOF(type) *swap_first = STAILQ_FIRST(head1); \
|
||||
QUEUE_TYPEOF(type) **swap_last = (head1)->stqh_last; \
|
||||
STAILQ_FIRST(head1) = STAILQ_FIRST(head2); \
|
||||
(head1)->stqh_last = (head2)->stqh_last; \
|
||||
STAILQ_FIRST(head2) = swap_first; \
|
||||
|
@ -347,6 +452,11 @@ struct name { \
|
|||
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) \
|
||||
{ NULL }
|
||||
|
||||
|
@ -356,11 +466,23 @@ struct { \
|
|||
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.
|
||||
*/
|
||||
|
||||
#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 { \
|
||||
if (LIST_FIRST((head)) != NULL && \
|
||||
LIST_FIRST((head))->field.le_prev != \
|
||||
|
@ -368,6 +490,12 @@ struct { \
|
|||
panic("Bad list head %p first->prev != head", (head)); \
|
||||
} 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 { \
|
||||
if (LIST_NEXT((elm), field) != NULL && \
|
||||
LIST_NEXT((elm), field)->field.le_prev != \
|
||||
|
@ -375,6 +503,11 @@ struct { \
|
|||
panic("Bad link elm %p next->prev != elm", (elm)); \
|
||||
} 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 { \
|
||||
if (*(elm)->field.le_prev != (elm)) \
|
||||
panic("Bad link elm %p prev->next != elm", (elm)); \
|
||||
|
@ -385,6 +518,23 @@ struct { \
|
|||
#define QMD_LIST_CHECK_PREV(elm, field)
|
||||
#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_FIRST(head) ((head)->lh_first)
|
||||
|
@ -394,11 +544,21 @@ struct { \
|
|||
(var); \
|
||||
(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) \
|
||||
for ((var) = LIST_FIRST((head)); \
|
||||
(var) && ((tvar) = LIST_NEXT((var), field), 1); \
|
||||
(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 { \
|
||||
LIST_FIRST((head)) = NULL; \
|
||||
} while (0)
|
||||
|
@ -430,9 +590,10 @@ struct { \
|
|||
|
||||
#define LIST_NEXT(elm, field) ((elm)->field.le_next)
|
||||
|
||||
#define LIST_PREV(elm, head, type, field) \
|
||||
((elm)->field.le_prev == &LIST_FIRST((head)) ? NULL : \
|
||||
__containerof((elm)->field.le_prev, struct type, field.le_next))
|
||||
#define LIST_PREV(elm, head, type, field) \
|
||||
((elm)->field.le_prev == &LIST_FIRST((head)) ? NULL : \
|
||||
__containerof((elm)->field.le_prev, \
|
||||
QUEUE_TYPEOF(type), field.le_next))
|
||||
|
||||
#define LIST_REMOVE(elm, field) do { \
|
||||
QMD_SAVELINK(oldnext, (elm)->field.le_next); \
|
||||
|
@ -448,7 +609,7 @@ struct { \
|
|||
} while (0)
|
||||
|
||||
#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((head2)) = swap_tmp; \
|
||||
if ((swap_tmp = LIST_FIRST((head1))) != NULL) \
|
||||
|
@ -467,6 +628,13 @@ struct name { \
|
|||
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) \
|
||||
{ NULL, &(head).tqh_first, TRACEBUF_INITIALIZER }
|
||||
|
||||
|
@ -477,10 +645,23 @@ struct { \
|
|||
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.
|
||||
*/
|
||||
#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 { \
|
||||
if (!TAILQ_EMPTY(head) && \
|
||||
TAILQ_FIRST((head))->field.tqe_prev != \
|
||||
|
@ -488,11 +669,22 @@ struct { \
|
|||
panic("Bad tailq head %p first->prev != head", (head)); \
|
||||
} 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 { \
|
||||
if (*(head)->tqh_last != NULL) \
|
||||
panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head)); \
|
||||
} 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 { \
|
||||
if (TAILQ_NEXT((elm), field) != NULL && \
|
||||
TAILQ_NEXT((elm), field)->field.tqe_prev != \
|
||||
|
@ -500,6 +692,11 @@ struct { \
|
|||
panic("Bad link elm %p next->prev != elm", (elm)); \
|
||||
} 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 { \
|
||||
if (*(elm)->field.tqe_prev != (elm)) \
|
||||
panic("Bad link elm %p prev->next != elm", (elm)); \
|
||||
|
@ -531,21 +728,41 @@ struct { \
|
|||
(var); \
|
||||
(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) \
|
||||
for ((var) = TAILQ_FIRST((head)); \
|
||||
(var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
|
||||
(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) \
|
||||
for ((var) = TAILQ_LAST((head), headname); \
|
||||
(var); \
|
||||
(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) \
|
||||
for ((var) = TAILQ_LAST((head), headname); \
|
||||
(var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \
|
||||
(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 { \
|
||||
TAILQ_FIRST((head)) = NULL; \
|
||||
(head)->tqh_last = &TAILQ_FIRST((head)); \
|
||||
|
@ -564,7 +781,7 @@ struct { \
|
|||
TAILQ_NEXT((listelm), field) = (elm); \
|
||||
(elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \
|
||||
QMD_TRACE_ELEM(&(elm)->field); \
|
||||
QMD_TRACE_ELEM(&listelm->field); \
|
||||
QMD_TRACE_ELEM(&(listelm)->field); \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
|
||||
|
@ -574,7 +791,7 @@ struct { \
|
|||
*(listelm)->field.tqe_prev = (elm); \
|
||||
(listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \
|
||||
QMD_TRACE_ELEM(&(elm)->field); \
|
||||
QMD_TRACE_ELEM(&listelm->field); \
|
||||
QMD_TRACE_ELEM(&(listelm)->field); \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_INSERT_HEAD(head, elm, field) do { \
|
||||
|
@ -627,8 +844,8 @@ struct { \
|
|||
} while (0)
|
||||
|
||||
#define TAILQ_SWAP(head1, head2, type, field) do { \
|
||||
struct type *swap_first = (head1)->tqh_first; \
|
||||
struct type **swap_last = (head1)->tqh_last; \
|
||||
QUEUE_TYPEOF(type) *swap_first = (head1)->tqh_first; \
|
||||
QUEUE_TYPEOF(type) **swap_last = (head1)->tqh_last; \
|
||||
(head1)->tqh_first = (head2)->tqh_first; \
|
||||
(head1)->tqh_last = (head2)->tqh_last; \
|
||||
(head2)->tqh_first = swap_first; \
|
||||
|
|
|
@ -37,6 +37,8 @@ typedef __uint32_t __ULong;
|
|||
|
||||
struct _reent;
|
||||
|
||||
struct __locale_t;
|
||||
|
||||
/*
|
||||
* If _REENT_SMALL is defined, we make struct _reent as small as possible,
|
||||
* 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 _current_category; /* unused */
|
||||
_CONST char *_current_locale; /* unused */
|
||||
int _unspecified_locale_info; /* unused, reserved for locale stuff */
|
||||
struct __locale_t *_locale;/* per-thread locale */
|
||||
|
||||
struct _mprec *_mp;
|
||||
|
||||
|
@ -429,7 +431,7 @@ extern const struct __sFILE_fake __sf_fake_stderr;
|
|||
_NULL, \
|
||||
0, \
|
||||
0, \
|
||||
"C", \
|
||||
_NULL, \
|
||||
_NULL, \
|
||||
_NULL, \
|
||||
0, \
|
||||
|
@ -446,16 +448,14 @@ extern const struct __sFILE_fake __sf_fake_stderr;
|
|||
_NULL \
|
||||
}
|
||||
|
||||
#define _REENT_INIT_PTR(var) \
|
||||
{ memset((var), 0, sizeof(*(var))); \
|
||||
(var)->_stdin = (__FILE *)&__sf_fake_stdin; \
|
||||
#define _REENT_INIT_PTR_ZEROED(var) \
|
||||
{ (var)->_stdin = (__FILE *)&__sf_fake_stdin; \
|
||||
(var)->_stdout = (__FILE *)&__sf_fake_stdout; \
|
||||
(var)->_stderr = (__FILE *)&__sf_fake_stderr; \
|
||||
(var)->_current_locale = "C"; \
|
||||
}
|
||||
|
||||
/* Only built the assert() calls if we are built with debugging. */
|
||||
#if DEBUG
|
||||
/* Only add assert() calls if we are specified to debug. */
|
||||
#ifdef _REENT_CHECK_DEBUG
|
||||
#include <assert.h>
|
||||
#define __reent_assert(x) assert(x)
|
||||
#else
|
||||
|
@ -578,8 +578,9 @@ struct _reent
|
|||
int _inc; /* used by tmpnam */
|
||||
char _emergency[_REENT_EMERGENCY_SIZE];
|
||||
|
||||
int _current_category; /* used by setlocale */
|
||||
_CONST char *_current_locale;
|
||||
/* TODO */
|
||||
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 */
|
||||
|
||||
|
@ -643,18 +644,27 @@ struct _reent
|
|||
of the above members (on the off chance that future binary compatibility
|
||||
would be broken otherwise). */
|
||||
struct _glue __sglue; /* root of glue chain */
|
||||
# ifndef _REENT_GLOBAL_STDIO_STREAMS
|
||||
__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) \
|
||||
{ 0, \
|
||||
&(var).__sf[0], \
|
||||
&(var).__sf[1], \
|
||||
&(var).__sf[2], \
|
||||
_REENT_STDIO_STREAM(&(var), 0), \
|
||||
_REENT_STDIO_STREAM(&(var), 1), \
|
||||
_REENT_STDIO_STREAM(&(var), 2), \
|
||||
0, \
|
||||
"", \
|
||||
0, \
|
||||
"C", \
|
||||
_NULL, \
|
||||
0, \
|
||||
_NULL, \
|
||||
_NULL, \
|
||||
|
@ -694,12 +704,10 @@ struct _reent
|
|||
{_NULL, 0, _NULL} \
|
||||
}
|
||||
|
||||
#define _REENT_INIT_PTR(var) \
|
||||
{ memset((var), 0, sizeof(*(var))); \
|
||||
(var)->_stdin = &(var)->__sf[0]; \
|
||||
(var)->_stdout = &(var)->__sf[1]; \
|
||||
(var)->_stderr = &(var)->__sf[2]; \
|
||||
(var)->_current_locale = "C"; \
|
||||
#define _REENT_INIT_PTR_ZEROED(var) \
|
||||
{ (var)->_stdin = _REENT_STDIO_STREAM(var, 0); \
|
||||
(var)->_stdout = _REENT_STDIO_STREAM(var, 1); \
|
||||
(var)->_stderr = _REENT_STDIO_STREAM(var, 2); \
|
||||
(var)->_new._reent._rand_next = 1; \
|
||||
(var)->_new._reent._r48._seed[0] = _RAND48_SEED_0; \
|
||||
(var)->_new._reent._r48._seed[1] = _RAND48_SEED_1; \
|
||||
|
@ -745,6 +753,11 @@ struct _reent
|
|||
|
||||
#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
|
||||
as well to make sure the freelist is correctly free'd. Therefore
|
||||
we define it here, rather than in stdlib/misc.c, as before. */
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#ifndef _SYS_SCHED_H_
|
||||
#define _SYS_SCHED_H_
|
||||
|
||||
#include <sys/_timespec.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
87
libc/xtensa-lx106-elf/include/sys/select.h
Normal file
87
libc/xtensa-lx106-elf/include/sys/select.h
Normal 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 */
|
|
@ -7,19 +7,22 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#include "_ansi.h"
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/features.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/_sigset.h>
|
||||
#include <sys/_timespec.h>
|
||||
|
||||
/* #ifndef __STRICT_ANSI__*/
|
||||
|
||||
/* Cygwin defines it's own sigset_t in include/cygwin/signal.h */
|
||||
#ifndef __CYGWIN__
|
||||
typedef unsigned long sigset_t;
|
||||
#if !defined(_SIGSET_T_DECLARED)
|
||||
#define _SIGSET_T_DECLARED
|
||||
typedef __sigset_t sigset_t;
|
||||
#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
|
||||
NOTE: P1003.1c/D10, p. 34 adds SIGEV_THREAD. */
|
||||
|
@ -67,14 +70,16 @@ typedef struct {
|
|||
int si_code; /* Cause of the signal */
|
||||
union sigval si_value; /* Signal value */
|
||||
} 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 */
|
||||
|
||||
#define SA_NOCLDSTOP 0x1 /* Do not generate SIGCHLD when children stop */
|
||||
#define SA_SIGINFO 0x2 /* Invoke the signal catching function with */
|
||||
/* three arguments instead of one. */
|
||||
#if __BSD_VISIBLE || __XSI_VISIBLE || __POSIX_VISIBLE >= 200112
|
||||
#if __BSD_VISIBLE || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809
|
||||
#define SA_ONSTACK 0x4 /* Signal delivery will be on a separate stack. */
|
||||
#endif
|
||||
|
||||
|
@ -107,7 +112,22 @@ struct sigaction {
|
|||
#define sa_sigaction _signal_handlers._sigaction
|
||||
#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
|
||||
* from <sys/features.h>.
|
||||
|
@ -125,6 +145,8 @@ struct sigaction {
|
|||
#define SS_ONSTACK 0x1
|
||||
#define SS_DISABLE 0x2
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Structure used in sigaltstack call.
|
||||
*/
|
||||
|
@ -133,58 +155,33 @@ typedef struct sigaltstack {
|
|||
int ss_flags; /* Flags. */
|
||||
size_t ss_size; /* Stack size. */
|
||||
} 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_BLOCK 1 /* set of signals to block */
|
||||
#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));
|
||||
#endif
|
||||
|
||||
#if defined(_POSIX_THREADS)
|
||||
#if __POSIX_VISIBLE >= 199506
|
||||
int _EXFUN(pthread_sigmask, (int how, const sigset_t *set, sigset_t *oset));
|
||||
#endif
|
||||
|
||||
#if defined(__CYGWIN__) || defined(__rtems__)
|
||||
#undef sigaddset
|
||||
#undef sigdelset
|
||||
#undef sigemptyset
|
||||
#undef sigfillset
|
||||
#undef sigismember
|
||||
|
||||
#ifdef _COMPILING_NEWLIB
|
||||
int _EXFUN(_kill, (pid_t, int));
|
||||
#endif /* _COMPILING_NEWLIB */
|
||||
#endif /* __CYGWIN__ || __rtems__ */
|
||||
#if defined(__CYGWIN__) || defined(__rtems__) || defined(__SPU__)
|
||||
|
||||
#if __POSIX_VISIBLE
|
||||
int _EXFUN(kill, (pid_t, int));
|
||||
#endif /* __CYGWIN__ || __rtems__ || __SPU__ */
|
||||
#if defined(__CYGWIN__) || defined(__rtems__)
|
||||
#endif
|
||||
|
||||
#if __BSD_VISIBLE || __XSI_VISIBLE >= 4
|
||||
int _EXFUN(killpg, (pid_t, int));
|
||||
#endif
|
||||
#if __POSIX_VISIBLE
|
||||
int _EXFUN(sigaction, (int, const struct sigaction *, struct sigaction *));
|
||||
int _EXFUN(sigaddset, (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(sigpending, (sigset_t *));
|
||||
int _EXFUN(sigsuspend, (const sigset_t *));
|
||||
int _EXFUN(sigpause, (int));
|
||||
int _EXFUN(sigwait, (const sigset_t *set, int *sig));
|
||||
|
||||
#ifdef __rtems__
|
||||
#if __BSD_VISIBLE || __XSI_VISIBLE || __POSIX_VISIBLE >= 200112
|
||||
#if !defined(__CYGWIN__) && !defined(__rtems__)
|
||||
/* 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));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(_POSIX_THREADS)
|
||||
#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
|
||||
#if __POSIX_VISIBLE >= 199506
|
||||
int _EXFUN(pthread_kill, (pthread_t thread, int sig));
|
||||
#endif
|
||||
|
||||
#if defined(_POSIX_REALTIME_SIGNALS)
|
||||
#if __POSIX_VISIBLE >= 199309
|
||||
|
||||
/* 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76
|
||||
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,
|
||||
(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 */
|
||||
int _EXFUN(sigqueue, (pid_t pid, int signo, const union sigval value));
|
||||
|
||||
#endif /* defined(_POSIX_REALTIME_SIGNALS) */
|
||||
|
||||
#endif /* defined(__CYGWIN__) || defined(__rtems__) */
|
||||
|
||||
/* #endif __STRICT_ANSI__ */
|
||||
#endif /* __POSIX_VISIBLE >= 199309 */
|
||||
|
||||
#if defined(___AM29K__)
|
||||
/* 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
|
||||
|
||||
#if defined(__CYGWIN__)
|
||||
#if __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809
|
||||
#include <sys/ucontext.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef _SIGNAL_H_
|
||||
/* Some applications take advantage of the fact that <sys/signal.h>
|
||||
* and <signal.h> are equivalent in glibc. Allow for that here. */
|
||||
|
|
|
@ -9,6 +9,7 @@ extern "C" {
|
|||
#include <time.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/_timespec.h>
|
||||
|
||||
/* dj's stat defines _STAT_H_ */
|
||||
#ifndef _STAT_H_
|
||||
|
@ -52,8 +53,8 @@ struct stat
|
|||
long st_spare2;
|
||||
time_t st_ctime;
|
||||
long st_spare3;
|
||||
long st_blksize;
|
||||
long st_blocks;
|
||||
blksize_t st_blksize;
|
||||
blkcnt_t st_blocks;
|
||||
long st_spare4[2];
|
||||
#endif
|
||||
#endif
|
||||
|
@ -81,12 +82,12 @@ struct stat
|
|||
#define S_ISUID 0004000 /* set user id on execution */
|
||||
#define S_ISGID 0002000 /* set group id on execution */
|
||||
#define S_ISVTX 0001000 /* save swapped text even after use */
|
||||
#ifndef _POSIX_SOURCE
|
||||
#if __BSD_VISIBLE
|
||||
#define S_IREAD 0000400 /* read permission, owner */
|
||||
#define S_IWRITE 0000200 /* write permission, owner */
|
||||
#define S_IEXEC 0000100 /* execute/search permission, owner */
|
||||
#define S_ENFMT 0002000 /* enforcement-mode locking */
|
||||
#endif /* !_POSIX_SOURCE */
|
||||
#endif /* !_BSD_VISIBLE */
|
||||
|
||||
#define S_IFMT _IFMT
|
||||
#define S_IFDIR _IFDIR
|
||||
|
@ -123,7 +124,7 @@ struct stat
|
|||
#define S_IWOTH 0000002 /* write permission, other */
|
||||
#define S_IXOTH 0000001/* execute/search permission, other */
|
||||
|
||||
#ifndef _POSIX_SOURCE
|
||||
#if __BSD_VISIBLE
|
||||
#define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) /* 0777 */
|
||||
#define ALLPERMS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) /* 07777 */
|
||||
#define DEFFILEMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) /* 0666 */
|
||||
|
@ -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 ));
|
||||
#endif
|
||||
|
||||
#if (__POSIX_VISIBLE >= 200809 || defined (__CYGWIN__)) && !defined(__INSIDE_CYGWIN__)
|
||||
#if __ATFILE_VISIBLE && !defined(__INSIDE_CYGWIN__)
|
||||
int _EXFUN(fchmodat, (int, const char *, mode_t, int));
|
||||
#endif
|
||||
#if (__BSD_VISIBLE || __POSIX_VISIBLE >= 200809 || defined (__CYGWIN__)) && !defined(__INSIDE_CYGWIN__)
|
||||
int _EXFUN(fstatat, (int, const char *__restrict , struct stat *__restrict, int));
|
||||
int _EXFUN(mkdirat, (int, const char *, mode_t));
|
||||
int _EXFUN(mkfifoat, (int, const char *, mode_t));
|
||||
#endif
|
||||
#if (__BSD_VISIBLE || __XSI_VISIBLE >= 700 || defined (__CYGWIN__)) && !defined(__INSIDE_CYGWIN__)
|
||||
int _EXFUN(mknodat, (int, const char *, mode_t, dev_t));
|
||||
#endif
|
||||
#if (__BSD_VISIBLE || __POSIX_VISIBLE >= 200809 || defined (__CYGWIN__)) && !defined(__INSIDE_CYGWIN__)
|
||||
int _EXFUN(utimensat, (int, const char *, const struct timespec *, int));
|
||||
#endif
|
||||
#if __POSIX_VISIBLE >= 200809 && !defined(__INSIDE_CYGWIN__)
|
||||
int _EXFUN(futimens, (int, const struct timespec *));
|
||||
#endif
|
||||
|
||||
|
|
|
@ -2,90 +2,301 @@
|
|||
Written by Geoffrey Noer <noer@cygnus.com>
|
||||
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_
|
||||
#define _SYS_TIME_H_
|
||||
#define _SYS_TIME_H_
|
||||
|
||||
#include <_ansi.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/_timeval.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/timespec.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
|
||||
#include <sys/select.h>
|
||||
#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 {
|
||||
int tz_minuteswest;
|
||||
int tz_dsttime;
|
||||
int tz_minuteswest; /* minutes west of Greenwich */
|
||||
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__
|
||||
#include <cygwin/sys_time.h>
|
||||
#endif /* __CYGWIN__ */
|
||||
static __inline void
|
||||
bintime_addx(struct bintime *_bt, uint64_t _x)
|
||||
{
|
||||
uint64_t _u;
|
||||
|
||||
#define ITIMER_REAL 0
|
||||
#define ITIMER_VIRTUAL 1
|
||||
#define ITIMER_PROF 2
|
||||
_u = _bt->frac;
|
||||
_bt->frac += _x;
|
||||
if (_u > _bt->frac)
|
||||
_bt->sec++;
|
||||
}
|
||||
|
||||
struct itimerval {
|
||||
struct timeval it_interval;
|
||||
struct timeval it_value;
|
||||
static __inline void
|
||||
bintime_add(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_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
|
||||
int _EXFUN(_gettimeofday, (struct timeval *__p, void *__tz));
|
||||
#endif
|
||||
|
||||
int _EXFUN(gettimeofday, (struct timeval *__restrict __p,
|
||||
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));
|
||||
__END_DECLS
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* _SYS_TIME_H_ */
|
||||
#endif /* !_KERNEL */
|
||||
#include <machine/_time.h>
|
||||
|
||||
#endif /* !_SYS_TIME_H_ */
|
||||
|
|
|
@ -15,11 +15,12 @@ extern "C" {
|
|||
#define _SYS_TIMEB_H
|
||||
|
||||
#include <_ansi.h>
|
||||
#include <machine/types.h>
|
||||
#include <sys/_types.h>
|
||||
|
||||
#ifndef __time_t_defined
|
||||
typedef _TIME_T_ time_t;
|
||||
#define __time_t_defined
|
||||
#if !defined(__time_t_defined) && !defined(_TIME_T_DECLARED)
|
||||
typedef _TIME_T_ time_t;
|
||||
#define __time_t_defined
|
||||
#define _TIME_T_DECLARED
|
||||
#endif
|
||||
|
||||
struct timeb
|
||||
|
|
|
@ -5,11 +5,12 @@ extern "C" {
|
|||
#define _SYS_TIMES_H
|
||||
|
||||
#include <_ansi.h>
|
||||
#include <machine/types.h>
|
||||
#include <sys/_types.h>
|
||||
|
||||
#ifndef __clock_t_defined
|
||||
typedef _CLOCK_T_ clock_t;
|
||||
#define __clock_t_defined
|
||||
#if !defined(__clock_t_defined) && !defined(_CLOCK_T_DECLARED)
|
||||
typedef _CLOCK_T_ clock_t;
|
||||
#define __clock_t_defined
|
||||
#define _CLOCK_T_DECLARED
|
||||
#endif
|
||||
|
||||
/* Get Process Times, P1003.1b-1993, p. 92 */
|
||||
|
|
63
libc/xtensa-lx106-elf/include/sys/timespec.h
Normal file
63
libc/xtensa-lx106-elf/include/sys/timespec.h
Normal 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_ */
|
801
libc/xtensa-lx106-elf/include/sys/tree.h
Normal file
801
libc/xtensa-lx106-elf/include/sys/tree.h
Normal 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_ */
|
|
@ -18,20 +18,12 @@
|
|||
#ifndef _SYS_TYPES_H
|
||||
|
||||
#include <_ansi.h>
|
||||
|
||||
#ifndef __INTTYPES_DEFINED__
|
||||
#define __INTTYPES_DEFINED__
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <machine/_types.h>
|
||||
|
||||
#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 */
|
||||
/* 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
|
||||
be preferred in new code. */
|
||||
#if ___int8_t_defined
|
||||
typedef __uint8_t u_int8_t;
|
||||
#endif
|
||||
|
@ -41,52 +33,54 @@ typedef __uint16_t u_int16_t;
|
|||
#if ___int32_t_defined
|
||||
typedef __uint32_t u_int32_t;
|
||||
#endif
|
||||
|
||||
#if ___int64_t_defined
|
||||
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 */
|
||||
#if ___int64_t_defined
|
||||
typedef __uint64_t u_quad_t;
|
||||
typedef __int64_t quad_t;
|
||||
typedef quad_t * qaddr_t;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* ! __INTTYPES_DEFINED */
|
||||
#endif /* __rtems__ || __XMK__ */
|
||||
|
||||
#ifndef __need_inttypes
|
||||
|
||||
#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/_stdint.h>
|
||||
|
||||
#ifdef __i386__
|
||||
#if defined (GO32) || defined (__MSDOS__)
|
||||
#define __MS_types__
|
||||
#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
|
||||
|
||||
#if __BSD_VISIBLE
|
||||
#include <machine/endian.h>
|
||||
#include <sys/select.h>
|
||||
# define physadr physadr_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
|
||||
/* also defined in mingw/gmon.h and in w32api/winsock[2].h */
|
||||
#ifndef __u_char_defined
|
||||
|
@ -107,36 +101,35 @@ typedef unsigned long u_long;
|
|||
#endif
|
||||
#define _BSDTYPES_DEFINED
|
||||
#endif
|
||||
#endif /*__BSD_VISIBLE || __CYGWIN__ */
|
||||
|
||||
#if __MISC_VISIBLE
|
||||
typedef unsigned short ushort; /* System V compatibility */
|
||||
typedef unsigned int uint; /* System V compatibility */
|
||||
typedef unsigned long ulong; /* System V compatibility */
|
||||
# endif /*!_POSIX_SOURCE */
|
||||
|
||||
#ifndef __clock_t_defined
|
||||
typedef _CLOCK_T_ clock_t;
|
||||
#define __clock_t_defined
|
||||
#endif
|
||||
|
||||
#ifndef __time_t_defined
|
||||
typedef _TIME_T_ time_t;
|
||||
#define __time_t_defined
|
||||
#ifndef _BLKCNT_T_DECLARED
|
||||
typedef __blkcnt_t blkcnt_t;
|
||||
#define _BLKCNT_T_DECLARED
|
||||
#endif
|
||||
|
||||
#ifndef __timespec_defined
|
||||
#define __timespec_defined
|
||||
/* Time Value Specification Structures, P1003.1b-1993, p. 261 */
|
||||
|
||||
struct timespec {
|
||||
time_t tv_sec; /* Seconds */
|
||||
long tv_nsec; /* Nanoseconds */
|
||||
};
|
||||
#ifndef _BLKSIZE_T_DECLARED
|
||||
typedef __blksize_t blksize_t;
|
||||
#define _BLKSIZE_T_DECLARED
|
||||
#endif
|
||||
|
||||
struct itimerspec {
|
||||
struct timespec it_interval; /* Timer period */
|
||||
struct timespec it_value; /* Timer expiration */
|
||||
};
|
||||
#if !defined(__clock_t_defined) && !defined(_CLOCK_T_DECLARED)
|
||||
typedef _CLOCK_T_ clock_t;
|
||||
#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
|
||||
typedef long daddr_t;
|
||||
|
@ -147,31 +140,27 @@ typedef char * caddr_t;
|
|||
#define __caddr_t_defined
|
||||
#endif
|
||||
|
||||
#ifndef __CYGWIN__
|
||||
#if defined(__MS_types__) || defined(__rtems__) || \
|
||||
defined(__sparc__) || defined(__SPU__)
|
||||
typedef unsigned long ino_t;
|
||||
#else
|
||||
typedef unsigned short ino_t;
|
||||
#ifndef _FSBLKCNT_T_DECLARED /* for statvfs() */
|
||||
typedef __fsblkcnt_t fsblkcnt_t;
|
||||
typedef __fsfilcnt_t fsfilcnt_t;
|
||||
#define _FSBLKCNT_T_DECLARED
|
||||
#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_size_t;
|
||||
|
||||
#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__ */
|
||||
#endif /* __i386__ && (GO32 || __MSDOS__) */
|
||||
|
||||
/*
|
||||
* 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.).
|
||||
*/
|
||||
|
||||
#ifndef __CYGWIN__ /* which defines these types in it's own types.h. */
|
||||
typedef _off_t off_t;
|
||||
typedef __dev_t dev_t;
|
||||
typedef __uid_t uid_t;
|
||||
typedef __gid_t gid_t;
|
||||
#ifndef _OFF_T_DECLARED
|
||||
typedef __off_t off_t; /* file offset */
|
||||
#define _OFF_T_DECLARED
|
||||
#endif
|
||||
#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
|
||||
|
||||
#if defined(__XMK__)
|
||||
typedef signed char pid_t;
|
||||
#else
|
||||
typedef int pid_t;
|
||||
#ifndef _PID_T_DECLARED
|
||||
typedef __pid_t pid_t; /* process id */
|
||||
#define _PID_T_DECLARED
|
||||
#endif
|
||||
|
||||
#if defined(__rtems__)
|
||||
typedef _mode_t mode_t;
|
||||
#ifndef _KEY_T_DECLARED
|
||||
typedef __key_t key_t; /* IPC key */
|
||||
#define _KEY_T_DECLARED
|
||||
#endif
|
||||
|
||||
#ifndef __CYGWIN__
|
||||
typedef long key_t;
|
||||
#endif
|
||||
#ifndef _SSIZE_T_DECLARED
|
||||
typedef _ssize_t ssize_t;
|
||||
|
||||
#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
|
||||
#define _SSIZE_T_DECLARED
|
||||
#endif
|
||||
|
||||
#ifndef __timer_t_defined
|
||||
typedef _TIMER_T_ timer_t;
|
||||
#define __timer_t_defined
|
||||
#ifndef _MODE_T_DECLARED
|
||||
typedef __mode_t mode_t; /* permissions */
|
||||
#define _MODE_T_DECLARED
|
||||
#endif
|
||||
|
||||
typedef unsigned long useconds_t;
|
||||
typedef long suseconds_t;
|
||||
#ifndef _NLINK_T_DECLARED
|
||||
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>
|
||||
|
||||
|
||||
/* 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__ */
|
||||
#include <sys/_pthreadtypes.h>
|
||||
#include <machine/types.h>
|
||||
|
||||
#endif /* !__need_inttypes */
|
||||
|
||||
|
|
|
@ -24,72 +24,89 @@ int _EXFUN(chmod, (const char *__path, mode_t __mode ));
|
|||
#if !defined(__INSIDE_CYGWIN__)
|
||||
int _EXFUN(chown, (const char *__path, uid_t __owner, gid_t __group ));
|
||||
#endif
|
||||
#if defined(__CYGWIN__) || defined(__rtems__)
|
||||
#if __BSD_VISIBLE || (__XSI_VISIBLE >= 4 && __POSIX_VISIBLE < 200112)
|
||||
int _EXFUN(chroot, (const char *__path ));
|
||||
#endif
|
||||
int _EXFUN(close, (int __fildes ));
|
||||
#if defined(__CYGWIN__)
|
||||
#if __POSIX_VISIBLE >= 199209
|
||||
size_t _EXFUN(confstr, (int __name, char *__buf, size_t __len));
|
||||
#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 ));
|
||||
#endif
|
||||
#if __XSI_VISIBLE && __XSI_VISIBLE < 600
|
||||
char * _EXFUN(cuserid, (char *__s ));
|
||||
#if defined(__CYGWIN__)
|
||||
#endif
|
||||
#if __BSD_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 500)
|
||||
int _EXFUN(daemon, (int nochdir, int noclose));
|
||||
#endif
|
||||
int _EXFUN(dup, (int __fildes ));
|
||||
int _EXFUN(dup2, (int __fildes, int __fildes2 ));
|
||||
#if defined(__CYGWIN__)
|
||||
#if __GNU_VISIBLE
|
||||
int _EXFUN(dup3, (int __fildes, int __fildes2, int flags));
|
||||
int _EXFUN(eaccess, (const char *__path, int __mode));
|
||||
#endif
|
||||
#if __XSI_VISIBLE
|
||||
void _EXFUN(encrypt, (char *__block, int __edflag));
|
||||
#endif
|
||||
#if __BSD_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 500)
|
||||
void _EXFUN(endusershell, (void));
|
||||
#endif
|
||||
#if __GNU_VISIBLE
|
||||
int _EXFUN(euidaccess, (const char *__path, int __mode));
|
||||
#endif
|
||||
int _EXFUN(execl, (const char *__path, const char *, ... ));
|
||||
int _EXFUN(execle, (const char *__path, const char *, ... ));
|
||||
int _EXFUN(execlp, (const char *__file, const char *, ... ));
|
||||
#if defined(__CYGWIN__)
|
||||
#if __MISC_VISIBLE
|
||||
int _EXFUN(execlpe, (const char *__file, const char *, ... ));
|
||||
#endif
|
||||
int _EXFUN(execv, (const char *__path, char * const __argv[] ));
|
||||
int _EXFUN(execve, (const char *__path, char * const __argv[], char * const __envp[] ));
|
||||
int _EXFUN(execvp, (const char *__file, char * const __argv[] ));
|
||||
#if defined(__CYGWIN__)
|
||||
#if __GNU_VISIBLE
|
||||
int _EXFUN(execvpe, (const char *__file, char * const __argv[], char * const __envp[] ));
|
||||
#endif
|
||||
#if __POSIX_VISIBLE >= 200809 || __BSD_VISIBLE || defined(__CYGWIN__)
|
||||
#if __ATFILE_VISIBLE
|
||||
int _EXFUN(faccessat, (int __dirfd, const char *__path, int __mode, int __flags));
|
||||
#endif
|
||||
#if defined(__CYGWIN__) || defined(__rtems__) || defined(__SPU__)
|
||||
#if __BSD_VISIBLE || __XSI_VISIBLE >= 4
|
||||
int _EXFUN(fchdir, (int __fildes));
|
||||
#endif
|
||||
int _EXFUN(fchmod, (int __fildes, mode_t __mode ));
|
||||
#if !defined(__INSIDE_CYGWIN__)
|
||||
int _EXFUN(fchown, (int __fildes, uid_t __owner, gid_t __group ));
|
||||
#endif
|
||||
#if __POSIX_VISIBLE >= 200809 || __BSD_VISIBLE || defined(__CYGWIN__)
|
||||
#if __ATFILE_VISIBLE
|
||||
int _EXFUN(fchownat, (int __dirfd, const char *__path, uid_t __owner, gid_t __group, int __flags));
|
||||
#endif
|
||||
#if defined(__CYGWIN__)
|
||||
#if __POSIX_VISIBLE >= 200809
|
||||
int _EXFUN(fexecve, (int __fd, char * const __argv[], char * const __envp[] ));
|
||||
#endif
|
||||
pid_t _EXFUN(fork, (void ));
|
||||
long _EXFUN(fpathconf, (int __fd, int __name ));
|
||||
int _EXFUN(fsync, (int __fd));
|
||||
int _EXFUN(fdatasync, (int __fd));
|
||||
#if defined(__CYGWIN__)
|
||||
#if __GNU_VISIBLE
|
||||
char * _EXFUN(get_current_dir_name, (void));
|
||||
#endif
|
||||
char * _EXFUN(getcwd, (char *__buf, size_t __size ));
|
||||
#if defined(__CYGWIN__)
|
||||
#if __BSD_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 500)
|
||||
int _EXFUN(getdomainname ,(char *__name, size_t __len));
|
||||
#endif
|
||||
#if __BSD_VISIBLE
|
||||
int _EXFUN(getentropy, (void *, size_t));
|
||||
#endif
|
||||
#if !defined(__INSIDE_CYGWIN__)
|
||||
gid_t _EXFUN(getegid, (void ));
|
||||
uid_t _EXFUN(geteuid, (void ));
|
||||
gid_t _EXFUN(getgid, (void ));
|
||||
#endif
|
||||
int _EXFUN(getgroups, (int __gidsetsize, gid_t __grouplist[] ));
|
||||
#if defined(__CYGWIN__)
|
||||
#if __BSD_VISIBLE || __XSI_VISIBLE >= 4
|
||||
long _EXFUN(gethostid, (void));
|
||||
#endif
|
||||
char * _EXFUN(getlogin, (void ));
|
||||
|
@ -98,37 +115,44 @@ int _EXFUN(getlogin_r, (char *name, size_t namesize) );
|
|||
#endif
|
||||
char * _EXFUN(getpass, (const char *__prompt));
|
||||
int _EXFUN(getpagesize, (void));
|
||||
#if defined(__CYGWIN__)
|
||||
#if __BSD_VISIBLE
|
||||
int _EXFUN(getpeereid, (int, uid_t *, gid_t *));
|
||||
#endif
|
||||
pid_t _EXFUN(getpgid, (pid_t));
|
||||
pid_t _EXFUN(getpgrp, (void ));
|
||||
pid_t _EXFUN(getpid, (void ));
|
||||
pid_t _EXFUN(getppid, (void ));
|
||||
#if defined(__CYGWIN__) || defined(__rtems__)
|
||||
#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 4
|
||||
pid_t _EXFUN(getsid, (pid_t));
|
||||
#endif
|
||||
#if !defined(__INSIDE_CYGWIN__)
|
||||
uid_t _EXFUN(getuid, (void ));
|
||||
#endif
|
||||
#ifdef __CYGWIN__
|
||||
#if __BSD_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 500)
|
||||
char * _EXFUN(getusershell, (void));
|
||||
#endif
|
||||
#if __BSD_VISIBLE || (__XSI_VISIBLE >= 4 && __POSIX_VISIBLE < 200809)
|
||||
char * _EXFUN(getwd, (char *__buf ));
|
||||
#endif
|
||||
#if __BSD_VISIBLE
|
||||
int _EXFUN(iruserok, (unsigned long raddr, int superuser, const char *ruser, const char *luser));
|
||||
#endif
|
||||
int _EXFUN(isatty, (int __fildes ));
|
||||
#if __BSD_VISIBLE
|
||||
int _EXFUN(issetugid, (void));
|
||||
#endif
|
||||
#if !defined(__INSIDE_CYGWIN__)
|
||||
int _EXFUN(lchown, (const char *__path, uid_t __owner, gid_t __group ));
|
||||
#endif
|
||||
int _EXFUN(link, (const char *__path1, const char *__path2 ));
|
||||
#if __POSIX_VISIBLE >= 200809 || __BSD_VISIBLE || defined(__CYGWIN__)
|
||||
#if __ATFILE_VISIBLE
|
||||
int _EXFUN(linkat, (int __dirfd1, const char *__path1, int __dirfd2, const char *__path2, int __flags ));
|
||||
#endif
|
||||
int _EXFUN(nice, (int __nice_value ));
|
||||
#if !defined(__INSIDE_CYGWIN__)
|
||||
off_t _EXFUN(lseek, (int __fildes, off_t __offset, int __whence ));
|
||||
#endif
|
||||
#if defined(__SPU__) || defined(__CYGWIN__)
|
||||
#if __MISC_VISIBLE || __XSI_VISIBLE >= 4
|
||||
#define F_ULOCK 0
|
||||
#define F_LOCK 1
|
||||
#define F_TLOCK 2
|
||||
|
@ -137,41 +161,41 @@ int _EXFUN(lockf, (int __fd, int __cmd, off_t __len));
|
|||
#endif
|
||||
long _EXFUN(pathconf, (const char *__path, int __name ));
|
||||
int _EXFUN(pause, (void ));
|
||||
#ifdef __CYGWIN__
|
||||
#if __POSIX_VISIBLE >= 199506
|
||||
int _EXFUN(pthread_atfork, (void (*)(void), void (*)(void), void (*)(void)));
|
||||
#endif
|
||||
int _EXFUN(pipe, (int __fildes[2] ));
|
||||
#ifdef __CYGWIN__
|
||||
#if __GNU_VISIBLE
|
||||
int _EXFUN(pipe2, (int __fildes[2], int flags));
|
||||
#endif
|
||||
ssize_t _EXFUN(pread, (int __fd, void *__buf, size_t __nbytes, off_t __offset));
|
||||
ssize_t _EXFUN(pwrite, (int __fd, const void *__buf, size_t __nbytes, off_t __offset));
|
||||
_READ_WRITE_RETURN_TYPE _EXFUN(read, (int __fd, void *__buf, size_t __nbyte ));
|
||||
#if defined(__CYGWIN__)
|
||||
#if __BSD_VISIBLE
|
||||
int _EXFUN(rresvport, (int *__alport));
|
||||
int _EXFUN(revoke, (char *__path));
|
||||
#endif
|
||||
int _EXFUN(rmdir, (const char *__path ));
|
||||
#if defined(__CYGWIN__)
|
||||
#if __BSD_VISIBLE
|
||||
int _EXFUN(ruserok, (const char *rhost, int superuser, const char *ruser, const char *luser));
|
||||
#endif
|
||||
void * _EXFUN(sbrk, (ptrdiff_t __incr));
|
||||
#if !defined(__INSIDE_CYGWIN__)
|
||||
#if defined(__CYGWIN__) || defined(__rtems__)
|
||||
#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112
|
||||
int _EXFUN(setegid, (gid_t __gid ));
|
||||
int _EXFUN(seteuid, (uid_t __uid ));
|
||||
#endif
|
||||
int _EXFUN(setgid, (gid_t __gid ));
|
||||
#endif
|
||||
#if defined(__CYGWIN__)
|
||||
#if __BSD_VISIBLE
|
||||
int _EXFUN(setgroups, (int ngroups, const gid_t *grouplist ));
|
||||
#endif
|
||||
#if __BSD_VISIBLE || (defined(_XOPEN_SOURCE) && __XSI_VISIBLE < 500)
|
||||
#if __BSD_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 500)
|
||||
int _EXFUN(sethostname, (const char *, size_t));
|
||||
#endif
|
||||
int _EXFUN(setpgid, (pid_t __pid, pid_t __pgid ));
|
||||
int _EXFUN(setpgrp, (void ));
|
||||
#if defined(__CYGWIN__) && !defined(__INSIDE_CYGWIN__)
|
||||
#if (__BSD_VISIBLE || __XSI_VISIBLE >= 4) && !defined(__INSIDE_CYGWIN__)
|
||||
int _EXFUN(setregid, (gid_t __rgid, gid_t __egid));
|
||||
int _EXFUN(setreuid, (uid_t __ruid, uid_t __euid));
|
||||
#endif
|
||||
|
@ -179,21 +203,25 @@ pid_t _EXFUN(setsid, (void ));
|
|||
#if !defined(__INSIDE_CYGWIN__)
|
||||
int _EXFUN(setuid, (uid_t __uid ));
|
||||
#endif
|
||||
#if defined(__CYGWIN__)
|
||||
#if __BSD_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 500)
|
||||
void _EXFUN(setusershell, (void));
|
||||
#endif
|
||||
unsigned _EXFUN(sleep, (unsigned int __seconds ));
|
||||
#if __XSI_VISIBLE
|
||||
void _EXFUN(swab, (const void *__restrict, void *__restrict, ssize_t));
|
||||
#endif
|
||||
long _EXFUN(sysconf, (int __name ));
|
||||
pid_t _EXFUN(tcgetpgrp, (int __fildes ));
|
||||
int _EXFUN(tcsetpgrp, (int __fildes, pid_t __pgrp_id ));
|
||||
char * _EXFUN(ttyname, (int __fildes ));
|
||||
#if defined(__CYGWIN__) || defined(__rtems__)
|
||||
int _EXFUN(ttyname_r, (int, char *, size_t));
|
||||
#endif
|
||||
int _EXFUN(ttyname_r, (int, char *, size_t));
|
||||
int _EXFUN(unlink, (const char *__path ));
|
||||
#if __XSI_VISIBLE >= 500 && __POSIX_VISIBLE < 200809 || __BSD_VISIBLE
|
||||
int _EXFUN(usleep, (useconds_t __useconds));
|
||||
#endif
|
||||
#if __BSD_VISIBLE
|
||||
int _EXFUN(vhangup, (void ));
|
||||
#endif
|
||||
_READ_WRITE_RETURN_TYPE _EXFUN(write, (int __fd, const void *__buf, size_t __nbyte ));
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
|
@ -207,9 +235,9 @@ int getopt(int, char * const [], const char *);
|
|||
extern int optreset; /* getopt(3) external variable */
|
||||
#endif
|
||||
|
||||
#ifndef _POSIX_SOURCE
|
||||
#if __BSD_VISIBLE || (__XSI_VISIBLE >= 4 && __POSIX_VISIBLE < 200809)
|
||||
pid_t _EXFUN(vfork, (void ));
|
||||
#endif /* _POSIX_SOURCE */
|
||||
#endif
|
||||
|
||||
#ifdef _COMPILING_NEWLIB
|
||||
/* 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[] ));
|
||||
#endif
|
||||
|
||||
#if defined(__CYGWIN__) || defined(__rtems__) || defined(__aarch64__) || defined (__arm__) || defined(__sh__) || defined(__SPU__)
|
||||
#if !defined(__INSIDE_CYGWIN__)
|
||||
#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 500
|
||||
int _EXFUN(ftruncate, (int __fd, off_t __length));
|
||||
#endif
|
||||
#if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 500
|
||||
int _EXFUN(truncate, (const char *, off_t __length));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__CYGWIN__) || defined(__rtems__)
|
||||
#if __BSD_VISIBLE || __POSIX_VISIBLE < 200112
|
||||
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));
|
||||
#endif
|
||||
|
||||
#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 500
|
||||
#if !(defined (_WINSOCK_H) || defined (_WINSOCKAPI_) || defined (__USE_W32_SOCKETS))
|
||||
/* winsock[2].h defines as __stdcall, and with int as 2nd arg */
|
||||
int _EXFUN(gethostname, (char *__name, size_t __len));
|
||||
#endif
|
||||
char * _EXFUN(mktemp, (char *));
|
||||
#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));
|
||||
#endif
|
||||
|
||||
#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 4
|
||||
ssize_t _EXFUN(readlink, (const char *__restrict __path,
|
||||
char *__restrict __buf, size_t __buflen));
|
||||
#if __POSIX_VISIBLE >= 200809 || __BSD_VISIBLE || defined(__CYGWIN__)
|
||||
int _EXFUN(symlink, (const char *__name1, const char *__name2));
|
||||
#endif
|
||||
#if __ATFILE_VISIBLE
|
||||
ssize_t _EXFUN(readlinkat, (int __dirfd1, const char *__restrict __path,
|
||||
char *__restrict __buf, size_t __buflen));
|
||||
#endif
|
||||
int _EXFUN(symlink, (const char *__name1, const char *__name2));
|
||||
#if __POSIX_VISIBLE >= 200809 || __BSD_VISIBLE || defined(__CYGWIN__)
|
||||
int _EXFUN(symlinkat, (const char *, int, const char *));
|
||||
int _EXFUN(unlinkat, (int, const char *, int));
|
||||
#endif
|
||||
|
@ -422,6 +459,22 @@ int _EXFUN(unlinkat, (int, const char *, int));
|
|||
#define _SC_THREAD_ROBUST_PRIO_INHERIT 122
|
||||
#define _SC_THREAD_ROBUST_PRIO_PROTECT 123
|
||||
#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
|
||||
|
@ -453,6 +506,7 @@ int _EXFUN(unlinkat, (int, const char *, int));
|
|||
#define _PC_POSIX_PERMISSIONS 90
|
||||
/* Ask for full POSIX permission support including uid/gid settings. */
|
||||
#define _PC_POSIX_SECURITY 91
|
||||
#define _PC_CASE_INSENSITIVE 92
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
|
@ -11,7 +11,7 @@ extern "C" {
|
|||
#define WUNTRACED 2
|
||||
|
||||
/* 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> == 1..7e, child has exited, info is the signal number.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue