-/* 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. */
cmn r0, $4096
RETINSTR(movcc, pc, lr)
b PLTJMP(syscall_error);
+#endif
PSEUDO_END (__mmap)