* Is __ffs64 supposed to be zero based? @ 2013-11-06 7:15 Ben Greear 2013-11-06 11:52 ` Clemens Ladisch 0 siblings, 1 reply; 3+ messages in thread From: Ben Greear @ 2013-11-06 7:15 UTC (permalink / raw) To: Linux Kernel Mailing List Similarly named methods elsewhere seem to indicate it is supposed to be ones-based counting (ie, bit (1<<0) would be considred 'bit 1'. Thanks, Ben -- Ben Greear <greearb@candelatech.com> Candela Technologies Inc http://www.candelatech.com ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Is __ffs64 supposed to be zero based? 2013-11-06 7:15 Is __ffs64 supposed to be zero based? Ben Greear @ 2013-11-06 11:52 ` Clemens Ladisch 2013-11-06 17:17 ` Ben Greear 0 siblings, 1 reply; 3+ messages in thread From: Clemens Ladisch @ 2013-11-06 11:52 UTC (permalink / raw) To: Ben Greear, Linux Kernel Mailing List Ben Greear wrote: > Similarly named methods elsewhere seem to indicate it is supposed to be > ones-based counting (ie, bit (1<<0) would be considred 'bit 1'. ffs() is defined to use one-based counting: <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ffs.html> __ffs() uses zero-based counting. On gcc, it's likely to be implemented with__builtin_ctz*(), whose documentation says: | Returns the number of trailing 0-bits in x, starting at the least | significant bit position. Regards, Clemens ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Is __ffs64 supposed to be zero based? 2013-11-06 11:52 ` Clemens Ladisch @ 2013-11-06 17:17 ` Ben Greear 0 siblings, 0 replies; 3+ messages in thread From: Ben Greear @ 2013-11-06 17:17 UTC (permalink / raw) To: Clemens Ladisch; +Cc: Linux Kernel Mailing List On 11/06/2013 03:52 AM, Clemens Ladisch wrote: > Ben Greear wrote: >> Similarly named methods elsewhere seem to indicate it is supposed to be >> ones-based counting (ie, bit (1<<0) would be considred 'bit 1'. > > ffs() is defined to use one-based counting: > <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ffs.html> > > __ffs() uses zero-based counting. On gcc, it's likely to be implemented > with__builtin_ctz*(), whose documentation says: > | Returns the number of trailing 0-bits in x, starting at the least > | significant bit position. Thanks for the information! Ben -- Ben Greear <greearb@candelatech.com> Candela Technologies Inc http://www.candelatech.com ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-11-06 17:17 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-11-06 7:15 Is __ffs64 supposed to be zero based? Ben Greear 2013-11-06 11:52 ` Clemens Ladisch 2013-11-06 17:17 ` Ben Greear
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox