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