1 1.4 danw /* $NetBSD: flt_rounds.c,v 1.4 1999/07/07 01:53:38 danw Exp $ */ 2 1.2 mycroft 3 1.2 mycroft #include <float.h> 4 1.1 thorpej 5 1.1 thorpej static const int map[] = { 6 1.1 thorpej 1, /* round to nearest */ 7 1.1 thorpej 0, /* round to zero */ 8 1.1 thorpej 2, /* round to positive infinity */ 9 1.1 thorpej 3 /* round to negative infinity */ 10 1.1 thorpej }; 11 1.1 thorpej 12 1.1 thorpej int 13 1.1 thorpej __flt_rounds() 14 1.1 thorpej { 15 1.1 thorpej double tmp; 16 1.1 thorpej int x; 17 1.1 thorpej 18 1.4 danw __asm__ __volatile("mffs %0; stfiwx %0,0,%1" : "=f"(tmp): "b"(&x)); 19 1.1 thorpej return map[x & 0x03]; 20 1.1 thorpej } 21