1 //===-- utilities_posix.cpp -------------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "gwp_asan/definitions.h" 10 #include "gwp_asan/utilities.h" 11 12 #ifdef ANDROID 13 #include <stdlib.h> 14 extern "C" GWP_ASAN_WEAK void android_set_abort_message(const char *); 15 #else // ANDROID 16 #include <stdio.h> 17 #endif 18 19 namespace gwp_asan { 20 21 #ifdef ANDROID 22 void Check(bool Condition, const char *Message) { 23 if (Condition) 24 return; 25 if (&android_set_abort_message != nullptr) 26 android_set_abort_message(Message); 27 abort(); 28 } 29 #else // ANDROID 30 void Check(bool Condition, const char *Message) { 31 if (Condition) 32 return; 33 fprintf(stderr, "%s", Message); 34 __builtin_trap(); 35 } 36 #endif // ANDROID 37 38 } // namespace gwp_asan 39