• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
19 extern void __cxa_finalize(void* dso_handle);
20 extern void native_bridge_exit(int status);
21 
exit(int status)22 void 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);
31   native_bridge_exit(status);
32   __builtin_unreachable();
33 }
34