1*0a6a1f1dSLionel Sambuc /* $NetBSD: fpgetround.c,v 1.7 2014/09/17 11:02:55 joerg Exp $ */ 22fe8fb19SBen Gras 32fe8fb19SBen Gras /* 42fe8fb19SBen Gras * Written by J.T. Conklin, Apr 11, 1995 52fe8fb19SBen Gras * Public domain. 62fe8fb19SBen Gras */ 72fe8fb19SBen Gras 82fe8fb19SBen Gras #include <sys/cdefs.h> 92fe8fb19SBen Gras #if defined(LIBC_SCCS) && !defined(lint) 10*0a6a1f1dSLionel Sambuc __RCSID("$NetBSD: fpgetround.c,v 1.7 2014/09/17 11:02:55 joerg Exp $"); 112fe8fb19SBen Gras #endif /* LIBC_SCCS and not lint */ 122fe8fb19SBen Gras 132fe8fb19SBen Gras #include "namespace.h" 142fe8fb19SBen Gras 152fe8fb19SBen Gras #include <ieeefp.h> 162fe8fb19SBen Gras 172fe8fb19SBen Gras #ifdef __weak_alias __weak_alias(fpgetround,_fpgetround)182fe8fb19SBen Gras__weak_alias(fpgetround,_fpgetround) 192fe8fb19SBen Gras #endif 202fe8fb19SBen Gras 212fe8fb19SBen Gras fp_rnd 22e415d488SLionel Sambuc fpgetround(void) 232fe8fb19SBen Gras { 24e415d488SLionel Sambuc fp_rnd x; 252fe8fb19SBen Gras 26*0a6a1f1dSLionel Sambuc __asm(".set push; .set noat; cfc1 %0,$31; .set pop" : "=r" (x)); 272fe8fb19SBen Gras return x & 0x03; 282fe8fb19SBen Gras } 29