Bring in FreeBSD's msun code for our libm.
[dragonfly.git] / lib / libm / i386 / s_trunc.S
1 /*
2  * Based on code written by J.T. Conklin <jtc@NetBSD.org>.
3  * Public domain.
4  *
5  * $FreeBSD: head/lib/msun/i387/s_trunc.S 217108 2011-01-07 16:13:12Z kib $
6  */
7
8 #include <machine/asm.h>
9
10 ENTRY(trunc)
11         pushl   %ebp
12         movl    %esp,%ebp
13         subl    $8,%esp
14
15         fstcw   -4(%ebp)                /* store fpu control word */
16         movw    -4(%ebp),%dx
17         orw     $0x0c00,%dx             /* round towards -oo */
18         movw    %dx,-8(%ebp)
19         fldcw   -8(%ebp)                /* load modfied control word */
20
21         fldl    8(%ebp)                 /* round */
22         frndint
23
24         fldcw   -4(%ebp)                /* restore original control word */
25
26         leave
27         ret
28 END(trunc)
29
30         .section .note.GNU-stack,"",%progbits