summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2015-04-09 14:20:34 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2015-04-09 14:20:34 +0000
commitd7030445278011b7fde64da88a99b778681d4a9f (patch)
treeef312b9237d9f9786ca415c7b0991a34dec57dd0
parente29104484ade68f538a28cb13eaeb279d5f10311 (diff)
parent5e997ea720d9d091fa875d959e0d87e2cb641f5b (diff)
downloadmpfr-d7030445278011b7fde64da88a99b778681d4a9f.tar.gz
Merged the latest changes from the trunk.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/new-sum@9365 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--doc/README.dev15
-rw-r--r--src/next.c6
-rw-r--r--src/sub1sp.c15
-rwxr-xr-xtools/ck-copyright-notice32
4 files changed, 49 insertions, 19 deletions
diff --git a/doc/README.dev b/doc/README.dev
index bebdd3bb4..067423f99 100644
--- a/doc/README.dev
+++ b/doc/README.dev
@@ -504,6 +504,21 @@ Quoted from <http://www.gnu.org/software/gcc/codingconventions.html>:
C-Reduce may be useful to try to identify whether a bug comes from the
compiler.
+ =====================================================================
+
+To do type punning (i.e. store a value of some type and reinterpret
+it as another type), use a union. This is valid in ISO C99 and above
+(in C99, see 6.5#7 and Note 82 of 6.5.2.3#3 for the clarification),
+but not in C++. So, users of a C++ compilers should make sure that
+their compiler supports type punning via a union. If some problem is
+reported, we should address it either by making the code compatible
+or by adding a configure test to reject the compiler.
+
+Some references:
+* https://en.wikipedia.org/wiki/Type_punning#Use_of_union
+* http://stackoverflow.com/questions/346622/opinions-on-type-punning-in-c
+ "Opinions on type-punning in C++?"
+
===========================================================================
Avoid variable names "l", "I" and "O", which look like "1" and "0" with
diff --git a/src/next.c b/src/next.c
index 0a36084f4..8703fa8e5 100644
--- a/src/next.c
+++ b/src/next.c
@@ -57,11 +57,9 @@ mpfr_nexttozero (mpfr_ptr x)
MPFR_SET_ZERO(x);
else
{
- mp_size_t i;
MPFR_SET_EXP (x, exp - 1);
- xp[0] = MPFR_LIMB_MAX << sh;
- for (i = 1; i < xn; i++)
- xp[i] = MPFR_LIMB_MAX;
+ /* The following is valid whether xn = 1 or xn > 1. */
+ xp[xn-1] |= MPFR_LIMB_HIGHBIT;
}
}
}
diff --git a/src/sub1sp.c b/src/sub1sp.c
index 5e4703b9b..d8f6e7513 100644
--- a/src/sub1sp.c
+++ b/src/sub1sp.c
@@ -694,7 +694,9 @@ mpfr_sub1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode)
{
/* ap was a power of 2, and we lose a bit */
/* Now it is 0111111111111111111[00000 */
- mpn_lshift(ap, ap, n, 1);
+ /* The following 2 lines are equivalent to: mpn_lshift(ap, ap, n, 1); */
+ ap[0] <<= 1;
+ ap[n-1] |= MPFR_LIMB_HIGHBIT;
bx--;
/* And the lost bit x depends on Cp+1, and Cp */
/* Compute Cp+1 if it isn't already compute (ie d==1) */
@@ -742,10 +744,10 @@ mpfr_sub1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode)
if (MPFR_UNLIKELY(ap[n-1] == MPFR_LIMB_HIGHBIT))
{
mp_size_t k = n-1;
- do {
+ do
k--;
- } while (k>=0 && ap[k]==0);
- if (MPFR_UNLIKELY(k<0))
+ while (k >= 0 && ap[k] == 0);
+ if (MPFR_UNLIKELY (k < 0))
{
/* It is a power of 2! */
/* Compute Cp+1 if it isn't already compute (ie d==1) */
@@ -763,11 +765,10 @@ mpfr_sub1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mpfr_rnd_t rnd_mode)
{
DEBUG( printf("(Truncate) Do sub\n") );
mpn_sub_1 (ap, ap, n, MPFR_LIMB_ONE << sh);
- mpn_lshift(ap, ap, n, 1);
- ap[0] |= MPFR_LIMB_ONE<<sh;
+ ap[n-1] |= MPFR_LIMB_HIGHBIT;
bx--;
/* FIXME: Explain why it works (or why not)... */
- inexact = (bcp1 == 0) ? 0 : (rnd_mode==MPFR_RNDN) ? -1 : 1;
+ inexact = (bcp1 == 0) ? 0 : (rnd_mode == MPFR_RNDN) ? -1 : 1;
goto end_of_sub;
}
}
diff --git a/tools/ck-copyright-notice b/tools/ck-copyright-notice
index c4caae1df..064698bb6 100755
--- a/tools/ck-copyright-notice
+++ b/tools/ck-copyright-notice
@@ -11,25 +11,41 @@
# PARTICULAR PURPOSE.
# ck-copyright-notice can be run from the tools directory
-dir=`pwd`
-[ -d src ] || [ "`basename "$dir"`" != tools ] || cd ..
+dir=$(pwd)
+[ -d src ] || [ "$(basename "$dir")" != tools ] || cd ..
+
+err=0
# Note: if paragraphs are reformatted, this may need to be updated.
-lgpl="`sed -n '/version [0-9.]* or any later version/ {
+yrx="\([0-9][0-9][0-9][0-9]\)"
+
+lgpl=$(sed -n "/version [0-9.]* or any later version/ {
s/.*version //
s/ or.*//
p
q
- }' doc/mpfr.texi`"
+ }" doc/mpfr.texi)
+
+clyr=$(sed -n "/^r/ {
+ s/.* | $yrx-.*/\1/p
+ q
+ }" ChangeLog)
# Do not use "find ... | while read file do ... done" because the "do"
# part needs to be run in the current shell, and some shells behave in
# a different way.
-srctests=`find src tests -name '*.[ch]'`
+srctests=$(find examples src tests -name '*.[ch]')
-err=0
-for file in $srctests
+# Take the copyright notice last year of NEWS file as a reference.
+z=$(sed -n "s/^Copyright 2000-$yrx Free Software Foundation.*/\1/p" NEWS)
+
+if [ $z -lt $clyr ]; then
+ echo "The copyright year of NEWS is out-of-date."
+ err=1
+fi
+
+for file in $srctests BUGS INSTALL README TODO configure.ac
do
y=""
case $file in
@@ -47,7 +63,7 @@ do
*/mparam.h)
y="2005-" ;;
esac
- grep -q "Copyright $y.* Free Software Foundation" "$file" && \
+ grep -q "Copyright $y.*$z Free Software Foundation" "$file" && \
grep -q "GNU MPFR Library" "$file" && \
grep -q "either version $lgpl of the License" "$file" && continue
echo "Possibly missing or incorrect copyright notice in $file"