From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 8058D3858D33 for ; Mon, 13 Feb 2023 23:33:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8058D3858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31DNO4NP021140 for ; Mon, 13 Feb 2023 23:33:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=NB2uh1ia6JgvhjI3VkNy+9/9ccP6duy9BjWG0M3p/e4=; b=OeQ8JkVk0Szme6HNW816wpPalczRZpk0poDziESnz77IC1O9X7voW/sydfvj6yACRanI DyZlt8yXoTWZGU8Jj5p1DSkbbmvtAjKA/rSZmb4BGfpg+MQW+svM+aSrYSSih/FDtnKb YaBUWlzwCN+IBlkae3z6l/ojRbtBtkzl5QBdTvaX4SRjPSB1aunAcAg1EBlzsVapCIcp ulMCs9wCzcM4rzWB3nO4qDNa1hCQj0MqziAkFRVvRzzcIAFhInlGhvKM3Q4V2VvGYDgk 77inKfO+XV/gL/8wKRqcf7WcIeRPifS0VLA37eZOgigqGEcuugPlY9/sKPzridYeeMvE rQ== Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nqxuk04xt-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 13 Feb 2023 23:33:22 +0000 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 31DLxMXU024146 for ; Mon, 13 Feb 2023 23:08:00 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([9.208.130.101]) by ppma02dal.us.ibm.com (PPS) with ESMTPS id 3np2n7827m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 13 Feb 2023 23:08:00 +0000 Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 31DN7wQd5833320 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Feb 2023 23:07:58 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4B6425806A; Mon, 13 Feb 2023 23:07:58 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BD74258066; Mon, 13 Feb 2023 23:07:57 +0000 (GMT) Received: from [9.65.254.199] (unknown [9.65.254.199]) by smtpav01.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 13 Feb 2023 23:07:57 +0000 (GMT) Message-ID: Date: Mon, 13 Feb 2023 17:07:56 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PATCH] Added Redirects to longdouble error functions [BZ #29033] To: Sachin Monga , libc-alpha@sourceware.org References: <20230209174528.292568-1-smonga@linux.ibm.com> Content-Language: en-US From: Paul E Murphy In-Reply-To: <20230209174528.292568-1-smonga@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: A6eT_LS6zXohK7NKDyP3ebR_i6aPNgHa X-Proofpoint-GUID: A6eT_LS6zXohK7NKDyP3ebR_i6aPNgHa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-13_12,2023-02-13_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 bulkscore=0 mlxscore=0 impostorscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302130206 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 2/9/23 11:45 AM, Sachin Monga via Libc-alpha wrote: > This patch redirects the error functions to the appropriate > longdouble variants which enables the compiler to optimize > for the abi ieeelongdouble. This is a tricky patch. Are there tests to verify this functions as desired when redirecting long double? If practical, please add some. > > Signed-off-by: Sachin Monga > --- > misc/bits/error-ldbl.h | 53 ++++++++++++++++++++++++++++++++++++++++-- > misc/sys/cdefs.h | 6 +++++ > 2 files changed, 57 insertions(+), 2 deletions(-) > > diff --git a/misc/bits/error-ldbl.h b/misc/bits/error-ldbl.h > index 599a7d6e06..73ecbe7a10 100644 > --- a/misc/bits/error-ldbl.h > +++ b/misc/bits/error-ldbl.h > @@ -20,5 +20,54 @@ > # error "Never include directly; use instead." > #endif > > -__LDBL_REDIR_DECL (error) > -__LDBL_REDIR_DECL (error_at_line) Does this still return the expected function with usage like? #include typedef void (error_func_t)(int,int,const char*,...); error_func_t get_error_func() { return &error; } > + > +__LDBL_REDIRECT (__error_alias, (int __status, int __errnum, > + const char *__format, ...), > + error) > + __attribute__ ((__format__ (__printf__, 3, 4))); > +__LDBL_REDIRECT (__error_noreturn, (int __status, int __errnum, > + const char *__format, ...), > + error) > + __attribute__ ((__noreturn__, __format__ (__printf__, 3, 4))); > + > + > +/* If we know the function will never return make sure the compiler > + realizes that, too. */ > +__extern_always_inline void > +error (int __status, int __errnum, const char *__format, ...) > +{ > + if (__builtin_constant_p (__status) && __status != 0) > + __error_noreturn (__status, __errnum, __format, __va_arg_pack ()); > + else > + __error_alias (__status, __errnum, __format, __va_arg_pack ()); > +} > + > + > +__LDBL_REDIRECT (__error_at_line_alias, (int __status, int __errnum, > + const char *__fname, > + unsigned int __line, > + const char *__format, ...), > + error_at_line) > + __attribute__ ((__format__ (__printf__, 5, 6))); > +__LDBL_REDIRECT (__error_at_line_noreturn, (int __status, int __errnum, > + const char *__fname, > + unsigned int __line, > + const char *__format, > + ...), > + error_at_line) > + __attribute__ ((__noreturn__, __format__ (__printf__, 5, 6))); > + > + > +/* If we know the function will never return make sure the compiler > + realizes that, too. */ > +__extern_always_inline void > +error_at_line (int __status, int __errnum, const char *__fname, > + unsigned int __line, const char *__format, ...) > +{ > + if (__builtin_constant_p (__status) && __status != 0) > + __error_at_line_noreturn (__status, __errnum, __fname, __line, __format, > + __va_arg_pack ()); > + else > + __error_at_line_alias (__status, __errnum, __fname, __line, > + __format, __va_arg_pack ()); > +} > diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h > index 66d6702123..34fdd3c24a 100644 > --- a/misc/sys/cdefs.h > +++ b/misc/sys/cdefs.h > @@ -245,6 +245,7 @@ > #if (defined __GNUC__ && __GNUC__ >= 2) || (__clang_major__ >= 4) > > # define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias)) > + Trivial nit, this change seems unrelated. > # ifdef __cplusplus > # define __REDIRECT_NTH(name, proto, alias) \ > name proto __THROW __asm__ (__ASMNAME (#alias)) > @@ -567,6 +568,8 @@ > # define __LDBL_REDIR(name, proto) ... unused__ldbl_redir > # define __LDBL_REDIR_DECL(name) \ > extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128")); > +# define __LDBL_REDIRECT(name, proto, alias) \ > + extern void name proto __asm (__ASMNAME ("__" #alias "ieee128")) Is it possible to use the existing __REDIRECT_LDBL macro instead of adding a new one? They seem identical save for an extra expansion with __REDIRECT_LDBL. > > /* Alias name defined automatically, with leading underscores. */ > # define __LDBL_REDIR2_DECL(name) \ > @@ -605,6 +608,8 @@ _Static_assert (0, "IEEE 128-bits long double requires redirection on this platf > extern __typeof (name) name __asm (__ASMNAME (#alias)); > # define __LDBL_REDIR_DECL(name) \ > extern __typeof (name) name __asm (__ASMNAME ("__nldbl_" #name)); > +# define __LDBL_REDIRECT(name, proto, alias) \ > + extern void name proto __asm (__ASMNAME ("__nldbl_" #alias)); > # define __REDIRECT_LDBL(name, proto, alias) \ > __LDBL_REDIR1 (name, proto, __nldbl_##alias) > # define __REDIRECT_NTH_LDBL(name, proto, alias) \ > @@ -619,6 +624,7 @@ _Static_assert (0, "IEEE 128-bits long double requires redirection on this platf > # define __LDBL_REDIR_NTH(name, proto) name proto __THROW > # define __LDBL_REDIR2_DECL(name) > # define __LDBL_REDIR_DECL(name) > +# define __LDBL_REDIRECT(name, proto, alias) > # ifdef __REDIRECT > # define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias) > # define __REDIRECT_NTH_LDBL(name, proto, alias) \