From d30e39112d769aa6115ae23e101b1cba8bb104ff Mon Sep 17 00:00:00 2001 From: martin Date: Sun, 16 Mar 2014 09:51:39 +0000 Subject: [PATCH] Provide all missing variants of trunc/floor/ceil. --- lib/libm/noieee_src/n_floor.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/libm/noieee_src/n_floor.c b/lib/libm/noieee_src/n_floor.c index 2299aeb982a4..73debb3863eb 100644 --- a/lib/libm/noieee_src/n_floor.c +++ b/lib/libm/noieee_src/n_floor.c @@ -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) /* 2**52 */ #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); +}