(root)/
glibc-2.38/
sysdeps/
ieee754/
ldbl-128/
s_totalordermagl.c
       1  /* Total order operation on absolute values.  ldbl-128 version.
       2     Copyright (C) 2016-2023 Free Software Foundation, Inc.
       3     This file is part of the GNU C Library.
       4  
       5     The GNU C Library is free software; you can redistribute it and/or
       6     modify it under the terms of the GNU Lesser General Public
       7     License as published by the Free Software Foundation; either
       8     version 2.1 of the License, or (at your option) any later version.
       9  
      10     The GNU C Library is distributed in the hope that it will be useful,
      11     but WITHOUT ANY WARRANTY; without even the implied warranty of
      12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13     Lesser General Public License for more details.
      14  
      15     You should have received a copy of the GNU Lesser General Public
      16     License along with the GNU C Library; if not, see
      17     <https://www.gnu.org/licenses/>.  */
      18  
      19  #include <math.h>
      20  #include <math_private.h>
      21  #include <libm-alias-ldouble.h>
      22  #include <nan-high-order-bit.h>
      23  #include <stdint.h>
      24  #include <shlib-compat.h>
      25  #include <first-versions.h>
      26  
      27  int
      28  __totalordermagl (const _Float128 *x, const _Float128 *y)
      29  {
      30    uint64_t hx, hy;
      31    uint64_t lx, ly;
      32    GET_LDOUBLE_WORDS64 (hx, lx, *x);
      33    GET_LDOUBLE_WORDS64 (hy, ly, *y);
      34    hx &= 0x7fffffffffffffffULL;
      35    hy &= 0x7fffffffffffffffULL;
      36  #if HIGH_ORDER_BIT_IS_SET_FOR_SNAN
      37    /* For the preferred quiet NaN convention, this operation is a
      38       comparison of the representations of the absolute values of the
      39       arguments.  If both arguments are NaNs, invert the
      40       quiet/signaling bit so comparing that way works.  */
      41    if ((hx > 0x7fff000000000000ULL || (hx == 0x7fff000000000000ULL
      42  				      && lx != 0))
      43        && (hy > 0x7fff000000000000ULL || (hy == 0x7fff000000000000ULL
      44  					 && ly != 0)))
      45      {
      46        hx ^= 0x0000800000000000ULL;
      47        hy ^= 0x0000800000000000ULL;
      48      }
      49  #endif
      50    return hx < hy || (hx == hy && lx <= ly);
      51  }
      52  #ifdef SHARED
      53  # define CONCATX(x, y) x ## y
      54  # define CONCAT(x, y) CONCATX (x, y)
      55  # define UNIQUE_ALIAS(name) CONCAT (name, __COUNTER__)
      56  # define do_symbol(orig_name, name, aliasname)		\
      57    strong_alias (orig_name, name)			\
      58    versioned_symbol (libm, name, aliasname, GLIBC_2_31)
      59  # undef weak_alias
      60  # define weak_alias(name, aliasname)			\
      61    do_symbol (name, UNIQUE_ALIAS (name), aliasname);
      62  #endif
      63  libm_alias_ldouble (__totalordermag, totalordermag)
      64  #if SHLIB_COMPAT (libm, GLIBC_2_25, GLIBC_2_31)
      65  int
      66  attribute_compat_text_section
      67  __totalordermag_compatl (_Float128 x, _Float128 y)
      68  {
      69    return __totalordermagl (&x, &y);
      70  }
      71  /* On platforms that reuse the _Float128 implementation for IEEE long
      72     double (powerpc64le), the libm_alias_float128_other_r_ldbl macro
      73     (which is called by the libm_alias_ldouble macro) is used to create
      74     aliases between *f128 (_Float128 API) and __*ieee128 functions.
      75     However, this compat version of totalordermagl is older than the
      76     availability of __ieee*128 symbols, thus, the compat alias is not
      77     required, nor desired.  */
      78  #undef libm_alias_float128_other_r_ldbl
      79  #define libm_alias_float128_other_r_ldbl(from, to, r)
      80  #undef do_symbol
      81  #define do_symbol(orig_name, name, aliasname)			\
      82    strong_alias (orig_name, name)				\
      83    compat_symbol (libm, name, aliasname,				\
      84  		 CONCAT (FIRST_VERSION_libm_, aliasname))
      85  libm_alias_ldouble (__totalordermag_compat, totalordermag)
      86  #endif