xref: /freebsd-src/contrib/llvm-project/compiler-rt/lib/builtins/arm/aeabi_div0.c (revision 0b57cec536236d46e3dba9bd041533462f33dbb7)
1*0b57cec5SDimitry Andric //===-- aeabi_div0.c - ARM Runtime ABI support routines for compiler-rt ---===//
2*0b57cec5SDimitry Andric //
3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*0b57cec5SDimitry Andric //
7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
8*0b57cec5SDimitry Andric //
9*0b57cec5SDimitry Andric // This file implements the division by zero helper routines as specified by the
10*0b57cec5SDimitry Andric // Run-time ABI for the ARM Architecture.
11*0b57cec5SDimitry Andric //
12*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
13*0b57cec5SDimitry Andric 
14*0b57cec5SDimitry Andric // RTABI 4.3.2 - Division by zero
15*0b57cec5SDimitry Andric //
16*0b57cec5SDimitry Andric // The *div0 functions:
17*0b57cec5SDimitry Andric // - Return the value passed to them as a parameter
18*0b57cec5SDimitry Andric // - Or, return a fixed value defined by the execution environment (such as 0)
19*0b57cec5SDimitry Andric // - Or, raise a signal (often SIGFPE) or throw an exception, and do not return
20*0b57cec5SDimitry Andric //
21*0b57cec5SDimitry Andric // An application may provide its own implementations of the *div0 functions to
22*0b57cec5SDimitry Andric // for a particular behaviour from the *div and *divmod functions called out of
23*0b57cec5SDimitry Andric // line.
24*0b57cec5SDimitry Andric 
25*0b57cec5SDimitry Andric #include "../int_lib.h"
26*0b57cec5SDimitry Andric 
27*0b57cec5SDimitry Andric // provide an unused declaration to pacify pendantic compilation
28*0b57cec5SDimitry Andric extern unsigned char declaration;
29*0b57cec5SDimitry Andric 
30*0b57cec5SDimitry Andric #if defined(__ARM_EABI__)
31*0b57cec5SDimitry Andric AEABI_RTABI int __attribute__((weak)) __attribute__((visibility("hidden")))
__aeabi_idiv0(int return_value)32*0b57cec5SDimitry Andric __aeabi_idiv0(int return_value) {
33*0b57cec5SDimitry Andric   return return_value;
34*0b57cec5SDimitry Andric }
35*0b57cec5SDimitry Andric 
36*0b57cec5SDimitry Andric AEABI_RTABI long long __attribute__((weak))
__aeabi_ldiv0(long long return_value)37*0b57cec5SDimitry Andric __attribute__((visibility("hidden"))) __aeabi_ldiv0(long long return_value) {
38*0b57cec5SDimitry Andric   return return_value;
39*0b57cec5SDimitry Andric }
40*0b57cec5SDimitry Andric #endif
41