You copied the Doc URL to your clipboard.

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, re-implement the C library help function __rt_raise(). The function prototype for __rt_raise() is as follows:

void __rt_raise(int signal, int type);

If you re-implement __rt_raise(), then either your own implementation, or the default library version, of __aeabi_idiv0() is included in the final image.

When a divide-by-zero error occurs, the default library version of __aeabi_idiv0() calls __rt_raise(2, 2) to raise SIGFPE with type DIVBYZERO. When a divide-by-zero error occurs, __aeabi_idiv0() calls __rt_raise(2, 2). Therefore, in your own the implementation of __rt_raise(), you must check (signal == 2) && (type == 2) must be checked to determine if division by zero has occurred.

If you have your own version of __aeabi_idiv0() and call the library version using $Super$$aeabi_idiv0(), then the library version does not call __rt_raise().

Was this page helpful? Yes No