1229109Sed/* ===-- int_util.c - Implement internal utilities --------------------------=== 2229109Sed * 3229109Sed * The LLVM Compiler Infrastructure 4229109Sed * 5229109Sed * This file is dual licensed under the MIT and the University of Illinois Open 6229109Sed * Source Licenses. See LICENSE.TXT for details. 7229109Sed * 8229109Sed * ===----------------------------------------------------------------------=== 9229109Sed */ 10229109Sed 11229109Sed#include "int_util.h" 12229109Sed#include "int_lib.h" 13229109Sed 14229109Sed/* NOTE: The definitions in this file are declared weak because we clients to be 15229109Sed * able to arbitrarily package individual functions into separate .a files. If 16229109Sed * we did not declare these weak, some link situations might end up seeing 17229109Sed * duplicate strong definitions of the same symbol. 18229109Sed * 19229109Sed * We can't use this solution for kernel use (which may not support weak), but 20229109Sed * currently expect that when built for kernel use all the functionality is 21229109Sed * packaged into a single library. 22229109Sed */ 23229109Sed 24229109Sed#ifdef KERNEL_USE 25229109Sed 26229109Sedextern void panic(const char *, ...) __attribute__((noreturn)); 27229109Sed__attribute__((visibility("hidden"))) 28229109Sedvoid compilerrt_abort_impl(const char *file, int line, const char *function) { 29229109Sed panic("%s:%d: abort in %s", file, line, function); 30229109Sed} 31229109Sed 32239138Sandrew#elif __APPLE__ && !__STATIC__ 33239138Sandrew 34239138Sandrew/* from libSystem.dylib */ 35239138Sandrewextern void __assert_rtn(const char *func, const char *file, 36239138Sandrew int line, const char * message) __attribute__((noreturn)); 37239138Sandrew 38239138Sandrew__attribute__((weak)) 39239138Sandrew__attribute__((visibility("hidden"))) 40239138Sandrewvoid compilerrt_abort_impl(const char *file, int line, const char *function) { 41239138Sandrew __assert_rtn(function, file, line, "libcompiler_rt abort"); 42239138Sandrew} 43239138Sandrew 44239138Sandrew 45229109Sed#else 46229109Sed 47229109Sed/* Get the system definition of abort() */ 48229109Sed#include <stdlib.h> 49229109Sed 50229109Sed__attribute__((weak)) 51229109Sed__attribute__((visibility("hidden"))) 52229109Sedvoid compilerrt_abort_impl(const char *file, int line, const char *function) { 53229109Sed abort(); 54229109Sed} 55229109Sed 56229109Sed#endif 57