blob: 871d191658cb13aa9f6a967e7f66112eb8387e8e [file] [log] [blame]
Daniel Dunbar2b88e032011-11-16 01:19:19 +00001/* ===-- 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 Dunbare2ed5fb2011-11-29 19:44:14 +000014/* 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 Dunbar2b88e032011-11-16 01:19:19 +000024#ifdef KERNEL_USE
25
26extern void panic(const char *, ...) __attribute__((noreturn));
27__attribute__((visibility("hidden")))
28void compilerrt_abort_impl(const char *file, int line, const char *function) {
29 panic("%s:%d: abort in %s", file, line, function);
30}
31
Nick Kledzik686f0d12012-02-03 23:53:40 +000032#elif __APPLE__ && !__STATIC__
33
34/* from libSystem.dylib */
35extern void __assert_rtn(const char *func, const char *file,
36 int line, const char * message) __attribute__((noreturn));
37
38__attribute__((weak))
39__attribute__((visibility("hidden")))
40void compilerrt_abort_impl(const char *file, int line, const char *function) {
41 __assert_rtn(function, file, line, "libcompiler_rt abort");
42}
43
44
Daniel Dunbar2b88e032011-11-16 01:19:19 +000045#else
46
47/* Get the system definition of abort() */
48#include <stdlib.h>
49
Daniel Dunbare2ed5fb2011-11-29 19:44:14 +000050__attribute__((weak))
Daniel Dunbar2b88e032011-11-16 01:19:19 +000051__attribute__((visibility("hidden")))
52void compilerrt_abort_impl(const char *file, int line, const char *function) {
53 abort();
54}
55
56#endif