32 lines · cpp
1//===----------------------------------------------------------------------===//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-exception6//7//===----------------------------------------------------------------------===//8 9#include <__config>10#include <__log_hardening_failure>11#include <cstdio>12 13#ifdef __BIONIC__14# include <syslog.h>15#endif // __BIONIC__16 17_LIBCPP_BEGIN_NAMESPACE_STD18 19void __log_hardening_failure(const char* message) noexcept {20 // Always log the message to `stderr` in case the platform-specific system calls fail.21 std::fputs(message, stderr);22 23#if defined(__BIONIC__)24 // Show error in logcat. The latter two arguments are ignored on Android.25 openlog("libc++", 0, 0);26 syslog(LOG_CRIT, "%s", message);27 closelog();28#endif29}30 31_LIBCPP_END_NAMESPACE_STD32