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