blob: 5ab64be975676f8cb30986e1c0644571a11d0880 [file] [log] [blame]
Lev Rumyantsevc6f684a2020-06-19 16:53:08 -07001/*
2 * Copyright (C) 2020 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 <unistd.h>
18
Lev Rumyantsevc6f684a2020-06-19 16:53:08 -070019extern void __cxa_finalize(void* dso_handle);
Evgeny Eltsine9f21962020-07-31 14:39:16 +020020extern void native_bridge_exit(int status);
Lev Rumyantsevc6f684a2020-06-19 16:53:08 -070021
22void exit(int status) {
23 // We don't need to call __cxa_thread_finalize because host "exit" would do that for us.
24 // __cxa_thread_finalize();
25 // That's slight deviation from standard behavior: there we first call __cxa_thread_finalize()
26 // for all objects and __cxa_finalize() for all objects and here we would first do
27 // __cxa_finalize() for guest objects, then __cxa_thread_finalize() (and after that we would do
28 // __cxa_finalize() for host objects, of course).
29 // TODO(b/65052237): Fix that with bionic refactoring?
30 __cxa_finalize(NULL);
Evgeny Eltsine9f21962020-07-31 14:39:16 +020031 native_bridge_exit(status);
Lev Rumyantsevc6f684a2020-06-19 16:53:08 -070032 __builtin_unreachable();
33}