[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: libc-mini.a or libmes-builtins.a should also include integer divisio
From: |
Danny Milosavljevic |
Subject: |
Re: libc-mini.a or libmes-builtins.a should also include integer division algorithm ? |
Date: |
Thu, 28 May 2020 15:47:18 +0200 |
> For comparison, GCC just emits a SIGFPE signal on division by zero (I've
> tried). That would mean that signal emission (or syscalls in general) would
> have to be builtin, too. But I guess that would be OK.
Some more details on what different compilers do:
http://www.keil.com/support/man/docs/armcc/armcc_chr1359124235078.htm ... wow,
complicated.
>__rt_raise(SIGFPE, DIVBYZERO)
And another:
https://stackoverflow.com/questions/6744453/how-to-track-down-a-sigfpe-arithmetic-exception?rq=1
> 3 raise() 0x402720ac
> 2 __aeabi_uldivmod() 0x400bb0b8
> 1 __divsi3() 0x400b9880
> Integer division-by-zero errors can be trapped and identified by
> re-implementing the appropriate C library helper functions. The default
> behavior when division by zero occurs is that when the signal function is
> used, or __rt_raise() or __aeabi_idiv0() are re-implemented, __aeabi_idiv0()
> is called. Otherwise, the division function returns zero. __aeabi_idiv0()
> raises SIGFPE with an additional argument, DIVBYZERO.
And to raise we'd use in mes:
int
raise (int signum)
{
return _sys_call2 (SYS_kill, (long) getpid(), (long) signum);
}
pid_t
getpid ()
{
return _sys_call (SYS_getpid);
}
That's not so bad...
(lib/linux/getpid.c and lib/posix/raise.c)
But still, would be easier just not to implement a default div0 handler and
have the user or libc supply one--at least at first.
pgpg9lQqTpvoV.pgp
Description: OpenPGP digital signature
- libc-mini.a should also include integer division algorithm, Danny Milosavljevic, 2020/05/28
- Re: libc-mini.a should also include integer division algorithm, Jan Nieuwenhuizen, 2020/05/28
- Re: libc-mini.a should also include integer division algorithm, Danny Milosavljevic, 2020/05/28
- [WIP wip-arm] Introduce mescc.a for division algorithm and move the latter there., Danny Milosavljevic, 2020/05/28
- [WIP v2] Introduce mescc.a for division algorithm and move the latter there., Danny Milosavljevic, 2020/05/28
- [WIP v3] Introduce mescc.a for division algorithm and move the latter there., Danny Milosavljevic, 2020/05/28
- Re: [WIP v3] Introduce mescc.a for division algorithm and move the latter there., Danny Milosavljevic, 2020/05/29
- Re: [WIP v3] Introduce mescc.a for division algorithm and move the latter there., Jan Nieuwenhuizen, 2020/05/29