]> git.saurik.com Git - apple/libpthread.git/blob - src/exports_internal.h
libpthread-454.80.2.tar.gz
[apple/libpthread.git] / src / exports_internal.h
1 /*
2 * Copyright (c) 2019 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 #ifndef __LIBPTHREAD_EXPORTS_INTERNAL_H__
25 #define __LIBPTHREAD_EXPORTS_INTERNAL_H__
26
27 /*!
28 * @file exports_internal.h
29 *
30 * @brief
31 * This file has prototypes for symbols / functions that are exported
32 * without a public header.
33 *
34 * @discussion
35 * This header is also fed to TAPI and needs to work without internal.h
36 */
37
38 #include <os/base.h>
39 #include <mach/mach.h>
40 #include <pthread.h>
41
42 struct ProgramVars;
43
44 OS_EXPORT int __is_threaded;
45
46 OS_EXPORT const int __unix_conforming;
47
48 OS_EXPORT
49 void
50 _pthread_set_self(pthread_t);
51
52 OS_EXPORT
53 pthread_t
54 _pthread_self(void);
55
56 OS_EXPORT
57 int
58 __pthread_init(const struct _libpthread_functions *pthread_funcs,
59 const char *envp[], const char *apple[],
60 const struct ProgramVars *vars);
61
62 OS_EXPORT OS_NORETURN
63 void
64 thread_start(pthread_t self, mach_port_t kport,
65 void *(*fun)(void *), void *arg,
66 size_t stacksize, unsigned int flags); // trampoline into _pthread_start
67
68 OS_EXPORT OS_NORETURN
69 void
70 _pthread_start(pthread_t thread, mach_port_t kport,
71 void *(*fun)(void *), void *arg,
72 size_t stacksize, unsigned int flags);
73
74 OS_EXPORT OS_NORETURN
75 void
76 start_wqthread(pthread_t self, mach_port_t kport,
77 void *stackaddr, void *unused, int reuse); // trampoline into _start_wqthread
78
79 OS_EXPORT
80 void
81 _pthread_wqthread(pthread_t self, mach_port_t kport,
82 void *stackaddr, void *keventlist, int flags, int nkevents);
83
84 #if defined(__x86_64__) || defined(__i386__) || defined(__arm64__)
85 OS_EXPORT
86 void
87 ___chkstk_darwin(void);
88
89 OS_EXPORT
90 void
91 thread_chkstk_darwin(void);
92 #endif // defined(__x86_64__) || defined(__i386__) || defined(__arm64__)
93
94 #pragma mark - exports with prototypes from not in libpthread
95
96 OS_EXPORT
97 int
98 sigwait(const sigset_t *, int *) __DARWIN_ALIAS_C(sigwait);
99
100 #pragma mark - shared with libsystem_kernel.dylib
101 /* Note: these can't use _pthread_malloc / _pthread_free unconditionally */
102
103 OS_EXPORT
104 void
105 _pthread_clear_qos_tsd(mach_port_t kport);
106
107 OS_EXPORT
108 void
109 _pthread_exit_if_canceled(int error);
110
111 #pragma mark - atfork libSystem integration
112
113 OS_EXPORT void _pthread_atfork_prepare_handlers(void);
114 OS_EXPORT void _pthread_atfork_prepare(void);
115 OS_EXPORT void _pthread_atfork_parent(void);
116 OS_EXPORT void _pthread_atfork_parent_handlers(void);
117 OS_EXPORT void _pthread_atfork_child(void);
118 OS_EXPORT void _pthread_atfork_child_handlers(void);
119 OS_EXPORT void _pthread_fork_prepare(void);
120 OS_EXPORT void _pthread_fork_parent(void);
121 OS_EXPORT void _pthread_fork_child(void);
122 OS_EXPORT void _pthread_fork_child_postinit(void);
123
124 #pragma mark - TAPI
125 #ifdef __clang_tapi__
126
127 #define declare_symbol(s) OS_EXPORT void __tapi_##s(void) asm("_" #s)
128
129 #if TARGET_OS_OSX && defined(__i386__)
130 // TAPI will see the $UNIX2003 redirected symbols
131 declare_symbol(pthread_cancel);
132 declare_symbol(pthread_cond_init);
133 declare_symbol(pthread_cond_timedwait);
134 declare_symbol(pthread_cond_wait);
135 declare_symbol(pthread_join);
136 declare_symbol(pthread_mutexattr_destroy);
137 declare_symbol(pthread_rwlock_destroy);
138 declare_symbol(pthread_rwlock_init);
139 declare_symbol(pthread_rwlock_rdlock);
140 declare_symbol(pthread_rwlock_tryrdlock);
141 declare_symbol(pthread_rwlock_trywrlock);
142 declare_symbol(pthread_rwlock_unlock);
143 declare_symbol(pthread_rwlock_wrlock);
144 declare_symbol(pthread_setcancelstate);
145 declare_symbol(pthread_setcanceltype);
146 declare_symbol(pthread_sigmask);
147 declare_symbol(pthread_testcancel);
148 declare_symbol(sigwait);
149 // TAPI will see the $NOCANCEL$UNIX2003 redirected symbols
150 declare_symbol(pthread_cond_timedwait$UNIX2003);
151 declare_symbol(pthread_cond_wait$UNIX2003);
152 declare_symbol(pthread_join$UNIX2003);
153 declare_symbol(sigwait$UNIX2003);
154 #else
155 // TAPI will see the $NOCANCEL redirected symbols
156 declare_symbol(pthread_cond_timedwait);
157 declare_symbol(pthread_cond_wait);
158 declare_symbol(pthread_join);
159 declare_symbol(sigwait);
160 #endif
161
162 #undef declare_symbol
163
164 #endif // __clang_tapi__
165 #endif // __LIBPTHREAD_EXPORTS_INTERNAL_H__