This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 3/3] Add ffsl(), ffsll(), fls(), flsl(), flsll()


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

Attachment: signature.asc
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]