From patchwork Fri Dec 21 19:21:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel F. T. Gomes" X-Patchwork-Id: 1017691 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-98731-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.eti.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="wrg/e3Jx"; dkim-atps=neutral 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 43Lz5t6BNNz9sDB for ; Sat, 22 Dec 2018 06:22:10 +1100 (AEDT) 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:mime-version:content-type; q=dns; s=default; b=EeaLJ ATdeUjKTFGWTZU67pF/+CCHXMJwbPDxpioq50xw3Wi1kbxWEFwGNHDg5voEvdulk 13kA05IB90vOHhec2iPs/7m2JkCZrfSfbwpUu33Bj9RRAiU+QanjiIEy/+D+vaM6 W4bs3XSLIXUmcFrKlQNu6MRxIzHt0wydI0jH88= 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:mime-version:content-type; s=default; bh=lpUgdDlWMdO lFO0ZMmdS5J9h424=; b=wrg/e3JxVueJiGGCBDtcMYaRCXQ+1hLlsZoVAwUDzw1 68zJ5jv8h9Se5sA6ora2oqwabslJZuQsIC31e0wOBGjNPhq36avv3Hpp55FkhNkx N3Bu2UwWNL3E8oZPw7Ekm1e29loWSo2O3imy7NgmV8NvGhuS2gINktPszQVzHJiA = Received: (qmail 53556 invoked by alias); 21 Dec 2018 19:21:41 -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 53404 invoked by uid 89); 21 Dec 2018 19:21:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=controls X-HELO: mo20.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v3 4/5] ldbl-opt: Add error and error_at_line (bug 23984) Date: Fri, 21 Dec 2018 17:21:06 -0200 Message-ID: <20181221192107.15146-5-gabriel@inconstante.eti.br> In-Reply-To: <20181221192107.15146-1-gabriel@inconstante.eti.br> References: <20181221192107.15146-1-gabriel@inconstante.eti.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 4412120260710616771 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrudejhedguddviecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu Changes since v2: - Added bits/error-ldbl.h to the list of installed headers. Changes since v1: - Added include/bits/error-ldbl.h - Added mention to bugzilla fix. -- 8< -- On platforms where long double may have the same format as double (-mlong-double-64), error and error_at_line do not take that into account and might produce wrong output if a long double conversion is requested by the format string ('%Lf'). This patch adds compatibility functions for this situation and redirects calls via header magic. Tested for powerpc64 and powerpc64le. [BZ #23984] * include/bits/error-ldbl.h: New file. * include/error.h: Include stdarg.h. Declare internal functions __error_internal and __error_at_line_internal. * misc/Makefile (headers): Add bits/error-ldbl.h. * misc/bits/error-ldbl.h: New file. * misc/error.h [__LDBL_COMPAT]: Include bits/error-ldbl.h and avoid the inclusion of bits/error.h. * sysdeps/ieee754/ldbl-opt/Versions (libc): Add __nldbl_error, and __nldbl_error_at_line. * sysdeps/ieee754/ldbl-opt/nldbl-compat.c: Include error.h. (__nldbl_error, __ndlbl_error_at_line): New functions. * sysdeps/ieee754/ldbl-opt/nldbl-compat.h: Include error.h. Redirect error and error_at_line. * sysdeps/unix/sysv/linux/alpha/libc.abilist: Update. * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise. --- include/bits/error-ldbl.h | 1 + include/error.h | 14 +++++++++++++ misc/Makefile | 2 +- misc/bits/error-ldbl.h | 24 ++++++++++++++++++++++ misc/error.h | 12 ++++++++--- sysdeps/ieee754/ldbl-opt/Versions | 1 + sysdeps/ieee754/ldbl-opt/nldbl-compat.c | 22 ++++++++++++++++++++ sysdeps/ieee754/ldbl-opt/nldbl-compat.h | 3 +++ sysdeps/unix/sysv/linux/alpha/libc.abilist | 2 ++ .../sysv/linux/powerpc/powerpc32/fpu/libc.abilist | 2 ++ .../linux/powerpc/powerpc32/nofpu/libc.abilist | 2 ++ .../sysv/linux/powerpc/powerpc64/be/libc.abilist | 2 ++ .../sysv/linux/powerpc/powerpc64/le/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist | 2 ++ sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist | 2 ++ 16 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 include/bits/error-ldbl.h create mode 100644 misc/bits/error-ldbl.h diff --git a/include/bits/error-ldbl.h b/include/bits/error-ldbl.h new file mode 100644 index 0000000000..84b2646867 --- /dev/null +++ b/include/bits/error-ldbl.h @@ -0,0 +1 @@ +#include diff --git a/include/error.h b/include/error.h index 70f3192fa6..9e96262fc5 100644 --- a/include/error.h +++ b/include/error.h @@ -1 +1,15 @@ +#ifndef _ERROR_H #include + +#include + +void +__error_internal (int status, int errnum, const char *message, + va_list args, unsigned int mode_flags); + +void +__error_at_line_internal (int status, int errnum, const char *file_name, + unsigned int line_number, const char *message, + va_list args, unsigned int mode_flags); + +#endif diff --git a/misc/Makefile b/misc/Makefile index 39829b95b2..7d1d76b3dc 100644 --- a/misc/Makefile +++ b/misc/Makefile @@ -37,7 +37,7 @@ headers := sys/uio.h bits/uio-ext.h bits/uio_lim.h \ bits/syslog.h bits/syslog-ldbl.h bits/syslog-path.h bits/error.h \ bits/select2.h bits/hwcap.h sys/auxv.h \ sys/sysmacros.h bits/sysmacros.h bits/types/struct_iovec.h \ - bits/err-ldbl.h + bits/err-ldbl.h bits/error-ldbl.h routines := brk sbrk sstk ioctl \ readv writev preadv preadv64 pwritev pwritev64 \ diff --git a/misc/bits/error-ldbl.h b/misc/bits/error-ldbl.h new file mode 100644 index 0000000000..d89a3f1181 --- /dev/null +++ b/misc/bits/error-ldbl.h @@ -0,0 +1,24 @@ +/* Redirections for error.h functions for -mlong-double-64. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _ERROR_H +# error "Never include directly; use instead." +#endif + +__LDBL_REDIR_DECL (error) +__LDBL_REDIR_DECL (error_at_line) diff --git a/misc/error.h b/misc/error.h index fcd5ad90dc..ac0c58622a 100644 --- a/misc/error.h +++ b/misc/error.h @@ -47,9 +47,15 @@ extern unsigned int error_message_count; variable controls whether this mode is selected or not. */ extern int error_one_per_line; - -#if defined __extern_always_inline && defined __va_arg_pack -# include +#ifdef __LDBL_COMPAT +# include +#else +/* Do not inline error and error_at_line when long double has the same + size of double, because that would invalidate the redirections to the + compatibility functions. */ +# if defined __extern_always_inline && defined __va_arg_pack +# include +# endif #endif __END_DECLS diff --git a/sysdeps/ieee754/ldbl-opt/Versions b/sysdeps/ieee754/ldbl-opt/Versions index 5bc88ddb8f..ced253cf66 100644 --- a/sysdeps/ieee754/ldbl-opt/Versions +++ b/sysdeps/ieee754/ldbl-opt/Versions @@ -82,6 +82,7 @@ libc { __nldbl_argp_error; __nldbl_argp_failure; __nldbl_warn; __nldbl_vwarn; __nldbl_warnx; __nldbl_vwarnx; __nldbl_err; __nldbl_verr; __nldbl_errx; __nldbl_verrx; + __nldbl_error; __nldbl_error_at_line; } } libm { diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c index 10c0fe6ac9..d9c6ac2e2c 100644 --- a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c +++ b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -1067,6 +1068,27 @@ __nldbl_vwarnx (const char *format, __gnuc_va_list ap) __vwarnx_internal (format, ap, PRINTF_LDBL_IS_DBL); } +void +__nldbl_error (int status, int errnum, const char *message, ...) +{ + va_list ap; + va_start (ap, message); + __error_internal (status, errnum, message, ap, PRINTF_LDBL_IS_DBL); + va_end (ap); +} + +void +__nldbl_error_at_line (int status, int errnum, const char *file_name, + unsigned int line_number, const char *message, + ...) +{ + va_list ap; + va_start (ap, message); + __error_at_line_internal (status, errnum, file_name, line_number, + message, ap, PRINTF_LDBL_IS_DBL); + va_end (ap); +} + #if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0) compat_symbol (libc, __nldbl__IO_printf, _IO_printf, GLIBC_2_0); compat_symbol (libc, __nldbl__IO_sprintf, _IO_sprintf, GLIBC_2_0); diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-compat.h b/sysdeps/ieee754/ldbl-opt/nldbl-compat.h index 35f49165e2..02f4988d40 100644 --- a/sysdeps/ieee754/ldbl-opt/nldbl-compat.h +++ b/sysdeps/ieee754/ldbl-opt/nldbl-compat.h @@ -28,6 +28,7 @@ #define __NO_LONG_DOUBLE_MATH 1 #include #include +#include #include #include #include @@ -88,6 +89,8 @@ NLDBL_DECL (err); NLDBL_DECL (verr); NLDBL_DECL (errx); NLDBL_DECL (verrx); +NLDBL_DECL (error); +NLDBL_DECL (error_at_line); /* These do not exist in the normal interface, but must exist in the __nldbl interface so that they can be called from libnldbl. */ diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist index 83d6f99ebe..2bbeaf653c 100644 --- a/sysdeps/unix/sysv/linux/alpha/libc.abilist +++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist @@ -2036,6 +2036,8 @@ GLIBC_2.28 thrd_yield F GLIBC_2.29 __nldbl_argp_error F GLIBC_2.29 __nldbl_argp_failure F GLIBC_2.29 __nldbl_err F +GLIBC_2.29 __nldbl_error F +GLIBC_2.29 __nldbl_error_at_line F GLIBC_2.29 __nldbl_errx F GLIBC_2.29 __nldbl_verr F GLIBC_2.29 __nldbl_verrx F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist index 06c1a6cb6f..66267fc611 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist @@ -1996,6 +1996,8 @@ GLIBC_2.28 thrd_yield F GLIBC_2.29 __nldbl_argp_error F GLIBC_2.29 __nldbl_argp_failure F GLIBC_2.29 __nldbl_err F +GLIBC_2.29 __nldbl_error F +GLIBC_2.29 __nldbl_error_at_line F GLIBC_2.29 __nldbl_errx F GLIBC_2.29 __nldbl_verr F GLIBC_2.29 __nldbl_verrx F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist index ecd6760acb..4e916770ea 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist @@ -2000,6 +2000,8 @@ GLIBC_2.28 thrd_yield F GLIBC_2.29 __nldbl_argp_error F GLIBC_2.29 __nldbl_argp_failure F GLIBC_2.29 __nldbl_err F +GLIBC_2.29 __nldbl_error F +GLIBC_2.29 __nldbl_error_at_line F GLIBC_2.29 __nldbl_errx F GLIBC_2.29 __nldbl_verr F GLIBC_2.29 __nldbl_verrx F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist index 4fc365747c..0ff7f021b1 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist @@ -126,6 +126,8 @@ GLIBC_2.28 thrd_yield F GLIBC_2.29 __nldbl_argp_error F GLIBC_2.29 __nldbl_argp_failure F GLIBC_2.29 __nldbl_err F +GLIBC_2.29 __nldbl_error F +GLIBC_2.29 __nldbl_error_at_line F GLIBC_2.29 __nldbl_errx F GLIBC_2.29 __nldbl_verr F GLIBC_2.29 __nldbl_verrx F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist index 915861b84d..442ed721c8 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist @@ -2231,6 +2231,8 @@ GLIBC_2.28 thrd_yield F GLIBC_2.29 __nldbl_argp_error F GLIBC_2.29 __nldbl_argp_failure F GLIBC_2.29 __nldbl_err F +GLIBC_2.29 __nldbl_error F +GLIBC_2.29 __nldbl_error_at_line F GLIBC_2.29 __nldbl_errx F GLIBC_2.29 __nldbl_verr F GLIBC_2.29 __nldbl_verrx F diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist index 343d13bea3..29b2d98f19 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist @@ -2005,6 +2005,8 @@ GLIBC_2.28 thrd_yield F GLIBC_2.29 __nldbl_argp_error F GLIBC_2.29 __nldbl_argp_failure F GLIBC_2.29 __nldbl_err F +GLIBC_2.29 __nldbl_error F +GLIBC_2.29 __nldbl_error_at_line F GLIBC_2.29 __nldbl_errx F GLIBC_2.29 __nldbl_verr F GLIBC_2.29 __nldbl_verrx F diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist index d25efda368..0e07880a52 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist @@ -1911,6 +1911,8 @@ GLIBC_2.29 __fentry__ F GLIBC_2.29 __nldbl_argp_error F GLIBC_2.29 __nldbl_argp_failure F GLIBC_2.29 __nldbl_err F +GLIBC_2.29 __nldbl_error F +GLIBC_2.29 __nldbl_error_at_line F GLIBC_2.29 __nldbl_errx F GLIBC_2.29 __nldbl_verr F GLIBC_2.29 __nldbl_verrx F diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist index a759b1ed88..29e4ad4635 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist @@ -1999,6 +1999,8 @@ GLIBC_2.28 thrd_yield F GLIBC_2.29 __nldbl_argp_error F GLIBC_2.29 __nldbl_argp_failure F GLIBC_2.29 __nldbl_err F +GLIBC_2.29 __nldbl_error F +GLIBC_2.29 __nldbl_error_at_line F GLIBC_2.29 __nldbl_errx F GLIBC_2.29 __nldbl_verr F GLIBC_2.29 __nldbl_verrx F