(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[glibc.git] / sysdeps / unix / sysv / linux / i386 / posix_fadvise64.S
blob99a3ea536d1a630656e41de419e29f1d6122d342
1 /* Copyright (C) 1995-2000,2002,2003,2004 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, write to the Free
16    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17    02111-1307 USA.  */
19 #include <sysdep.h>
20 #include <bp-sym.h>
21 #include <bp-asm.h>
23 #include "kernel-features.h"
25 #define EINVAL  22
26 #define ENOSYS  38
27 #define EOVERFLOW 75
29 #define SVRSP   16              /* saved register space */
30 #define PARMS   LINKAGE+SVRSP   /* space for 4 saved regs */
31 #define FD      PARMS
32 #define OFFLO   FD+4
33 #define OFFHI   OFFLO+4
34 #define LENLO   OFFHI+4
35 #define LENHI   LENLO+4
36 #define FLAGS   LENHI+4
38         .text
39 ENTRY (BP_SYM (__posix_fadvise64_l64))
41 #ifdef __NR_fadvise64_64
43         /* Save registers.  */
44         pushl   %ebp
45         pushl   %ebx
46         pushl   %esi
47         pushl   %edi
49         movl    FD(%esp), %ebx
50         movl    OFFLO(%esp), %ecx
51         movl    OFFHI(%esp), %edx
52         movl    LENLO(%esp), %esi
53         movl    LENHI(%esp), %edi
54         movl    FLAGS(%esp), %ebp
56         movl    $SYS_ify(fadvise64_64), %eax
57         ENTER_KERNEL
59         /* Restore registers.  */
60         popl    %edi
61         popl    %esi
62         popl    %ebx
63         popl    %ebp
65 #ifndef __ASSUME_FADVISE64_64_SYSCALL
66         cmpl    $-ENOSYS, %eax
67         je      1f
68 #endif
70         /* The function returns zero, or the error number.  So all we
71            have to do is negate the value passed back from the kernel.  */
72         /* If 0 > %eax > -4096 there was an error.  */
73         negl    %eax
75         /* Successful; return the syscall's value.  */
76         ret
77 #endif
79 #if defined __NR_fadvise64 \
80     && (!defined __ASSUME_FADVISE64_64_SYSCALL || !defined __NR_fadvise64_64)
81 1:      /* Save registers.  */
82         pushl   %ebx
83         pushl   %esi
84         pushl   %edi
86         /* Overflow check.  */
87         cmpl    $0, LENHI(%esp)
88         movl    $-EOVERFLOW, %eax
89         jne     L(overflow)
91         movl    FD(%esp), %ebx
92         movl    OFFLO(%esp), %ecx
93         movl    OFFHI(%esp), %edx
94         movl    LENLO(%esp), %esi
95         movl    FLAGS(%esp), %edi
97         movl    $SYS_ify(fadvise64), %eax
98         ENTER_KERNEL
100         /* Restore registers.  */
101 L(overflow):
102         popl    %edi
103         popl    %esi
104         popl    %ebx
106         /* If 0 > %eax > -4096 there was an error.  */
107         negl    %eax
109         /* Successful; return the syscall's value.  */
110         ret
111 #else
112         movl    $ENOSYS, %eax
113         ret
114 #endif
116 END (BP_SYM (__posix_fadvise64_l64))
118 #ifdef __NR_fadvise64
119         .section        .text.compat, "ax"
120 ENTRY (__posix_fadvise64_l32)
121         DO_CALL (fadvise64, 5)
122         negl %eax
123         ret
124 PSEUDO_END_ERRVAL (__posix_fadvise64_l32)
125 #else
126 ENTRY (BP_SYM (__posix_fadvise64_l32))
127         movl    $ENOSYS, %eax
128         ret
129 END (BP_SYM (__posix_fadvise64_l32))
130 #endif
132 default_symbol_version (__posix_fadvise64_l64, posix_fadvise64, GLIBC_2.3.3)
133 symbol_version (__posix_fadvise64_l32, posix_fadvise64, GLIBC_2.2)