Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Jun 2016 10:14:25 +0000 (UTC)
From:      "Andrey A. Chernov" <ache@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r301115 - head/lib/libc/stdlib
Message-ID:  <201606011014.u51AEPFX090427@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ache
Date: Wed Jun  1 10:14:25 2016
New Revision: 301115
URL: https://svnweb.freebsd.org/changeset/base/301115

Log:
  Don't use fixup for C99 and up, the compiler result is already correct.
  
  Suggested by: bde
  
  MFC after:      1 week

Modified:
  head/lib/libc/stdlib/div.c
  head/lib/libc/stdlib/imaxdiv.c
  head/lib/libc/stdlib/ldiv.c
  head/lib/libc/stdlib/lldiv.c

Modified: head/lib/libc/stdlib/div.c
==============================================================================
--- head/lib/libc/stdlib/div.c	Wed Jun  1 10:14:04 2016	(r301114)
+++ head/lib/libc/stdlib/div.c	Wed Jun  1 10:14:25 2016	(r301115)
@@ -46,6 +46,7 @@ div(num, denom)
 
 	r.quot = num / denom;
 	r.rem = num % denom;
+#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
 	/*
 	 * The ANSI standard says that |r.quot| <= |n/d|, where
 	 * n/d is to be computed in infinite precision.  In other
@@ -73,5 +74,6 @@ div(num, denom)
 		r.quot++;
 		r.rem -= denom;
 	}
+#endif
 	return (r);
 }

Modified: head/lib/libc/stdlib/imaxdiv.c
==============================================================================
--- head/lib/libc/stdlib/imaxdiv.c	Wed Jun  1 10:14:04 2016	(r301114)
+++ head/lib/libc/stdlib/imaxdiv.c	Wed Jun  1 10:14:25 2016	(r301115)
@@ -37,9 +37,11 @@ imaxdiv(intmax_t numer, intmax_t denom)
 
 	retval.quot = numer / denom;
 	retval.rem = numer % denom;
+#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
 	if (numer >= 0 && retval.rem < 0) {
 		retval.quot++;
 		retval.rem -= denom;
 	}
+#endif
 	return (retval);
 }

Modified: head/lib/libc/stdlib/ldiv.c
==============================================================================
--- head/lib/libc/stdlib/ldiv.c	Wed Jun  1 10:14:04 2016	(r301114)
+++ head/lib/libc/stdlib/ldiv.c	Wed Jun  1 10:14:25 2016	(r301115)
@@ -48,9 +48,11 @@ ldiv(num, denom)
 
 	r.quot = num / denom;
 	r.rem = num % denom;
+#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
 	if (num >= 0 && r.rem < 0) {
 		r.quot++;
 		r.rem -= denom;
 	}
+#endif
 	return (r);
 }

Modified: head/lib/libc/stdlib/lldiv.c
==============================================================================
--- head/lib/libc/stdlib/lldiv.c	Wed Jun  1 10:14:04 2016	(r301114)
+++ head/lib/libc/stdlib/lldiv.c	Wed Jun  1 10:14:25 2016	(r301115)
@@ -37,9 +37,11 @@ lldiv(long long numer, long long denom)
 
 	retval.quot = numer / denom;
 	retval.rem = numer % denom;
+#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
 	if (numer >= 0 && retval.rem < 0) {
 		retval.quot++;
 		retval.rem -= denom;
 	}
+#endif
 	return (retval);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201606011014.u51AEPFX090427>