[PATCH 3/3] Add ffsl(), ffsll(), fls(), flsl(), flsll()
Corinna Vinschen
vinschen@redhat.com
Wed Jul 5 08:42:00 GMT 2017
On Jul 5 08:06, Sebastian Huber wrote:
> On 04/07/17 15:34, Sebastian Huber wrote:
>
> > +int
> > +fls(int i)
> > +{
> > +
> > + return (sizeof(i) * CHAR_BIT - __builtin_clz(i));
> > +}
>
> I just realized that the result of __builtin_clz(i) is undefined if i == 0.
> However, fls(0) should return 0. So this must be changed to:
>
> int
> fls(int i)
> {
>
> if (i == 0)
> return (0);
>
> return (sizeof(i) * CHAR_BIT - __builtin_clz(i));
> }
>
> Similar for flsl() and flsll().
Are you going to send a new patch series ir just a v2 for path 3?
Corinna
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20170705/63e1049e/attachment.sig>
More information about the Newlib
mailing list