]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/msun/i387/s_trunc.S
Merge llvm-project release/18.x llvmorg-18-init-18361-g22683463740e
[FreeBSD/FreeBSD.git] / lib / msun / i387 / s_trunc.S
1 /*
2  * Based on code written by J.T. Conklin <jtc@NetBSD.org>.
3  * Public domain.
4  */
5
6 #include <machine/asm.h>
7 ENTRY(trunc)
8         pushl   %ebp
9         movl    %esp,%ebp
10         subl    $8,%esp
11
12         fstcw   -4(%ebp)                /* store fpu control word */
13         movw    -4(%ebp),%dx
14         orw     $0x0c00,%dx             /* round towards -oo */
15         movw    %dx,-8(%ebp)
16         fldcw   -8(%ebp)                /* load modified control word */
17
18         fldl    8(%ebp)                 /* round */
19         frndint
20
21         fldcw   -4(%ebp)                /* restore original control word */
22
23         leave
24         ret
25 END(trunc)
26
27         .section .note.GNU-stack,"",%progbits