Skip to content
This repository has been archived by the owner on Feb 26, 2020. It is now read-only.

Add functions and macros as used upstream. #363

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/sys/sysmacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ extern unsigned long spl_hostid;

/* Missing misc functions */
extern int highbit(unsigned long i);
extern int highbit64(uint64_t i);
extern uint32_t zone_get_hostid(void *zone);
extern void spl_setup(void);
extern void spl_cleanup(void);
Expand All @@ -172,6 +173,9 @@ extern void spl_cleanup(void);
#ifndef roundup
#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
#endif
#ifndef howmany
#define howmany(x, y) (((x) + ((y) - 1)) / (y))
#endif

/*
* Compatibility macros/typedefs needed for Solaris -> Linux port
Expand Down
30 changes: 30 additions & 0 deletions module/spl/spl-generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,36 @@ highbit(unsigned long i)
}
EXPORT_SYMBOL(highbit);

int
highbit64(uint64_t i)
{
register int h = 1;
SENTRY;

if (i == 0)
SRETURN(0);
if (i & 0xffffffff00000000ull) {
h += 32; i >>= 32;
}
if (i & 0xffff0000) {
h += 16; i >>= 16;
}
if (i & 0xff00) {
h += 8; i >>= 8;
}
if (i & 0xf0) {
h += 4; i >>= 4;
}
if (i & 0xc) {
h += 2; i >>= 2;
}
if (i & 0x2) {
h += 1;
}
SRETURN(h);
}
EXPORT_SYMBOL(highbit64);

#if BITS_PER_LONG == 32
/*
* Support 64/64 => 64 division on a 32-bit platform. While the kernel
Expand Down