<div dir="ltr">On Sat, Sep 6, 2014 at 3:40 PM, Renato Golin <span dir="ltr"><<a href="mailto:renato.golin@linaro.org" target="_blank">renato.golin@linaro.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 6 September 2014 22:46, Saleem Abdulrasool <<a href="mailto:compnerd@compnerd.org">compnerd@compnerd.org</a>> wrote:<br>
> I did dig into this further and it seems that they are, in fact, considered<br>
> part of the RT-ABI :-(.  Ive committed a simple conforming implementation in<br>
> SVN r217322.<br>
<br>
</span>Hi Saleem,<br>
<br>
This implementation will differ from the current sdiv's expected<br>
(return 0) if called from a place that doesn't mov r0, #0 just before<br>
calling div0.<br></blockquote><div><br></div><div>Why not adjust this instead?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
ARM and GCC both throw an exception, and on non-EABI ARM, we're<br>
returning zero, so it would be good to have at least one consistent<br>
behaviour.<br></blockquote><div><br></div><div>I think its better to avoid pulling in a dependency on the target libc, particularly if you want to permit the use of compiler-rt in a bare-metal environment.  This implementation conforms to the specification and can be overridden if the libc wishes to catch the div-by-zero.</div><div><br></div><div>We could use __rt_raise(2, 2), which would need to call signal as well, so you end up growing a dependency on the target environment's libc implementation.  I think that expanding the responsibility of compiler-rt from supporting the code generation from the compiler to integrating into the target environment's libc can be problematic.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I think we should return zero on both idiv0 and ldiv0 and move the<br>
"mov r0, #0" inside the #else for now.<br></blockquote><div><br></div><div>Why 0 and not infinity?  Or some other value?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
cheers,<br>
--renato</blockquote><div> </div></div>-- <br>Saleem Abdulrasool<br>compnerd (at) compnerd (dot) org
</div></div>