From patchwork Mon May 23 22:18:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. Murphy" X-Patchwork-Id: 625420 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rDCcl1ZWtz9t0r for ; Tue, 24 May 2016 08:19:03 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=fdyPED3E; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references:in-reply-to:references; q=dns; s=default; b=T2oKMjjQ yN/5Rt/4hfYBDnjIi7JlTPIitx1ozxSIo8PY9LTr++J2C5J6zaQ5O0uqSxsYMqCl MjuY0eGODhrd6oBk3Joem/bjuW+vwPJs7m5xSmYnoW1+Bu+FErbFRh8ZEJpcohq2 wJA8V833qjgiX7MYg75Fthk+m301nk8iyqg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references:in-reply-to:references; s=default; bh=bE7pFZjgsYQra7 qxc33YB94RfgU=; b=fdyPED3EQYxbjzhY5NmKc1BF7XvUddmyIIZrD+HuNgOD39 +OCvMM3k8wMo8sPM8Y7B81xSfJCILQOThrwdz8zOFtxjG5DNqG42S+ZTnYDmz3MH 2qjLymuoT+gRCoSRNSDjXGgFK4MM6mut3RjGMkwXQzMovYpoNR2UtDEEnTpoQ= Received: (qmail 48195 invoked by alias); 23 May 2016 22:18:45 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 48073 invoked by uid 89); 23 May 2016 22:18:44 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=1007, appropriately, Hx-languages-length:4996 X-HELO: e33.co.us.ibm.com X-IBM-Helo: d03dlp02.boulder.ibm.com X-IBM-MailFrom: murphyp@linux.vnet.ibm.com X-IBM-RcptTo: libc-alpha@sourceware.org From: "Paul E. Murphy" To: libc-alpha@sourceware.org Subject: [PATCHv3 3/3] Refactor tst-strtod-round-data.h to avoid adding a type suffix Date: Mon, 23 May 2016 17:18:30 -0500 Message-Id: <53e9c5a00ee5841cdb8335be2d280d2a8ce8c603.1464041464.git.murphyp@linux.vnet.ibm.com> In-Reply-To: References: In-Reply-To: References: X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16052322-0009-0000-0000-000037A3DE6E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused Refactor the generator to avoid the need to mix the format and the type. This updates tst-strtod.h to append the proper suffix for the type being tested. This allows for a trivial addition of float128. NOTE: reviewers, you will need to build gen-tst-strtod-round.c and regenerate tst-strtod-round-data.h. This keeps the patch concise. * stdlib/gen-tst-strtod-round.c (printfp): Remove the literal suffix. (round_str): Likewise. (round_for_all): Likewise. * stdlib/tst-strtod.h (TEST): Apply the correct literal suffix to floating point literals. (INFINITYf): New macro. (INFINITYL): Likewise. * stdlib/tst-strtod-round-data.h: Regenerate. --- stdlib/gen-tst-strtod-round.c | 40 +++++++++++++++++++--------------------- stdlib/tst-strtod.h | 17 ++++++++++++----- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/stdlib/gen-tst-strtod-round.c b/stdlib/gen-tst-strtod-round.c index 26c2ec2..897fc59 100644 --- a/stdlib/gen-tst-strtod-round.c +++ b/stdlib/gen-tst-strtod-round.c @@ -60,19 +60,18 @@ string_to_fp (mpfr_t f, const char *s, mpfr_rnd_t rnd) #endif } -static void -print_fp (FILE *fout, mpfr_t f, const char *suffix, const char *suffix2) +void +print_fp (FILE *fout, mpfr_t f, const char *suffix) { if (mpfr_inf_p (f)) - mpfr_fprintf (fout, "\t%sINFINITY%s", mpfr_signbit (f) ? "-" : "", - suffix2); + mpfr_fprintf (fout, "\tINFINITY%s", mpfr_signbit (f) ? "-" : ""); else - mpfr_fprintf (fout, "\t%Ra%s%s", f, suffix, suffix2); + mpfr_fprintf (fout, "\t%Ra%s", f, suffix); } static void -round_str (FILE *fout, const char *s, const char *suffix, - int prec, int emin, int emax, bool ibm_ld) +round_str (FILE *fout, const char *s, int prec, int emin, int emax, + bool ibm_ld) { mpfr_t f; mpfr_set_default_prec (prec); @@ -94,13 +93,13 @@ round_str (FILE *fout, const char *s, const char *suffix, mpfr_clear (max_value); } mpfr_fprintf (fout, "\t%s,\n", r ? "false" : "true"); - print_fp (fout, f, suffix, ",\n"); + print_fp (fout, f, ",\n"); string_to_fp (f, s, MPFR_RNDN); - print_fp (fout, f, suffix, ",\n"); + print_fp (fout, f, ",\n"); string_to_fp (f, s, MPFR_RNDZ); - print_fp (fout, f, suffix, ",\n"); + print_fp (fout, f, ",\n"); string_to_fp (f, s, MPFR_RNDU); - print_fp (fout, f, suffix, ""); + print_fp (fout, f, ""); mpfr_clear (f); } @@ -108,21 +107,20 @@ static void round_for_all (FILE *fout, const char *s) { static const struct fmt { - const char *suffix; int prec; int emin; int emax; bool ibm_ld; } formats[7] = { - { "f", 24, -148, 128, false }, - { "", 53, -1073, 1024, false }, - { "L", 53, -1073, 1024, false }, + { 24, -148, 128, false }, + { 53, -1073, 1024, false }, + { 53, -1073, 1024, false }, /* This is the Intel extended float format. */ - { "L", 64, -16444, 16384, false }, + { 64, -16444, 16384, false }, /* This is the Motorola extended float format. */ - { "L", 64, -16445, 16384, false }, - { "L", 106, -1073, 1024, true }, - { "L", 113, -16493, 16384, false }, + { 64, -16445, 16384, false }, + { 106, -1073, 1024, true }, + { 113, -16493, 16384, false }, }; mpfr_fprintf (fout, " TEST (\""); const char *p; @@ -136,8 +134,8 @@ round_for_all (FILE *fout, const char *s) int i; for (i = 0; i < 7; i++) { - round_str (fout, s, formats[i].suffix, formats[i].prec, - formats[i].emin, formats[i].emax, formats[i].ibm_ld); + round_str (fout, s, formats[i].prec, formats[i].emin, + formats[i].emax, formats[i].ibm_ld); if (i < 6) mpfr_fprintf (fout, ",\n"); } diff --git a/stdlib/tst-strtod.h b/stdlib/tst-strtod.h index a22e2b8..5bd5aa9 100644 --- a/stdlib/tst-strtod.h +++ b/stdlib/tst-strtod.h @@ -100,7 +100,9 @@ /* This macro is used in conjunction with the output from the gen-tst-strtod-round utility to select the appropriately - rounded long double value for a given format. */ + rounded long double value for a given format. Note that + the literal suffix must be appended before the token is + potentially expanded, so we can fixup such mangling later on. */ #define TEST(s, \ fx, fd, fn, fz, fu, \ dx, dd, dn, dz, du, \ @@ -113,13 +115,18 @@ s, \ { fx, dx, LDC (ld53x, ld64ix, ld64mx, ld106x, ld113x) }, \ { \ - { fn, dn, LDC (ld53n, ld64in, ld64mn, ld106n, ld113n) }, \ - { fd, dd, LDC (ld53d, ld64id, ld64md, ld106d, ld113d) }, \ - { fz, dz, LDC (ld53z, ld64iz, ld64mz, ld106z, ld113z) }, \ - { fu, du, LDC (ld53u, ld64iu, ld64mu, ld106u, ld113u) } \ + { fn ## f, dn, LDC (ld53n ## L, ld64in ## L, ld64mn ## L, ld106n ## L, ld113n ## L)},\ + { fd ## f, dd, LDC (ld53d ## L, ld64id ## L, ld64md ## L, ld106d ## L, ld113d ## L)},\ + { fz ## f, dz, LDC (ld53z ## L, ld64iz ## L, ld64mz ## L, ld106z ## L, ld113z ## L)},\ + { fu ## f, du, LDC (ld53u ## L, ld64iu ## L, ld64mu ## L, ld106u ## L, ld113u ## L)} \ } \ } +/* Note that the above will mangle constants generated by + the generator program. We fix those up below. */ +#define INFINITYf INFINITY +#define INFINITYL INFINITY + struct test_exactness { STRUCT_FOREACH_TYPE ()