]> git.saurik.com Git - apple/libpthread.git/blame - src/exports_internal.h
libpthread-454.100.8.tar.gz
[apple/libpthread.git] / src / exports_internal.h
CommitLineData
c1f56ec9
A
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
42struct ProgramVars;
43
44OS_EXPORT int __is_threaded;
45
46OS_EXPORT const int __unix_conforming;
47
48OS_EXPORT
49void
50_pthread_set_self(pthread_t);
51
52OS_EXPORT
53pthread_t
54_pthread_self(void);
55
56OS_EXPORT
57int
58__pthread_init(const struct _libpthread_functions *pthread_funcs,
59 const char *envp[], const char *apple[],
60 const struct ProgramVars *vars);
61
62OS_EXPORT OS_NORETURN
63void
64thread_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
68OS_EXPORT OS_NORETURN
69void
70_pthread_start(pthread_t thread, mach_port_t kport,
71 void *(*fun)(void *), void *arg,
72 size_t stacksize, unsigned int flags);
73
74OS_EXPORT OS_NORETURN
75void
76start_wqthread(pthread_t self, mach_port_t kport,
77 void *stackaddr, void *unused, int reuse); // trampoline into _start_wqthread
78
79OS_EXPORT
80void
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__)
85OS_EXPORT
86void
87___chkstk_darwin(void);
88
89OS_EXPORT
90void
91thread_chkstk_darwin(void);
92#endif // defined(__x86_64__) || defined(__i386__) || defined(__arm64__)
93
94#pragma mark - exports with prototypes from not in libpthread
95
96OS_EXPORT
97int
98sigwait(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
103OS_EXPORT
104void
105_pthread_clear_qos_tsd(mach_port_t kport);
106
107OS_EXPORT
108void
109_pthread_exit_if_canceled(int error);
110
111#pragma mark - atfork libSystem integration
112
113OS_EXPORT void _pthread_atfork_prepare_handlers(void);
114OS_EXPORT void _pthread_atfork_prepare(void);
115OS_EXPORT void _pthread_atfork_parent(void);
116OS_EXPORT void _pthread_atfork_parent_handlers(void);
117OS_EXPORT void _pthread_atfork_child(void);
118OS_EXPORT void _pthread_atfork_child_handlers(void);
119OS_EXPORT void _pthread_fork_prepare(void);
120OS_EXPORT void _pthread_fork_parent(void);
121OS_EXPORT void _pthread_fork_child(void);
122OS_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
131declare_symbol(pthread_cancel);
132declare_symbol(pthread_cond_init);
133declare_symbol(pthread_cond_timedwait);
134declare_symbol(pthread_cond_wait);
135declare_symbol(pthread_join);
136declare_symbol(pthread_mutexattr_destroy);
137declare_symbol(pthread_rwlock_destroy);
138declare_symbol(pthread_rwlock_init);
139declare_symbol(pthread_rwlock_rdlock);
140declare_symbol(pthread_rwlock_tryrdlock);
141declare_symbol(pthread_rwlock_trywrlock);
142declare_symbol(pthread_rwlock_unlock);
143declare_symbol(pthread_rwlock_wrlock);
144declare_symbol(pthread_setcancelstate);
145declare_symbol(pthread_setcanceltype);
146declare_symbol(pthread_sigmask);
147declare_symbol(pthread_testcancel);
148declare_symbol(sigwait);
149// TAPI will see the $NOCANCEL$UNIX2003 redirected symbols
150declare_symbol(pthread_cond_timedwait$UNIX2003);
151declare_symbol(pthread_cond_wait$UNIX2003);
152declare_symbol(pthread_join$UNIX2003);
153declare_symbol(sigwait$UNIX2003);
154#else
155// TAPI will see the $NOCANCEL redirected symbols
156declare_symbol(pthread_cond_timedwait);
157declare_symbol(pthread_cond_wait);
158declare_symbol(pthread_join);
159declare_symbol(sigwait);
160#endif
161
162#undef declare_symbol
163
164#endif // __clang_tapi__
165#endif // __LIBPTHREAD_EXPORTS_INTERNAL_H__