xref: /openbsd-src/lib/libc/arch/amd64/gen/fpgetround.S (revision 631951aab24dc7dce7719dfa2487185ea5ef120f)
1/*	$OpenBSD: fpgetround.S,v 1.3 2018/07/03 23:14:05 mortimer Exp $	*/
2/*	$NetBSD: fpgetround.S,v 1.3 2002/06/12 19:17:22 fvdl Exp $	*/
3
4/*
5 * Written by J.T. Conklin, Apr 4, 1995
6 * Public domain.
7 */
8
9#include <machine/asm.h>
10
11/*
12 * XXX store only x87 state. If an application only uses the fp*
13 * interface, this should be in sync with the SSE mxcsr register.
14 */
15
16#ifdef WEAK_ALIAS
17WEAK_ALIAS(fpgetround, _fpgetround)
18ENTRY(_fpgetround)
19#else
20ENTRY(fpgetround)
21#endif
22	RETGUARD_SETUP(fpgetround, r11)
23	fnstcw -4(%rsp)
24	movl -4(%rsp),%eax
25	rorl $10,%eax
26	andl $3,%eax
27	RETGUARD_CHECK(fpgetround, r11)
28	ret
29#ifdef WEAK_ALIAS
30END(_fpgetround)
31#else
32END(fpgetround)
33#endif
34