summaryrefslogtreecommitdiff
path: root/src/lib/libc/include
diff options
context:
space:
mode:
authorcvs2svn <admin@example.com>2021-08-18 16:06:57 +0000
committercvs2svn <admin@example.com>2021-08-18 16:06:57 +0000
commitd56c8fa8260d226f98b26f017b45b9c2b135f38d (patch)
tree348178b41617813cc93787187984a734ef8379ca /src/lib/libc/include
parent18b9c1bcab7c37d8c5bd05b8e0d14d0c59d96650 (diff)
downloadopenbsd-tb_20210818.tar.gz
openbsd-tb_20210818.tar.bz2
openbsd-tb_20210818.zip
This commit was manufactured by cvs2git to create tag 'tb_20210818'.tb_20210818
Diffstat (limited to '')
-rw-r--r--src/lib/libc/include/DETAILS133
-rw-r--r--src/lib/libc/include/README97
-rw-r--r--src/lib/libc/include/atfork.h45
-rw-r--r--src/lib/libc/include/cancel.h78
-rw-r--r--src/lib/libc/include/ctype_private.h9
-rw-r--r--src/lib/libc/include/localedef.h106
-rw-r--r--src/lib/libc/include/mpool.h122
-rw-r--r--src/lib/libc/include/namespace.h90
-rw-r--r--src/lib/libc/include/thread_private.h426
9 files changed, 0 insertions, 1106 deletions
diff --git a/src/lib/libc/include/DETAILS b/src/lib/libc/include/DETAILS
deleted file mode 100644
index 6382cc1c0d..0000000000
--- a/src/lib/libc/include/DETAILS
+++ /dev/null
@@ -1,133 +0,0 @@
1The goal: calls from inside libc to other libc functions should
2 * not be overridable (except for the malloc family), and
3 * not have pointless inefficiencies.
4
5To achieve this, we arrange that all these internal call be via
6identifiers that are of hidden visibility and--to avoid confusion
7and work correctly in static executables--are in the reserved
8namespace.
9
10This document describes the details of the naming scheme and how
11it is implemented.
12
13I've chosen a prefix of underbar-libc-underbar ("_libc_") for this.
14These are not declared directly; instead, the gcc "asm labels"
15extension is used to rename the function.
16
17We need many of the symbols to be weak in *static* builds, but they
18can be strong in the dynamic library, as there's a natural precedence
19from the search order there. When the descriptions below say a
20name is "weak", that is only necessary for the static library and
21not for the shared library. Note: use defined(PIC) to recognize
22when compiling the shared objects: some archs define __PIC__ *all*
23the time.
24
25---------
26
27For syscalls which are not cancellation points, such as getpid(),
28the identifiers are just:
29 _libc_getpid hidden alias, for use internal to libc only
30 _thread_sys_getpid global name, for use outside libc only
31 getpid weak alias, for use outside libc only
32
33For syscalls which are cancellation points, such as wait4(), there
34are identifiers that do not provide cancellation:
35 _libc_wait4 hidden alias, for use internal to libc only
36 _thread_sys_wait4 global name, for use outside libc only
37...and identifiers that do provide cancellation:
38 wait4 weak alias, for general use
39 _libc_wait4_cancel hidden name, for use internal to libc only
40Inside libc, the bare name ("wait4") binds to the version *with*
41cancellation. If it's necessary to use the syscall without doing
42cancellation it can be obtained by calling HIDDEN(x) instead of
43just x.
44
45Some other calls need to be wrapped for reasons other than cancellation,
46such as to provide functionality beyond the underlying syscall (e.g.,
47ptrace). For these, there are identifiers for the raw call, without
48the wrapping:
49 _libc_ptrace hidden alias, for use internal to libc only
50 _thread_sys_ptrace global name, for use outside libc only
51...and identifiers that do provide the libc wrapping:
52 ptrace weak alias, for general use
53 _libc_ptrace_wrap hidden name, for use internal to libc only
54Inside libc, the bare name ("ptrace") binds to the wrapper; if
55the raw version is necessary it can be obtained by calling HIDDEN(x)
56instead of just x.
57
58For syscalls implemented in ASM, the aliases of the raw syscall stub
59are provided by the ASM macros. Of the macros used by sys/Makefile.inc:
60RSYSCALL(), PSEUDO(), and PSEUDO_NOERROR() generate all three names
61(ala getpid() above), while RSYSCALL_HIDDEN() generates just the
62_thread_sys_x and _libc_x names.
63
64
65
66By using gcc's "asm label" extension, we can usually avoid having
67to type those prefixes in the .h and .c files. However, for those
68cases where a non-default binding is necessary we can use these macros
69to get the desired identifier:
70
71 CANCEL(x)
72 This expands to the internal, hidden name of a cancellation
73 wrapper: _libc_x_cancel. ex: CANCEL(fsync)(fd)
74
75 WRAP(x)
76 This expands to the internal, hidden name of a non-cancellation
77 wrapper: _libc_x_wrap. ex: WRAP(sigprocmask)(set)
78
79
80In order to actually set up the desired asm labels, we use these in
81the internal .h files:
82 PROTO_NORMAL(x) Symbols used both internally and externally
83 This makes gcc convert use of x to use _libc_x instead
84 ex: PROTO_NORMAL(getpid)
85
86 PROTO_STD_DEPRECATED(x) Standard C symbols that we don't want to use
87 This just marks the symbol as deprecated, with no renaming.
88 ex: PROTO_STD_DEPRECATED(strcpy)
89
90 PROTO_DEPRECATED(x) Symbols not in ISO C that we don't want to use
91 This marks the symbol as both weak and deprecated, with no renaming
92 ex: PROTO_DEPRECATED(creat)
93
94 PROTO_CANCEL(x) Functions that have cancellation wrappers
95 Like PROTO_NORMAL(x), but also declares _libc_x_cancel
96 ex: PROTO_CANCEL(wait4)
97
98 PROTO_WRAP(x) Functions that have wrappers for other reasons
99 Like PROTO_NORMAL(x), but also declares _libc_x_wrap. Internal
100 calls that want the wrapper's processing should invoke WRAP(x)(...)
101 ex: PROTO_WRAP(sigaction)
102
103
104Finally, to create the expected aliases, we use these in the .c files
105where the definitions are:
106 DEF_STRONG(x) Symbols reserved to or specified by ISO C
107 This defines x as a strong alias for _libc_x; this must only
108 be used for symbols that are reserved by the C standard
109 (or reserved in the external identifier namespace).
110 Matches with PROTO_NORMAL()
111 ex: DEF_STRONG(fopen)
112
113 DEF_WEAK(x) Symbols used internally and not in ISO C
114 This defines x as a weak alias for _libc_x
115 Matches with PROTO_NORMAL()
116 ex: DEF_WEAK(lseek)
117
118 DEF_CANCEL(x) Symbols that have a cancellation wrapper
119 This defines x as a weak alias for _libc_x_cancel.
120 Matches with PROTO_CANCEL()
121 ex: DEF_CANCEL(read)
122
123 DEF_WRAP(x)
124 This defines x as a weak alias for _libc_x_wrap.
125 Matches with PROTO_WRAP()
126 ex: DEF_WRAP(ptrace)
127
128 MAKE_CLONE(dst, src) Symbols that are exact clones of other symbols
129 This declares _libc_dst as being the same type as dst, and makes
130 _libc_dst a strong, hidden alias for _libc_src. You still need to
131 DEF_STRONG(dst) or DEF_WEAK(dst) to alias dst itself
132 ex: MAKE_CLONE(SHA224Pad, SHA256Pad)
133
diff --git a/src/lib/libc/include/README b/src/lib/libc/include/README
deleted file mode 100644
index 6410072c96..0000000000
--- a/src/lib/libc/include/README
+++ /dev/null
@@ -1,97 +0,0 @@
1So you want to add an interface to libc...
2
3CASE I: internal symbols
4
5 A) used in a single file
6 Duh: use whatever name you want and make it static
7
8 B) used in multiple files
9 Give it a name in the implementation namespace (leading underbar)
10 and declare it in a __{BEGIN,END}_HIDDEN_DECLS block in a .h
11 file inside libc. If it's used in just a single subdir of
12 libc *and* that subdir has an appropriate .h file in it, then
13 declare it there.
14 Example: stdio/local.h.
15 Otherwise, declare it in one of the hidden/* files.
16 Example: _mktemp() in hidden/stdio.h
17
18CASE II: external symbols
19
20 First of all, add your symbol to Symbols.list. MD symbols go in
21 arch/*/Symbols.list (shock, I know)
22
23 Declare your function in the appropriate header. It almost certainly
24 should be in a public header installed under /usr/include/. Exceptions
25 are symbols that are just shared between libc and libpthread/csu/ld.so
26 which are only declared in libc/include/* or just in each .c file.
27
28 A) objects (variables)
29 That's it, you're done.
30
31 B) plain C functions (not syscalls)
32 1) functions that are *not* called from inside libc
33
34 If this function is specified in the ISO C standard or its
35 name begins with an underbar, then in the hidden/* version
36 of the header where you declared the function, add this line:
37 PROTO_STD_DEPRECATED(your_function_name);
38
39 Otherwise, this is *not* a function specified in the ISO C
40 standard and its name begins with a letter. In the hidden/*
41 version of the header where you declared the function, add
42 this line:
43 PROTO_DEPRECATED(your_function_name);
44
45 2) functions that are called from inside libc
46
47 In the hidden/* version of the header where you declared
48 the function, add this line:
49 PROTO_NORMAL(your_function_name);
50
51 Then, in the .c file(s) where the function is defined:
52 - if the function is specified in the ISO C standard or
53 its name begins with an underbar, add
54 DEF_STRONG(your_function_name);
55
56 - otherwise, add:
57 DEF_WEAK(your_function_name);
58
59 C) syscalls that require cancellation or other libpthread wrappers
60 You're done in libc, but go to libpthread and add the wrapper there.
61
62 D) syscalls that require libc wrappers for other reasons
63 First of all, make sure this really is the Right Thing. Talk
64 with kettenis, deraadt, miod, and guenther.
65
66 1) If the actual syscall doesn't have the same calling convention
67 as the C interface, then maybe it shouldn't be exported at
68 all and you should just have an ASM stub, like SYS___tfork
69 --> __tfork_thread() or SYS_break --> brk() and sbrk(). If
70 it _could_ be called from C, then give the syscall a name
71 different from the C API. Syscalls that fail this for
72 historical reasons (e.g., getlogin) are generated with
73 PSEUDO in libc/sys/Makefile.inc, so the ASM stub has a
74 leading underbar. Go read gen/getlogin.c for an example
75 of how to do this.
76
77 2) Otherwise, you're sane and have a syscall like sigaction()
78 which requires a wrapper but whose syscall API is the same
79 as the C API. Then:
80 - generate the ASM stub with HIDDEN in libc/sys/Makefile.inc
81 - in the proper hidden/*.h file add
82 PROTO_WRAP(your_function_name)
83 - the wrapper function should be defined in
84 libc/sys/w_your_function_name.c
85 which should define WRAP(your_function_name) and
86 follow it with DEF_WRAP(your_function_name). Look at
87 libc/sys/w_sigaction.c for an example.
88 - by default, libc code that calls your_function_name()
89 will get the real syscall and *not* the wrapper. libc
90 calls that needd to go through the wrapper should invoke
91 WRAP(your_function_name)
92
93 E) syscalls that don't require any wrapping
94 In the hidden/* version of the header where you declared the
95 function, add this line:
96 PROTO_NORMAL(your_function_name);
97
diff --git a/src/lib/libc/include/atfork.h b/src/lib/libc/include/atfork.h
deleted file mode 100644
index f09de4892a..0000000000
--- a/src/lib/libc/include/atfork.h
+++ /dev/null
@@ -1,45 +0,0 @@
1/* $OpenBSD: atfork.h,v 1.2 2015/08/27 04:37:09 guenther Exp $ */
2
3/*
4 * Copyright (c) 2008 Kurt Miller <kurt@openbsd.org>
5 * Copyright (c) 2008 Philip Guenther <guenther@openbsd.org>
6 * Copyright (c) 2003 Daniel Eischen <deischen@freebsd.org>
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Neither the name of the author nor the names of any co-contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 * $FreeBSD: /repoman/r/ncvs/src/lib/libc_r/uthread/uthread_atfork.c,v 1.1 2004/12/10 03:36:45 grog Exp $
31 */
32
33#include <sys/queue.h>
34
35struct atfork_fn {
36 TAILQ_ENTRY(atfork_fn) fn_next;
37 void (*fn_prepare)(void);
38 void (*fn_parent)(void);
39 void (*fn_child)(void);
40 void *fn_dso;
41};
42
43__BEGIN_HIDDEN_DECLS
44extern TAILQ_HEAD(atfork_listhead, atfork_fn) _atfork_list;
45__END_HIDDEN_DECLS
diff --git a/src/lib/libc/include/cancel.h b/src/lib/libc/include/cancel.h
deleted file mode 100644
index c452bf3d4c..0000000000
--- a/src/lib/libc/include/cancel.h
+++ /dev/null
@@ -1,78 +0,0 @@
1/* $OpenBSD: cancel.h,v 1.5 2017/09/05 02:40:54 guenther Exp $ */
2/*
3 * Copyright (c) 2015 Philip Guenther <guenther@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#ifndef _CANCEL_H_
19#define _CANCEL_H_
20
21#include <tib.h>
22#include "thread_private.h"
23
24/* process a cancel request at a cancel point */
25__dead void _thread_canceled(void);
26
27#ifdef __LIBC__
28PROTO_NORMAL(_thread_canceled);
29#endif
30
31#if defined(__LIBC__) && !defined(TCB_HAVE_MD_GET)
32/*
33 * Override TIB_GET macro to use the caching callback
34 */
35#undef TIB_GET
36#define TIB_GET() TCB_TO_TIB(_thread_cb.tc_tcb())
37#endif
38
39#define PREP_CANCEL_POINT(tib) \
40 int _cantcancel = (tib)->tib_cantcancel
41
42#define ENTER_CANCEL_POINT_INNER(tib, can_cancel, delay) \
43 if (_cantcancel == 0) { \
44 (tib)->tib_cancel_point = (delay) ? \
45 CANCEL_POINT_DELAYED : CANCEL_POINT; \
46 if (can_cancel) { \
47 __asm volatile("":::"memory"); \
48 if (__predict_false((tib)->tib_canceled)) \
49 _thread_canceled(); \
50 } \
51 }
52
53#define LEAVE_CANCEL_POINT_INNER(tib, can_cancel) \
54 if (_cantcancel == 0) { \
55 (tib)->tib_cancel_point = 0; \
56 if (can_cancel) { \
57 __asm volatile("":::"memory"); \
58 if (__predict_false((tib)->tib_canceled)) \
59 _thread_canceled(); \
60 } \
61 }
62
63/*
64 * Enter or leave a cancelation point, optionally processing pending
65 * cancelation requests. Note that ENTER_CANCEL_POINT opens a block
66 * and LEAVE_CANCEL_POINT must close that same block.
67 */
68#define ENTER_CANCEL_POINT(can_cancel) \
69 { \
70 struct tib *_tib = TIB_GET(); \
71 PREP_CANCEL_POINT(_tib); \
72 ENTER_CANCEL_POINT_INNER(_tib, can_cancel, 0)
73
74#define LEAVE_CANCEL_POINT(can_cancel) \
75 LEAVE_CANCEL_POINT_INNER(_tib, can_cancel); \
76 }
77
78#endif /* _CANCEL_H_ */
diff --git a/src/lib/libc/include/ctype_private.h b/src/lib/libc/include/ctype_private.h
deleted file mode 100644
index cbe1b20475..0000000000
--- a/src/lib/libc/include/ctype_private.h
+++ /dev/null
@@ -1,9 +0,0 @@
1/* $OpenBSD: ctype_private.h,v 1.2 2015/08/27 04:37:09 guenther Exp $ */
2/* Written by Marc Espie, public domain */
3#define CTYPE_NUM_CHARS 256
4
5__BEGIN_HIDDEN_DECLS
6extern const char _C_ctype_[];
7extern const short _C_toupper_[];
8extern const short _C_tolower_[];
9__END_HIDDEN_DECLS
diff --git a/src/lib/libc/include/localedef.h b/src/lib/libc/include/localedef.h
deleted file mode 100644
index 12dd47fffa..0000000000
--- a/src/lib/libc/include/localedef.h
+++ /dev/null
@@ -1,106 +0,0 @@
1/* $OpenBSD: localedef.h,v 1.1 2016/05/23 00:05:15 guenther Exp $ */
2/* $NetBSD: localedef.h,v 1.4 1996/04/09 20:55:31 cgd Exp $ */
3
4/*
5 * Copyright (c) 1994 Winning Strategies, Inc.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Winning Strategies, Inc.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#ifndef _LOCALEDEF_H_
35#define _LOCALEDEF_H_
36
37#include <sys/types.h>
38
39typedef struct
40{
41 char *yesexpr;
42 char *noexpr;
43 char *yesstr;
44 char *nostr;
45} _MessagesLocale;
46
47
48typedef struct
49{
50 char *int_curr_symbol;
51 char *currency_symbol;
52 char *mon_decimal_point;
53 char *mon_thousands_sep;
54 char *mon_grouping;
55 char *positive_sign;
56 char *negative_sign;
57 char int_frac_digits;
58 char frac_digits;
59 char p_cs_precedes;
60 char p_sep_by_space;
61 char n_cs_precedes;
62 char n_sep_by_space;
63 char p_sign_posn;
64 char n_sign_posn;
65 char int_p_cs_precedes;
66 char int_p_sep_by_space;
67 char int_n_cs_precedes;
68 char int_n_sep_by_space;
69 char int_p_sign_posn;
70 char int_n_sign_posn;
71} _MonetaryLocale;
72
73
74typedef struct
75{
76 const char *decimal_point;
77 const char *thousands_sep;
78 const char *grouping;
79} _NumericLocale;
80
81
82typedef struct {
83 const char *abday[7];
84 const char *day[7];
85 const char *abmon[12];
86 const char *mon[12];
87 const char *am_pm[2];
88 const char *d_t_fmt;
89 const char *d_fmt;
90 const char *t_fmt;
91 const char *t_fmt_ampm;
92} _TimeLocale;
93
94
95__BEGIN_HIDDEN_DECLS
96extern const _MessagesLocale *_CurrentMessagesLocale;
97extern const _MessagesLocale _DefaultMessagesLocale;
98extern const _MonetaryLocale *_CurrentMonetaryLocale;
99extern const _MonetaryLocale _DefaultMonetaryLocale;
100extern const _NumericLocale *_CurrentNumericLocale;
101extern const _NumericLocale _DefaultNumericLocale;
102extern const _TimeLocale *_CurrentTimeLocale;
103extern const _TimeLocale _DefaultTimeLocale;
104__END_HIDDEN_DECLS
105
106#endif /* !_LOCALEDEF_H_ */
diff --git a/src/lib/libc/include/mpool.h b/src/lib/libc/include/mpool.h
deleted file mode 100644
index 005b006d17..0000000000
--- a/src/lib/libc/include/mpool.h
+++ /dev/null
@@ -1,122 +0,0 @@
1/* $OpenBSD: mpool.h,v 1.1 2015/09/09 15:35:24 guenther Exp $ */
2/* $NetBSD: mpool.h,v 1.7 1996/05/03 21:13:41 cgd Exp $ */
3
4/*-
5 * Copyright (c) 1991, 1993, 1994
6 * The Regents of the University of California. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the University nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * @(#)mpool.h 8.4 (Berkeley) 11/2/95
33 */
34
35#ifndef _MPOOL_H_
36#define _MPOOL_H_
37
38#include <sys/queue.h>
39
40/*
41 * The memory pool scheme is a simple one. Each in-memory page is referenced
42 * by a bucket which is threaded in up to two of three ways. All active pages
43 * are threaded on a hash chain (hashed by page number) and an lru chain.
44 * Inactive pages are threaded on a free chain. Each reference to a memory
45 * pool is handed an opaque MPOOL cookie which stores all of this information.
46 */
47#define HASHSIZE 128
48#define HASHKEY(pgno) ((pgno - 1 + HASHSIZE) % HASHSIZE)
49
50/* The BKT structures are the elements of the queues. */
51typedef struct _bkt {
52 TAILQ_ENTRY(_bkt) hq; /* hash queue */
53 TAILQ_ENTRY(_bkt) q; /* lru queue */
54 void *page; /* page */
55 pgno_t pgno; /* page number */
56
57#define MPOOL_DIRTY 0x01 /* page needs to be written */
58#define MPOOL_PINNED 0x02 /* page is pinned into memory */
59#define MPOOL_INUSE 0x04 /* page address is valid */
60 u_int8_t flags; /* flags */
61} BKT;
62
63typedef struct MPOOL {
64 TAILQ_HEAD(_lqh, _bkt) lqh; /* lru queue head */
65 /* hash queue array */
66 TAILQ_HEAD(_hqh, _bkt) hqh[HASHSIZE];
67 pgno_t curcache; /* current number of cached pages */
68 pgno_t maxcache; /* max number of cached pages */
69 pgno_t npages; /* number of pages in the file */
70 unsigned long pagesize; /* file page size */
71 int fd; /* file descriptor */
72 /* page in conversion routine */
73 void (*pgin)(void *, pgno_t, void *);
74 /* page out conversion routine */
75 void (*pgout)(void *, pgno_t, void *);
76 void *pgcookie; /* cookie for page in/out routines */
77#ifdef STATISTICS
78 unsigned long cachehit;
79 unsigned long cachemiss;
80 unsigned long pagealloc;
81 unsigned long pageflush;
82 unsigned long pageget;
83 unsigned long pagenew;
84 unsigned long pageput;
85 unsigned long pageread;
86 unsigned long pagewrite;
87#endif
88} MPOOL;
89
90#define MPOOL_IGNOREPIN 0x01 /* Ignore if the page is pinned. */
91#define MPOOL_PAGE_REQUEST 0x01 /* Allocate a new page with a
92 specific page number. */
93#define MPOOL_PAGE_NEXT 0x02 /* Allocate a new page with the next
94 page number. */
95
96__BEGIN_HIDDEN_DECLS
97MPOOL *mpool_open(void *, int, pgno_t, pgno_t);
98void mpool_filter(MPOOL *, void (*)(void *, pgno_t, void *),
99 void (*)(void *, pgno_t, void *), void *);
100void *mpool_new(MPOOL *, pgno_t *, unsigned int);
101void *mpool_get(MPOOL *, pgno_t, unsigned int);
102int mpool_delete(MPOOL *, void *);
103int mpool_put(MPOOL *, void *, unsigned int);
104int mpool_sync(MPOOL *);
105int mpool_close(MPOOL *);
106
107PROTO_NORMAL(mpool_open);
108PROTO_NORMAL(mpool_filter);
109PROTO_NORMAL(mpool_new);
110PROTO_NORMAL(mpool_get);
111PROTO_NORMAL(mpool_delete);
112PROTO_NORMAL(mpool_put);
113PROTO_NORMAL(mpool_sync);
114PROTO_NORMAL(mpool_close);
115
116#ifdef STATISTICS
117void mpool_stat(MPOOL *);
118PROTO_NORMAL(mpool_stat);
119#endif
120__END_HIDDEN_DECLS
121
122#endif
diff --git a/src/lib/libc/include/namespace.h b/src/lib/libc/include/namespace.h
deleted file mode 100644
index b42c00e4a1..0000000000
--- a/src/lib/libc/include/namespace.h
+++ /dev/null
@@ -1,90 +0,0 @@
1/* $OpenBSD: namespace.h,v 1.15 2019/11/25 22:57:28 guenther Exp $ */
2
3#ifndef _LIBC_NAMESPACE_H_
4#define _LIBC_NAMESPACE_H_
5
6/*
7 * Copyright (c) 2015 Philip Guenther <guenther@openbsd.org>
8 *
9 * Permission to use, copy, modify, and distribute this software for any
10 * purpose with or without fee is hereby granted, provided that the above
11 * copyright notice and this permission notice appear in all copies.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * For explanations of how to use these, see README
24 * For explanations of why we use them and how they work, see DETAILS
25 */
26
27#include <sys/cdefs.h> /* for __dso_hidden and __{weak,strong}_alias */
28
29#define __dso_protected __attribute__((__visibility__("protected")))
30
31#define HIDDEN(x) _libc_##x
32#define CANCEL(x) _libc_##x##_cancel
33#define WRAP(x) _libc_##x##_wrap
34#define HIDDEN_STRING(x) "_libc_" __STRING(x)
35#define CANCEL_STRING(x) "_libc_" __STRING(x) "_cancel"
36#define WRAP_STRING(x) "_libc_" __STRING(x) "_wrap"
37
38#define PROTO_NORMAL(x) __dso_hidden typeof(x) x asm(HIDDEN_STRING(x))
39#define PROTO_STD_DEPRECATED(x) typeof(x) x __attribute__((deprecated))
40#define PROTO_DEPRECATED(x) typeof(x) x __attribute__((deprecated, weak))
41#define PROTO_CANCEL(x) __dso_hidden typeof(x) HIDDEN(x), \
42 x asm(CANCEL_STRING(x))
43#define PROTO_WRAP(x) PROTO_NORMAL(x), WRAP(x)
44#define PROTO_PROTECTED(x) __dso_protected typeof(x) x
45
46#define DEF_STRONG(x) __strong_alias(x, HIDDEN(x))
47#define DEF_WEAK(x) __weak_alias(x, HIDDEN(x))
48#define DEF_CANCEL(x) __weak_alias(x, CANCEL(x))
49#define DEF_WRAP(x) __weak_alias(x, WRAP(x))
50#define DEF_SYS(x) __strong_alias(_thread_sys_##x, HIDDEN(x))
51
52#if !defined(__clang__) && __GNUC__ != 3
53/* our gcc 4.2 handles redirecting builtins via PROTO_NORMAL()'s asm() label */
54#define DEF_BUILTIN(x) DEF_STRONG(x)
55#define BUILTIN
56#else
57/*
58 * clang and gcc can't redirect builtins via asm() labels, so mark
59 * them protected instead.
60 */
61#define DEF_BUILTIN(x) __asm("")
62#define BUILTIN __dso_protected
63#endif
64
65#define MAKE_CLONE(dst, src) __dso_hidden typeof(dst) HIDDEN(dst) \
66 __attribute__((alias (HIDDEN_STRING(src))))
67
68#define __relro __attribute__((section(".data.rel.ro")))
69
70
71/*
72 * gcc and clang will generate calls to the functions below.
73 * Declare and redirect them here so we always go
74 * directly to our hidden aliases.
75 */
76#include <sys/_types.h>
77BUILTIN void *memmove(void *, const void *, __size_t);
78BUILTIN void *memcpy(void *__restrict, const void *__restrict, __size_t);
79BUILTIN void *memset(void *, int, __size_t);
80BUILTIN void __stack_smash_handler(const char [], int __unused);
81#if !defined(__clang__) && __GNUC__ != 3
82PROTO_NORMAL(memmove);
83PROTO_NORMAL(memcpy);
84PROTO_NORMAL(memset);
85PROTO_NORMAL(__stack_smash_handler);
86#endif
87#undef BUILTIN
88
89#endif /* _LIBC_NAMESPACE_H_ */
90
diff --git a/src/lib/libc/include/thread_private.h b/src/lib/libc/include/thread_private.h
deleted file mode 100644
index 237c3fbd03..0000000000
--- a/src/lib/libc/include/thread_private.h
+++ /dev/null
@@ -1,426 +0,0 @@
1/* $OpenBSD: thread_private.h,v 1.36 2021/01/06 19:54:17 otto Exp $ */
2
3/* PUBLIC DOMAIN: No Rights Reserved. Marco S Hyman <marc@snafu.org> */
4
5#ifndef _THREAD_PRIVATE_H_
6#define _THREAD_PRIVATE_H_
7
8#include <stdio.h> /* for FILE and __isthreaded */
9
10#define _MALLOC_MUTEXES 32
11void _malloc_init(int);
12#ifdef __LIBC__
13PROTO_NORMAL(_malloc_init);
14#endif /* __LIBC__ */
15
16/*
17 * The callbacks needed by libc to handle the threaded case.
18 * NOTE: Bump the version when you change the struct contents!
19 *
20 * tc_canceled:
21 * If not NULL, what to do when canceled (otherwise _exit(0))
22 *
23 * tc_flockfile, tc_ftrylockfile, and tc_funlockfile:
24 * If not NULL, these implement the flockfile() family.
25 * XXX In theory, you should be able to lock a FILE before
26 * XXX loading libpthread and have that be a real lock on it,
27 * XXX but that doesn't work without the libc base version
28 * XXX tracking the recursion count.
29 *
30 * tc_malloc_lock and tc_malloc_unlock:
31 * tc_atexit_lock and tc_atexit_unlock:
32 * tc_atfork_lock and tc_atfork_unlock:
33 * tc_arc4_lock and tc_arc4_unlock:
34 * The locks used by the malloc, atexit, atfork, and arc4 subsystems.
35 * These have to be ordered specially in the fork/vfork wrappers
36 * and may be implemented differently than the general mutexes
37 * in the callbacks below.
38 *
39 * tc_mutex_lock and tc_mutex_unlock:
40 * Lock and unlock the given mutex. If the given mutex is NULL
41 * a mutex is allocated and initialized automatically.
42 *
43 * tc_mutex_destroy:
44 * Destroy/deallocate the given mutex.
45 *
46 * tc_tag_lock and tc_tag_unlock:
47 * Lock and unlock the mutex associated with the given tag.
48 * If the given tag is NULL a tag is allocated and initialized
49 * automatically.
50 *
51 * tc_tag_storage:
52 * Returns a pointer to per-thread instance of data associated
53 * with the given tag. If the given tag is NULL a tag is
54 * allocated and initialized automatically.
55 *
56 * tc_fork, tc_vfork:
57 * If not NULL, they are called instead of the syscall stub, so that
58 * the thread library can do necessary locking and reinitialization.
59 *
60 * tc_thread_release:
61 * Handles the release of a thread's TIB and struct pthread and the
62 * notification of other threads...when there are other threads.
63 *
64 * tc_thread_key_zero:
65 * For each thread, zero out the key data associated with the given key.
66
67 * If <machine/tcb.h> doesn't define TCB_GET(), then locating the TCB in a
68 * threaded process requires a syscall (__get_tcb(2)) which is too much
69 * overhead for single-threaded processes. For those archs, there are two
70 * additional callbacks, though they are placed first in the struct for
71 * convenience in ASM:
72 *
73 * tc_errnoptr:
74 * Returns the address of the thread's errno.
75 *
76 * tc_tcb:
77 * Returns the address of the thread's TCB.
78 */
79
80struct pthread;
81struct thread_callbacks {
82 int *(*tc_errnoptr)(void); /* MUST BE FIRST */
83 void *(*tc_tcb)(void);
84 __dead void (*tc_canceled)(void);
85 void (*tc_flockfile)(FILE *);
86 int (*tc_ftrylockfile)(FILE *);
87 void (*tc_funlockfile)(FILE *);
88 void (*tc_malloc_lock)(int);
89 void (*tc_malloc_unlock)(int);
90 void (*tc_atexit_lock)(void);
91 void (*tc_atexit_unlock)(void);
92 void (*tc_atfork_lock)(void);
93 void (*tc_atfork_unlock)(void);
94 void (*tc_arc4_lock)(void);
95 void (*tc_arc4_unlock)(void);
96 void (*tc_mutex_lock)(void **);
97 void (*tc_mutex_unlock)(void **);
98 void (*tc_mutex_destroy)(void **);
99 void (*tc_tag_lock)(void **);
100 void (*tc_tag_unlock)(void **);
101 void *(*tc_tag_storage)(void **, void *, size_t, void (*)(void *),
102 void *);
103 __pid_t (*tc_fork)(void);
104 __pid_t (*tc_vfork)(void);
105 void (*tc_thread_release)(struct pthread *);
106 void (*tc_thread_key_zero)(int);
107};
108
109__BEGIN_PUBLIC_DECLS
110/*
111 * Set the callbacks used by libc
112 */
113void _thread_set_callbacks(const struct thread_callbacks *_cb, size_t _len);
114__END_PUBLIC_DECLS
115
116#ifdef __LIBC__
117__BEGIN_HIDDEN_DECLS
118/* the current set */
119extern struct thread_callbacks _thread_cb;
120__END_HIDDEN_DECLS
121#endif /* __LIBC__ */
122
123/*
124 * helper macro to make unique names in the thread namespace
125 */
126#define __THREAD_NAME(name) __CONCAT(_thread_tagname_,name)
127
128/*
129 * Macros used in libc to access thread mutex, keys, and per thread storage.
130 * _THREAD_PRIVATE_KEY and _THREAD_PRIVATE_MUTEX are different macros for
131 * historical reasons. They do the same thing, define a static variable
132 * keyed by 'name' that identifies a mutex and a key to identify per thread
133 * data.
134 */
135#define _THREAD_PRIVATE_KEY(name) \
136 static void *__THREAD_NAME(name)
137#define _THREAD_PRIVATE_MUTEX(name) \
138 static void *__THREAD_NAME(name)
139
140
141#ifndef __LIBC__ /* building some sort of reach around */
142
143#define _THREAD_PRIVATE_MUTEX_LOCK(name) do {} while (0)
144#define _THREAD_PRIVATE_MUTEX_UNLOCK(name) do {} while (0)
145#define _THREAD_PRIVATE(keyname, storage, error) &(storage)
146#define _THREAD_PRIVATE_DT(keyname, storage, dt, error) &(storage)
147#define _MUTEX_LOCK(mutex) do {} while (0)
148#define _MUTEX_UNLOCK(mutex) do {} while (0)
149#define _MUTEX_DESTROY(mutex) do {} while (0)
150#define _MALLOC_LOCK(n) do {} while (0)
151#define _MALLOC_UNLOCK(n) do {} while (0)
152#define _ATEXIT_LOCK() do {} while (0)
153#define _ATEXIT_UNLOCK() do {} while (0)
154#define _ATFORK_LOCK() do {} while (0)
155#define _ATFORK_UNLOCK() do {} while (0)
156#define _ARC4_LOCK() do {} while (0)
157#define _ARC4_UNLOCK() do {} while (0)
158
159#else /* building libc */
160#define _THREAD_PRIVATE_MUTEX_LOCK(name) \
161 do { \
162 if (_thread_cb.tc_tag_lock != NULL) \
163 _thread_cb.tc_tag_lock(&(__THREAD_NAME(name))); \
164 } while (0)
165#define _THREAD_PRIVATE_MUTEX_UNLOCK(name) \
166 do { \
167 if (_thread_cb.tc_tag_unlock != NULL) \
168 _thread_cb.tc_tag_unlock(&(__THREAD_NAME(name))); \
169 } while (0)
170#define _THREAD_PRIVATE(keyname, storage, error) \
171 (_thread_cb.tc_tag_storage == NULL ? &(storage) : \
172 _thread_cb.tc_tag_storage(&(__THREAD_NAME(keyname)), \
173 &(storage), sizeof(storage), NULL, (error)))
174
175#define _THREAD_PRIVATE_DT(keyname, storage, dt, error) \
176 (_thread_cb.tc_tag_storage == NULL ? &(storage) : \
177 _thread_cb.tc_tag_storage(&(__THREAD_NAME(keyname)), \
178 &(storage), sizeof(storage), (dt), (error)))
179
180/*
181 * Macros used in libc to access mutexes.
182 */
183#define _MUTEX_LOCK(mutex) \
184 do { \
185 if (__isthreaded) \
186 _thread_cb.tc_mutex_lock(mutex); \
187 } while (0)
188#define _MUTEX_UNLOCK(mutex) \
189 do { \
190 if (__isthreaded) \
191 _thread_cb.tc_mutex_unlock(mutex); \
192 } while (0)
193#define _MUTEX_DESTROY(mutex) \
194 do { \
195 if (__isthreaded) \
196 _thread_cb.tc_mutex_destroy(mutex); \
197 } while (0)
198
199/*
200 * malloc lock/unlock prototypes and definitions
201 */
202#define _MALLOC_LOCK(n) \
203 do { \
204 if (__isthreaded) \
205 _thread_cb.tc_malloc_lock(n); \
206 } while (0)
207#define _MALLOC_UNLOCK(n) \
208 do { \
209 if (__isthreaded) \
210 _thread_cb.tc_malloc_unlock(n); \
211 } while (0)
212
213#define _ATEXIT_LOCK() \
214 do { \
215 if (__isthreaded) \
216 _thread_cb.tc_atexit_lock(); \
217 } while (0)
218#define _ATEXIT_UNLOCK() \
219 do { \
220 if (__isthreaded) \
221 _thread_cb.tc_atexit_unlock(); \
222 } while (0)
223
224#define _ATFORK_LOCK() \
225 do { \
226 if (__isthreaded) \
227 _thread_cb.tc_atfork_lock(); \
228 } while (0)
229#define _ATFORK_UNLOCK() \
230 do { \
231 if (__isthreaded) \
232 _thread_cb.tc_atfork_unlock(); \
233 } while (0)
234
235#define _ARC4_LOCK() \
236 do { \
237 if (__isthreaded) \
238 _thread_cb.tc_arc4_lock(); \
239 } while (0)
240#define _ARC4_UNLOCK() \
241 do { \
242 if (__isthreaded) \
243 _thread_cb.tc_arc4_unlock(); \
244 } while (0)
245#endif /* __LIBC__ */
246
247
248/*
249 * Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org>
250 * All Rights Reserved.
251 *
252 * Permission to use, copy, modify, and distribute this software for any
253 * purpose with or without fee is hereby granted, provided that the above
254 * copyright notice and this permission notice appear in all copies.
255 *
256 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
257 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
258 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
259 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
260 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
261 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
262 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
263 */
264/*
265 * Private data structures that back up the typedefs in pthread.h.
266 * Since only the thread library cares about their size or arrangement,
267 * it should be possible to switch libraries without relinking.
268 *
269 * Do not reorder _atomic_lock_t and sem_t variables in the structs.
270 * This is due to alignment requirements of certain arches like hppa.
271 * The current requirement is 16 bytes.
272 *
273 * THE MACHINE DEPENDENT CERROR CODE HAS HARD CODED OFFSETS INTO PTHREAD_T!
274 */
275
276#include <sys/queue.h>
277#include <pthread.h>
278#include <semaphore.h>
279#include <machine/spinlock.h>
280
281#define _SPINLOCK_UNLOCKED _ATOMIC_LOCK_UNLOCKED
282
283struct __sem {
284 _atomic_lock_t lock;
285 volatile int waitcount;
286 volatile int value;
287 int shared;
288};
289
290TAILQ_HEAD(pthread_queue, pthread);
291
292#ifdef FUTEX
293
294struct pthread_mutex {
295 volatile unsigned int lock;
296 int type;
297 pthread_t owner;
298 int count;
299 int prioceiling;
300};
301
302struct pthread_cond {
303 volatile unsigned int seq;
304 clockid_t clock;
305 struct pthread_mutex *mutex;
306};
307
308struct pthread_rwlock {
309 volatile unsigned int value;
310};
311
312#else
313
314struct pthread_mutex {
315 _atomic_lock_t lock;
316 struct pthread_queue lockers;
317 int type;
318 pthread_t owner;
319 int count;
320 int prioceiling;
321};
322
323struct pthread_cond {
324 _atomic_lock_t lock;
325 struct pthread_queue waiters;
326 struct pthread_mutex *mutex;
327 clockid_t clock;
328};
329
330struct pthread_rwlock {
331 _atomic_lock_t lock;
332 pthread_t owner;
333 struct pthread_queue writers;
334 int readers;
335};
336#endif /* FUTEX */
337
338struct pthread_mutex_attr {
339 int ma_type;
340 int ma_protocol;
341 int ma_prioceiling;
342};
343
344struct pthread_cond_attr {
345 clockid_t ca_clock;
346};
347
348struct pthread_attr {
349 void *stack_addr;
350 size_t stack_size;
351 size_t guard_size;
352 int detach_state;
353 int contention_scope;
354 int sched_policy;
355 struct sched_param sched_param;
356 int sched_inherit;
357};
358
359struct rthread_storage {
360 int keyid;
361 struct rthread_storage *next;
362 void *data;
363};
364
365struct rthread_cleanup_fn {
366 void (*fn)(void *);
367 void *arg;
368 struct rthread_cleanup_fn *next;
369};
370
371struct tib;
372struct stack;
373struct pthread {
374 struct __sem donesem;
375 unsigned int flags;
376 _atomic_lock_t flags_lock;
377 struct tib *tib;
378 void *retval;
379 void *(*fn)(void *);
380 void *arg;
381 char name[32];
382 struct stack *stack;
383 LIST_ENTRY(pthread) threads;
384 TAILQ_ENTRY(pthread) waiting;
385 pthread_cond_t blocking_cond;
386 struct pthread_attr attr;
387 struct rthread_storage *local_storage;
388 struct rthread_cleanup_fn *cleanup_fns;
389
390 /* cancel received in a delayed cancel block? */
391 int delayed_cancel;
392};
393/* flags in pthread->flags */
394#define THREAD_DONE 0x001
395#define THREAD_DETACHED 0x002
396
397/* flags in tib->tib_thread_flags */
398#define TIB_THREAD_ASYNC_CANCEL 0x001
399#define TIB_THREAD_INITIAL_STACK 0x002 /* has stack from exec */
400
401#define ENTER_DELAYED_CANCEL_POINT(tib, self) \
402 (self)->delayed_cancel = 0; \
403 ENTER_CANCEL_POINT_INNER(tib, 1, 1)
404
405/*
406 * Internal functions exported from libc's thread bits for use by libpthread
407 */
408void _spinlock(volatile _atomic_lock_t *);
409int _spinlocktry(volatile _atomic_lock_t *);
410void _spinunlock(volatile _atomic_lock_t *);
411
412void _rthread_debug(int, const char *, ...)
413 __attribute__((__format__ (printf, 2, 3)));
414pid_t _thread_dofork(pid_t (*_sys_fork)(void));
415void _thread_finalize(void);
416
417/*
418 * Threading syscalls not declared in system headers
419 */
420__dead void __threxit(pid_t *);
421int __thrsleep(const volatile void *, clockid_t,
422 const struct timespec *, volatile void *, const int *);
423int __thrwakeup(const volatile void *, int n);
424int __thrsigdivert(sigset_t, siginfo_t *, const struct timespec *);
425
426#endif /* _THREAD_PRIVATE_H_ */