1/*
2 * Written by J.T. Conklin <jtc@netbsd.org>.
3 * Changes for long double by Ulrich Drepper <drepper@cygnus.com>
4 * Changes for x86-64 by Andreas Jaeger <aj@suse.de>=09
5 * Public domain.
6 */
7
8#include <machine/asm.h>
9
10ENTRY(__floorl)
11 fldt 8(%rsp)
12
13 fnstenv -28(%rsp) /* store fpu environment */
14
15 /* We use here %edx although only the low 1 bits are defined.
16 But none of the operations should care and they are faster
17 than the 16 bit operations. */
18 movl $0x400,%edx /* round towards -oo */
19 orl -28(%rsp),%edx
20 andl $0xf7ff,%edx
21 movl %edx,-32(%rsp)
22 fldcw -32(%rsp) /* load modified control word */
23
24 frndint /* round */
25
26 /* Preserve "invalid" exceptions from sNaN input. */
27 fnstsw
28 andl $0x1, %eax
29 orl %eax, -24(%rsp)
30
31 fldenv -28(%rsp) /* restore original environment */
32
33 ret
34END (__floorl)
35weak_alias (__floorl, floorl)
36