4.55 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 automatically provides 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.
Related concepts
4.53 Integer division-by-zero errors in C code
4.54 About trapping integer division-by-zero errors with __aeabi_idiv0()
4.56 Identification of integer division-by-zero errors in C code
4.57 Examining parameters when integer division-by-zero errors occur in C code
Related information
Run-time ABI for the ARM Architecture
Non-ConfidentialPDF file icon PDF versionARM DUI0375E
Copyright © 2007, 2008, 2011, 2012, 2014 ARM. All rights reserved.