| 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 <libm-alias-ldouble.h> |
| 9 | #include <machine/asm.h> |
| 10 | |
| 11 | ENTRY(__floorl) |
| 12 | fldt 8(%rsp) |
| 13 | |
| 14 | fnstenv -28(%rsp) /* store fpu environment */ |
| 15 | |
| 16 | /* We use here %edx although only the low 1 bits are defined. |
| 17 | But none of the operations should care and they are faster |
| 18 | than the 16 bit operations. */ |
| 19 | movl $0x400,%edx /* round towards -oo */ |
| 20 | orl -28(%rsp),%edx |
| 21 | andl $0xf7ff,%edx |
| 22 | movl %edx,-32(%rsp) |
| 23 | fldcw -32(%rsp) /* load modified control word */ |
| 24 | |
| 25 | frndint /* round */ |
| 26 | |
| 27 | /* Preserve "invalid" exceptions from sNaN input. */ |
| 28 | fnstsw |
| 29 | andl $0x1, %eax |
| 30 | orl %eax, -24(%rsp) |
| 31 | |
| 32 | fldenv -28(%rsp) /* restore original environment */ |
| 33 | |
| 34 | ret |
| 35 | END (__floorl) |
| 36 | libm_alias_ldouble (__floor, floor) |
| 37 | |