Daniel Dunbar | 2b88e03 | 2011-11-16 01:19:19 +0000 | [diff] [blame] | 1 | /* ===-- int_util.c - Implement internal utilities --------------------------=== |
| 2 | * |
| 3 | * The LLVM Compiler Infrastructure |
| 4 | * |
| 5 | * This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | * Source Licenses. See LICENSE.TXT for details. |
| 7 | * |
| 8 | * ===----------------------------------------------------------------------=== |
| 9 | */ |
| 10 | |
| 11 | #include "int_util.h" |
| 12 | #include "int_lib.h" |
| 13 | |
Daniel Dunbar | e2ed5fb | 2011-11-29 19:44:14 +0000 | [diff] [blame^] | 14 | /* NOTE: The definitions in this file are declared weak because we clients to be |
| 15 | * able to arbitrarily package individual functions into separate .a files. If |
| 16 | * we did not declare these weak, some link situations might end up seeing |
| 17 | * duplicate strong definitions of the same symbol. |
| 18 | * |
| 19 | * We can't use this solution for kernel use (which may not support weak), but |
| 20 | * currently expect that when built for kernel use all the functionality is |
| 21 | * packaged into a single library. |
| 22 | */ |
| 23 | |
Daniel Dunbar | 2b88e03 | 2011-11-16 01:19:19 +0000 | [diff] [blame] | 24 | #ifdef KERNEL_USE |
| 25 | |
| 26 | extern void panic(const char *, ...) __attribute__((noreturn)); |
| 27 | __attribute__((visibility("hidden"))) |
| 28 | void compilerrt_abort_impl(const char *file, int line, const char *function) { |
| 29 | panic("%s:%d: abort in %s", file, line, function); |
| 30 | } |
| 31 | |
| 32 | #else |
| 33 | |
| 34 | /* Get the system definition of abort() */ |
| 35 | #include <stdlib.h> |
| 36 | |
Daniel Dunbar | e2ed5fb | 2011-11-29 19:44:14 +0000 | [diff] [blame^] | 37 | __attribute__((weak)) |
Daniel Dunbar | 2b88e03 | 2011-11-16 01:19:19 +0000 | [diff] [blame] | 38 | __attribute__((visibility("hidden"))) |
| 39 | void compilerrt_abort_impl(const char *file, int line, const char *function) { |
| 40 | abort(); |
| 41 | } |
| 42 | |
| 43 | #endif |