2.9
[glibc/nacl-glibc.git] / sysdeps / unix / sysv / linux / s390 / s390-64 / mmap.S
blob443d432e1cc0c4b7b66e7990660763418a5b1ff8
1 /* Wrapper around mmap system call.  64 bit S/390 version.
2    Copyright (C) 2001 Free Software Foundation, Inc.
3    Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
4    This file is part of the GNU C Library.
6    The GNU C Library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
11    The GNU C Library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library; if not, write to the Free
18    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19    02111-1307 USA.  */
21 #include <sysdep.h>
23 #define EINVAL  22
25         .text
27 ENTRY(__mmap)
28         /* Save registers and setup stack frame.  */
29         stmg    %r6,%r15,48(%r15)
30         cfi_offset (%r15,-40)
31         cfi_offset (%r14,-48)
32         cfi_offset (%r13,-56)
33         cfi_offset (%r12,-64)
34         cfi_offset (%r11,-72)
35         cfi_offset (%r10,-80)
36         cfi_offset (%r9,-88)
37         cfi_offset (%r8,-96)
38         cfi_offset (%r7,-104)
39         cfi_offset (%r6,-112)
40         lgr     %r1,%r15
41         lg      %r0,8(%r15)             /* Load eos.  */
42         aghi    %r15,-208               /* Buy stack space.  */
43         cfi_adjust_cfa_offset (208)
44         stg     %r1,0(%r15)             /* Store back chain.  */
45         stg     %r0,8(%r15)             /* Store eos.  */
47         /* Store parameters on stack, because old_mmap 
48            takes only one parameter: a pointer to the parameter area.  */
49         mvc     200(8,%r15),368(%r15)   /* Move 'offset'.  */
50         lgfr    %r6,%r6
51         stg     %r6,192(%r15)           /* Store 'fd'.  */
52         lgfr    %r5,%r5
53         stg     %r5,184(%r15)           /* Store 'flags'.  */
54         lgfr    %r4,%r4
55         stg     %r4,176(%r15)           /* Store 'prot'.  */
56         stg     %r3,168(%r15)           /* Store 'length'.  */
57         stg     %r2,160(%r15)           /* Store 'start'.  */
59         la      %r2,160(%r15)           /* Load address of parameter list.  */
60         /* Do the system call trap.  */
61         svc     SYS_ify(mmap)
63         lg      %r15,0(%r15)            /* Load back chain.  */
64         cfi_adjust_cfa_offset (-208)
65         lmg     %r6,%r15,48(%r15)       /* Load registers.  */
67         /* Check gpr 2 for error.  */ 
68         lghi    %r0,-4096
69         clgr    %r2,%r0
70         jgnl    SYSCALL_ERROR_LABEL
72         /* Successful; return the syscall's value.  */
73         br      %r14
75 PSEUDO_END (__mmap)
77 weak_alias (__mmap, mmap)
78 weak_alias (__mmap, mmap64)
79 weak_alias (__mmap, __mmap64)