* [rust-dev] Find first set
@ 2015-01-12 17:12 Matthew Hammer
2015-01-12 17:17 ` Kevin McGuire
0 siblings, 1 reply; 3+ messages in thread
From: Matthew Hammer @ 2015-01-12 17:12 UTC (permalink / raw)
To: rust-dev
[-- Attachment #1: Type: text/plain, Size: 459 bytes --]
Hi Rust Developers,
I’m in need of this bit-level operation:
http://en.wikipedia.org/wiki/Find_first_set <http://en.wikipedia.org/wiki/Find_first_set>
I’m happy to implement it as a loop, but it seems like many architectures support it directly, as does libc.
Does anyone know if this is implemented in the Rust standard library or among the current primitives?
Searching for “ffs” in the source tree got me nowhere.
Thanks,
-Matt
[-- Attachment #2: Type: text/html, Size: 1032 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [rust-dev] Find first set
2015-01-12 17:12 [rust-dev] Find first set Matthew Hammer
@ 2015-01-12 17:17 ` Kevin McGuire
2015-01-12 17:44 ` Peter Marheine
0 siblings, 1 reply; 3+ messages in thread
From: Kevin McGuire @ 2015-01-12 17:17 UTC (permalink / raw)
To: Matthew Hammer; +Cc: rust-dev
On Mon, Jan 12, 2015 at 11:12 AM, Matthew Hammer <hammer@cs.umd.edu> wrote:
> Hi Rust Developers,
> I’m in need of this bit-level operation:
>
> http://en.wikipedia.org/wiki/Find_first_set
>
> I’m happy to implement it as a loop, but it seems like many architectures
> support it directly, as does libc.
>
> Does anyone know if this is implemented in the Rust standard library or
> among the current primitives?
>
> Searching for “ffs” in the source tree got me nowhere.
>
> Thanks,
> -Matt
I know that there have been people who have brought this to attention.
I know there is likely someone who has written a solution, but I can
not remember where it was located.
I do remember that it involved the usage of inline assembly and
#[cfg()] directives. It essentially provided a general implementation
that worked everywhere, then it provided implementations specific to a
certain architecture. By using the config attribute one could toggle
between the generic or architecture specific method being implemented
and thus callable.
I do not know for certain if it is or is not implemented in the
standard library, but I have the feeling that it is not. I tried to
look for it but failed.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [rust-dev] Find first set
2015-01-12 17:17 ` Kevin McGuire
@ 2015-01-12 17:44 ` Peter Marheine
0 siblings, 0 replies; 3+ messages in thread
From: Peter Marheine @ 2015-01-12 17:44 UTC (permalink / raw)
To: Kevin McGuire; +Cc: rust-dev
You can express ffs in terms of nlz, which is available as
Int::leading_zeros and appears to be implemented with LLVM intrinsics
for most types.
On Mon, Jan 12, 2015 at 10:17 AM, Kevin McGuire <kmcg3413@gmail.com> wrote:
> On Mon, Jan 12, 2015 at 11:12 AM, Matthew Hammer <hammer@cs.umd.edu> wrote:
>> Hi Rust Developers,
>> I’m in need of this bit-level operation:
>>
>> http://en.wikipedia.org/wiki/Find_first_set
>>
>> I’m happy to implement it as a loop, but it seems like many architectures
>> support it directly, as does libc.
>>
>> Does anyone know if this is implemented in the Rust standard library or
>> among the current primitives?
>>
>> Searching for “ffs” in the source tree got me nowhere.
>>
>> Thanks,
>> -Matt
>
> I know that there have been people who have brought this to attention.
> I know there is likely someone who has written a solution, but I can
> not remember where it was located.
>
> I do remember that it involved the usage of inline assembly and
> #[cfg()] directives. It essentially provided a general implementation
> that worked everywhere, then it provided implementations specific to a
> certain architecture. By using the config attribute one could toggle
> between the generic or architecture specific method being implemented
> and thus callable.
>
> I do not know for certain if it is or is not implemented in the
> standard library, but I have the feeling that it is not. I tried to
> look for it but failed.
> _______________________________________________
> Rust-dev mailing list
> Rust-dev@mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
--
Peter Marheine
Don't Panic
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-01-12 17:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-12 17:12 [rust-dev] Find first set Matthew Hammer
2015-01-12 17:17 ` Kevin McGuire
2015-01-12 17:44 ` Peter Marheine
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox