Skip to content

Commit 1dc5088

Browse files
amotintonyhutter
authored andcommitted
FreeBSD: Remove HAVE_INLINE_FLSL use
These macros are deprecated in FreeBSD kernel for several years, and unneeded for much longer. Instead, similar to Linux, let kernel let compiler do the right things. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Alexander Motin <alexander.motin@TrueNAS.com> Closes openzfs#18004
1 parent 135fffb commit 1dc5088

File tree

1 file changed

+4
-73
lines changed

1 file changed

+4
-73
lines changed

include/os/freebsd/spl/sys/sysmacros.h

Lines changed: 4 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -290,80 +290,11 @@ extern unsigned char bcd_to_byte[256];
290290
#define offsetof(type, field) __offsetof(type, field)
291291
#endif
292292

293-
/*
294-
* Find highest one bit set.
295-
* Returns bit number + 1 of highest bit that is set, otherwise returns 0.
296-
* High order bit is 31 (or 63 in _LP64 kernel).
297-
*/
298-
static __inline int
299-
highbit(ulong_t i)
300-
{
301-
#if defined(HAVE_INLINE_FLSL)
302-
return (flsl(i));
303-
#else
304-
int h = 1;
293+
#define highbit(x) flsl(x)
294+
#define lowbit(x) ffsl(x)
305295

306-
if (i == 0)
307-
return (0);
308-
#ifdef _LP64
309-
if (i & 0xffffffff00000000ul) {
310-
h += 32; i >>= 32;
311-
}
312-
#endif
313-
if (i & 0xffff0000) {
314-
h += 16; i >>= 16;
315-
}
316-
if (i & 0xff00) {
317-
h += 8; i >>= 8;
318-
}
319-
if (i & 0xf0) {
320-
h += 4; i >>= 4;
321-
}
322-
if (i & 0xc) {
323-
h += 2; i >>= 2;
324-
}
325-
if (i & 0x2) {
326-
h += 1;
327-
}
328-
return (h);
329-
#endif
330-
}
331-
332-
/*
333-
* Find highest one bit set.
334-
* Returns bit number + 1 of highest bit that is set, otherwise returns 0.
335-
*/
336-
static __inline int
337-
highbit64(uint64_t i)
338-
{
339-
#if defined(HAVE_INLINE_FLSLL)
340-
return (flsll(i));
341-
#else
342-
int h = 1;
343-
344-
if (i == 0)
345-
return (0);
346-
if (i & 0xffffffff00000000ULL) {
347-
h += 32; i >>= 32;
348-
}
349-
if (i & 0xffff0000) {
350-
h += 16; i >>= 16;
351-
}
352-
if (i & 0xff00) {
353-
h += 8; i >>= 8;
354-
}
355-
if (i & 0xf0) {
356-
h += 4; i >>= 4;
357-
}
358-
if (i & 0xc) {
359-
h += 2; i >>= 2;
360-
}
361-
if (i & 0x2) {
362-
h += 1;
363-
}
364-
return (h);
365-
#endif
366-
}
296+
#define highbit64(x) flsll(x)
297+
#define lowbit64(x) ffsll(x)
367298

368299
#ifdef __cplusplus
369300
}

0 commit comments

Comments
 (0)