[clang-format] Write in text mode with LF in dump_format_[help|style].py
[llvm-project.git] / compiler-rt / lib / gwp_asan / platform_specific / utilities_fuchsia.cpp
blobfecf94b0d1a1962488b6f11d64fffe4824d076fb
1 //===-- utilities_fuchsia.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 //===----------------------------------------------------------------------===//
9 #include "gwp_asan/utilities.h"
11 #include <alloca.h>
12 #include <stdio.h>
13 #include <string.h>
14 #include <zircon/sanitizer.h>
15 #include <zircon/status.h>
17 namespace gwp_asan {
18 void die(const char *Message) {
19 __sanitizer_log_write(Message, strlen(Message));
20 __builtin_trap();
23 void dieWithErrorCode(const char *Message, int64_t ErrorCode) {
24 const char *error_str =
25 _zx_status_get_string(static_cast<zx_status_t>(ErrorCode));
26 size_t buffer_size = strlen(Message) + 32 + strlen(error_str);
27 char *buffer = static_cast<char *>(alloca(buffer_size));
28 snprintf(buffer, buffer_size, "%s (Error Code: %s)", Message, error_str);
29 __sanitizer_log_write(buffer, strlen(buffer));
30 __builtin_trap();
32 } // namespace gwp_asan