]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/LibC/Main/Ipf/flt_rounds.c
Standard Libraries for EDK II.
[mirror_edk2.git] / StdLib / LibC / Main / Ipf / flt_rounds.c
diff --git a/StdLib/LibC/Main/Ipf/flt_rounds.c b/StdLib/LibC/Main/Ipf/flt_rounds.c
new file mode 100644 (file)
index 0000000..0a18bb7
--- /dev/null
@@ -0,0 +1,25 @@
+/*\r
+ * Written by J.T. Conklin, Apr 10, 1995\r
+ * Public domain.\r
+ */\r
+\r
+#include <sys/EfiCdefs.h>\r
+/* __FBSDID("$FreeBSD: src/lib/libc/ia64/gen/flt_rounds.c,v 1.1 2004/07/19 08:17:24 das Exp $"); */\r
+\r
+#include <float.h>\r
+\r
+static const int map[] = {\r
+       1,      /* round to nearest */\r
+       3,      /* round to zero */\r
+       2,      /* round to negative infinity */\r
+       0       /* round to positive infinity */\r
+};\r
+\r
+int\r
+__flt_rounds(void)\r
+{\r
+       int x;\r
+\r
+       __asm("mov %0=ar.fpsr" : "=r" (x));\r
+        return (map[(x >> 10) & 0x03]);\r
+}\r