1 /*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <android/api-level.h>
18
19 // __register_atfork wasn't available until android-23. When using libc.a, we're
20 // using the latest library regardless of target API level.
21 #if defined(_FORCE_CRT_ATFORK) || __ANDROID_API__ >= 23
22
23 extern void* __dso_handle;
24
25 extern int __register_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void), void* dso);
26
27 #ifndef _LIBC
28 // Libc used to export this in previous versions, therefore it needs
29 // to remain global for binary compatibility.
30 __attribute__ ((visibility ("hidden")))
31 #endif
pthread_atfork(void (* prepare)(void),void (* parent)(void),void (* child)(void))32 int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)) {
33 return __register_atfork(prepare, parent, child, &__dso_handle);
34 }
35
36 #endif
37