aboutsummaryrefslogtreecommitdiffstats
path: root/modules/spl/spl-generic.c
diff options
context:
space:
mode:
Diffstat (limited to 'modules/spl/spl-generic.c')
-rw-r--r--modules/spl/spl-generic.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/modules/spl/spl-generic.c b/modules/spl/spl-generic.c
index 60bebfdc4..1f982f8bd 100644
--- a/modules/spl/spl-generic.c
+++ b/modules/spl/spl-generic.c
@@ -8,6 +8,37 @@
int p0 = 0;
EXPORT_SYMBOL(p0);
+int
+highbit(unsigned long i)
+{
+ register int h = 1;
+
+ if (i == 0)
+ return (0);
+#if BITS_PER_LONG == 64
+ if (i & 0xffffffff00000000ul) {
+ h += 32; i >>= 32;
+ }
+#endif
+ 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;
+ }
+ return (h);
+}
+EXPORT_SYMBOL(highbit);
+
static int __init spl_init(void)
{
printk(KERN_INFO "spl: Loaded Solaris Porting Layer v%s\n", VERSION);