mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-25 12:11:10 +00:00
5a82c74822
Also, change sources.redhat.com to sourceware.org. This patch was automatically generated by running the following shell script, which uses GNU sed, and which avoids modifying files imported from upstream: sed -ri ' s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g ' \ $(find $(git ls-files) -prune -type f \ ! -name '*.po' \ ! -name 'ChangeLog*' \ ! -path COPYING ! -path COPYING.LIB \ ! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \ ! -path manual/texinfo.tex ! -path scripts/config.guess \ ! -path scripts/config.sub ! -path scripts/install-sh \ ! -path scripts/mkinstalldirs ! -path scripts/move-if-change \ ! -path INSTALL ! -path locale/programs/charmap-kw.h \ ! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \ ! '(' -name configure \ -execdir test -f configure.ac -o -f configure.in ';' ')' \ ! '(' -name preconfigure \ -execdir test -f preconfigure.ac ';' ')' \ -print) and then by running 'make dist-prepare' to regenerate files built from the altered files, and then executing the following to cleanup: chmod a+x sysdeps/unix/sysv/linux/riscv/configure # Omit irrelevant whitespace and comment-only changes, # perhaps from a slightly-different Autoconf version. git checkout -f \ sysdeps/csky/configure \ sysdeps/hppa/configure \ sysdeps/riscv/configure \ sysdeps/unix/sysv/linux/csky/configure # Omit changes that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines git checkout -f \ sysdeps/powerpc/powerpc64/ppc-mcount.S \ sysdeps/unix/sysv/linux/s390/s390-64/syscall.S # Omit change that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
145 lines
3.7 KiB
C
145 lines
3.7 KiB
C
/* Copyright (C) 2012-2019 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
Contributed by Marek Polacek <polacek@redhat.com>, 2012.
|
|
|
|
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
|
|
<https://www.gnu.org/licenses/>. */
|
|
|
|
/* Adapted from gcc.dg/torture/builtin-complex-1.c test from GCC
|
|
testsuite written by Joseph S. Myers. */
|
|
|
|
#include <complex.h>
|
|
|
|
static int result;
|
|
|
|
#define COMPARE_BODY(A, B, TYPE, COPYSIGN) \
|
|
do { \
|
|
TYPE s1 = COPYSIGN ((TYPE) 1.0, A); \
|
|
TYPE s2 = COPYSIGN ((TYPE) 1.0, B); \
|
|
if (s1 != s2) \
|
|
result |= 1; \
|
|
if ((__builtin_isnan (A) != 0) != (__builtin_isnan (B) != 0)) \
|
|
result |= 1; \
|
|
if ((A != B) != (__builtin_isnan (A) != 0)) \
|
|
result |= 1; \
|
|
} while (0)
|
|
|
|
#ifdef CMPLX
|
|
|
|
static void
|
|
comparef (float a, float b)
|
|
{
|
|
COMPARE_BODY (a, b, float, __builtin_copysignf);
|
|
}
|
|
|
|
static void
|
|
compare (double a, double b)
|
|
{
|
|
COMPARE_BODY (a, b, double, __builtin_copysign);
|
|
}
|
|
|
|
static void
|
|
comparel (long double a, long double b)
|
|
{
|
|
COMPARE_BODY (a, b, long double, __builtin_copysignl);
|
|
}
|
|
|
|
static void
|
|
comparecf (_Complex float a, float r, float i)
|
|
{
|
|
comparef (__real__ a, r);
|
|
comparef (__imag__ a, i);
|
|
}
|
|
|
|
static void
|
|
comparec (_Complex double a, double r, double i)
|
|
{
|
|
compare (__real__ a, r);
|
|
compare (__imag__ a, i);
|
|
}
|
|
|
|
static void
|
|
comparecl (_Complex long double a, long double r, long double i)
|
|
{
|
|
comparel (__real__ a, r);
|
|
comparel (__imag__ a, i);
|
|
}
|
|
|
|
#define VERIFY(A, B, TYPE, COMPARE, CL) \
|
|
do { \
|
|
TYPE a = A; \
|
|
TYPE b = B; \
|
|
_Complex TYPE cr = CL (a, b); \
|
|
static _Complex TYPE cs = CL (A, B); \
|
|
COMPARE (cr, A, B); \
|
|
COMPARE (cs, A, B); \
|
|
} while (0)
|
|
|
|
#define ALL_CHECKS(PZ, NZ, NAN, INF, TYPE, COMPARE, CL) \
|
|
do { \
|
|
VERIFY (PZ, PZ, TYPE, COMPARE, CL); \
|
|
VERIFY (PZ, NZ, TYPE, COMPARE, CL); \
|
|
VERIFY (PZ, NAN, TYPE, COMPARE, CL); \
|
|
VERIFY (PZ, INF, TYPE, COMPARE, CL); \
|
|
VERIFY (NZ, PZ, TYPE, COMPARE, CL); \
|
|
VERIFY (NZ, NZ, TYPE, COMPARE, CL); \
|
|
VERIFY (NZ, NAN, TYPE, COMPARE, CL); \
|
|
VERIFY (NZ, INF, TYPE, COMPARE, CL); \
|
|
VERIFY (NAN, PZ, TYPE, COMPARE, CL); \
|
|
VERIFY (NAN, NZ, TYPE, COMPARE, CL); \
|
|
VERIFY (NAN, NAN, TYPE, COMPARE, CL); \
|
|
VERIFY (NAN, INF, TYPE, COMPARE, CL); \
|
|
VERIFY (INF, PZ, TYPE, COMPARE,CL); \
|
|
VERIFY (INF, NZ, TYPE, COMPARE, CL); \
|
|
VERIFY (INF, NAN, TYPE, COMPARE, CL); \
|
|
VERIFY (INF, INF, TYPE, COMPARE, CL); \
|
|
} while (0)
|
|
|
|
static void
|
|
check_float (void)
|
|
{
|
|
ALL_CHECKS (0.0f, -0.0f, __builtin_nanf (""), __builtin_inff (),
|
|
float, comparecf, CMPLXF);
|
|
}
|
|
|
|
static void
|
|
check_double (void)
|
|
{
|
|
ALL_CHECKS (0.0, -0.0, __builtin_nan (""), __builtin_inf (),
|
|
double, comparec, CMPLX);
|
|
}
|
|
|
|
static void
|
|
check_long_double (void)
|
|
{
|
|
ALL_CHECKS (0.0l, -0.0l, __builtin_nanl (""), __builtin_infl (),
|
|
long double, comparecl, CMPLXL);
|
|
}
|
|
#endif
|
|
|
|
static int
|
|
do_test (void)
|
|
{
|
|
#ifdef CMPLX
|
|
check_float ();
|
|
check_double ();
|
|
check_long_double ();
|
|
#endif
|
|
|
|
return result;
|
|
}
|
|
|
|
#define TEST_FUNCTION do_test ()
|
|
#include "../test-skeleton.c"
|