Synchronize on NetBSD-CVS (2013/12/1 12:00:00 UTC)

- Fix for possible unset uid/gid in toproto
 - Fix for default mtree style
 - Update libelf
 - Importing libexecinfo
 - Resynchronize GCC, mpc, gmp, mpfr
 - build.sh: Replace params with show-params.
     This has been done as the make target has been renamed in the same
     way, while a new target named params has been added. This new
     target generates a file containing all the parameters, instead of
     printing it on the console.
 - Update test48 with new etc/services (Fix by Ben Gras <ben@minix3.org)
     get getservbyport() out of the inner loop

Change-Id: Ie6ad5226fa2621ff9f0dee8782ea48f9443d2091
This commit is contained in:
2014-07-28 17:05:06 +02:00
parent ff10274392
commit 84d9c625bf
4655 changed files with 379308 additions and 151050 deletions
+15 -29
View File
@@ -1,4 +1,4 @@
/* $NetBSD: difftime.c,v 1.11 2012/03/20 16:39:08 matt Exp $ */
/* $NetBSD: difftime.c,v 1.15 2013/09/20 19:06:54 christos Exp $ */
/*
** This file is in the public domain, so clarified as of
@@ -10,45 +10,35 @@
#if 0
static char elsieid[] = "@(#)difftime.c 8.1";
#else
__RCSID("$NetBSD: difftime.c,v 1.11 2012/03/20 16:39:08 matt Exp $");
__RCSID("$NetBSD: difftime.c,v 1.15 2013/09/20 19:06:54 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
/*LINTLIBRARY*/
#include "private.h" /* for time_t, TYPE_INTEGRAL, and TYPE_SIGNED */
#include "private.h" /* for time_t and TYPE_SIGNED */
double
double ATTRIBUTE_CONST
difftime(const time_t time1, const time_t time0)
{
/*
** If (sizeof (double) > sizeof (time_t)) simply convert and subtract
** (assuming that the larger type has more precision).
** This is the common real-world case circa 2004.
*/
/* LINTED constant */
/*CONSTCOND*/
if (sizeof (double) > sizeof (time_t))
return (double) time1 - (double) time0;
/* LINTED constant */
if (!TYPE_INTEGRAL(time_t)) {
/*
** time_t is floating.
*/
return time1 - time0;
}
/* LINTED constant */
/*LINTED const not */
if (!TYPE_SIGNED(time_t)) {
/*
** time_t is integral and unsigned.
** The difference of two unsigned values can't overflow
** if the minuend is greater than or equal to the subtrahend.
*/
if (time1 >= time0)
return time1 - time0;
else return -((double) (time0 - time1));
return time1 - time0;
else return -(double) (time0 - time1);
}
/*
** time_t is integral and signed.
** Handle cases where both time1 and time0 have the same sign
** (meaning that their difference cannot overflow).
*/
@@ -56,21 +46,17 @@ difftime(const time_t time1, const time_t time0)
return time1 - time0;
/*
** time1 and time0 have opposite signs.
** Punt if unsigned long is too narrow.
** Punt if uintmax_t is too narrow.
** This suffers from double rounding; attempt to lessen that
** by using long double temporaries.
*/
/* CONSTCOND */
if (sizeof (unsigned long) < sizeof (time_t))
/* CONSTCOND */
if (sizeof (uintmax_t) < sizeof (time_t))
return (double) time1 - (double) time0;
/*
** Stay calm...decent optimizers will eliminate the complexity below.
*/
if (time1 >= 0 /* && time0 < 0 */)
return (unsigned long) time1 +
(unsigned long) (-(time0 + 1)) + 1;
return -(double) ((unsigned long) time0 +
(unsigned long) (-(time1 + 1)) + 1);
return (uintmax_t) time1 + (uintmax_t) (-(time0 + 1)) + 1;
return -(double) ((uintmax_t) time0 + (uintmax_t) (-(time1 + 1)) + 1);
}
#if defined(__minix) && defined(__weak_alias)
__weak_alias(difftime, __difftime50)
#endif