Skip to content
Snippets Groups Projects
Commit 7445c1e0 authored by Glauber Costa's avatar Glauber Costa
Browse files

bsd: add fls implementation

Because this is arch specific, I am adding it to a newly created file in
arch/x64. I am making it available to BSD through netport for the lack of a
better place
parent 1d44eb79
No related branches found
No related tags found
No related merge requests found
#ifndef ARCH_BITOPS_H_
#define ARCH_BITOPS_H_
static inline unsigned int
bsrl(unsigned int mask)
{
unsigned int result;
asm volatile("bsrl %1,%0" : "=r" (result) : "rm" (mask));
return result;
}
static inline int
fls(int mask)
{
return (mask == 0 ? mask : (int)bsrl((unsigned int)mask) + 1);
}
#endif
......@@ -12,6 +12,7 @@
#include <osv/debug.h>
#define __NEED_socklen_t
#include <bits/alltypes.h>
#include "bitops.h"
__BEGIN_DECLS
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment