Move all files into ports/ subdirectory in preparation for merge with glibc
[glibc.git] / ports / sysdeps / unix / sysv / linux / arm / mmap64.S
blobbe4dd52de49d829ed553ce82a8c07066b976bd48
1 /* Copyright (C) 2000, 2003, 2005, 2009 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
4    The GNU C Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Lesser General Public
6    License as published by the Free Software Foundation; either
7    version 2.1 of the License, or (at your option) any later version.
9    The GNU C Library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Lesser General Public License for more details.
14    You should have received a copy of the GNU Lesser General Public
15    License along with the GNU C Library.  If not, see
16    <http://www.gnu.org/licenses/>.  */
18 #include <sysdep.h>
20 #define EINVAL          22
22 #ifdef __ARMEB__
23 # define LOW_OFFSET      8 + 4
24 /* The initial + 4 is for the stack postdecrement.  */
25 # define HIGH_OFFSET 4 + 8 + 0
26 #else
27 # define LOW_OFFSET      8 + 0
28 # define HIGH_OFFSET 4 + 8 + 4
29 #endif
31         /* The mmap2 system call takes six arguments, all in registers.  */
32         .text
33 ENTRY (__mmap64)
34         ldr     ip, [sp, $LOW_OFFSET]
35         str     r5, [sp, #-4]!
36         cfi_adjust_cfa_offset (4)
37         cfi_rel_offset (r5, 0)
38         ldr     r5, [sp, $HIGH_OFFSET]
39         str     r4, [sp, #-4]!
40         cfi_adjust_cfa_offset (4)
41         cfi_rel_offset (r4, 0)
42         cfi_remember_state
43         movs    r4, ip, lsl $20         @ check that offset is page-aligned
44         mov     ip, ip, lsr $12
45         moveqs  r4, r5, lsr $12         @ check for overflow
46         bne     .Linval
47         ldr     r4, [sp, $8]            @ load fd
48         orr     r5, ip, r5, lsl $20     @ compose page offset
49         DO_CALL (mmap2, 0)
50         cmn     r0, $4096
51         ldmfd   sp!, {r4, r5}
52         cfi_adjust_cfa_offset (-8)
53         cfi_restore (r4)
54         cfi_restore (r5)
55         RETINSTR(cc, lr)
56         b       PLTJMP(syscall_error)
58         cfi_restore_state
59 .Linval:
60         mov     r0, $-EINVAL
61         ldmfd   sp!, {r4, r5}
62         cfi_adjust_cfa_offset (-8)
63         cfi_restore (r4)
64         cfi_restore (r5)
65         b       PLTJMP(syscall_error)
66 PSEUDO_END (__mmap64)
68 weak_alias (__mmap64, mmap64)