1*e64bea71SDimitry Andric //===----------------------------------------------------------------------===// 2*e64bea71SDimitry Andric // 3*e64bea71SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*e64bea71SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*e64bea71SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*e64bea71SDimitry Andric // 7*e64bea71SDimitry Andric //===----------------------------------------------------------------------===// 8*e64bea71SDimitry Andric 9*e64bea71SDimitry Andric #include <__config> 10*e64bea71SDimitry Andric #include <__log_hardening_failure> 11*e64bea71SDimitry Andric #include <cstdio> 12*e64bea71SDimitry Andric 13*e64bea71SDimitry Andric #ifdef __BIONIC__ 14*e64bea71SDimitry Andric # include <syslog.h> 15*e64bea71SDimitry Andric #endif // __BIONIC__ 16*e64bea71SDimitry Andric 17*e64bea71SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD 18*e64bea71SDimitry Andric __log_hardening_failure(const char * message)19*e64bea71SDimitry Andricvoid __log_hardening_failure(const char* message) noexcept { 20*e64bea71SDimitry Andric // Always log the message to `stderr` in case the platform-specific system calls fail. 21*e64bea71SDimitry Andric std::fputs(message, stderr); 22*e64bea71SDimitry Andric 23*e64bea71SDimitry Andric #if defined(__BIONIC__) 24*e64bea71SDimitry Andric // Show error in logcat. The latter two arguments are ignored on Android. 25*e64bea71SDimitry Andric openlog("libc++", 0, 0); 26*e64bea71SDimitry Andric syslog(LOG_CRIT, "%s", message); 27*e64bea71SDimitry Andric closelog(); 28*e64bea71SDimitry Andric #endif 29*e64bea71SDimitry Andric } 30*e64bea71SDimitry Andric 31*e64bea71SDimitry Andric _LIBCPP_END_NAMESPACE_STD 32