From patchwork Mon Sep 11 23:27:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 812658 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-84474-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="DZYAQhaK"; 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 3xrkcf1rxGz9s7F for ; Tue, 12 Sep 2017 09:28:02 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=t0QzE+TEhJ/HduMLuOe+nl5OFVEdz Vb8TME7CjN2rlL1/1G2UinTXX9R4m0xhaQ/j7uDk3OWORmK5zZlhFiq2JOMCjJwz V3HUS8SGCs/8nbkM3gNmX4oPzrGOITxIeW/rtUVWp9EcARLoP2KDDhaL/TDGe9Io JVyJMK1UEQ0jsI= 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:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=AAPT57cfGYQ68bLY51OMJ5LWF6k=; b=DZY AQhaKbtL6GmuMwxtJOs6q4CZpphUaAm8CKgRgwgfxHbTxsXaBV4Uv8BeGZXcKNdv LKm1J1O3bdfqAFyvzsOdcGHAl1u1+4vurwdF+suxOO0cdlf9gF46RgIAQDiNZUI8 +4sIF9YYB95Jgtdn+XYjtx5uSRY4J4ZYZY3T0oiY= Received: (qmail 107651 invoked by alias); 11 Sep 2017 23:27:56 -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 107636 invoked by uid 89); 11 Sep 2017 23:27:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy= X-HELO: relay1.mentorg.com Date: Mon, 11 Sep 2017 23:27:43 +0000 From: Joseph Myers To: Subject: Define and use a libm_alias_float macro [committed] Message-ID: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) Fully supporting TS 18661-3 _FloatN / _FloatNx types in the cases where they have the same format as other supported types (in line with the principles described at ) means adding a lot of function aliases to libm (and a few to libc). float functions will have *f32 aliases, double functions will have *f32x and *f64 aliases, long double functions may have *f64x, *f128 or both aliases depending on the configuration, float128 functions have have *f64x aliases depending on the configuration. At present, most individual libm functions have their own weak_alias calls to define the public names for those functions. For TS 18661-3 support, it is desirable that functions not all need to duplicate the logic for which alias names to define. Thus, common macros for defining the public aliases to a libm function make sense. In the double and long double cases, such macros will also help simplify existing code (with LONG_DOUBLE_COMPAT etc. conditionals), by eliminating existing conditionals and ldbl-opt / ldbl-64-128 wrappers (using the generated ldbl-compat-choose.h to allow a single macro definition to expand appropriately for each symbol depending on LONG_DOUBLE_COMPAT for that symbol). This patch starts the process of adding such macros with a straightforward case: a libm_alias_float macro, initially only used in the case of type-generic templates, to define aliases for float functions (currently just the *f public names, in future also *f32). Future patches are intended to add such macros for other types and to extend the cases in which they are used, with a view to as many places as possible using them before support for _FloatN / _FloatNx aliases is enabled. (I think it's inevitable that some places doing architecture-specific things with aliases and symbol versioning may end up needing to replicate logic for the new aliases, but hopefully the number of such places can be kept to a minimum.) The libm_alias_float macro takes unsuffixed names for both the internal and public function names. The need for unsuffixed public names is obvious, since such macros will end up defining multiple public names with different suffixes. Unsuffixed internal names are because I expect the ldbl-128 functions to end up in a form that always defines *f128 names and sometimes also defines *l names - with the main internal names being e.g. __ieee754_f128 (so many macros in float128_private.h can go away). But __ieee754_l aliases will still be needed for e.g. use from math/ complex functions, meaning the alias macro needs to see just __ieee754_ as internal name so it can create an alias based on that name. Since libm_alias_float128 will thus need the unsuffixed internal name, it seems to make sense for all such macros to receive the unsuffixed name. Tested for x86_64. Also tested with build-many-glibcs.py that installed stripped shared libraries are unchanged by the patch. Committed. 2017-09-11 Joseph Myers * sysdeps/generic/libm-alias-float.h: New file. * sysdeps/generic/math-type-macros-float.h: Include . [!declare_mgen_alias] (declare_mgen_alias): Define macro. diff --git a/sysdeps/generic/libm-alias-float.h b/sysdeps/generic/libm-alias-float.h new file mode 100644 index 0000000..23f0166 --- /dev/null +++ b/sysdeps/generic/libm-alias-float.h @@ -0,0 +1,35 @@ +/* Define aliases for libm float functions. + Copyright (C) 2017 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 _LIBM_ALIAS_FLOAT_H +#define _LIBM_ALIAS_FLOAT_H + +/* Define aliases for a float libm function that has internal name + FROM ## f ## R and public names TO ## suffix ## R for each suffix + of a supported floating-point type with the same format as float. + This should only be used for functions where such public names + exist for _FloatN types, not for implementation-namespace exported + names (where there is one name per format, not per type) or for + obsolescent functions not provided for _FloatN types. */ +#define libm_alias_float_r(from, to, r) \ + weak_alias (from ## f ## r, to ## f ## r) + +/* Likewise, but without the R suffix. */ +#define libm_alias_float(from, to) libm_alias_float_r (from, to, ) + +#endif diff --git a/sysdeps/generic/math-type-macros-float.h b/sysdeps/generic/math-type-macros-float.h index cc8c4b0..b23789f 100644 --- a/sysdeps/generic/math-type-macros-float.h +++ b/sysdeps/generic/math-type-macros-float.h @@ -30,6 +30,12 @@ the double macro constants. */ #define M_MLIT(c) c +#include + +#ifndef declare_mgen_alias +# define declare_mgen_alias(from, to) libm_alias_float (from, to) +#endif + /* Supply the generic macros. */ #include