blob: 02e383d31f8f41c666be50082494830b95a3b555 [file] [log] [blame]
Dmitriy Ivanovea295f62014-11-20 20:47:02 -08001/*
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
Dan Albert2e2c72d2018-01-24 13:19:08 -080017#include <android/api-level.h>
18
Dan Albert3e4d4d42018-01-24 22:35:19 -080019// __register_atfork wasn't available until android-23. When using libc.a, we're
20// using the latest library regardless of target API level.
Elliott Hughes95c6cd72019-12-20 13:26:14 -080021#if defined(_FORCE_CRT_ATFORK) || __ANDROID_API__ >= 23
Dan Albert2e2c72d2018-01-24 13:19:08 -080022
Dmitriy Ivanovea295f62014-11-20 20:47:02 -080023extern void* __dso_handle;
24
25extern 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
32int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)) {
33 return __register_atfork(prepare, parent, child, &__dso_handle);
34}
35
Elliott Hughes95c6cd72019-12-20 13:26:14 -080036#endif