| Dmitriy Ivanov | ea295f6 | 2014-11-20 20:47:02 -0800 | [diff] [blame] | 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 |  | 
| Dan Albert | 2e2c72d | 2018-01-24 13:19:08 -0800 | [diff] [blame] | 17 | #include <android/api-level.h> | 
|  | 18 |  | 
| Dan Albert | 3e4d4d4 | 2018-01-24 22:35:19 -0800 | [diff] [blame] | 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. | 
| Elliott Hughes | 95c6cd7 | 2019-12-20 13:26:14 -0800 | [diff] [blame] | 21 | #if defined(_FORCE_CRT_ATFORK) || __ANDROID_API__ >= 23 | 
| Dan Albert | 2e2c72d | 2018-01-24 13:19:08 -0800 | [diff] [blame] | 22 |  | 
| Dmitriy Ivanov | ea295f6 | 2014-11-20 20:47:02 -0800 | [diff] [blame] | 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 | 
|  | 32 | int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)) { | 
|  | 33 | return __register_atfork(prepare, parent, child, &__dso_handle); | 
|  | 34 | } | 
|  | 35 |  | 
| Elliott Hughes | 95c6cd7 | 2019-12-20 13:26:14 -0800 | [diff] [blame] | 36 | #endif |