2 * Copyright (c) 2019 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
24 #ifndef __LIBPTHREAD_EXPORTS_INTERNAL_H__
25 #define __LIBPTHREAD_EXPORTS_INTERNAL_H__
28 * @file exports_internal.h
31 * This file has prototypes for symbols / functions that are exported
32 * without a public header.
35 * This header is also fed to TAPI and needs to work without internal.h
39 #include <mach/mach.h>
44 OS_EXPORT
int __is_threaded
;
46 OS_EXPORT
const int __unix_conforming
;
50 _pthread_set_self(pthread_t
);
58 __pthread_init(const struct _libpthread_functions
*pthread_funcs
,
59 const char *envp
[], const char *apple
[],
60 const struct ProgramVars
*vars
);
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
70 _pthread_start(pthread_t thread
, mach_port_t kport
,
71 void *(*fun
)(void *), void *arg
,
72 size_t stacksize
, unsigned int flags
);
76 start_wqthread(pthread_t self
, mach_port_t kport
,
77 void *stackaddr
, void *unused
, int reuse
); // trampoline into _start_wqthread
81 _pthread_wqthread(pthread_t self
, mach_port_t kport
,
82 void *stackaddr
, void *keventlist
, int flags
, int nkevents
);
84 #if defined(__x86_64__) || defined(__i386__) || defined(__arm64__)
87 ___chkstk_darwin(void);
91 thread_chkstk_darwin(void);
92 #endif // defined(__x86_64__) || defined(__i386__) || defined(__arm64__)
94 #pragma mark - exports with prototypes from not in libpthread
98 sigwait(const sigset_t
*, int *) __DARWIN_ALIAS_C(sigwait
);
100 #pragma mark - shared with libsystem_kernel.dylib
101 /* Note: these can't use _pthread_malloc / _pthread_free unconditionally */
105 _pthread_clear_qos_tsd(mach_port_t kport
);
109 _pthread_exit_if_canceled(int error
);
111 #pragma mark - atfork libSystem integration
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);
125 #ifdef __clang_tapi__
127 #define declare_symbol(s) OS_EXPORT void __tapi_##s(void) asm("_" #s)
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
);
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
);
162 #undef declare_symbol
164 #endif // __clang_tapi__
165 #endif // __LIBPTHREAD_EXPORTS_INTERNAL_H__