Use sys_mmap2 if it's known to be available.
authorUlrich Drepper <drepper@redhat.com>
Sun, 14 Sep 2003 19:54:40 +0000 (19:54 +0000)
committerUlrich Drepper <drepper@redhat.com>
Sun, 14 Sep 2003 19:54:40 +0000 (19:54 +0000)
sysdeps/unix/sysv/linux/arm/mmap.S

index af93c7b..7beba68 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2000, 2003 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
    02111-1307 USA.  */
 
 #include <sysdep.h>
+#include <kernel-features.h>
+
+#define        EINVAL          22
 
        .text
 
 ENTRY (__mmap)
+# ifdef __ASSUME_MMAP2_SYSCALL
+       /* This code is actually a couple of cycles slower than the
+          sys_mmap version below, so it might seem like a loss.  But the
+          code path inside the kernel is sufficiently much shorter to
+          make it a net gain to use mmap2 when it's known to be
+          available.  */
+
+       /* shuffle args */
+       str     r5, [sp, #-4]!
+       ldr     r5, [sp, #8]
+       str     r4, [sp, #-4]!
+       ldr     r4, [sp, #8]
+
+       /* convert offset to pages */
+       movs    ip, r5, lsl #20
+       bne     .Linval
+       mov     r5, r5, lsr #12
+       
+       /* do the syscall */
+       swi     SYS_ify (mmap2)
+
+       /* restore registers */
+2:
+       ldr     r4, [sp], #4
+       ldr     r5, [sp], #4
+
+       cmn     r0, $4096
+       RETINSTR(movcc, pc, lr)
+       b       PLTJMP(syscall_error)
 
+.Linval:
+       mov     r0, #-EINVAL
+       b       2b
+# else
        /* Because we can only get five args through the syscall interface, and
           mmap() takes six, we need to build a parameter block and pass its
           address instead.  The 386 port does a similar trick.  */
@@ -49,6 +85,7 @@ ENTRY (__mmap)
        cmn     r0, $4096
        RETINSTR(movcc, pc, lr)
        b       PLTJMP(syscall_error);
+#endif
 
 PSEUDO_END (__mmap)