brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · bbb735c Raw
64 lines · c
1//===-- int_util.c - Implement internal utilities -------------------------===//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 "int_lib.h"10 11// NOTE: The definitions in this file are declared weak because we clients to be12// able to arbitrarily package individual functions into separate .a files. If13// we did not declare these weak, some link situations might end up seeing14// duplicate strong definitions of the same symbol.15//16// We can't use this solution for kernel use (which may not support weak), but17// currently expect that when built for kernel use all the functionality is18// packaged into a single library.19 20#ifdef KERNEL_USE21 22NORETURN extern void panic(const char *, ...);23#ifndef _WIN3224__attribute__((visibility("hidden")))25#endif26void __compilerrt_abort_impl(const char *file, int line, const char *function) {27  panic("%s:%d: abort in %s", file, line, function);28}29 30#elif __APPLE__31 32// from libSystem.dylib33NORETURN extern void __assert_rtn(const char *func, const char *file, int line,34                                  const char *message);35 36__attribute__((weak))37__attribute__((visibility("hidden")))38void __compilerrt_abort_impl(const char *file, int line, const char *function) {39  __assert_rtn(function, file, line, "libcompiler_rt abort");40}41 42#else43 44#ifdef _WIN3245#include <stdlib.h>46#endif47 48#ifndef _WIN3249__attribute__((weak))50__attribute__((visibility("hidden")))51#endif52void __compilerrt_abort_impl(const char *file, int line, const char *function) {53#if !__STDC_HOSTED__54  // Avoid depending on libc when compiling with -ffreestanding.55  __builtin_trap();56#elif defined(_WIN32)57  abort();58#else59  __builtin_abort();60#endif61}62 63#endif64