[uClibc-cvs] uClibc/libc/sysdeps/linux/common mmap64.c,1.4,1.5

Erik Andersen andersen at uclibc.org
Fri Jun 27 08:05:43 UTC 2003


Update of /var/cvs/uClibc/libc/sysdeps/linux/common
In directory winder:/tmp/cvs-serv24566

Modified Files:
	mmap64.c 
Log Message:
Actually, some arches do support _syscall6, so implement a generic version
for them...
 -Erik


Index: mmap64.c
===================================================================
RCS file: /var/cvs/uClibc/libc/sysdeps/linux/common/mmap64.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- mmap64.c	27 Jun 2003 07:49:25 -0000	1.4
+++ mmap64.c	27 Jun 2003 08:05:40 -0000	1.5
@@ -17,17 +17,13 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
+/* Massivly hacked up for uClibc by Erik Andersen */
+
 #include <errno.h>
 #include <unistd.h>
 #include <sysdep.h>
 #include <sys/mman.h>
 
-/* Massivly hackd up for uClibc by Erik Andersen
- * 
- * This version is a stub that just chops off everything at the mmap 32 bit
- * mmap() address space...  You need to add in an arch specific implementation
- * to override this as there is not a generic way for me to implement this
- * particular syscall. */
 
 #if defined __UCLIBC_HAS_LFS__
 
@@ -44,7 +40,17 @@
 # undef __USE_FILE_OFFSET64
 #endif
 
-#undef	creat
+
+#if ! defined __NR_mmap2 || ! defined _syscall6
+
+/* 
+ * This version is a stub that just chops off everything at the mmap 32 bit
+ * mmap() address space...  You will probably need to add in an arch specific
+ * implementation to override this as there is not a generic way for me to
+ * implement this particular syscall if your arch lacks _syscall6...
+ *
+*/
+
 __ptr_t mmap64(__ptr_t addr, size_t len, int prot, int flags, int fd, __off64_t offset)
 {
     if (offset != (off_t) offset || (offset + len) != (off_t) (offset + len))
@@ -55,5 +61,28 @@
 
     return mmap (addr, len, prot, flags, fd, (off_t) offset);
 }
+
+#else
+
+#define __NR___syscall_mmap2	    __NR_mmap2
+static inline _syscall6(void *, __syscall_mmap2, void *, addr, 
+	size_t len, int, prot, int, flags, int, fd, off_t, offset);
+
+/* This is always 12, even on architectures where PAGE_SHIFT != 12.  */
+# ifndef MMAP2_PAGE_SHIFT
+#  define MMAP2_PAGE_SHIFT 12
+# endif
+
+void * __mmap64 (void *addr, size_t len, int prot, int flags, int fd, off64_t offset)
+{
+    void *result;
+    if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1)) {
+	__set_errno (EINVAL);
+	return MAP_FAILED;
+    }
+    return(__syscall_mmap2(addr, len, prot, flags, fd, (off_t) (offset >> MMAP2_PAGE_SHIFT)));
+}
+
+#endif
 #endif /* __UCLIBC_HAS_LFS__ */
 



More information about the uClibc-cvs mailing list