svn commit: trunk/uClibc/libc/sysdeps/linux: bfin common
vapier at uclibc.org
vapier at uclibc.org
Sat Jan 5 02:40:03 PST 2008
Author: vapier
Date: 2008-01-05 02:40:03 -0800 (Sat, 05 Jan 2008)
New Revision: 20729
Log:
if an arch does not provide __NR_mmap, fall back to __NR_mmap2 (this just generalizes what Blackfin was already doing)
Removed:
trunk/uClibc/libc/sysdeps/linux/bfin/mmap.c
Modified:
trunk/uClibc/libc/sysdeps/linux/bfin/Makefile.arch
trunk/uClibc/libc/sysdeps/linux/common/mmap.c
Changeset:
Modified: trunk/uClibc/libc/sysdeps/linux/bfin/Makefile.arch
===================================================================
--- trunk/uClibc/libc/sysdeps/linux/bfin/Makefile.arch 2008-01-05 10:05:27 UTC (rev 20728)
+++ trunk/uClibc/libc/sysdeps/linux/bfin/Makefile.arch 2008-01-05 10:40:03 UTC (rev 20729)
@@ -5,7 +5,7 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-CSRC := brk.c bsdsetjmp.c clone.c syscall.c mmap.c
+CSRC := brk.c bsdsetjmp.c clone.c syscall.c
SSRC := __longjmp.S setjmp.S bsd-_setjmp.S vfork.S
Deleted: trunk/uClibc/libc/sysdeps/linux/bfin/mmap.c
===================================================================
--- trunk/uClibc/libc/sysdeps/linux/bfin/mmap.c 2008-01-05 10:05:27 UTC (rev 20728)
+++ trunk/uClibc/libc/sysdeps/linux/bfin/mmap.c 2008-01-05 10:40:03 UTC (rev 20729)
@@ -1,24 +0,0 @@
-/* Use new style mmap for bfin */
-
-#include <unistd.h>
-#include <errno.h>
-#include <sys/mman.h>
-#include <sys/syscall.h>
-#include <asm/page.h>
-
-#define __NR___syscall_mmap2 __NR_mmap2
-inline _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr,
- size_t, len, int, prot, int, flags, int, fd, off_t, offset);
-
-libc_hidden_proto(mmap)
-
-__ptr_t mmap(__ptr_t addr, size_t len, int prot,
- int flags, int fd, __off_t offset)
-{
- if (offset & ~PAGE_MASK) {
- return NULL;
- }
- return __syscall_mmap2(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
-}
-
-libc_hidden_def(mmap)
Modified: trunk/uClibc/libc/sysdeps/linux/common/mmap.c
===================================================================
--- trunk/uClibc/libc/sysdeps/linux/common/mmap.c 2008-01-05 10:05:27 UTC (rev 20728)
+++ trunk/uClibc/libc/sysdeps/linux/common/mmap.c 2008-01-05 10:40:03 UTC (rev 20729)
@@ -10,6 +10,7 @@
#include <sys/syscall.h>
#include <unistd.h>
#include <sys/mman.h>
+#include <bits/uClibc_page.h>
#ifdef __NR_mmap
@@ -41,4 +42,32 @@
#endif
libc_hidden_def(mmap)
+
+#elif defined(__NR_mmap2)
+
+libc_hidden_proto(mmap)
+
+#define __NR___syscall_mmap2 __NR_mmap2
+static inline _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr,
+ size_t, len, int, prot, int, flags, int, fd, off_t, offset);
+
+/* Some architectures always use 12 as page shift for mmap2() eventhough the
+ * real PAGE_SHIFT != 12. Other architectures use the same value as
+ * PAGE_SHIFT...
+ */
+# ifndef MMAP2_PAGE_SHIFT
+# define MMAP2_PAGE_SHIFT 12
+# endif
+
+__ptr_t mmap(__ptr_t addr, size_t len, int prot, int flags, int fd, __off_t offset)
+{
+ if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1)) {
+ __set_errno(EINVAL);
+ return MAP_FAILED;
+ }
+ return __syscall_mmap2(addr, len, prot, flags, fd, offset >> MMAP2_PAGE_SHIFT);
+}
+
+libc_hidden_def(mmap)
+
#endif
More information about the uClibc-cvs
mailing list