Module Name: src
Committed By: martin
Date: Sun Mar 16 09:51:39 UTC 2014
Modified Files:
src/lib/libm/noieee_src: n_floor.c
Log Message:
Provide all missing variants of trunc/floor/ceil.
To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libm/noieee_src/n_floor.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libm/noieee_src/n_floor.c
diff -u src/lib/libm/noieee_src/n_floor.c:1.7 src/lib/libm/noieee_src/n_floor.c:1.8
--- src/lib/libm/noieee_src/n_floor.c:1.7 Thu Dec 9 22:52:59 2010
+++ src/lib/libm/noieee_src/n_floor.c Sun Mar 16 09:51:39 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: n_floor.c,v 1.7 2010/12/09 22:52:59 abs Exp $ */
+/* $NetBSD: n_floor.c,v 1.8 2014/03/16 09:51:39 martin Exp $ */
/*
* Copyright (c) 1985, 1993
* The Regents of the University of California. All rights reserved.
@@ -45,6 +45,12 @@ ic(L, 4503599627370496.0E0, 52, 1.0)
#define L vccast(L)
#endif
+#ifdef __weak_alias
+__weak_alias(ceill, ceil);
+__weak_alias(floorl, floor);
+__weak_alias(truncl, trunc);
+#endif
+
/*
* floor(x) := the largest integer no larger than x;
* ceil(x) := -floor(-x), for all real x.
@@ -216,3 +222,15 @@ llrintf(float x)
t = x + s; /* x+s rounded to integer */
return (t - s);
}
+
+double
+trunc(double x)
+{
+ return x < 0 ? ceil(x) : floor(x);
+}
+
+float
+truncf(float x)
+{
+ return x < 0 ? ceilf(x) : floorf(x);
+}