hjl / source-git / glibc

Forked from source-git/glibc 3 years ago
Clone

Blame sysdeps/ieee754/ldbl-128ibm/test-fmodrem-ldbl-128ibm.c

Packit 6c4009
/* Test for ldbl-128ibm fmodl etc. handling of equal values.
Packit 6c4009
   Copyright (C) 2016-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <fenv.h>
Packit 6c4009
#include <float.h>
Packit 6c4009
#include <math.h>
Packit 6c4009
#include <stdio.h>
Packit 6c4009
Packit 6c4009
/* FUNC is defined to be the name of the function to test.  */
Packit 6c4009
#define STRX(x) #x
Packit 6c4009
#define STR(x) STRX (x)
Packit 6c4009
#define SFUNC STR (FUNC)
Packit 6c4009
Packit 6c4009
union u
Packit 6c4009
{
Packit 6c4009
  long double ld;
Packit 6c4009
  double d[2];
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
volatile union u p1 = { .d = { DBL_MIN, 0.0 } };
Packit 6c4009
volatile union u p2 = { .d = { DBL_MIN, -0.0 } };
Packit 6c4009
volatile union u m1 = { .d = { -DBL_MIN, 0.0 } };
Packit 6c4009
volatile union u m2 = { .d = { -DBL_MIN, -0.0 } };
Packit 6c4009
Packit 6c4009
static int
Packit 6c4009
test_func (const char *s, long double x, long double y, long double expected)
Packit 6c4009
{
Packit 6c4009
  volatile long double r;
Packit 6c4009
  r = FUNC (x, y);
Packit 6c4009
  if (r != expected || copysignl (1.0, r) != copysignl (1.0, expected))
Packit 6c4009
    {
Packit 6c4009
      printf ("FAIL: " SFUNC " (%s)\n", s);
Packit 6c4009
      return 1;
Packit 6c4009
    }
Packit 6c4009
  else
Packit 6c4009
    {
Packit 6c4009
      printf ("PASS: " SFUNC " (%s)\n", s);
Packit 6c4009
      return 0;
Packit 6c4009
    }
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
#define TEST_FUNC(a, b, e) test_func (#a ", " #b, a, b, e)
Packit 6c4009
Packit 6c4009
static int
Packit 6c4009
do_test (void)
Packit 6c4009
{
Packit 6c4009
  int result = 0;
Packit 6c4009
  SETUP;
Packit 6c4009
  result |= TEST_FUNC (p1.ld, p1.ld, 0.0L);
Packit 6c4009
  result |= TEST_FUNC (p1.ld, p2.ld, 0.0L);
Packit 6c4009
  result |= TEST_FUNC (p1.ld, m1.ld, 0.0L);
Packit 6c4009
  result |= TEST_FUNC (p1.ld, m2.ld, 0.0L);
Packit 6c4009
  result |= TEST_FUNC (p2.ld, p1.ld, 0.0L);
Packit 6c4009
  result |= TEST_FUNC (p2.ld, p2.ld, 0.0L);
Packit 6c4009
  result |= TEST_FUNC (p2.ld, m1.ld, 0.0L);
Packit 6c4009
  result |= TEST_FUNC (p2.ld, m2.ld, 0.0L);
Packit 6c4009
  result |= TEST_FUNC (m1.ld, p1.ld, -0.0L);
Packit 6c4009
  result |= TEST_FUNC (m1.ld, p2.ld, -0.0L);
Packit 6c4009
  result |= TEST_FUNC (m1.ld, m1.ld, -0.0L);
Packit 6c4009
  result |= TEST_FUNC (m1.ld, m2.ld, -0.0L);
Packit 6c4009
  result |= TEST_FUNC (m2.ld, p1.ld, -0.0L);
Packit 6c4009
  result |= TEST_FUNC (m2.ld, p2.ld, -0.0L);
Packit 6c4009
  result |= TEST_FUNC (m2.ld, m1.ld, -0.0L);
Packit 6c4009
  result |= TEST_FUNC (m2.ld, m2.ld, -0.0L);
Packit 6c4009
  return result;
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
#define TEST_FUNCTION do_test ()
Packit 6c4009
#include "../../../test-skeleton.c"