Use the BSR instruction on i386 to get the page shift
diff --git a/klibc/getpageshift.c b/klibc/getpageshift.c
deleted file mode 100644
index 40e8574..0000000
--- a/klibc/getpageshift.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * getpageshift.c
- *
- * Return the current page size as a shift count
- */
-
-#include <klibc/compiler.h>
-#include <sys/syscall.h>
-#include <unistd.h>
-
-int __getpageshift(void)
-{
- static int page_shift;
- int page_size;
-
- if ( __likely(page_shift) )
- return page_shift;
-
- page_size = getpagesize();
-
- while ( page_size > 1 ) {
- page_shift++;
- page_size >>= 1;
- }
-
- return page_shift;
-}
diff --git a/klibc/getpagesize.c b/klibc/getpagesize.c
deleted file mode 100644
index 98e814f..0000000
--- a/klibc/getpagesize.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * getpagesize.c
- */
-
-#include <klibc/compiler.h>
-#include <sys/syscall.h>
-#include <unistd.h>
-#include <sys/sysinfo.h>
-
-int getpagesize(void)
-{
- static int page_size;
- struct sysinfo si;
- int rv;
-
- if ( __likely(page_size) )
- return page_size;
-
- rv = sysinfo(&si);
- if ( rv == -1 )
- return -1;
-
- return (page_size = si.mem_unit);
-}
diff --git a/klibc/libc_init.c b/klibc/libc_init.c
index 494d8cc..444097d 100644
--- a/klibc/libc_init.c
+++ b/klibc/libc_init.c
@@ -65,10 +65,15 @@
}
__page_size = page_size;
+
+#if defined(__i386__) || defined(__x86_64__)
+ asm("bsrl %1,%0" : "=r" (page_shift) : "rm" (page_size));
+#else
while ( page_size > 1 ) {
page_shift++;
page_size >>= 1;
}
+#endif
__page_shift = page_shift;
environ = envp;