summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Makefile4
-rw-r--r--include/arpa/nameser_compat.h4
-rw-r--r--include/assert.h15
-rw-r--r--include/complex.h11
-rw-r--r--include/dlfcn.h1
-rw-r--r--include/glob.h3
-rw-r--r--include/gssapi/gssapi.h4
-rw-r--r--include/netdb.h2
-rw-r--r--include/regex.h2
-rw-r--r--include/resolv.h2
-rw-r--r--include/rpc/svc.h2
-rw-r--r--include/rpcsvc/mount.x4
-rw-r--r--include/rpcsvc/nfs_prot.x4
-rw-r--r--include/rpcsvc/nis.x4
-rw-r--r--include/signal.h6
-rw-r--r--include/stdalign.h47
-rw-r--r--include/stdatomic.h329
-rw-r--r--include/stdbool.h7
-rw-r--r--include/stdio.h10
-rw-r--r--include/stdlib.h15
-rw-r--r--include/stdnoreturn.h38
-rw-r--r--include/tgmath.h132
-rw-r--r--include/unistd.h1
-rw-r--r--include/xlocale.h4
24 files changed, 565 insertions, 86 deletions
diff --git a/include/Makefile b/include/Makefile
index c6fb526..5fc3923 100644
--- a/include/Makefile
+++ b/include/Makefile
@@ -19,8 +19,8 @@ INCS= a.out.h ar.h assert.h bitstring.h complex.h cpio.h _ctype.h ctype.h \
printf.h proc_service.h pthread.h \
pthread_np.h pwd.h ranlib.h readpassphrase.h regex.h \
res_update.h resolv.h runetype.h search.h semaphore.h setjmp.h \
- signal.h spawn.h stab.h \
- stdbool.h stddef.h stdio.h stdlib.h string.h stringlist.h \
+ signal.h spawn.h stab.h stdalign.h stdatomic.h stdbool.h stddef.h \
+ stdnoreturn.h stdio.h stdlib.h string.h stringlist.h \
strings.h sysexits.h tar.h termios.h tgmath.h \
time.h timeconv.h timers.h ttyent.h \
ulimit.h unistd.h utime.h utmpx.h uuid.h varargs.h vis.h \
diff --git a/include/arpa/nameser_compat.h b/include/arpa/nameser_compat.h
index 161fed3..91ff176 100644
--- a/include/arpa/nameser_compat.h
+++ b/include/arpa/nameser_compat.h
@@ -63,7 +63,7 @@ typedef struct {
/* fields in third byte */
unsigned qr: 1; /*%< response flag */
unsigned opcode: 4; /*%< purpose of message */
- unsigned aa: 1; /*%< authoritive answer */
+ unsigned aa: 1; /*%< authoritative answer */
unsigned tc: 1; /*%< truncated message */
unsigned rd: 1; /*%< recursion desired */
/* fields in fourth byte */
@@ -77,7 +77,7 @@ typedef struct {
/* fields in third byte */
unsigned rd :1; /*%< recursion desired */
unsigned tc :1; /*%< truncated message */
- unsigned aa :1; /*%< authoritive answer */
+ unsigned aa :1; /*%< authoritative answer */
unsigned opcode :4; /*%< purpose of message */
unsigned qr :1; /*%< response flag */
/* fields in fourth byte */
diff --git a/include/assert.h b/include/assert.h
index 5621f8c..c880a78 100644
--- a/include/assert.h
+++ b/include/assert.h
@@ -57,7 +57,22 @@
#ifndef _ASSERT_H_
#define _ASSERT_H_
+
+/*
+ * Static assertions. In principle we could define static_assert for
+ * C++ older than C++11, but this breaks if _Static_assert is
+ * implemented as a macro.
+ *
+ * C++ template parameters may contain commas, even if not enclosed in
+ * parentheses, causing the _Static_assert macro to be invoked with more
+ * than two parameters.
+ */
+#if __ISO_C_VISIBLE >= 2011 && !defined(__cplusplus)
+#define static_assert _Static_assert
+#endif
+
__BEGIN_DECLS
void __assert(const char *, const char *, int, const char *) __dead2;
__END_DECLS
+
#endif /* !_ASSERT_H_ */
diff --git a/include/complex.h b/include/complex.h
index 4142304..0702541 100644
--- a/include/complex.h
+++ b/include/complex.h
@@ -29,18 +29,23 @@
#ifndef _COMPLEX_H
#define _COMPLEX_H
+#include <sys/cdefs.h>
+
#ifdef __GNUC__
#if __STDC_VERSION__ < 199901
#define _Complex __complex__
#endif
-#define _Complex_I 1.0fi
+#define _Complex_I ((float _Complex)1.0i)
+#endif
+
+#ifdef __generic
+_Static_assert(__generic(_Complex_I, float _Complex, 1, 0),
+ "_Complex_I must be of type float _Complex");
#endif
#define complex _Complex
#define I _Complex_I
-#include <sys/cdefs.h>
-
__BEGIN_DECLS
double cabs(double complex);
diff --git a/include/dlfcn.h b/include/dlfcn.h
index 794fde1..c508843 100644
--- a/include/dlfcn.h
+++ b/include/dlfcn.h
@@ -118,6 +118,7 @@ void *dlopen(const char *, int);
void *dlsym(void * __restrict, const char * __restrict);
#if __BSD_VISIBLE
+void *fdlopen(int, int);
int dladdr(const void * __restrict, Dl_info * __restrict);
dlfunc_t dlfunc(void * __restrict, const char * __restrict);
int dlinfo(void * __restrict, int, void * __restrict);
diff --git a/include/glob.h b/include/glob.h
index 351b6c4..073805b 100644
--- a/include/glob.h
+++ b/include/glob.h
@@ -98,7 +98,8 @@ typedef struct {
#endif /* __BSD_VISIBLE */
__BEGIN_DECLS
-int glob(const char *, int, int (*)(const char *, int), glob_t *);
+int glob(const char * __restrict, int,
+ int (*)(const char *, int), glob_t * __restrict);
void globfree(glob_t *);
__END_DECLS
diff --git a/include/gssapi/gssapi.h b/include/gssapi/gssapi.h
index 16a588e..d5294de 100644
--- a/include/gssapi/gssapi.h
+++ b/include/gssapi/gssapi.h
@@ -756,11 +756,11 @@ OM_uint32 gss_release_oid
OM_uint32 gss_decapsulate_token
(const gss_buffer_t, /* mechanism independent token */
gss_OID, /* desired mechanism */
- gss_buffer_t /* decapsulated mechanism dependant token */
+ gss_buffer_t /* decapsulated mechanism dependent token */
);
OM_uint32 gss_encapsulate_token
- (const gss_buffer_t, /* mechanism dependant token */
+ (const gss_buffer_t, /* mechanism dependent token */
gss_OID, /* desired mechanism */
gss_buffer_t /* encapsulated mechanism independent token */
);
diff --git a/include/netdb.h b/include/netdb.h
index 2c2e4b3..9ed6e61 100644
--- a/include/netdb.h
+++ b/include/netdb.h
@@ -276,7 +276,7 @@ int getservbyport_r(int, const char *, struct servent *, char *,
int getservent_r(struct servent *, char *, size_t,
struct servent **);
void herror(const char *);
-__const char *hstrerror(int);
+const char *hstrerror(int);
int innetgr(const char *, const char *, const char *, const char *);
void setnetgrent(const char *);
#endif
diff --git a/include/regex.h b/include/regex.h
index fb9b99c..e8b185c 100644
--- a/include/regex.h
+++ b/include/regex.h
@@ -51,7 +51,7 @@ typedef __size_t size_t;
typedef struct {
int re_magic;
size_t re_nsub; /* number of parenthesized subexpressions */
- __const char *re_endp; /* end pointer for REG_PEND */
+ const char *re_endp; /* end pointer for REG_PEND */
struct re_guts *re_g; /* none of your business :-) */
} regex_t;
diff --git a/include/resolv.h b/include/resolv.h
index f59f445..458835b 100644
--- a/include/resolv.h
+++ b/include/resolv.h
@@ -184,7 +184,7 @@ struct __res_state {
u_int16_t nscount;
u_int16_t nstimes[MAXNS]; /*%< ms. */
int nssocks[MAXNS];
- struct __res_state_ext *ext; /*%< extention for IPv6 */
+ struct __res_state_ext *ext; /*%< extension for IPv6 */
} _ext;
} _u;
};
diff --git a/include/rpc/svc.h b/include/rpc/svc.h
index 8466ef8..d73625e 100644
--- a/include/rpc/svc.h
+++ b/include/rpc/svc.h
@@ -314,7 +314,7 @@ __END_DECLS
* Somebody has to wait for incoming requests and then call the correct
* service routine. The routine svc_run does infinite waiting; i.e.,
* svc_run never returns.
- * Since another (co-existant) package may wish to selectively wait for
+ * Since another (co-existent) package may wish to selectively wait for
* incoming calls or other events outside of the rpc architecture, the
* routine svc_getreq is provided. It must be passed readfds, the
* "in-place" results of a select system call (see select, section 2).
diff --git a/include/rpcsvc/mount.x b/include/rpcsvc/mount.x
index 9596661..b3b21f7 100644
--- a/include/rpcsvc/mount.x
+++ b/include/rpcsvc/mount.x
@@ -150,7 +150,7 @@ program MOUNTPROG {
version MOUNTVERS {
/*
* Does no work. It is made available in all RPC services
- * to allow server reponse testing and timing
+ * to allow server response testing and timing
*/
void
MOUNTPROC_NULL(void) = 0;
@@ -205,7 +205,7 @@ program MOUNTPROG {
version MOUNTVERS3 {
/*
* Does no work. It is made available in all RPC services
- * to allow server reponse testing and timing
+ * to allow server response testing and timing
*/
void
MOUNTPROC_NULL(void) = 0;
diff --git a/include/rpcsvc/nfs_prot.x b/include/rpcsvc/nfs_prot.x
index 8a09ac3..70b24fe 100644
--- a/include/rpcsvc/nfs_prot.x
+++ b/include/rpcsvc/nfs_prot.x
@@ -121,7 +121,7 @@ struct fattr {
unsigned uid; /* owner user id */
unsigned gid; /* owner group id */
unsigned size; /* file size in bytes */
- unsigned blocksize; /* prefered block size */
+ unsigned blocksize; /* preferred block size */
unsigned rdev; /* special device # */
unsigned blocks; /* Kb of disk used by file */
unsigned fsid; /* device # */
@@ -402,7 +402,7 @@ struct fattr3 {
uid3 uid; /* owner user id */
gid3 gid; /* owner group id */
size3 size; /* file size in bytes */
- size3 used; /* prefered block size */
+ size3 used; /* preferred block size */
specdata3 rdev; /* special device # */
uint64 fsid; /* device # */
fileid3 fileid; /* inode # */
diff --git a/include/rpcsvc/nis.x b/include/rpcsvc/nis.x
index 7ebb19d..758fcb7 100644
--- a/include/rpcsvc/nis.x
+++ b/include/rpcsvc/nis.x
@@ -192,8 +192,8 @@ struct ping_args {
* note that modifications will appear as two entries, for names, they have
* an "OLD" entry followed by a "NEW" entry. For entries in tables, there
* is a remove followed by an add. It is done this way so that we can read
- * the log backwards to back out transactions and forwards to propogate
- * updated.
+ * the log backwards to back out transactions and forwards to propagate
+ * updates.
*/
enum log_entry_t {
LOG_NOP = 0,
diff --git a/include/signal.h b/include/signal.h
index 32b9e6b..e7447df 100644
--- a/include/signal.h
+++ b/include/signal.h
@@ -42,9 +42,9 @@
* XXX should enlarge these, if only to give empty names instead of bounds
* errors for large signal numbers.
*/
-extern __const char *__const sys_signame[NSIG];
-extern __const char *__const sys_siglist[NSIG];
-extern __const int sys_nsig;
+extern const char * const sys_signame[NSIG];
+extern const char * const sys_siglist[NSIG];
+extern const int sys_nsig;
#endif
#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
diff --git a/include/stdalign.h b/include/stdalign.h
new file mode 100644
index 0000000..2fb13aa
--- /dev/null
+++ b/include/stdalign.h
@@ -0,0 +1,47 @@
+/*-
+ * Copyright (c) 2012 Ed Schouten <ed@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef __alignas_is_defined
+#define __alignas_is_defined 1
+
+#if !defined(__cplusplus) || __cplusplus < 201103L
+#include <sys/cdefs.h>
+#define alignas _Alignas
+#endif
+
+#endif /* !__alignas_is_defined */
+
+#ifndef __alignof_is_defined
+#define __alignof_is_defined 1
+
+#if !defined(__cplusplus) || __cplusplus < 201103L
+#include <sys/cdefs.h>
+#define alignof _Alignof
+#endif
+
+#endif /* !__alignof_is_defined */
diff --git a/include/stdatomic.h b/include/stdatomic.h
new file mode 100644
index 0000000..18769bb
--- /dev/null
+++ b/include/stdatomic.h
@@ -0,0 +1,329 @@
+/*-
+ * Copyright (c) 2011 Ed Schouten <ed@FreeBSD.org>
+ * David Chisnall <theraven@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 _STDATOMIC_H_
+#define _STDATOMIC_H_
+
+#include <sys/cdefs.h>
+#include <sys/_types.h>
+
+#if __has_feature(cxx_atomic)
+#define __CLANG_ATOMICS
+#elif __GNUC_PREREQ__(4, 7)
+#define __GNUC_ATOMICS
+#elif !defined(__GNUC__)
+#error "stdatomic.h does not support your compiler"
+#endif
+
+#if !defined(__CLANG_ATOMICS)
+#define _Atomic(T) struct { volatile T __val; }
+#endif
+
+/*
+ * 7.17.2 Initialization.
+ */
+
+#if defined(__CLANG_ATOMICS)
+#define ATOMIC_VAR_INIT(value) (value)
+#define atomic_init(obj, value) __atomic_init(obj, value)
+#else
+#define ATOMIC_VAR_INIT(value) { .__val = (value) }
+#define atomic_init(obj, value) do { \
+ (obj)->__val = (value); \
+} while (0)
+#endif
+
+/*
+ * Clang and recent GCC both provide predefined macros for the memory
+ * orderings. If we are using a compiler that doesn't define them, use the
+ * clang values - these will be ignored in the fallback path.
+ */
+
+#ifndef __ATOMIC_RELAXED
+#define __ATOMIC_RELAXED 0
+#endif
+#ifndef __ATOMIC_CONSUME
+#define __ATOMIC_CONSUME 1
+#endif
+#ifndef __ATOMIC_ACQUIRE
+#define __ATOMIC_ACQUIRE 2
+#endif
+#ifndef __ATOMIC_RELEASE
+#define __ATOMIC_RELEASE 3
+#endif
+#ifndef __ATOMIC_ACQ_REL
+#define __ATOMIC_ACQ_REL 4
+#endif
+#ifndef __ATOMIC_SEQ_CST
+#define __ATOMIC_SEQ_CST 5
+#endif
+
+/*
+ * 7.17.3 Order and consistency.
+ *
+ * The memory_order_* constants that denote the barrier behaviour of the
+ * atomic operations.
+ */
+
+enum memory_order {
+ memory_order_relaxed = __ATOMIC_RELAXED,
+ memory_order_consume = __ATOMIC_CONSUME,
+ memory_order_acquire = __ATOMIC_ACQUIRE,
+ memory_order_release = __ATOMIC_RELEASE,
+ memory_order_acq_rel = __ATOMIC_ACQ_REL,
+ memory_order_seq_cst = __ATOMIC_SEQ_CST
+};
+
+/*
+ * 7.17.4 Fences.
+ */
+
+#if defined(__CLANG_ATOMICS) || defined(__GNUC_ATOMICS)
+#define atomic_thread_fence(order) __atomic_thread_fence(order)
+#define atomic_signal_fence(order) __atomic_signal_fence(order)
+#else
+#define atomic_thread_fence(order) __sync_synchronize()
+#define atomic_signal_fence(order) __asm volatile ("" : : : "memory")
+#endif
+
+/*
+ * 7.17.5 Lock-free property.
+ */
+
+#if defined(__CLANG_ATOMICS)
+#define atomic_is_lock_free(obj) \
+ __atomic_is_lock_free(sizeof(obj))
+#elif defined(__GNUC_ATOMICS)
+#define atomic_is_lock_free(obj) \
+ __atomic_is_lock_free(sizeof((obj)->__val))
+#else
+#define atomic_is_lock_free(obj) \
+ (sizeof((obj)->__val) <= sizeof(void *))
+#endif
+
+/*
+ * 7.17.6 Atomic integer types.
+ */
+
+typedef _Atomic(_Bool) atomic_bool;
+typedef _Atomic(char) atomic_char;
+typedef _Atomic(signed char) atomic_schar;
+typedef _Atomic(unsigned char) atomic_uchar;
+typedef _Atomic(short) atomic_short;
+typedef _Atomic(unsigned short) atomic_ushort;
+typedef _Atomic(int) atomic_int;
+typedef _Atomic(unsigned int) atomic_uint;
+typedef _Atomic(long) atomic_long;
+typedef _Atomic(unsigned long) atomic_ulong;
+typedef _Atomic(long long) atomic_llong;
+typedef _Atomic(unsigned long long) atomic_ullong;
+#if 0
+typedef _Atomic(__char16_t) atomic_char16_t;
+typedef _Atomic(__char32_t) atomic_char32_t;
+#endif
+typedef _Atomic(__wchar_t) atomic_wchar_t;
+typedef _Atomic(__int_least8_t) atomic_int_least8_t;
+typedef _Atomic(__uint_least8_t) atomic_uint_least8_t;
+typedef _Atomic(__int_least16_t) atomic_int_least16_t;
+typedef _Atomic(__uint_least16_t) atomic_uint_least16_t;
+typedef _Atomic(__int_least32_t) atomic_int_least32_t;
+typedef _Atomic(__uint_least32_t) atomic_uint_least32_t;
+typedef _Atomic(__int_least64_t) atomic_int_least64_t;
+typedef _Atomic(__uint_least64_t) atomic_uint_least64_t;
+typedef _Atomic(__int_fast8_t) atomic_int_fast8_t;
+typedef _Atomic(__uint_fast8_t) atomic_uint_fast8_t;
+typedef _Atomic(__int_fast16_t) atomic_int_fast16_t;
+typedef _Atomic(__uint_fast16_t) atomic_uint_fast16_t;
+typedef _Atomic(__int_fast32_t) atomic_int_fast32_t;
+typedef _Atomic(__uint_fast32_t) atomic_uint_fast32_t;
+typedef _Atomic(__int_fast64_t) atomic_int_fast64_t;
+typedef _Atomic(__uint_fast64_t) atomic_uint_fast64_t;
+typedef _Atomic(__intptr_t) atomic_intptr_t;
+typedef _Atomic(__uintptr_t) atomic_uintptr_t;
+typedef _Atomic(__size_t) atomic_size_t;
+typedef _Atomic(__ptrdiff_t) atomic_ptrdiff_t;
+typedef _Atomic(__intmax_t) atomic_intmax_t;
+typedef _Atomic(__uintmax_t) atomic_uintmax_t;
+
+/*
+ * 7.17.7 Operations on atomic types.
+ */
+
+/*
+ * Compiler-specific operations.
+ */
+
+#if defined(__CLANG_ATOMICS)
+#define atomic_compare_exchange_strong_explicit(object, expected, \
+ desired, success, failure) \
+ __atomic_compare_exchange_strong(object, expected, desired, \
+ success, failure)
+#define atomic_compare_exchange_weak_explicit(object, expected, \
+ desired, success, failure) \
+ __atomic_compare_exchange_weak(object, expected, desired, \
+ success, failure)
+#define atomic_exchange_explicit(object, desired, order) \
+ __atomic_exchange(object, desired, order)
+#define atomic_fetch_add_explicit(object, operand, order) \
+ __atomic_fetch_add(object, operand, order)
+#define atomic_fetch_and_explicit(object, operand, order) \
+ __atomic_fetch_and(object, operand, order)
+#define atomic_fetch_or_explicit(object, operand, order) \
+ __atomic_fetch_or(object, operand, order)
+#define atomic_fetch_sub_explicit(object, operand, order) \
+ __atomic_fetch_sub(object, operand, order)
+#define atomic_fetch_xor_explicit(object, operand, order) \
+ __atomic_fetch_xor(object, operand, order)
+#define atomic_load_explicit(object, order) \
+ __atomic_load(object, order)
+#define atomic_store_explicit(object, desired, order) \
+ __atomic_store(object, desired, order)
+#elif defined(__GNUC_ATOMICS)
+#define atomic_compare_exchange_strong_explicit(object, expected, \
+ desired, success, failure) \
+ __atomic_compare_exchange_n(&(object)->__val, expected, \
+ desired, 0, success, failure)
+#define atomic_compare_exchange_weak_explicit(object, expected, \
+ desired, success, failure) \
+ __atomic_compare_exchange_n(&(object)->__val, expected, \
+ desired, 1, success, failure)
+#define atomic_exchange_explicit(object, desired, order) \
+ __atomic_exchange_n(&(object)->__val, desired, order)
+#define atomic_fetch_add_explicit(object, operand, order) \
+ __atomic_fetch_add(&(object)->__val, operand, order)
+#define atomic_fetch_and_explicit(object, operand, order) \
+ __atomic_fetch_and(&(object)->__val, operand, order)
+#define atomic_fetch_or_explicit(object, operand, order) \
+ __atomic_fetch_or(&(object)->__val, operand, order)
+#define atomic_fetch_sub_explicit(object, operand, order) \
+ __atomic_fetch_sub(&(object)->__val, operand, order)
+#define atomic_fetch_xor_explicit(object, operand, order) \
+ __atomic_fetch_xor(&(object)->__val, operand, order)
+#define atomic_load_explicit(object, order) \
+ __atomic_load_n(&(object)->__val, order)
+#define atomic_store_explicit(object, desired, order) \
+ __atomic_store_n(&(object)->__val, desired, order)
+#else
+#define atomic_compare_exchange_strong_explicit(object, expected, \
+ desired, success, failure) ({ \
+ __typeof__((object)->__val) __v; \
+ _Bool __r; \
+ __v = __sync_val_compare_and_swap(&(object)->__val, \
+ *(expected), desired); \
+ __r = *(expected) == __v; \
+ *(expected) = __v; \
+ __r; \
+})
+
+#define atomic_compare_exchange_weak_explicit(object, expected, \
+ desired, success, failure) \
+ atomic_compare_exchange_strong_explicit(object, expected, \
+ desired, success, failure)
+#if __has_builtin(__sync_swap)
+/* Clang provides a full-barrier atomic exchange - use it if available. */
+#define atomic_exchange_explicit(object, desired, order) \
+ __sync_swap(&(object)->__val, desired)
+#else
+/*
+ * __sync_lock_test_and_set() is only an acquire barrier in theory (although in
+ * practice it is usually a full barrier) so we need an explicit barrier after
+ * it.
+ */
+#define atomic_exchange_explicit(object, desired, order) ({ \
+ __typeof__((object)->__val) __v; \
+ __v = __sync_lock_test_and_set(&(object)->__val, desired); \
+ __sync_synchronize(); \
+ __v; \
+})
+#endif
+#define atomic_fetch_add_explicit(object, operand, order) \
+ __sync_fetch_and_add(&(object)->__val, operand)
+#define atomic_fetch_and_explicit(object, operand, order) \
+ __sync_fetch_and_and(&(object)->__val, operand)
+#define atomic_fetch_or_explicit(object, operand, order) \
+ __sync_fetch_and_or(&(object)->__val, operand)
+#define atomic_fetch_sub_explicit(object, operand, order) \
+ __sync_fetch_and_sub(&(object)->__val, operand)
+#define atomic_fetch_xor_explicit(object, operand, order) \
+ __sync_fetch_and_xor(&(object)->__val, operand)
+#define atomic_load_explicit(object, order) \
+ __sync_fetch_and_add(&(object)->__val, 0)
+#define atomic_store_explicit(object, desired, order) do { \
+ __sync_synchronize(); \
+ (object)->__val = (desired); \
+ __sync_synchronize(); \
+} while (0)
+#endif
+
+/*
+ * Convenience functions.
+ */
+
+#define atomic_compare_exchange_strong(object, expected, desired) \
+ atomic_compare_exchange_strong_explicit(object, expected, \
+ desired, memory_order_seq_cst, memory_order_seq_cst)
+#define atomic_compare_exchange_weak(object, expected, desired) \
+ atomic_compare_exchange_weak_explicit(object, expected, \
+ desired, memory_order_seq_cst, memory_order_seq_cst)
+#define atomic_exchange(object, desired) \
+ atomic_exchange_explicit(object, desired, memory_order_seq_cst)
+#define atomic_fetch_add(object, operand) \
+ atomic_fetch_add_explicit(object, operand, memory_order_seq_cst)
+#define atomic_fetch_and(object, operand) \
+ atomic_fetch_and_explicit(object, operand, memory_order_seq_cst)
+#define atomic_fetch_or(object, operand) \
+ atomic_fetch_or_explicit(object, operand, memory_order_seq_cst)
+#define atomic_fetch_sub(object, operand) \
+ atomic_fetch_sub_explicit(object, operand, memory_order_seq_cst)
+#define atomic_fetch_xor(object, operand) \
+ atomic_fetch_xor_explicit(object, operand, memory_order_seq_cst)
+#define atomic_load(object) \
+ atomic_load_explicit(object, memory_order_seq_cst)
+#define atomic_store(object, desired) \
+ atomic_store_explicit(object, desired, memory_order_seq_cst)
+
+/*
+ * 7.17.8 Atomic flag type and operations.
+ */
+
+typedef atomic_bool atomic_flag;
+
+#define ATOMIC_FLAG_INIT ATOMIC_VAR_INIT(0)
+
+#define atomic_flag_clear_explicit(object, order) \
+ atomic_store_explicit(object, 0, order)
+#define atomic_flag_test_and_set_explicit(object, order) \
+ atomic_compare_exchange_strong_explicit(object, 0, 1, order, order)
+
+#define atomic_flag_clear(object) \
+ atomic_flag_clear_explicit(object, memory_order_seq_cst)
+#define atomic_flag_test_and_set(object) \
+ atomic_flag_test_and_set_explicit(object, memory_order_seq_cst)
+
+#endif /* !_STDATOMIC_H_ */
diff --git a/include/stdbool.h b/include/stdbool.h
index c0d6459..48070c1 100644
--- a/include/stdbool.h
+++ b/include/stdbool.h
@@ -26,9 +26,7 @@
* $FreeBSD$
*/
-#ifndef _STDBOOL_H_
-#define _STDBOOL_H_
-
+#ifndef __bool_true_false_are_defined
#define __bool_true_false_are_defined 1
#ifndef __cplusplus
@@ -42,5 +40,4 @@ typedef int _Bool;
#endif
#endif /* !__cplusplus */
-
-#endif /* !_STDBOOL_H_ */
+#endif /* __bool_true_false_are_defined */
diff --git a/include/stdio.h b/include/stdio.h
index bbeb0de..02032d9 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -205,7 +205,7 @@ __END_DECLS
/* System V/ANSI C; this is the wrong way to do this, do *not* use these. */
#if __XSI_VISIBLE
-#define P_tmpdir "/var/tmp/"
+#define P_tmpdir "/tmp/"
#endif
#define L_tmpnam 1024 /* XXX must be == PATH_MAX */
#define TMP_MAX 308915776
@@ -404,8 +404,8 @@ int vasprintf(char **, const char *, __va_list)
* positive errno values. Use strerror() or strerror_r() from <string.h>
* instead.
*/
-extern __const int sys_nerr;
-extern __const char *__const sys_errlist[];
+extern const int sys_nerr;
+extern const char * const sys_errlist[];
/*
* Stdio function-access interface.
@@ -470,6 +470,9 @@ static __inline int __sputc(int _c, FILE *_p) {
__swbuf((int)(c), p) : \
(*(p)->_p = (c), (int)*(p)->_p++))
#endif
+
+extern int __isthreaded;
+
#ifndef __cplusplus
#define __sfeof(p) (((p)->_flags & __SEOF) != 0)
@@ -477,7 +480,6 @@ static __inline int __sputc(int _c, FILE *_p) {
#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))
#define __sfileno(p) ((p)->_file)
-extern int __isthreaded;
#define feof(p) (!__isthreaded ? __sfeof(p) : (feof)(p))
#define ferror(p) (!__isthreaded ? __sferror(p) : (ferror)(p))
diff --git a/include/stdlib.h b/include/stdlib.h
index c19eef0..2c62f09 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -149,13 +149,14 @@ _Noreturn void _Exit(int);
#endif /* __ISO_C_VISIBLE >= 1999 */
/*
- * If we're in a mode greater than C99, expose C1x functions.
+ * If we're in a mode greater than C99, expose C11 functions.
*/
-#if __ISO_C_VISIBLE > 1999
-_Noreturn void quick_exit(int)
-int
-at_quick_exit(void (*func)(void));
-#endif /* __ISO_C_VISIBLE > 1999 */
+#if __ISO_C_VISIBLE >= 2011
+void * aligned_alloc(size_t, size_t);
+int at_quick_exit(void (*)(void));
+_Noreturn void
+ quick_exit(int);
+#endif /* __ISO_C_VISIBLE >= 2011 */
/*
* Extensions made by POSIX relative to C. We don't know yet which edition
* of POSIX made these extensions, so assume they've always been there until
@@ -271,7 +272,7 @@ char *devname_r(__dev_t, __mode_t, char *, int);
char *fdevname(int);
char *fdevname_r(int, char *, int);
int getloadavg(double [], int);
-__const char *
+const char *
getprogname(void);
int heapsort(void *, size_t, size_t, int (*)(const void *, const void *));
diff --git a/include/stdnoreturn.h b/include/stdnoreturn.h
new file mode 100644
index 0000000..218a3a0
--- /dev/null
+++ b/include/stdnoreturn.h
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2012 Ed Schouten <ed@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifdef __cplusplus
+#error "<stdnoreturn.h> cannot be used in combination with C++11."
+#endif
+
+#ifndef noreturn
+
+#include <sys/cdefs.h>
+#define noreturn _Noreturn
+
+#endif /* !noreturn */
diff --git a/include/tgmath.h b/include/tgmath.h
index 7ff8dd4..9302302 100644
--- a/include/tgmath.h
+++ b/include/tgmath.h
@@ -2,6 +2,9 @@
* Copyright (c) 2004 Stefan Farfeleder.
* All rights reserved.
*
+ * Copyright (c) 2012 Ed Schouten <ed@FreeBSD.org>
+ * All rights reserved.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -33,64 +36,104 @@
#include <math.h>
/*
- * This implementation of <tgmath.h> requires two implementation-dependent
- * macros to be defined:
- * __tg_impl_simple(x, y, z, fn, fnf, fnl, ...)
+ * This implementation of <tgmath.h> uses the two following macros,
+ * which are based on the macros described in C11 proposal N1404:
+ * __tg_impl_simple(x, y, z, fnl, fn, fnf, ...)
* Invokes fnl() if the corresponding real type of x, y or z is long
* double, fn() if it is double or any has an integer type, and fnf()
* otherwise.
- * __tg_impl_full(x, y, z, fn, fnf, fnl, cfn, cfnf, cfnl, ...)
- * Invokes [c]fnl() if the corresponding real type of x, y or z is long
+ * __tg_impl_full(x, y, cfnl, cfn, cfnf, fnl, fn, fnf, ...)
+ * Invokes [c]fnl() if the corresponding real type of x or y is long
* double, [c]fn() if it is double or any has an integer type, and
* [c]fnf() otherwise. The function with the 'c' prefix is called if
- * any of x, y or z is a complex number.
+ * any of x or y is a complex number.
* Both macros call the chosen function with all additional arguments passed
* to them, as given by __VA_ARGS__.
*
* Note that these macros cannot be implemented with C's ?: operator,
* because the return type of the whole expression would incorrectly be long
* double complex regardless of the argument types.
+ *
+ * The structure of the C11 implementation of these macros can in
+ * principle be reused for non-C11 compilers, but due to an integer
+ * promotion bug for complex types in GCC 4.2, simply let non-C11
+ * compilers use an inefficient yet reliable version.
*/
-#if __GNUC_PREREQ__(3, 1)
-#define __tg_type(e, t) __builtin_types_compatible_p(__typeof__(e), t)
-#define __tg_type3(e1, e2, e3, t) \
- (__tg_type(e1, t) || __tg_type(e2, t) || __tg_type(e3, t))
-#define __tg_type_corr(e1, e2, e3, t) \
- (__tg_type3(e1, e2, e3, t) || __tg_type3(e1, e2, e3, t _Complex))
-#define __tg_integer(e1, e2, e3) \
- (((__typeof__(e1))1.5 == 1) || ((__typeof__(e2))1.5 == 1) || \
- ((__typeof__(e3))1.5 == 1))
-#define __tg_is_complex(e1, e2, e3) \
- (__tg_type3(e1, e2, e3, float _Complex) || \
- __tg_type3(e1, e2, e3, double _Complex) || \
- __tg_type3(e1, e2, e3, long double _Complex) || \
- __tg_type3(e1, e2, e3, __typeof__(_Complex_I)))
-
-#define __tg_impl_simple(x, y, z, fn, fnf, fnl, ...) \
- __builtin_choose_expr(__tg_type_corr(x, y, z, long double), \
- fnl(__VA_ARGS__), __builtin_choose_expr( \
- __tg_type_corr(x, y, z, double) || __tg_integer(x, y, z),\
- fn(__VA_ARGS__), fnf(__VA_ARGS__)))
-
-#define __tg_impl_full(x, y, z, fn, fnf, fnl, cfn, cfnf, cfnl, ...) \
- __builtin_choose_expr(__tg_is_complex(x, y, z), \
- __tg_impl_simple(x, y, z, cfn, cfnf, cfnl, __VA_ARGS__), \
- __tg_impl_simple(x, y, z, fn, fnf, fnl, __VA_ARGS__))
-
-#else /* __GNUC__ */
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
+#define __tg_generic(x, cfnl, cfn, cfnf, fnl, fn, fnf) \
+ _Generic(x, \
+ long double _Complex: cfnl, \
+ double _Complex: cfn, \
+ float _Complex: cfnf, \
+ long double: fnl, \
+ default: fn, \
+ float: fnf \
+ )
+#define __tg_type(x) \
+ __tg_generic(x, (long double _Complex)0, (double _Complex)0, \
+ (float _Complex)0, (long double)0, (double)0, (float)0)
+#define __tg_impl_simple(x, y, z, fnl, fn, fnf, ...) \
+ __tg_generic( \
+ __tg_type(x) + __tg_type(y) + __tg_type(z), \
+ fnl, fn, fnf, fnl, fn, fnf)(__VA_ARGS__)
+#define __tg_impl_full(x, y, cfnl, cfn, cfnf, fnl, fn, fnf, ...) \
+ __tg_generic( \
+ __tg_type(x) + __tg_type(y), \
+ cfnl, cfn, cfnf, fnl, fn, fnf)(__VA_ARGS__)
+#elif defined(__generic)
+#define __tg_generic_simple(x, fnl, fn, fnf) \
+ __generic(x, long double _Complex, fnl, \
+ __generic(x, double _Complex, fn, \
+ __generic(x, float _Complex, fnf, \
+ __generic(x, long double, fnl, \
+ __generic(x, float, fnf, fn)))))
+#define __tg_impl_simple(x, y, z, fnl, fn, fnf, ...) \
+ __tg_generic_simple(x, \
+ __tg_generic_simple(y, \
+ __tg_generic_simple(z, fnl, fnl, fnl), \
+ __tg_generic_simple(z, fnl, fnl, fnl), \
+ __tg_generic_simple(z, fnl, fnl, fnl)), \
+ __tg_generic_simple(y, \
+ __tg_generic_simple(z, fnl, fnl, fnl), \
+ __tg_generic_simple(z, fnl, fn , fn ), \
+ __tg_generic_simple(z, fnl, fn , fn )), \
+ __tg_generic_simple(y, \
+ __tg_generic_simple(z, fnl, fnl, fnl), \
+ __tg_generic_simple(z, fnl, fn , fn ), \
+ __tg_generic_simple(z, fnl, fn , fnf)))(__VA_ARGS__)
+#define __tg_generic_full(x, cfnl, cfn, cfnf, fnl, fn, fnf) \
+ __generic(x, long double _Complex, cfnl, \
+ __generic(x, double _Complex, cfn, \
+ __generic(x, float _Complex, cfnf, \
+ __generic(x, long double, fnl, \
+ __generic(x, float, fnf, fn)))))
+#define __tg_impl_full(x, y, cfnl, cfn, cfnf, fnl, fn, fnf, ...) \
+ __tg_generic_full(x, \
+ __tg_generic_full(y, cfnl, cfnl, cfnl, cfnl, cfnl, cfnl), \
+ __tg_generic_full(y, cfnl, cfn , cfn , cfnl, cfn , cfn ), \
+ __tg_generic_full(y, cfnl, cfn , cfnf, cfnl, cfn , cfnf), \
+ __tg_generic_full(y, cfnl, cfnl, cfnl, fnl , fnl , fnl ), \
+ __tg_generic_full(y, cfnl, cfn , cfn , fnl , fn , fn ), \
+ __tg_generic_full(y, cfnl, cfn , cfnf, fnl , fn , fnf )) \
+ (__VA_ARGS__)
+#else
#error "<tgmath.h> not implemented for this compiler"
-#endif /* !__GNUC__ */
+#endif
/* Macros to save lots of repetition below */
#define __tg_simple(x, fn) \
- __tg_impl_simple(x, x, x, fn, fn##f, fn##l, x)
+ __tg_impl_simple(x, x, x, fn##l, fn, fn##f, x)
#define __tg_simple2(x, y, fn) \
- __tg_impl_simple(x, x, y, fn, fn##f, fn##l, x, y)
+ __tg_impl_simple(x, x, y, fn##l, fn, fn##f, x, y)
+#define __tg_simple3(x, y, z, fn) \
+ __tg_impl_simple(x, y, z, fn##l, fn, fn##f, x, y, z)
#define __tg_simplev(x, fn, ...) \
- __tg_impl_simple(x, x, x, fn, fn##f, fn##l, __VA_ARGS__)
+ __tg_impl_simple(x, x, x, fn##l, fn, fn##f, __VA_ARGS__)
#define __tg_full(x, fn) \
- __tg_impl_full(x, x, x, fn, fn##f, fn##l, c##fn, c##fn##f, c##fn##l, x)
+ __tg_impl_full(x, x, c##fn##l, c##fn, c##fn##f, fn##l, fn, fn##f, x)
+#define __tg_full2(x, y, fn) \
+ __tg_impl_full(x, y, c##fn##l, c##fn, c##fn##f, fn##l, fn, fn##f, x, y)
/* 7.22#4 -- These macros expand to real or complex functions, depending on
* the type of their arguments. */
@@ -108,13 +151,12 @@
#define tanh(x) __tg_full(x, tanh)
#define exp(x) __tg_full(x, exp)
#define log(x) __tg_full(x, log)
-#define pow(x, y) __tg_impl_full(x, x, y, pow, powf, powl, \
- cpow, cpowf, cpowl, x, y)
+#define pow(x, y) __tg_full2(x, y, pow)
#define sqrt(x) __tg_full(x, sqrt)
/* "The corresponding type-generic macro for fabs and cabs is fabs." */
-#define fabs(x) __tg_impl_full(x, x, x, fabs, fabsf, fabsl, \
- cabs, cabsf, cabsl, x)
+#define fabs(x) __tg_impl_full(x, x, cabsl, cabs, cabsf, \
+ fabsl, fabs, fabsf, x)
/* 7.22#5 -- These macros are only defined for arguments with real type. */
#define atan2(x, y) __tg_simple2(x, y, atan2)
@@ -127,7 +169,7 @@
#define expm1(x) __tg_simple(x, expm1)
#define fdim(x, y) __tg_simple2(x, y, fdim)
#define floor(x) __tg_simple(x, floor)
-#define fma(x, y, z) __tg_impl_simple(x, y, z, fma, fmaf, fmal, x, y, z)
+#define fma(x, y, z) __tg_simple3(x, y, z, fma)
#define fmax(x, y) __tg_simple2(x, y, fmax)
#define fmin(x, y) __tg_simple2(x, y, fmin)
#define fmod(x, y) __tg_simple2(x, y, fmod)
@@ -148,8 +190,8 @@
#define nextafter(x, y) __tg_simple2(x, y, nextafter)
#define nexttoward(x, y) __tg_simplev(x, nexttoward, x, y)
#define remainder(x, y) __tg_simple2(x, y, remainder)
-#define remquo(x, y, z) __tg_impl_simple(x, x, y, remquo, remquof, \
- remquol, x, y, z)
+#define remquo(x, y, z) __tg_impl_simple(x, x, y, remquol, remquo, \
+ remquof, x, y, z)
#define rint(x) __tg_simple(x, rint)
#define round(x) __tg_simple(x, round)
#define scalbn(x, y) __tg_simplev(x, scalbn, x, y)
diff --git a/include/unistd.h b/include/unistd.h
index f073f8d..90694ed 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -511,6 +511,7 @@ int initgroups(const char *, gid_t);
int iruserok(unsigned long, int, const char *, const char *);
int iruserok_sa(const void *, int, int, const char *, const char *);
int issetugid(void);
+void __FreeBSD_libc_enter_restricted_mode(void);
long lpathconf(const char *, int);
#ifndef _MKDTEMP_DECLARED
char *mkdtemp(char *);
diff --git a/include/xlocale.h b/include/xlocale.h
index 30fe87e..1f27894 100644
--- a/include/xlocale.h
+++ b/include/xlocale.h
@@ -157,9 +157,9 @@ int vfscanf_l(FILE * __restrict, locale_t, const char * __restrict, __va_list)
__scanflike(3, 0);
int vscanf_l(locale_t, const char * __restrict, __va_list) __scanflike(2, 0);
int vsnprintf_l(char * __restrict, size_t, locale_t, const char * __restrict,
- va_list) __printflike(4, 0);
+ __va_list) __printflike(4, 0);
int vsscanf_l(const char * __restrict, locale_t, const char * __restrict,
- va_list) __scanflike(3, 0);
+ __va_list) __scanflike(3, 0);
int dprintf_l(int, locale_t, const char * __restrict, ...) __printflike(3, 4);
int vdprintf_l(int, locale_t, const char * __restrict, __va_list)
__printflike(3, 0);
OpenPOWER on IntegriCloud