xref: /openbsd-src/lib/libc/arch/amd64/gen/flt_rounds.S (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
1/*	$OpenBSD: flt_rounds.S,v 1.6 2015/11/14 21:53:03 guenther Exp $	*/
2/*	$NetBSD: flt_rounds.S,v 1.2 2002/06/06 23:04:35 fvdl Exp $	*/
3
4/*
5 * Written by J.T. Conklin, Apr 4, 1995
6 * Public domain.
7 */
8
9#include "DEFS.h"
10
11	.text
12	_ALIGN_TEXT
13_map:
14	.byte 1		/* round to nearest */
15	.byte 3		/* round to negative infinity */
16	.byte 2		/* round to positive infinity */
17	.byte 0		/* round to zero */
18
19ENTRY(__flt_rounds)
20	fnstcw -4(%rsp)
21	movl -4(%rsp),%eax
22	shrl $10,%eax
23	andl $3,%eax
24#ifdef __PIC__
25	leaq _map(%rip),%rcx
26	movb (%rcx,%rax,1),%al
27#else
28	movb _map(,%rax,1),%al
29#endif
30	ret
31END_STRONG(__flt_rounds)
32