]> git.proxmox.com Git - rustc.git/blob - vendor/compiler_builtins/compiler-rt/lib/builtins/int_util.c
New upstream version 1.36.0+dfsg1
[rustc.git] / vendor / compiler_builtins / compiler-rt / lib / builtins / int_util.c
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_lib.h"
12 #include "int_util.h"
13
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
24 #ifdef KERNEL_USE
25
26 NORETURN extern void panic(const char *, ...);
27 #ifndef _WIN32
28 __attribute__((visibility("hidden")))
29 #endif
30 void __compilerrt_abort_impl(const char *file, int line, const char *function) {
31 panic("%s:%d: abort in %s", file, line, function);
32 }
33
34 #elif __APPLE__
35
36 /* from libSystem.dylib */
37 NORETURN extern void __assert_rtn(const char *func, const char *file, int line,
38 const char *message);
39
40 #ifndef _WIN32
41 __attribute__((weak))
42 __attribute__((visibility("hidden")))
43 #endif
44 void __compilerrt_abort_impl(const char *file, int line, const char *function) {
45 __assert_rtn(function, file, line, "libcompiler_rt abort");
46 }
47
48 #elif __Fuchsia__
49
50 #ifndef _WIN32
51 __attribute__((weak))
52 __attribute__((visibility("hidden")))
53 #endif
54 void __compilerrt_abort_impl(const char *file, int line, const char *function) {
55 __builtin_trap();
56 }
57
58 #else
59
60 /* Get the system definition of abort() */
61 #include <stdlib.h>
62
63 #ifndef _WIN32
64 __attribute__((weak))
65 __attribute__((visibility("hidden")))
66 #endif
67 void __compilerrt_abort_impl(const char *file, int line, const char *function) {
68 abort();
69 }
70
71 #endif