summaryrefslogtreecommitdiffstats
path: root/lib/libc/arch/amd64/gen/flt_rounds.S
blob: 2830a1707b995d29f48843af566bfb7edc6259c0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*	$OpenBSD: flt_rounds.S,v 1.8 2018/07/03 23:14:05 mortimer Exp $	*/
/*	$NetBSD: flt_rounds.S,v 1.2 2002/06/06 23:04:35 fvdl Exp $	*/

/*
 * Written by J.T. Conklin, Apr 4, 1995
 * Public domain.
 */

#include "DEFS.h"

	.section .rodata
_map:
	.byte 1		/* round to nearest */
	.byte 3		/* round to negative infinity */
	.byte 2		/* round to positive infinity */
	.byte 0		/* round to zero */

ENTRY(__flt_rounds)
	RETGUARD_SETUP(__flt_rounds, r11)
	fnstcw -4(%rsp)
	movl -4(%rsp),%eax
	shrl $10,%eax
	andl $3,%eax
#ifdef __PIC__
	leaq _map(%rip),%rcx
	movb (%rcx,%rax,1),%al
#else
	movb _map(,%rax,1),%al
#endif
	RETGUARD_CHECK(__flt_rounds, r11)
	ret
END_STRONG(__flt_rounds)