summaryrefslogtreecommitdiff
path: root/src/lib/libc/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/include')
-rw-r--r--src/lib/libc/include/DETAILS133
-rw-r--r--src/lib/libc/include/README110
-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.h98
-rw-r--r--src/lib/libc/include/thread_private.h427
9 files changed, 0 insertions, 1128 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 89acee491e..0000000000
--- a/src/lib/libc/include/README
+++ /dev/null
@@ -1,110 +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
32 B) plain C functions (not syscalls)
33 1) functions that are *not* called from inside libc
34
35 If this function is specified in the ISO C standard or its
36 name begins with an underbar, then in the hidden/* version
37 of the header where you declared the function, add this line:
38 PROTO_STD_DEPRECATED(your_function_name);
39
40 Otherwise, this is *not* a function specified in the ISO C
41 standard and its name begins with a letter. In the hidden/*
42 version of the header where you declared the function, add
43 this line:
44 PROTO_DEPRECATED(your_function_name);
45
46 Note: the "DEPRECATED" suffix is about a detail of
47 how the macros work and has nothing to do with whether the
48 function itself is a Good Thing vs deprecated.
49
50 2) functions that are called from inside libc
51
52 In the hidden/* version of the header where you declared
53 the function, add this line:
54 PROTO_NORMAL(your_function_name);
55
56 Then, in the .c file(s) where the function is defined:
57 - if the function is specified in the ISO C standard or
58 its name begins with an underbar, add
59 DEF_STRONG(your_function_name);
60
61 - otherwise, add:
62 DEF_WEAK(your_function_name);
63
64
65 C) syscalls that don't require any wrapping
66
67 In the hidden/* version of the header where you declared the
68 function, add this line:
69 PROTO_NORMAL(your_function_name);
70
71 Generate the stub by adding it to the ASM variable in
72 libc/sys/Makefile.inc
73
74
75 D) syscalls that require cancellation or similar wrappers that don't
76 change the function signature
77
78 Generate the stub by adding it to the HIDDEN (*not* ASM!)
79 variable in libc/sys/Makefile.inc
80
81 In the hidden/* version of the header where you declared the
82 function, add this line:
83 PROTO_WRAP(your_function_name);
84
85 The wrapper function should be defined in
86 libc/sys/w_your_function_name.c
87 which should define WRAP(your_function_name) and follow it
88 with DEF_WRAP(your_function_name). Look at libc/sys/w_sigaction.c
89 for an example.
90
91 By default, libc code that calls your_function_name() will get
92 the real syscall and *not* the wrapper. libc calls that need
93 to go through the wrapper should invoke WRAP(your_function_name)
94
95
96 E) syscalls that require libc wrappers for other reasons
97 First of all, make sure this really is the Right Thing. Talk
98 with kettenis, deraadt, millert, and guenther.
99
100 If the actual syscall doesn't have the same calling convention
101 as the C interface, then maybe it shouldn't be exported at all
102 and you should just have an ASM stub, like SYS___tfork -->
103 __tfork_thread() or SYS_break --> brk() and sbrk(). If it
104 _could_ be called from C, then give the syscall a name different
105 from the C API. Syscalls that fail this for historical reasons
106 (e.g., exit == _exit(2)) are generated with PSEUDO/PSEUDO_NOERR
107 in libc/sys/Makefile.inc, so the ASM stub has a leading underbar.
108 Go read gen/getlogin.c rev 1.13 for an example of how to do
109 this, but don't pick this option, really.
110
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 8503de47be..0000000000
--- a/src/lib/libc/include/namespace.h
+++ /dev/null
@@ -1,98 +0,0 @@
1/* $OpenBSD: namespace.h,v 1.16 2023/10/29 14:26:13 millert 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 * ISO C11 or higher is required to build libc.
24 * This must come _before_ sys/cdefs.h is included.
25 */
26#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112
27#define _ISOC11_SOURCE 1
28#endif
29
30/*
31 * For explanations of how to use these, see README
32 * For explanations of why we use them and how they work, see DETAILS
33 */
34
35#include <sys/cdefs.h> /* for __dso_hidden and __{weak,strong}_alias */
36
37#define __dso_protected __attribute__((__visibility__("protected")))
38
39#define HIDDEN(x) _libc_##x
40#define CANCEL(x) _libc_##x##_cancel
41#define WRAP(x) _libc_##x##_wrap
42#define HIDDEN_STRING(x) "_libc_" __STRING(x)
43#define CANCEL_STRING(x) "_libc_" __STRING(x) "_cancel"
44#define WRAP_STRING(x) "_libc_" __STRING(x) "_wrap"
45
46#define PROTO_NORMAL(x) __dso_hidden typeof(x) x asm(HIDDEN_STRING(x))
47#define PROTO_STD_DEPRECATED(x) typeof(x) x __attribute__((deprecated))
48#define PROTO_DEPRECATED(x) typeof(x) x __attribute__((deprecated, weak))
49#define PROTO_CANCEL(x) __dso_hidden typeof(x) HIDDEN(x), \
50 x asm(CANCEL_STRING(x))
51#define PROTO_WRAP(x) PROTO_NORMAL(x), WRAP(x)
52#define PROTO_PROTECTED(x) __dso_protected typeof(x) x
53
54#define DEF_STRONG(x) __strong_alias(x, HIDDEN(x))
55#define DEF_WEAK(x) __weak_alias(x, HIDDEN(x))
56#define DEF_CANCEL(x) __weak_alias(x, CANCEL(x))
57#define DEF_WRAP(x) __weak_alias(x, WRAP(x))
58#define DEF_SYS(x) __strong_alias(_thread_sys_##x, HIDDEN(x))
59
60#if !defined(__clang__) && __GNUC__ != 3
61/* our gcc 4.2 handles redirecting builtins via PROTO_NORMAL()'s asm() label */
62#define DEF_BUILTIN(x) DEF_STRONG(x)
63#define BUILTIN
64#else
65/*
66 * clang and gcc can't redirect builtins via asm() labels, so mark
67 * them protected instead.
68 */
69#define DEF_BUILTIN(x) __asm("")
70#define BUILTIN __dso_protected
71#endif
72
73#define MAKE_CLONE(dst, src) __dso_hidden typeof(dst) HIDDEN(dst) \
74 __attribute__((alias (HIDDEN_STRING(src))))
75
76#define __relro __attribute__((section(".data.rel.ro")))
77
78
79/*
80 * gcc and clang will generate calls to the functions below.
81 * Declare and redirect them here so we always go
82 * directly to our hidden aliases.
83 */
84#include <sys/_types.h>
85BUILTIN void *memmove(void *, const void *, __size_t);
86BUILTIN void *memcpy(void *__restrict, const void *__restrict, __size_t);
87BUILTIN void *memset(void *, int, __size_t);
88BUILTIN void __stack_smash_handler(const char [], int __unused);
89#if !defined(__clang__) && __GNUC__ != 3
90PROTO_NORMAL(memmove);
91PROTO_NORMAL(memcpy);
92PROTO_NORMAL(memset);
93PROTO_NORMAL(__stack_smash_handler);
94#endif
95#undef BUILTIN
96
97#endif /* _LIBC_NAMESPACE_H_ */
98
diff --git a/src/lib/libc/include/thread_private.h b/src/lib/libc/include/thread_private.h
deleted file mode 100644
index 1ec1071161..0000000000
--- a/src/lib/libc/include/thread_private.h
+++ /dev/null
@@ -1,427 +0,0 @@
1/* $OpenBSD: thread_private.h,v 1.37 2024/08/18 02:25:51 guenther 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
8extern int __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 __sFILE;
81struct pthread;
82struct thread_callbacks {
83 int *(*tc_errnoptr)(void); /* MUST BE FIRST */
84 void *(*tc_tcb)(void);
85 __dead void (*tc_canceled)(void);
86 void (*tc_flockfile)(struct __sFILE *);
87 int (*tc_ftrylockfile)(struct __sFILE *);
88 void (*tc_funlockfile)(struct __sFILE *);
89 void (*tc_malloc_lock)(int);
90 void (*tc_malloc_unlock)(int);
91 void (*tc_atexit_lock)(void);
92 void (*tc_atexit_unlock)(void);
93 void (*tc_atfork_lock)(void);
94 void (*tc_atfork_unlock)(void);
95 void (*tc_arc4_lock)(void);
96 void (*tc_arc4_unlock)(void);
97 void (*tc_mutex_lock)(void **);
98 void (*tc_mutex_unlock)(void **);
99 void (*tc_mutex_destroy)(void **);
100 void (*tc_tag_lock)(void **);
101 void (*tc_tag_unlock)(void **);
102 void *(*tc_tag_storage)(void **, void *, size_t, void (*)(void *),
103 void *);
104 __pid_t (*tc_fork)(void);
105 __pid_t (*tc_vfork)(void);
106 void (*tc_thread_release)(struct pthread *);
107 void (*tc_thread_key_zero)(int);
108};
109
110__BEGIN_PUBLIC_DECLS
111/*
112 * Set the callbacks used by libc
113 */
114void _thread_set_callbacks(const struct thread_callbacks *_cb, size_t _len);
115__END_PUBLIC_DECLS
116
117#ifdef __LIBC__
118__BEGIN_HIDDEN_DECLS
119/* the current set */
120extern struct thread_callbacks _thread_cb;
121__END_HIDDEN_DECLS
122#endif /* __LIBC__ */
123
124/*
125 * helper macro to make unique names in the thread namespace
126 */
127#define __THREAD_NAME(name) __CONCAT(_thread_tagname_,name)
128
129/*
130 * Macros used in libc to access thread mutex, keys, and per thread storage.
131 * _THREAD_PRIVATE_KEY and _THREAD_PRIVATE_MUTEX are different macros for
132 * historical reasons. They do the same thing, define a static variable
133 * keyed by 'name' that identifies a mutex and a key to identify per thread
134 * data.
135 */
136#define _THREAD_PRIVATE_KEY(name) \
137 static void *__THREAD_NAME(name)
138#define _THREAD_PRIVATE_MUTEX(name) \
139 static void *__THREAD_NAME(name)
140
141
142#ifndef __LIBC__ /* building some sort of reach around */
143
144#define _THREAD_PRIVATE_MUTEX_LOCK(name) do {} while (0)
145#define _THREAD_PRIVATE_MUTEX_UNLOCK(name) do {} while (0)
146#define _THREAD_PRIVATE(keyname, storage, error) &(storage)
147#define _THREAD_PRIVATE_DT(keyname, storage, dt, error) &(storage)
148#define _MUTEX_LOCK(mutex) do {} while (0)
149#define _MUTEX_UNLOCK(mutex) do {} while (0)
150#define _MUTEX_DESTROY(mutex) do {} while (0)
151#define _MALLOC_LOCK(n) do {} while (0)
152#define _MALLOC_UNLOCK(n) do {} while (0)
153#define _ATEXIT_LOCK() do {} while (0)
154#define _ATEXIT_UNLOCK() do {} while (0)
155#define _ATFORK_LOCK() do {} while (0)
156#define _ATFORK_UNLOCK() do {} while (0)
157#define _ARC4_LOCK() do {} while (0)
158#define _ARC4_UNLOCK() do {} while (0)
159
160#else /* building libc */
161#define _THREAD_PRIVATE_MUTEX_LOCK(name) \
162 do { \
163 if (_thread_cb.tc_tag_lock != NULL) \
164 _thread_cb.tc_tag_lock(&(__THREAD_NAME(name))); \
165 } while (0)
166#define _THREAD_PRIVATE_MUTEX_UNLOCK(name) \
167 do { \
168 if (_thread_cb.tc_tag_unlock != NULL) \
169 _thread_cb.tc_tag_unlock(&(__THREAD_NAME(name))); \
170 } while (0)
171#define _THREAD_PRIVATE(keyname, storage, error) \
172 (_thread_cb.tc_tag_storage == NULL ? &(storage) : \
173 _thread_cb.tc_tag_storage(&(__THREAD_NAME(keyname)), \
174 &(storage), sizeof(storage), NULL, (error)))
175
176#define _THREAD_PRIVATE_DT(keyname, storage, dt, error) \
177 (_thread_cb.tc_tag_storage == NULL ? &(storage) : \
178 _thread_cb.tc_tag_storage(&(__THREAD_NAME(keyname)), \
179 &(storage), sizeof(storage), (dt), (error)))
180
181/*
182 * Macros used in libc to access mutexes.
183 */
184#define _MUTEX_LOCK(mutex) \
185 do { \
186 if (__isthreaded) \
187 _thread_cb.tc_mutex_lock(mutex); \
188 } while (0)
189#define _MUTEX_UNLOCK(mutex) \
190 do { \
191 if (__isthreaded) \
192 _thread_cb.tc_mutex_unlock(mutex); \
193 } while (0)
194#define _MUTEX_DESTROY(mutex) \
195 do { \
196 if (__isthreaded) \
197 _thread_cb.tc_mutex_destroy(mutex); \
198 } while (0)
199
200/*
201 * malloc lock/unlock prototypes and definitions
202 */
203#define _MALLOC_LOCK(n) \
204 do { \
205 if (__isthreaded) \
206 _thread_cb.tc_malloc_lock(n); \
207 } while (0)
208#define _MALLOC_UNLOCK(n) \
209 do { \
210 if (__isthreaded) \
211 _thread_cb.tc_malloc_unlock(n); \
212 } while (0)
213
214#define _ATEXIT_LOCK() \
215 do { \
216 if (__isthreaded) \
217 _thread_cb.tc_atexit_lock(); \
218 } while (0)
219#define _ATEXIT_UNLOCK() \
220 do { \
221 if (__isthreaded) \
222 _thread_cb.tc_atexit_unlock(); \
223 } while (0)
224
225#define _ATFORK_LOCK() \
226 do { \
227 if (__isthreaded) \
228 _thread_cb.tc_atfork_lock(); \
229 } while (0)
230#define _ATFORK_UNLOCK() \
231 do { \
232 if (__isthreaded) \
233 _thread_cb.tc_atfork_unlock(); \
234 } while (0)
235
236#define _ARC4_LOCK() \
237 do { \
238 if (__isthreaded) \
239 _thread_cb.tc_arc4_lock(); \
240 } while (0)
241#define _ARC4_UNLOCK() \
242 do { \
243 if (__isthreaded) \
244 _thread_cb.tc_arc4_unlock(); \
245 } while (0)
246#endif /* __LIBC__ */
247
248
249/*
250 * Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org>
251 * All Rights Reserved.
252 *
253 * Permission to use, copy, modify, and distribute this software for any
254 * purpose with or without fee is hereby granted, provided that the above
255 * copyright notice and this permission notice appear in all copies.
256 *
257 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
258 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
259 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
260 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
261 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
262 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
263 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
264 */
265/*
266 * Private data structures that back up the typedefs in pthread.h.
267 * Since only the thread library cares about their size or arrangement,
268 * it should be possible to switch libraries without relinking.
269 *
270 * Do not reorder _atomic_lock_t and sem_t variables in the structs.
271 * This is due to alignment requirements of certain arches like hppa.
272 * The current requirement is 16 bytes.
273 *
274 * THE MACHINE DEPENDENT CERROR CODE HAS HARD CODED OFFSETS INTO PTHREAD_T!
275 */
276
277#include <sys/queue.h>
278#include <pthread.h>
279#include <semaphore.h>
280#include <machine/spinlock.h>
281
282#define _SPINLOCK_UNLOCKED _ATOMIC_LOCK_UNLOCKED
283
284struct __sem {
285 _atomic_lock_t lock;
286 volatile int waitcount;
287 volatile int value;
288 int shared;
289};
290
291TAILQ_HEAD(pthread_queue, pthread);
292
293#ifdef FUTEX
294
295struct pthread_mutex {
296 volatile unsigned int lock;
297 int type;
298 pthread_t owner;
299 int count;
300 int prioceiling;
301};
302
303struct pthread_cond {
304 volatile unsigned int seq;
305 clockid_t clock;
306 struct pthread_mutex *mutex;
307};
308
309struct pthread_rwlock {
310 volatile unsigned int value;
311};
312
313#else
314
315struct pthread_mutex {
316 _atomic_lock_t lock;
317 struct pthread_queue lockers;
318 int type;
319 pthread_t owner;
320 int count;
321 int prioceiling;
322};
323
324struct pthread_cond {
325 _atomic_lock_t lock;
326 struct pthread_queue waiters;
327 struct pthread_mutex *mutex;
328 clockid_t clock;
329};
330
331struct pthread_rwlock {
332 _atomic_lock_t lock;
333 pthread_t owner;
334 struct pthread_queue writers;
335 int readers;
336};
337#endif /* FUTEX */
338
339struct pthread_mutex_attr {
340 int ma_type;
341 int ma_protocol;
342 int ma_prioceiling;
343};
344
345struct pthread_cond_attr {
346 clockid_t ca_clock;
347};
348
349struct pthread_attr {
350 void *stack_addr;
351 size_t stack_size;
352 size_t guard_size;
353 int detach_state;
354 int contention_scope;
355 int sched_policy;
356 struct sched_param sched_param;
357 int sched_inherit;
358};
359
360struct rthread_storage {
361 int keyid;
362 struct rthread_storage *next;
363 void *data;
364};
365
366struct rthread_cleanup_fn {
367 void (*fn)(void *);
368 void *arg;
369 struct rthread_cleanup_fn *next;
370};
371
372struct tib;
373struct stack;
374struct pthread {
375 struct __sem donesem;
376 unsigned int flags;
377 _atomic_lock_t flags_lock;
378 struct tib *tib;
379 void *retval;
380 void *(*fn)(void *);
381 void *arg;
382 char name[32];
383 struct stack *stack;
384 LIST_ENTRY(pthread) threads;
385 TAILQ_ENTRY(pthread) waiting;
386 pthread_cond_t blocking_cond;
387 struct pthread_attr attr;
388 struct rthread_storage *local_storage;
389 struct rthread_cleanup_fn *cleanup_fns;
390
391 /* cancel received in a delayed cancel block? */
392 int delayed_cancel;
393};
394/* flags in pthread->flags */
395#define THREAD_DONE 0x001
396#define THREAD_DETACHED 0x002
397
398/* flags in tib->tib_thread_flags */
399#define TIB_THREAD_ASYNC_CANCEL 0x001
400#define TIB_THREAD_INITIAL_STACK 0x002 /* has stack from exec */
401
402#define ENTER_DELAYED_CANCEL_POINT(tib, self) \
403 (self)->delayed_cancel = 0; \
404 ENTER_CANCEL_POINT_INNER(tib, 1, 1)
405
406/*
407 * Internal functions exported from libc's thread bits for use by libpthread
408 */
409void _spinlock(volatile _atomic_lock_t *);
410int _spinlocktry(volatile _atomic_lock_t *);
411void _spinunlock(volatile _atomic_lock_t *);
412
413void _rthread_debug(int, const char *, ...)
414 __attribute__((__format__ (printf, 2, 3)));
415pid_t _thread_dofork(pid_t (*_sys_fork)(void));
416void _thread_finalize(void);
417
418/*
419 * Threading syscalls not declared in system headers
420 */
421__dead void __threxit(pid_t *);
422int __thrsleep(const volatile void *, clockid_t,
423 const struct timespec *, volatile void *, const int *);
424int __thrwakeup(const volatile void *, int n);
425int __thrsigdivert(sigset_t, siginfo_t *, const struct timespec *);
426
427#endif /* _THREAD_PRIVATE_H_ */