]>
Commit | Line | Data |
---|---|---|
a334319f | 1 | /* Copyright (C) 1995,96,97,98,99,2000,2002 Free Software Foundation, Inc. |
ae1025be | 2 | This file is part of the GNU C Library. |
28f540f4 | 3 | |
ae1025be | 4 | The GNU C Library is free software; you can redistribute it and/or |
41bdb6e2 AJ |
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. | |
28f540f4 | 8 | |
ae1025be UD |
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 | |
41bdb6e2 | 12 | Lesser General Public License for more details. |
28f540f4 | 13 | |
41bdb6e2 AJ |
14 | You should have received a copy of the GNU Lesser General Public |
15 | License along with the GNU C Library; if not, write to the Free | |
16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
17 | 02111-1307 USA. */ | |
28f540f4 RM |
18 | |
19 | #include <sysdep.h> | |
20 | ||
a334319f | 21 | #include "kernel-features.h" |
d587d83b UD |
22 | |
23 | #define EINVAL 22 | |
24 | ||
c14e4c32 | 25 | .text |
d2f5be2a UD |
26 | |
27 | ENTRY (__mmap) | |
28 | ||
a334319f | 29 | /* I don't think it is worthwhile trzing to use mmap2 whenever it |
d587d83b UD |
30 | is available. Only use it when we are sure the syscall exists. */ |
31 | #ifdef __ASSUME_MMAP2_SYSCALL | |
32 | ||
33 | /* Save registers. */ | |
34 | pushl %ebp | |
35 | pushl %ebx | |
36 | pushl %esi | |
37 | pushl %edi | |
38 | ||
d587d83b UD |
39 | movl 20(%esp), %ebx |
40 | movl 24(%esp), %ecx | |
41 | movl 28(%esp), %edx | |
42 | movl 32(%esp), %esi | |
43 | movl 36(%esp), %edi | |
44 | movl 40(%esp), %ebp | |
b0af120f | 45 | testl $0xfff, %ebp |
29b3c4f2 UD |
46 | movl $-EINVAL, %eax |
47 | jne L(skip) | |
d587d83b UD |
48 | shrl $12, %ebp /* mmap2 takes the offset in pages. */ |
49 | ||
29b3c4f2 UD |
50 | movl $SYS_ify(mmap2), %eax /* System call number in %eax. */ |
51 | ||
d587d83b | 52 | /* Do the system call trap. */ |
f051627f | 53 | ENTER_KERNEL |
29b3c4f2 | 54 | L(skip): |
d587d83b UD |
55 | /* Restore registers. */ |
56 | popl %edi | |
57 | popl %esi | |
58 | popl %ebx | |
59 | popl %ebp | |
60 | ||
61 | #else | |
62 | ||
d2f5be2a UD |
63 | /* Save registers. */ |
64 | movl %ebx, %edx | |
65 | ||
66 | movl $SYS_ify(mmap), %eax /* System call number in %eax. */ | |
67 | ||
68 | lea 4(%esp), %ebx /* Address of args is 1st arg. */ | |
69 | ||
ae1025be | 70 | /* Do the system call trap. */ |
d2f5be2a UD |
71 | int $0x80 |
72 | ||
73 | /* Restore registers. */ | |
74 | movl %edx, %ebx | |
75 | ||
d587d83b UD |
76 | #endif |
77 | ||
57ba7bb4 UD |
78 | /* If 0 > %eax > -4096 there was an error. */ |
79 | cmpl $-4096, %eax | |
c0fb8a56 | 80 | ja SYSCALL_ERROR_LABEL |
d2f5be2a UD |
81 | |
82 | /* Successful; return the syscall's value. */ | |
8fb3e007 | 83 | L(pseudo_end): |
d2f5be2a | 84 | ret |
6ed0492f UD |
85 | |
86 | PSEUDO_END (__mmap) | |
d2f5be2a UD |
87 | |
88 | weak_alias (__mmap, mmap) |