About trapping integer division-by-zero
errors with __rt_raise()
By default, integer division by zero returns zero. If you
want to intercept division by zero, you can re-implement the C library
helper function __rt_raise(). The function
prototype for __rt_raise() is:
void __rt_raise(int signal, int type);
If you re-implement __rt_raise(), then
the library will automatically provide the signal-handling library
version of __aeabi_idiv0(), which calls __rt_raise(),
then that library version of __aeabi_idiv0() is
included in the final image.
In that case, when a divide-by-zero error occurs, __aeabi_idiv0() calls __rt_raise(SIGFPE, DIVBYZERO).
Therefore, if you re-implement __rt_raise(),
you must check (signal == SIGFPE) && (type == DIVBYZERO) to
determine if division by zero has occurred.
This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.
ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.