xref: /openbsd/lib/libc/arch/amd64/gen/fpgetround.S (revision fc61954a)
1/*	$OpenBSD: fpgetround.S,v 1.2 2015/05/29 08:50:12 uebayasi 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	fnstcw -4(%rsp)
23	movl -4(%rsp),%eax
24	rorl $10,%eax
25	andl $3,%eax
26	ret
27#ifdef WEAK_ALIAS
28END(_fpgetround)
29#else
30END(fpgetround)
31#endif
32