summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/arch/x86_64/asm/syscall.h56
-rw-r--r--include/arch/x86_64/asm/vdso.h29
-rw-r--r--include/errno.h5
-rw-r--r--include/sched.h72
-rw-r--r--include/stdatomic.h101
-rw-r--r--include/stdio.h19
-rw-r--r--include/sys/cdefs.h1
-rw-r--r--include/sys/mman.h1
-rw-r--r--include/threads.h7
9 files changed, 183 insertions, 108 deletions
diff --git a/include/arch/x86_64/asm/syscall.h b/include/arch/x86_64/asm/syscall.h
index b3d1ae48..181120ec 100644
--- a/include/arch/x86_64/asm/syscall.h
+++ b/include/arch/x86_64/asm/syscall.h
@@ -1,81 +1,79 @@
#ifndef __ASM_SYSCALL_H
#define __ASM_SYSCALL_H
-static __inline long __syscall0(long n)
+__attribute__((__always_inline__)) inline unsigned long __syscall0(long n)
{
unsigned long ret;
- __asm__ volatile("syscall"
- : "=a"(ret)
- : "a"(n)
- : "rcx", "r11", "memory");
+ __asm__ volatile("syscall" : "=a"(ret) : "a"(n) : "rcx", "r11", "memory");
return ret;
}
-static __inline long __syscall1(long n, long a1)
+__attribute__((__always_inline__)) inline unsigned long __syscall1(long n, long a1)
{
unsigned long ret;
- __asm__ __volatile__("syscall"
- : "=a"(ret)
- : "a"(n), "D"(a1)
- : "rcx", "r11", "memory");
+ __asm__ __volatile__("syscall" : "=a"(ret) : "a"(n), "D"(a1) : "rcx", "r11", "memory");
return ret;
}
-static inline long __syscall2(long n, long a1, long a2)
+__attribute__((__always_inline__)) inline unsigned long __syscall2(long n, long a1, long a2)
{
unsigned long ret;
- __asm__ volatile("syscall"
- : "=a"(ret)
- : "a"(n), "D"(a1), "S"(a2)
- : "rcx", "r11", "memory");
+ __asm__ volatile("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2) : "rcx", "r11", "memory");
return ret;
}
-static inline long __syscall3(long n, long a1, long a2, long a3)
+__attribute__((__always_inline__)) inline unsigned long __syscall3(long n, long a1, long a2, long a3)
{
unsigned long ret;
- __asm__ volatile("syscall"
- : "=a"(ret)
- : "a"(n), "D"(a1), "S"(a2), "d"(a3)
- : "rcx", "r11", "memory");
+ __asm__ volatile("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2), "d"(a3) : "rcx", "r11", "memory");
return ret;
}
-static inline long __syscall4(long n, long a1, long a2, long a3, long a4)
+__attribute__((__always_inline__)) inline unsigned long __syscall4(long n, long a1, long a2, long a3, long a4)
{
unsigned long ret;
register long r10 __asm__("r10") = a4;
+ __asm__ volatile("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2), "d"(a3), "r"(r10) : "rcx", "r11", "memory");
+ return ret;
+}
+
+__attribute__((__always_inline__)) inline unsigned long __syscall5(long n, long a1, long a2, long a3, long a4, long a5)
+{
+ unsigned long ret;
+ register long r10 __asm__("r10") = a4;
+ register long r8 __asm__("r8") = a5;
__asm__ volatile("syscall"
: "=a"(ret)
- : "a"(n), "D"(a1), "S"(a2), "d"(a3), "r"(r10)
+ : "a"(n), "D"(a1), "S"(a2), "d"(a3), "r"(r10), "r"(r8)
: "rcx", "r11", "memory");
return ret;
}
-static inline long __syscall5(long n, long a1, long a2, long a3, long a4,
- long a5)
+__attribute__((__always_inline__)) inline unsigned long __syscall6(long n, long a1, long a2, long a3, long a4, long a5,
+ long a6)
{
unsigned long ret;
register long r10 __asm__("r10") = a4;
register long r8 __asm__("r8") = a5;
+ register long r9 __asm__("r9") = a6;
__asm__ volatile("syscall"
: "=a"(ret)
- : "a"(n), "D"(a1), "S"(a2), "d"(a3), "r"(r10), "r"(r8)
+ : "a"(n), "D"(a1), "S"(a2), "d"(a3), "r"(r10), "r"(r8), "r"(r9)
: "rcx", "r11", "memory");
return ret;
}
-static inline long __syscall6(long n, long a1, long a2, long a3, long a4,
- long a5, long a6)
+__attribute__((__always_inline__)) inline unsigned long __syscall7(long n, long a1, long a2, long a3, long a4, long a5,
+ long a6, long a7)
{
unsigned long ret;
register long r10 __asm__("r10") = a4;
register long r8 __asm__("r8") = a5;
register long r9 __asm__("r9") = a6;
+ register long r12 __asm__("r12") = a7;
__asm__ volatile("syscall"
: "=a"(ret)
- : "a"(n), "D"(a1), "S"(a2), "d"(a3), "r"(r10), "r"(r8),
- "r"(r9)
+ : "a"(n), "D"(a1), "S"(a2), "d"(a3), "r"(r10), "r"(r8), "r"(r9), "r"(r12)
: "rcx", "r11", "memory");
return ret;
}
diff --git a/include/arch/x86_64/asm/vdso.h b/include/arch/x86_64/asm/vdso.h
index 7f0ea2aa..2fb34473 100644
--- a/include/arch/x86_64/asm/vdso.h
+++ b/include/arch/x86_64/asm/vdso.h
@@ -1,22 +1,35 @@
#ifndef __ASM_VDSO_H
#define __ASM_VDSO_H
+/*
+ * vDSO support interface.
+ *
+ * IMPORTANT:
+ * Do not define storage in this header. This header is included by multiple
+ * translation units; defining `static` variables here causes each TU to get its
+ * own copy, which makes initialization inconsistent and prevents dead-stripping.
+ *
+ * The actual storage/definitions must live in a single .c file (e.g.
+ * `lib/libc/internal/init/vdso.c`), and this header should only declare them.
+ */
+
struct timespec;
#define __VDSO_CLOCK_GETTIME
#define __VDSO_GETCPU
#define __VDSO_TIME
-static int (*__vdso_clock_gettime)(int, struct timespec *) = 0;
-static int (*__vdso_getcpu)(unsigned *, unsigned *, void *) = 0;
-static int (*__vdso_time)(long *) = 0;
+/* Resolved vDSO entry points (set by __init_vdso). */
+extern int (*__vdso_clock_gettime)(int, struct timespec *);
+extern int (*__vdso_getcpu)(unsigned *, unsigned *, void *);
+extern int (*__vdso_time)(long *);
-struct {
+/* Symbol table used by __init_vdso to locate vDSO functions. */
+struct __vdso_sym {
const char *name;
void *func;
-} __vdso_symtab[] = { { "__vdso_clock_gettime", (void *)&__vdso_clock_gettime },
- { "__vdso_getcpu", (void *)&__vdso_getcpu },
- { "__vdso_time", (void *)&__vdso_time },
- { 0, 0 } };
+};
+
+extern struct __vdso_sym __vdso_symtab[];
#endif
diff --git a/include/errno.h b/include/errno.h
index 800f9a9b..3dd2fa30 100644
--- a/include/errno.h
+++ b/include/errno.h
@@ -1,7 +1,8 @@
#ifndef __ERRNO_H
#define __ERRNO_H
-extern _Thread_local int errno;
+#include <sys/cdefs.h>
+#define errno (*__errno())
#define EPERM 1
#define ENOENT 2
@@ -138,4 +139,6 @@ extern _Thread_local int errno;
#define ERFKILL 132
#define EHWPOISON 133
+__const int *__errno(void);
+
#endif
diff --git a/include/sched.h b/include/sched.h
new file mode 100644
index 00000000..a0bd5af7
--- /dev/null
+++ b/include/sched.h
@@ -0,0 +1,72 @@
+#ifndef __SCHED_H
+#define __SCHED_H
+
+#include <sys/cdefs.h>
+
+#define __BITS_TIMESPEC_H_
+#include <bits/timespec.h>
+
+__BEGIN_DECLS
+
+#define SCHED_OTHER 0
+#define SCHED_FIFO 1
+#define SCHED_RR 2
+#define SCHED_BATCH 3
+#define SCHED_IDLE 5
+#define SCHED_DEADLINE 6
+#define SCHED_RESET_ON_FORK 0x40000000
+
+#define CLONE_CHILD_CLEARTID 0x00200000
+#define CLONE_CHILD_SETTID 0x01000000
+#define CLONE_DETACHED 0x00400000
+#define CLONE_FILES 0x00000400
+#define CLONE_FS 0x00000200
+#define CLONE_IO 0x80000000
+#define CLONE_NEWCGROUP 0x02000000
+#define CLONE_NEWIPC 0x08000000
+#define CLONE_NEWNET 0x40000000
+#define CLONE_NEWNS 0x00020000
+#define CLONE_NEWPID 0x20000000
+#define CLONE_NEWTIME 0x00000080
+#define CLONE_NEWUSER 0x10000000
+#define CLONE_NEWUTS 0x04000000
+#define CLONE_PARENT 0x00008000
+#define CLONE_PARENT_SETTID 0x00100000
+#define CLONE_PIDFD 0x00001000
+#define CLONE_PTRACE 0x00002000
+#define CLONE_SETTLS 0x00080000
+#define CLONE_SIGHAND 0x00000800
+#define CLONE_SYSVSEM 0x00040000
+#define CLONE_THREAD 0x00010000
+#define CLONE_UNTRACED 0x00800000
+#define CLONE_VFORK 0x00004000
+#define CLONE_VM 0x00000100
+#define CSIGNAL 0x000000ff
+
+#define SCHED_OTHER 0
+#define SCHED_FIFO 1
+#define SCHED_RR 2
+#define SCHED_BATCH 3
+#define SCHED_IDLE 5
+#define SCHED_DEADLINE 6
+#define SCHED_RESET_ON_FORK 0x40000000
+
+typedef __INT64_TYPE__ pid_t;
+typedef __INT64_TYPE__ time_t;
+
+struct sched_param {
+ int sched_priority;
+};
+
+int sched_get_priority_max(int);
+int sched_get_priority_min(int);
+int sched_getparam(pid_t, struct sched_param *);
+int sched_getscheduler(pid_t);
+int sched_rr_get_interval(pid_t, struct timespec *);
+int sched_setparam(pid_t, const struct sched_param *);
+int sched_setscheduler(pid_t, int, const struct sched_param *);
+int sched_yield(void);
+
+__END_DECLS
+
+#endif
diff --git a/include/stdatomic.h b/include/stdatomic.h
index 8863815d..d487464e 100644
--- a/include/stdatomic.h
+++ b/include/stdatomic.h
@@ -1,7 +1,6 @@
#ifndef __STDATOMIC_H
#define __STDATOMIC_H
-#include <stdatomic.h>
#define atomic_bool _Atomic _Bool
#define atomic_char _Atomic char
#define atomic_schar _Atomic signed char
@@ -54,117 +53,89 @@ typedef enum {
memory_order_seq_cst = __ATOMIC_SEQ_CST
} memory_order;
-#define atomic_flag_clear_explicit(__ATOMIC_FLAG, __MEMORY_ORDER) \
- __atomic_clear((__ATOMIC_FLAG), (__MEMORY_ORDER))
+#define atomic_flag_clear_explicit(__ATOMIC_FLAG, __MEMORY_ORDER) __atomic_clear((__ATOMIC_FLAG), (__MEMORY_ORDER))
-#define atomic_flag_clear(__ATOMIC_FLAG) \
- atomic_flag_clear_explicit((__ATOMIC_FLAG), memory_order_seq_cst)
+#define atomic_flag_clear(__ATOMIC_FLAG) atomic_flag_clear_explicit((__ATOMIC_FLAG), memory_order_seq_cst)
#define atomic_flag_test_and_set_explicit(__ATOMIC_FLAG, __MEMORY_ORDER) \
__atomic_test_and_set((__ATOMIC_FLAG), (__MEMORY_ORDER))
-#define atomic_flag_test_and_set(__ATOMIC_FLAG) \
- atomic_flag_test_and_set_explicit((__ATOMIC_FLAG), memory_order_seq_cst)
+#define atomic_flag_test_and_set(__ATOMIC_FLAG) atomic_flag_test_and_set_explicit((__ATOMIC_FLAG), memory_order_seq_cst)
-#define atomic_signal_fence(__MEMORY_ORDER) \
- __atomic_signal_fence(__MEMORY_ORDER)
+#define atomic_signal_fence(__MEMORY_ORDER) __atomic_signal_fence(__MEMORY_ORDER)
-#define atomic_thread_fence(__MEMORY_ORDER) \
- __atomic_thread_fence(__MEMORY_ORDER)
+#define atomic_thread_fence(__MEMORY_ORDER) __atomic_thread_fence(__MEMORY_ORDER)
-#define atomic_compare_exchange_strong_explicit(__ATOMIC_OBJECT_PTR, \
- __VALUE_PTR, __DESIRED, \
- __SUCCESS_MEMORDER, \
- __FAILURE_MEMORDER) \
- __atomic_compare_exchange_n((__ATOMIC_OBJECT_PTR), (__VALUE_PTR), \
- (__DESIRED), 0, (__SUCCESS_MEMORDER), \
+#define atomic_compare_exchange_strong_explicit(__ATOMIC_OBJECT_PTR, __VALUE_PTR, __DESIRED, __SUCCESS_MEMORDER, \
+ __FAILURE_MEMORDER) \
+ __atomic_compare_exchange_n((__ATOMIC_OBJECT_PTR), (__VALUE_PTR), (__DESIRED), 0, (__SUCCESS_MEMORDER), \
(__FAILURE_MEMORDER))
-#define atomic_compare_exchange_strong(__ATOMIC_OBJECT_PTR, __VALUE_PTR, \
- __DESIRED) \
- atomic_compare_exchange_strong_explicit((__ATOMIC_OBJECT_PTR), \
- (__VALUE_PTR), (__DESIRED), \
- memory_order_seq_cst, \
- memory_order_seq_cst)
-
-#define atomic_compare_exchange_weak_explicit(__ATOMIC_OBJECT_PTR, \
- __VALUE_PTR, __DESIRED, \
- __SUCCESS_MEMORDER, \
- __FAILURE_MEMORDER) \
- __atomic_compare_exchange_n((__ATOMIC_OBJECT_PTR), (__VALUE_PTR), \
- (__DESIRED), 1, (__SUCCESS_MEMORDER), \
+#define atomic_compare_exchange_strong(__ATOMIC_OBJECT_PTR, __VALUE_PTR, __DESIRED) \
+ atomic_compare_exchange_strong_explicit((__ATOMIC_OBJECT_PTR), (__VALUE_PTR), (__DESIRED), \
+ memory_order_seq_cst, memory_order_seq_cst)
+
+#define atomic_compare_exchange_weak_explicit(__ATOMIC_OBJECT_PTR, __VALUE_PTR, __DESIRED, __SUCCESS_MEMORDER, \
+ __FAILURE_MEMORDER) \
+ __atomic_compare_exchange_n((__ATOMIC_OBJECT_PTR), (__VALUE_PTR), (__DESIRED), 1, (__SUCCESS_MEMORDER), \
(__FAILURE_MEMORDER))
-#define atomic_compare_exchange_weak(__ATOMIC_OBJECT_PTR, __VALUE_PTR, \
- __DESIRED) \
- atomic_compare_exchange_weak_explicit((__ATOMIC_OBJECT_PTR), \
- (__VALUE_PTR), (__DESIRED), \
- memory_order_seq_cst, \
+#define atomic_compare_exchange_weak(__ATOMIC_OBJECT_PTR, __VALUE_PTR, __DESIRED) \
+ atomic_compare_exchange_weak_explicit((__ATOMIC_OBJECT_PTR), (__VALUE_PTR), (__DESIRED), memory_order_seq_cst, \
memory_order_seq_cst)
-#define atomic_exchange_explicit(__ATOMIC_OBJECT_PTR, __DESIRED, \
- __MEMORY_ORDER) \
- __atomic_exchange_n((__ATOMIC_OBJECT_PTR), (__DESIRED), \
- (__MEMORY_ORDER))
+#define atomic_exchange_explicit(__ATOMIC_OBJECT_PTR, __DESIRED, __MEMORY_ORDER) \
+ __atomic_exchange_n((__ATOMIC_OBJECT_PTR), (__DESIRED), (__MEMORY_ORDER))
-#define atomic_exchange(__ATOMIC_OBJECT_PTR, __DESIRED) \
- atomic_exchange_explicit((__ATOMIC_OBJECT_PTR), (__DESIRED), \
- memory_order_seq_cst)
+#define atomic_exchange(__ATOMIC_OBJECT_PTR, __DESIRED) \
+ atomic_exchange_explicit((__ATOMIC_OBJECT_PTR), (__DESIRED), memory_order_seq_cst)
#define atomic_fetch_add_explicit(__ATOMIC_OBJECT_PTR, __ARG, __MEMORY_ORDER) \
__atomic_fetch_add((__ATOMIC_OBJECT_PTR), (__ARG), (__MEMORY_ORDER))
-#define atomic_fetch_add(__ATOMIC_OBJECT_PTR, __ARG) \
- atomic_fetch_add_explicit((__ATOMIC_OBJECT_PTR), (__ARG), \
- memory_order_seq_cst)
+#define atomic_fetch_add(__ATOMIC_OBJECT_PTR, __ARG) \
+ atomic_fetch_add_explicit((__ATOMIC_OBJECT_PTR), (__ARG), memory_order_seq_cst)
#define atomic_fetch_and_explicit(__ATOMIC_OBJECT_PTR, __ARG, __MEMORY_ORDER) \
__atomic_fetch_and((__ATOMIC_OBJECT_PTR), (__ARG), (__MEMORY_ORDER))
-#define atomic_fetch_and(__ATOMIC_OBJECT_PTR, __ARG) \
- atomic_fetch_and_explicit((__ATOMIC_OBJECT_PTR), (__ARG), \
- memory_order_seq_cst)
+#define atomic_fetch_and(__ATOMIC_OBJECT_PTR, __ARG) \
+ atomic_fetch_and_explicit((__ATOMIC_OBJECT_PTR), (__ARG), memory_order_seq_cst)
#define atomic_fetch_or_explicit(__ATOMIC_OBJECT_PTR, __ARG, __MEMORY_ORDER) \
__atomic_fetch_or((__ATOMIC_OBJECT_PTR), (__ARG), (__MEMORY_ORDER))
-#define atomic_fetch_or(__ATOMIC_OBJECT_PTR, __ARG) \
- atomic_fetch_or_explicit((__ATOMIC_OBJECT_PTR), (__ARG), \
- memory_order_seq_cst)
+#define atomic_fetch_or(__ATOMIC_OBJECT_PTR, __ARG) \
+ atomic_fetch_or_explicit((__ATOMIC_OBJECT_PTR), (__ARG), memory_order_seq_cst)
#define atomic_fetch_sub_explicit(__ATOMIC_OBJECT_PTR, __ARG, __MEMORY_ORDER) \
__atomic_fetch_sub((__ATOMIC_OBJECT_PTR), (__ARG), (__MEMORY_ORDER))
-#define atomic_fetch_sub(__ATOMIC_OBJECT_PTR, __ARG) \
- atomic_fetch_sub_explicit((__ATOMIC_OBJECT_PTR), (__ARG), \
- memory_order_seq_cst)
+#define atomic_fetch_sub(__ATOMIC_OBJECT_PTR, __ARG) \
+ atomic_fetch_sub_explicit((__ATOMIC_OBJECT_PTR), (__ARG), memory_order_seq_cst)
#define atomic_fetch_xor_explicit(__ATOMIC_OBJECT_PTR, __ARG, __MEMORY_ORDER) \
__atomic_fetch_xor((__ATOMIC_OBJECT_PTR), (__ARG), (__MEMORY_ORDER))
-#define atomic_fetch_xor(__ATOMIC_OBJECT_PTR, __ARG) \
- atomic_fetch_xor_explicit((__ATOMIC_OBJECT_PTR), (__ARG), \
- memory_order_seq_cst)
+#define atomic_fetch_xor(__ATOMIC_OBJECT_PTR, __ARG) \
+ atomic_fetch_xor_explicit((__ATOMIC_OBJECT_PTR), (__ARG), memory_order_seq_cst)
#define atomic_load_explicit(__ATOMIC_OBJECT_PTR, __MEMORY_ORDER) \
__atomic_load_n((__ATOMIC_OBJECT_PTR), (__MEMORY_ORDER))
-#define atomic_load(__ATOMIC_OBJECT_PTR) \
- atomic_load_explicit((__ATOMIC_OBJECT_PTR), memory_order_seq_cst)
+#define atomic_load(__ATOMIC_OBJECT_PTR) atomic_load_explicit((__ATOMIC_OBJECT_PTR), memory_order_seq_cst)
#define atomic_store_explicit(__ATOMIC_OBJECT_PTR, __DESIRED, __MEMORY_ORDER) \
__atomic_store_n((__ATOMIC_OBJECT_PTR), (__DESIRED), (__MEMORY_ORDER))
-#define atomic_store(__ATOMIC_OBJECT_PTR, __DESIRED) \
- atomic_store_explicit((__ATOMIC_OBJECT_PTR), (__DESIRED), \
- memory_order_seq_cst)
+#define atomic_store(__ATOMIC_OBJECT_PTR, __DESIRED) \
+ atomic_store_explicit((__ATOMIC_OBJECT_PTR), (__DESIRED), memory_order_seq_cst)
#define atomic_init(__ATOMIC_OBJECT_PTR, __DESIRED) \
__atomic_store_n((__ATOMIC_OBJECT_PTR), (__DESIRED), __ATOMIC_RELAXED)
-#define atomic_is_lock_free(__ATOMIC_OBJECT_PTR) \
- __atomic_is_lock_free(sizeof(*(__ATOMIC_OBJECT_PTR)), \
- (__ATOMIC_OBJECT_PTR))
+#define atomic_is_lock_free(__ATOMIC_OBJECT_PTR) \
+ __atomic_is_lock_free(sizeof(*(__ATOMIC_OBJECT_PTR)), (__ATOMIC_OBJECT_PTR))
#define ATOMIC_FLAG_INIT { 0 }
diff --git a/include/stdio.h b/include/stdio.h
index 65aff35c..47231b0e 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -69,7 +69,6 @@ size_t fwrite(const void *restrict, size_t, size_t, FILE *restrict);
int getc(FILE *);
int getchar(void);
int getc_unlocked(FILE *);
-int getchar_unlocked(void);
ssize_t getdelim(char **restrict, size_t *restrict, int, FILE *restrict);
ssize_t getline(char **restrict, size_t *restrict, FILE *restrict);
FILE *open_memstream(char **, size_t *);
@@ -79,8 +78,6 @@ FILE *popen(const char *, const char *);
int printf(const char *restrict, ...);
int putc(int, FILE *);
int putchar(int);
-int putc_unlocked(int, FILE *);
-int putchar_unlocked(int);
int puts(const char *);
int remove(const char *);
int rename(const char *, const char *);
@@ -105,4 +102,20 @@ int vsnprintf(char *restrict, size_t, const char *restrict, va_list);
int vsprintf(char *restrict, const char *restrict, va_list);
int vsscanf(const char *restrict, const char *restrict, va_list);
+int getc_unlocked(FILE *);
+int getchar_unlocked(void);
+int putc_unlocked(int, FILE *);
+int putchar_unlocked(int);
+void clearerr_unlocked(FILE *);
+int feof_unlocked(FILE *);
+int ferror_unlocked(FILE *);
+int fileno_unlocked(FILE *);
+int fflush_unlocked(FILE *);
+int fgetc_unlocked(FILE *);
+int fputc_unlocked(int, FILE *);
+size_t fread_unlocked(void *restrict, size_t, size_t, FILE *restrict);
+size_t fwrite_unlocked(const void *, size_t, size_t, FILE *);
+char *fgets_unlocked(char *, int, FILE *);
+int fputs_unlocked(const char *, FILE *);
+
#endif
diff --git a/include/sys/cdefs.h b/include/sys/cdefs.h
index cd490d6b..bbb12fb2 100644
--- a/include/sys/cdefs.h
+++ b/include/sys/cdefs.h
@@ -22,6 +22,7 @@
#define __nodiscard __attribute__((__warn_unused_result__))
#define __weak __attribute__((__weak__))
#define __naked __attribute__((__naked__))
+#define __const __attribute__((__const__))
#define __predict_true(exp) __builtin_expect((exp) != 0, 1)
#define __predict_false(exp) __builtin_expect((exp) != 0, 0)
diff --git a/include/sys/mman.h b/include/sys/mman.h
index 78b72c48..a8e9308f 100644
--- a/include/sys/mman.h
+++ b/include/sys/mman.h
@@ -31,5 +31,6 @@ typedef __UINT32_TYPE__ mode_t;
void *mmap(void *, size_t, int, int, int, off_t);
int munmap(void *, size_t);
int posix_madvise(void *, size_t, int);
+int mprotect(void *, size_t, int);
#endif
diff --git a/include/threads.h b/include/threads.h
index 54daec7b..2aec9204 100644
--- a/include/threads.h
+++ b/include/threads.h
@@ -35,19 +35,21 @@ enum {
};
void call_once(once_flag *, void (*)(void));
+
int cnd_broadcast(cnd_t *);
void cnd_destroy(cnd_t *);
int cnd_init(cnd_t *);
int cnd_signal(cnd_t *);
-int cnd_timedwait(cnd_t *restrict, mtx_t *restrict,
- const struct timespec *restrict);
+int cnd_timedwait(cnd_t *restrict, mtx_t *restrict, const struct timespec *restrict);
int cnd_wait(cnd_t *, mtx_t *);
+
void mtx_destroy(mtx_t *);
int mtx_init(mtx_t *, int);
int mtx_lock(mtx_t *);
int mtx_timedlock(mtx_t *restrict, const struct timespec *restrict);
int mtx_trylock(mtx_t *);
int mtx_unlock(mtx_t *);
+
int thrd_create(thrd_t *, thrd_start_t, void *);
thrd_t thrd_current(void);
int thrd_detach(thrd_t);
@@ -56,6 +58,7 @@ _Noreturn void thrd_exit(int);
int thrd_join(thrd_t, int *);
int thrd_sleep(const struct timespec *, struct timespec *);
void thrd_yield(void);
+
int tss_create(tss_t *, tss_dtor_t);
void tss_delete(tss_t);
void *tss_get(tss_t);