More sys_mmap2 madness.  Different architectures implement this differently.
Not only is the shift count inconsistent, but some architectures test that
the offset is valid, others don't, so do it ourselves.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
diff --git a/klibc/mmap.c b/klibc/mmap.c
index da11c70..2412e32 100644
--- a/klibc/mmap.c
+++ b/klibc/mmap.c
@@ -10,19 +10,23 @@
 #include <bitsize.h>
 
 /*
- * MMAP2_SHIFT is definitely *NOT* equal to getpageshift() for
- * at least some architectures...
- */
-#if defined(__i386__) || defined( __sparc__) || defined(__arm__)
-# define MMAP2_SHIFT	12	/* Fixed by syscall definition */
-#endif
-
-/*
  * Set in SYSCALLS whether or not we should use an unadorned mmap() system
  * call (typical on 64-bit architectures).
  */
 #if (_BITSIZE == 32 && defined(__NR_mmap2)) || (_BITSIZE == 64 && !defined(__NR_mmap))
 
+/*
+ * Some architectures use a fixed value for MMAP2_SHIFT, other use the
+ * current page size.  This, of course, isn't documented or even
+ * #define'd anywhere.
+ */
+#if defined(__cris__) || defined(__m68k__) || defined(__mips__)
+/* Use the current page size */
+#else
+# define MMAP2_SHIFT	12	/* Fixed by syscall definition */
+#endif
+
+
 /* This architecture uses mmap2(). The Linux mmap2() system call takes
    a page offset as the offset argument.  We need to make sure we have
    the proper conversion in place. */
@@ -33,12 +37,12 @@
 {
 #ifdef MMAP2_SHIFT
   const int mmap2_shift = MMAP2_SHIFT;
-  const unsigned long mmap2_mask = (1UL << mmap2_shift) - 1;
 #else
-  extern unsigned int __page_size, __page_shift;
+  extern unsigned int __page_shift;
   const int mmap2_shift = __page_shift;
-  const unsigned long mmap2_mask = (unsigned long)__page_size - 1;
 #endif
+  extern unsigned int __page_size;
+  const unsigned int mmap2_mask = __page_size - 1;
 
   if ( offset & mmap2_mask ) {
     errno = EINVAL;