public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix nexttowardl if compiling new program against new glibc headers with -mlong-double-64
@ 2006-02-02 15:23 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2006-02-02 15:23 UTC (permalink / raw)
  To: Roland McGrath; +Cc: Glibc hackers

[-- Attachment #1: Type: text/plain, Size: 1969 bytes --]

Hi!

I have (hopefully) finished the ldbl-dbl-tst.c testcase I posted
a few weeks ago and tested it in various ways on ppc{32,64} and s390{,x}
with already installed new glibc, in all cases using -O0 -fno-builtin
to avoid compiler/inlines optimizing stuff out.
1) compiled/linked the program against older (non-ldbl) glibc, run against old glibc
2) run the same binary against new glibc
3) compile against old glibc, link with -lnldbl_nonshared -lm, run against new glibc
4) compile/run against new glibc with -mlong-double-64
5) compile/run against new glibc with -mlong-double-128
Repeat the same also for -D_FORTIFY_SOURCE=2.

The only failures were in 4) on s390{,x} where it segfaulted, fixed by
the patch below, and 5) on ppc{32,64} where the test on line 262 failed,
due to apparently different rounding.
#include <printf.h>
#include <stdio.h>

int main (void)
{
  register_printf_function ('B', printf_size, printf_size_info);
  register_printf_function ('b', printf_size, printf_size_info);
  printf ("%LB %LB %B %B\n", 3.25L, 7834.5L, 3.75, 7835.5);
  puts ("Expected");
  printf ("3.250  7.835K 3.750  7.835K\n");
  return 0;
}

on ppc{32,64} with -mlong-double-128 prints:
3.250  7.834K 3.750  7.835K
Expected
3.250  7.835K 3.750  7.835K
while on x86_64 or s390/s390x with -mlong-double-128 prints the expected
output.

2006-02-02  Jakub Jelinek  <jakub@redhat.com>

	* math/math.h [__LDBL_COMPAT && __USE_ISOC99] (nexttowardl): New
	prototype.

--- libc/math/math.h.jj	2006-01-14 17:41:02.000000000 +0100
+++ libc/math/math.h	2006-02-02 15:26:29.000000000 +0100
@@ -110,6 +110,9 @@ extern float __REDIRECT_NTH (nexttowardf
      __attribute__ ((__const__));
 extern double __REDIRECT_NTH (nexttoward, (double __x, long double __y),
 			      nextafter) __attribute__ ((__const__));
+extern long double __REDIRECT_NTH (nexttowardl,
+				   (long double __x, long double __y),
+				   nextafter) __attribute__ ((__const__));
 #    endif
 #   endif
 

	Jakub

[-- Attachment #2: ldbl-dbl-tst.c --]
[-- Type: text/plain, Size: 24501 bytes --]

#define _GNU_SOURCE 1
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>
#include <monetary.h>
#include <printf.h>
#include <math.h>
#include <complex.h>
#include <syslog.h>
#include <string.h>
#include <obstack.h>
#include <unistd.h>
#include <locale.h>

#define obstack_chunk_alloc malloc
#define obstack_chunk_free free

#ifdef __NO_LONG_DOUBLE_MATH
/* Provide prototypes ourselves.  */
extern long double acoshl (long double);
extern long double acosl (long double);
extern long double asinhl (long double);
extern long double asinl (long double);
extern long double atan2l (long double, long double);
extern long double atanhl (long double);
extern long double atanl (long double);
extern long double cbrtl (long double);
extern long double ceill (long double);
extern long double copysignl (long double, long double);
extern long double coshl (long double);
extern long double cosl (long double);
extern long double dreml (long double, long double);
extern long double erfcl (long double);
extern long double erfl (long double);
extern long double exp10l (long double);
extern long double exp2l (long double);
extern long double expl (long double);
extern long double expm1l (long double);
extern long double fabsl (long double);
extern long double fdiml (long double, long double);
extern int __finitel (long double);
extern int finitel (long double);
extern long double floorl (long double);
extern long double fmal (long double, long double, long double);
extern long double fmaxl (long double, long double);
extern long double fminl (long double, long double);
extern long double fmodl (long double, long double);
extern long double frexpl (long double, int *);
extern long double gammal (long double);
extern long double hypotl (long double, long double);
extern int ilogbl (long double);
extern int isinfl (long double);
extern int isnanl (long double);
extern long double j0l (long double);
extern long double j1l (long double);
extern long double jnl (int, long double);
extern long double ldexpl (long double, int);
extern long double lgammal (long double);
extern long double lgammal_r (long double, int *);
extern long long int llrintl (long double);
extern long long int llroundl (long double);
extern long double log10l (long double);
extern long double log1pl (long double);
extern long double log2l (long double);
extern long double logbl (long double);
extern long double logl (long double);
extern long int lrintl (long double);
extern long int lroundl (long double);
extern long double nanl (const char *);
extern long double nexttowardl (long double, long double);
extern long double modfl (long double, long double *);
extern long double nearbyintl (long double);
extern long double nextafterl (long double, long double);
extern long double pow10l (long double);
extern long double powl (long double, long double);
extern long double remainderl (long double, long double);
extern long double remquol (long double, long double, int *);
extern long double rintl (long double);
extern long double roundl (long double);
extern long double scalbl (long double, long double);
extern long double scalblnl (long double, long int);
extern long double scalbnl (long double, int);
extern long double significandl (long double);
extern void sincosl (long double, long double *, long double *);
extern long double sinhl (long double);
extern long double sinl (long double);
extern long double sqrtl (long double);
extern long double tanhl (long double);
extern long double tanl (long double);
extern long double tgammal (long double);
extern long double truncl (long double);
extern long double y0l (long double);
extern long double y1l (long double);
extern long double ynl (int, long double);
#endif

_Complex long double lc1;
long double l1, l2;
_Complex double dc1;
double d1, d2;

int failures;
#define CHECK(x) \
  do {								\
    if (!(x))							\
      {								\
	fprintf (stderr, "failure on line %d\n", __LINE__);	\
	++failures;						\
      }								\
  } while (0)

#define CHECK2(x, y) \
  do {								\
    l1 = x;							\
    /* Avoid using fabsl here, we want to test it too.  */	\
    CHECK ((l1 > y && (l1 - y) < 0.01L)				\
	   || (l1 <= y && (y - l1) < 0.01L));			\
  } while (0)

#define CHECK3(fn, x, y) \
  CHECK2 (fn##l (x##L), y##L);					\
  CHECK2 (fn (x), y)

#define CHECK4(fn, x, y, z) \
  CHECK2 (fn##l (x##L, y##L), z##L);				\
  CHECK2 (fn (x, y), z)

#define CHECK5(fn, x, y, z, w) \
  CHECK2 (fn##l (x##L, y##L, z##L), w##L);			\
  CHECK2 (fn (x, y, z), w)

#define CHECKC3(fn, x, yr, yc) \
  lc1 = fn##l (x##L);						\
  CHECK2 (__real__ lc1, yr##L);					\
  CHECK2 (__imag__ lc1, yc##L);					\
  dc1 = fn (x);							\
  CHECK2 (__real__ dc1, yr);					\
  CHECK2 (__imag__ dc1, yc)

#define CHECKC4(fn, x, y, zr, zc) \
  lc1 = fn##l (x##L, y##L);					\
  CHECK2 (__real__ lc1, zr##L);					\
  CHECK2 (__imag__ lc1, zc##L);					\
  dc1 = fn (x, y);						\
  CHECK2 (__real__ dc1, zr);					\
  CHECK2 (__imag__ dc1, zc)

void
test (va_list *ap, va_list *pap)
{
  int i;

  if (freopen ("/proc/self/fd/1", "w", stderr) == NULL)
    CHECK (0);

  CHECK (setlocale (LC_ALL, "en_US.ISO-8859-1") != NULL);
  locale_t loc = newlocale (LC_ALL_MASK, "en_US.ISO-8859-1", NULL);
  CHECK (loc != NULL);
  locale_t loc2 = newlocale (LC_ALL_MASK, "cs_CZ.UTF-8", NULL);
  CHECK (loc2 != NULL);

  char tmpp2[] = "/tmp/tst-ldbl-dbl-XXXXXX";
  int fd = mkstemp (tmpp2);
  if (fd < 0)
    CHECK (0);
  char tmpp[sizeof ("/proc/self/fd/%d") + 3 * sizeof (int)];
  snprintf (tmpp, sizeof (tmpp), "/proc/self/fd/%d", fd);
  unlink (tmpp2);
  if (freopen (tmpp, "w", stdout) == NULL)
    CHECK (0);

  /* asprintf, dprintf, fprintf, fwprintf, obstack_printf, obstack_vprintf,
     printf, printf_size, snprintf, sprintf, swprintf, vasprintf, vdprintf,
     vfprintf, vfwprintf, vprintf, vsnprintf, vsprintf, vswprintf, vwprintf,
     wprintf */
  /* _IO_fprintf, _IO_printf, _IO_sprintf, _IO_vfprintf, _IO_vsprintf,
     __asprintf, __vsnprintf, __fprintf_chk, __fwprintf_chk, __printf_chk,
     __snprintf_chk, __sprintf_chk, __swprintf_chk, __vfprintf_chk,
     __vfwprintf_chk, __vprintf_chk, __vsnprintf_chk, __vsprintf_chk,
     __vswprintf_chk, __vwprintf_chk, __wprintf_chk, __printf_fp */
  char *p;
  p = NULL;
  asprintf (&p, "%Lg %5.9Lf %g %5.9f\n", 3.25L, 7834.5L, 3.75, 7835.5);
  CHECK (strcmp (p, "3.25 7834.500000000 3.75 7835.500000000\n") == 0);
  free (p);
  p = NULL;
  vasprintf (&p, "%Lg %5.9Lf %g %5.9f\n", *ap++);
  CHECK (strcmp (p, "3.25 7834.500000000 3.75 7835.500000000\n") == 0);
  free (p);
  fflush (stdout);
  dprintf (1, "%Lg %5.9Lf %g %5.9f\n", 3.25L, 7834.5L, 3.75, 7835.5);
  vdprintf (1, "%Lg %5.9Lf %g %5.9f\n", *ap++);
  fflush (stdout);
  fprintf (stdout, "%Lg %5.9Lf %g %5.9f\n", 3.25L, 7834.5L, 3.75, 7835.5);
  vfprintf (stdout, "%Lg %5.9Lf %g %5.9f\n", *ap++);
  printf ("%Lg %5.9Lf %g %5.9f\n", 3.25L, 7834.5L, 3.75, 7835.5);
  vprintf ("%Lg %5.9Lf %g %5.9f\n", *ap++);
  struct obstack o;
  obstack_init (&o);
  obstack_printf (&o, "%Lg %5.9Lf %g %5.9f\n", 3.25L, 7834.5L, 3.75, 7835.5);
  obstack_1grow (&o, 0);
  p = obstack_finish (&o);
  CHECK (strcmp (p, "3.25 7834.500000000 3.75 7835.500000000\n") == 0);
  obstack_1grow (&o, 'z');
  obstack_finish (&o);
  obstack_vprintf (&o, "%Lg %5.9Lf %g %5.9f\n", *ap++);
  obstack_1grow (&o, 0);
  p = obstack_finish (&o);
  CHECK (strcmp (p, "3.25 7834.500000000 3.75 7835.500000000\n") == 0);
  obstack_free (&o, NULL);
  char buf[80];
  memset (buf, 0, sizeof (buf));
  sprintf (buf, "%Lg %5.9Lf %g %5.9f\n", 3.25L, 7834.5L, 3.75, 7835.5);
  CHECK (strcmp (buf, "3.25 7834.500000000 3.75 7835.500000000\n") == 0);
  memset (buf, 0, sizeof (buf));
  vsprintf (buf, "%Lg %5.9Lf %g %5.9f\n", *ap++);
  CHECK (strcmp (buf, "3.25 7834.500000000 3.75 7835.500000000\n") == 0);
  memset (buf, 0, sizeof (buf));
  snprintf (buf, 80, "%Lg %5.9Lf %g %5.9f\n", 3.25L, 7834.5L, 3.75, 7835.5);
  CHECK (strcmp (buf, "3.25 7834.500000000 3.75 7835.500000000\n") == 0);
  memset (buf, 0, sizeof (buf));
  vsnprintf (buf, 80, "%Lg %5.9Lf %g %5.9f\n", *ap++);
  CHECK (strcmp (buf, "3.25 7834.500000000 3.75 7835.500000000\n") == 0);
  fflush (stdout);
  if (freopen (tmpp, "r", stdin) == NULL)
    CHECK (0);
  for (i = 0; i < 6; i++)
    {
      memset (buf, 0, sizeof (buf));
      CHECK (fgets (buf, sizeof (buf), stdin) == buf);
      CHECK (strcmp (buf, "3.25 7834.500000000 3.75 7835.500000000\n") == 0);
    }
  if (freopen (tmpp, "w", stdout) == NULL)
    CHECK (0);
  fwprintf (stdout, L"%Lg %5.9Lf %g %5.9f\n", 3.25L, 7834.5L, 3.75, 7835.5);
  vfwprintf (stdout, L"%Lg %5.9Lf %g %5.9f\n", *ap++);
  wprintf (L"%Lg %5.9Lf %g %5.9f\n", 3.25L, 7834.5L, 3.75, 7835.5);
  vwprintf (L"%Lg %5.9Lf %g %5.9f\n", *ap++);
  fflush (stdout);
  if (freopen (tmpp, "r", stdin) == NULL)
    CHECK (0);
  for (i = 0; i < 4; i++)
    {
      memset (buf, 0, sizeof (buf));
      CHECK (fgets (buf, sizeof (buf), stdin) == buf);
      CHECK (strcmp (buf, "3.25 7834.500000000 3.75 7835.500000000\n") == 0);
    }
  if (freopen (tmpp, "w", stdout) == NULL)
    CHECK (0);
  wchar_t wbuf[80];
  memset (wbuf, 0, sizeof (wbuf));
  swprintf (wbuf, 80, L"%Lg %5.9Lf %g %5.9f\n", 3.25L, 7834.5L, 3.75, 7835.5);
  CHECK (wcscmp (wbuf, L"3.25 7834.500000000 3.75 7835.500000000\n") == 0);
  memset (wbuf, 0, sizeof (wbuf));
  vswprintf (wbuf, 80, L"%Lg %5.9Lf %g %5.9f\n", *ap++);
  CHECK (wcscmp (wbuf, L"3.25 7834.500000000 3.75 7835.500000000\n") == 0);
  register_printf_function ('B', printf_size, printf_size_info);
  register_printf_function ('b', printf_size, printf_size_info);
  memset (buf, 0, sizeof (buf));
  sprintf (buf, "%LB %LB %B %B\n", 3.25L, 7834.5L, 3.75, 7835.5);
  CHECK (strcmp (buf, "3.250  7.835K 3.750  7.835K\n") == 0);
  memset (buf, 0, sizeof (buf));
  vsprintf (buf, "%Lb %Lb %b %b\n", *ap++);
  CHECK (strcmp (buf, "3.250  7.651k 3.750  7.652k\n") == 0);

  /* fscanf, fwscanf, scanf, sscanf, swscanf, vfscanf, vfwscanf, vscanf,
     vsscanf, vswscanf, vwscanf, wscanf */
  /* _IO_sscanf, _IO_vfscanf, __vfscanf, __vsscanf */
  l1 = 0; l2 = 0; d1 = 0; d2 = 0;
  CHECK (sscanf ("8.125 16372.625 -9.5 32163.125", "%Lf %Lf %lf %lf\n", &l1, &l2, &d1, &d2) == 4);
  CHECK (l1 == 8.125L && l2 == 16372.625 && d1 == -9.5 && d2 == 32163.125);
  l1 = 0; l2 = 0; d1 = 0; d2 = 0;
  CHECK (vsscanf ("8.125 16372.625 -9.5 32163.125", "%Lf %Lf %lf %lf\n", *pap++) == 4);
  CHECK (l1 == 8.125L && l2 == 16372.625 && d1 == -9.5 && d2 == 32163.125);
  for (i = 0; i < 4; i++)
    puts ("8.125 16372.625 -9.5 32163.125");
  fflush (stdout);
  if (freopen (tmpp, "r", stdin) == NULL)
    CHECK (0);
  l1 = 0; l2 = 0; d1 = 0; d2 = 0;
  CHECK (fscanf (stdin, "%Lf %Lf %lf %lf\n", &l1, &l2, &d1, &d2) == 4);
  CHECK (l1 == 8.125L && l2 == 16372.625 && d1 == -9.5 && d2 == 32163.125);
  l1 = 0; l2 = 0; d1 = 0; d2 = 0;
  CHECK (vfscanf (stdin, "%Lf %Lf %lf %lf\n", *pap++) == 4);
  CHECK (l1 == 8.125L && l2 == 16372.625 && d1 == -9.5 && d2 == 32163.125);
  l1 = 0; l2 = 0; d1 = 0; d2 = 0;
  CHECK (scanf ("%Lf %Lf %lf %lf\n", &l1, &l2, &d1, &d2) == 4);
  CHECK (l1 == 8.125L && l2 == 16372.625 && d1 == -9.5 && d2 == 32163.125);
  l1 = 0; l2 = 0; d1 = 0; d2 = 0;
  CHECK (vscanf ("%Lf %Lf %lf %lf\n", *pap++) == 4);
  CHECK (l1 == 8.125L && l2 == 16372.625 && d1 == -9.5 && d2 == 32163.125);
  if (freopen (tmpp, "r", stdin) == NULL)
    CHECK (0);
  l1 = 0; l2 = 0; d1 = 0; d2 = 0;
  CHECK (swscanf (L"8.125 16372.625 -9.5 32163.125", L"%Lf %Lf %lf %lf\n", &l1, &l2, &d1, &d2) == 4);
  CHECK (l1 == 8.125L && l2 == 16372.625 && d1 == -9.5 && d2 == 32163.125);
  l1 = 0; l2 = 0; d1 = 0; d2 = 0;
  CHECK (vswscanf (L"8.125 16372.625 -9.5 32163.125", L"%Lf %Lf %lf %lf\n", *pap++) == 4);
  CHECK (l1 == 8.125L && l2 == 16372.625 && d1 == -9.5 && d2 == 32163.125);
  l1 = 0; l2 = 0; d1 = 0; d2 = 0;
  CHECK (fwscanf (stdin, L"%Lf %Lf %lf %lf\n", &l1, &l2, &d1, &d2) == 4);
  CHECK (l1 == 8.125L && l2 == 16372.625 && d1 == -9.5 && d2 == 32163.125);
  l1 = 0; l2 = 0; d1 = 0; d2 = 0;
  CHECK (vfwscanf (stdin, L"%Lf %Lf %lf %lf\n", *pap++) == 4);
  CHECK (l1 == 8.125L && l2 == 16372.625 && d1 == -9.5 && d2 == 32163.125);
  l1 = 0; l2 = 0; d1 = 0; d2 = 0;
  CHECK (wscanf (L"%Lf %Lf %lf %lf\n", &l1, &l2, &d1, &d2) == 4);
  CHECK (l1 == 8.125L && l2 == 16372.625 && d1 == -9.5 && d2 == 32163.125);
  l1 = 0; l2 = 0; d1 = 0; d2 = 0;
  CHECK (vwscanf (L"%Lf %Lf %lf %lf\n", *pap++) == 4);
  CHECK (l1 == 8.125L && l2 == 16372.625 && d1 == -9.5 && d2 == 32163.125);

  /* syslog, vsyslog */
  /* __syslog_chk, __vsyslog_chk */
  syslog (1, "long double test %Lg %5.9Lf %g %5.9f\n", 3.25L, 7834.5L, 3.75, 7835.5);
  vsyslog (1, "long double test %Lg %5.9Lf %g %5.9f\n", *ap++);

  /* qecvt, qecvt_r, qfcvt, qfcvt_r, qgcvt */
  int decpt, sign;
  decpt = -1300; sign = -1300;
  CHECK (strcmp (qecvt (3.25L, 8, &decpt, &sign), "32500000") == 0);
  CHECK (decpt == 1 && sign == 0);
  decpt = -1300; sign = -1300;
  CHECK (strcmp (qecvt (-7834.5L, 9, &decpt, &sign), "783450000") == 0);
  CHECK (decpt == 4 && sign == 1);
  decpt = -1300; sign = -1300;
  CHECK (strcmp (ecvt (3.75, 8, &decpt, &sign), "37500000") == 0);
  CHECK (decpt == 1 && sign == 0);
  decpt = -1300; sign = -1300;
  CHECK (strcmp (ecvt (-7835.5, 9, &decpt, &sign), "783550000") == 0);
  CHECK (decpt == 4 && sign == 1);
  decpt = -1300; sign = -1300;
  CHECK (strcmp (qfcvt (3.25L, 8, &decpt, &sign), "325000000") == 0);
  CHECK (decpt == 1 && sign == 0);
  decpt = -1300; sign = -1300;
  CHECK (strcmp (qfcvt (-7834.5L, 9, &decpt, &sign), "7834500000000") == 0);
  CHECK (decpt == 4 && sign == 1);
  decpt = -1300; sign = -1300;
  CHECK (strcmp (fcvt (3.75, 8, &decpt, &sign), "375000000") == 0);
  CHECK (decpt == 1 && sign == 0);
  decpt = -1300; sign = -1300;
  CHECK (strcmp (fcvt (-7835.5, 9, &decpt, &sign), "7835500000000") == 0);
  CHECK (decpt == 4 && sign == 1);
  decpt = -1300; sign = -1300;
  memset (buf, 0, sizeof (buf));
  CHECK (qecvt_r (3.25L, 8, &decpt, &sign, buf, sizeof (buf)) == 0);
  CHECK (strcmp (buf, "32500000") == 0);
  CHECK (decpt == 1 && sign == 0);
  decpt = -1300; sign = -1300;
  memset (buf, 0, sizeof (buf));
  CHECK (qecvt_r (-7834.5L, 9, &decpt, &sign, buf, sizeof (buf)) == 0);
  CHECK (strcmp (buf, "783450000") == 0);
  CHECK (decpt == 4 && sign == 1);
  decpt = -1300; sign = -1300;
  memset (buf, 0, sizeof (buf));
  CHECK (ecvt_r (3.75, 8, &decpt, &sign, buf, sizeof (buf)) == 0);
  CHECK (strcmp (buf, "37500000") == 0);
  CHECK (decpt == 1 && sign == 0);
  decpt = -1300; sign = -1300;
  memset (buf, 0, sizeof (buf));
  CHECK (ecvt_r (-7835.5, 9, &decpt, &sign, buf, sizeof (buf)) == 0);
  CHECK (strcmp (buf, "783550000") == 0);
  CHECK (decpt == 4 && sign == 1);
  decpt = -1300; sign = -1300;
  memset (buf, 0, sizeof (buf));
  CHECK (qfcvt_r (3.25L, 8, &decpt, &sign, buf, sizeof (buf)) == 0);
  CHECK (strcmp (buf, "325000000") == 0);
  CHECK (decpt == 1 && sign == 0);
  decpt = -1300; sign = -1300;
  memset (buf, 0, sizeof (buf));
  CHECK (qfcvt_r (-7834.5L, 9, &decpt, &sign, buf, sizeof (buf)) == 0);
  CHECK (strcmp (buf, "7834500000000") == 0);
  CHECK (decpt == 4 && sign == 1);
  decpt = -1300; sign = -1300;
  memset (buf, 0, sizeof (buf));
  CHECK (fcvt_r (3.75, 8, &decpt, &sign, buf, sizeof (buf)) == 0);
  CHECK (strcmp (buf, "375000000") == 0);
  CHECK (decpt == 1 && sign == 0);
  decpt = -1300; sign = -1300;
  memset (buf, 0, sizeof (buf));
  CHECK (fcvt_r (-7835.5, 9, &decpt, &sign, buf, sizeof (buf)) == 0);
  CHECK (strcmp (buf, "7835500000000") == 0);
  CHECK (decpt == 4 && sign == 1);
  memset (buf, 0, sizeof (buf));
  CHECK (qgcvt (3.251L, 3, buf) == buf);
  CHECK (strcmp (buf, "3.25") == 0);
  memset (buf, 0, sizeof (buf));
  CHECK (qgcvt (7834.51L, 5, buf) == buf);
  CHECK (strcmp (buf, "7834.5") == 0);
  memset (buf, 0, sizeof (buf));
  CHECK (gcvt (3.751, 3, buf) == buf);
  CHECK (strcmp (buf, "3.75") == 0);
  memset (buf, 0, sizeof (buf));
  CHECK (gcvt (7835.51, 5, buf) == buf);
  CHECK (strcmp (buf, "7835.5") == 0);

  /* strfmon, strfmon_l */
  /* __strfmon_l */
  memset (buf, 0, sizeof (buf));
  strfmon (buf, sizeof (buf), "%Ln %Ln %n %n", 3.25L, 7834.5L, 3.75, 7835.5);
  CHECK (strcmp (buf, "$3.25 $7,834.50 $3.75 $7,835.50") == 0);
  memset (buf, 0, sizeof (buf));
  strfmon_l (buf, sizeof (buf), loc, "%Ln %Ln %n %n", 3.25L, 7834.5L, 3.75, 7835.5);
  CHECK (strcmp (buf, "$3.25 $7,834.50 $3.75 $7,835.50") == 0);

  /* strtold, strtold_l, wcstold, wcstold_l */
  /* __strtold_l, __wcstold_l, __strtold_internal, __wcstold_internal */
  char *q = "1324.75";
  CHECK (strtold (q, &p) == 1324.75L && p == q + 7);
  q = "12325,75";
  CHECK (strtold_l (q, &p, loc2) == 12325.75L && p == q + 8);
  wchar_t *r = L"1374.25", *s;
  CHECK (wcstold (r, &s) == 1374.25L && s == r + 7);
  r = L"18374,125";
  CHECK (wcstold_l (r, &s, loc2) == 18374.125L && s == r + 9);

  /* acoshl, acosl, asinhl, asinl, atan2l, atanhl, atanl, cabsl, cacoshl,
     cacosl, cargl, casinhl, casinl, catanhl, catanl, cbrtl, ccoshl, ccosl,
     ceill, cexpl, cimagl, clog10l, clogl, conjl, copysignl, coshl, cosl,
     cpowl, cprojl, creall, csinhl, csinl, csqrtl, ctanhl, ctanl, dreml,
     erfcl, erfl, exp10l, exp2l, expl, expm1l, fabsl, fdiml, finitel, floorl,
     fmal, fmaxl, fminl, fmodl, frexpl, gammal, hypotl, ilogbl, isinfl,
     isnanl, j0l, j1l, jnl, ldexpl, lgammal, lgammal_r, llrintl, llroundl,
     log10l, log1pl, log2l, logbl, logl, lrintl, lroundl, nexttoward,
     nexttowardf, modfl, nanl, nearbyintl, nextafterl, nexttowardl,
     pow10l, powl, remainderl, remquol, rintl, roundl, scalbl, scalblnl,
     scalbnl, significandl, sincosl, sinhl, sinl, sqrtl, tanhl, tanl,
     tgammal, truncl, y0l, y1l, ynl */
  /* __clog10l, __finitel, __isinfl, __isnanl, __signbitl */
  CHECK3 (acosh, 7.0, 2.6339);
  CHECK3 (acos, 0.75, 0.722734);
  CHECK3 (asinh, 0.75, 0.69314718);
  CHECK3 (asin, 0.75, 0.848062078);
  CHECK4 (atan2, 0.75, 1.0, 0.6435011);
  CHECK3 (atanh, 0.75, 0.97295507);
  CHECK3 (atan, 0.75, 0.6435011);
  CHECK3 (cabs, 0.75 + I * 1.25, 1.457737973711325);
  CHECKC3 (cacosh, 0.75 + I * 1.25, 1.1323936316053, 1.1175201491561);
  CHECKC3 (cacos, -2 + I * -3, 2.141449111115996, 1.9833870299165);
  CHECK3 (carg, 2.0 + I * 3.0, 0.982793723247);
  CHECKC3 (casinh, 0.75 + I * 1.25, 1.03171853444778, 0.91173829096849);
  CHECKC3 (casin, -2 + I * -3, -0.570652784321, -1.9833870299165354);
  CHECKC3 (catanh, 0.75 + I * 1.25, 0.26149213879567, 0.99682512646392);
  CHECKC3 (catan, -2 + I * -3, -1.4099210495965755, -0.229072682968539);
  CHECK3 (cbrt, 0.75, 0.908560296);
  CHECKC3 (ccosh, -2 + I * -3, -3.72454550491532, 0.5118225699873846);
  CHECKC3 (ccos, 0.75 + I * 1.25, 1.38173873063426, -1.09193013555397);
  CHECK3 (ceil, 0.25, 1.0);
  CHECKC3 (cexp, -2.0 + I * -3.0, -0.13398091492954, -0.019098516261135);
  CHECK3 (cimag, 6.5 + I * 18.5, 18.5);
  CHECKC3 (clog10, 0.75 + I * 1.25, 0.163679467193165, 0.447486970040493);
  CHECKC3 (clog, -2 + I * -3, 1.28247467873077, -2.15879893034246417);
  CHECKC3 (conj, 3.0 + I * -4.0, 3.0, 4.0);
  CHECK4 (copysign, 3.25, -5.125, -3.25);
  CHECK3 (cosh, 0.75, 1.29468328);
  CHECK3 (cos, 0.75, 0.731688868);
  CHECKC4 (cpow, 0.75 + I * 1.25, I * 1.0, 0.3318254391776, 0.131338600281);
  CHECKC3 (cproj, 2.0 + I * 3.0, 0.2857142857142857, 0.42857142857142857);
  CHECK3 (creal, 6.5 + I * 18.5, 6.5);
  CHECKC3 (csinh, 0.75 + I * 1.25, 0.25929485455116, 1.228634524095);
  CHECKC3 (csin, 0.75 + I * 1.25, 1.28722291002649, 1.1721063598927);
  CHECKC3 (csqrt, -2 + I * 3, 0.8959774761298, 1.67414922803554);
  CHECKC3 (ctanh, 0.75 + I * 1.25, 1.37260757053, 0.38579595260975);
  CHECKC3 (ctan, 0.75 + I * 1.25, 0.160807785916206, 0.9753632850312356);
  CHECK4 (drem, 6.2, 2.31, -0.73);
  CHECK3 (erfc, 2.0, 0.00467773498);
  CHECK3 (erf, 2.0, 0.995322265);
  CHECK3 (exp10, 0.75, 5.6234132519);
#ifndef __NO_LONG_DOUBLE_MATH
  /* exp2l hasn't been exported from libm before glibc 2.4.  */
  CHECK3 (exp2, 0.75, 1.68179283);
#endif
  CHECK3 (exp, 0.75, 2.1170000166);
  CHECK3 (expm1, 0.75, 1.1170000166);
  CHECK3 (fabs, -17.25, 17.25);
  CHECK4 (fdim, 7.9, 2.3, 5.6);
  CHECK (finitel (2.5L) != 0);
  CHECK (finitel (HUGE_VALL) == 0);
  CHECK (finitel ((long double) NAN) == 0);
  CHECK (finite (2.5) != 0);
  CHECK (finite (HUGE_VAL) == 0);
  CHECK (finite ((double) NAN) == 0);
  CHECK (__finitel (2.5L) != 0);
  CHECK (__finitel (HUGE_VALL) == 0);
  CHECK (__finitel ((long double) NAN) == 0);
  CHECK (__finite (2.5) != 0);
  CHECK (__finite (HUGE_VAL) == 0);
  CHECK (__finite ((double) NAN) == 0);
  CHECK3 (floor, 3.25, 3.0);
  CHECK5 (fma, 2.4, 4.8, 7.1, 18.62);
  CHECK4 (fmax, 17.8, 19.1, 19.1);
  CHECK4 (fmin, 17.8, 19.1, 17.8);
  CHECK4 (fmod, 6.2, 2.31, 1.58);
  i = -1;
  CHECK2 (frexpl (12.8L, &i), 0.8L);
  CHECK (i == 4);
  i = -1;
  CHECK2 (frexp (12.8, &i), 0.8);
  CHECK (i == 4);
  CHECK3 (gamma, 3, 0.6931471805599);
  CHECK4 (hypot, 0.7, -12.4, 12.4197423);
  CHECK (ilogbl (-2000.0L) == 10);
  CHECK (ilogb (-2000.0) == 10);
  CHECK (isinfl (HUGE_VALL) == 1);
  CHECK (isinfl (-HUGE_VALL) == -1);
  CHECK (isinfl (3.2L) == 0);
  CHECK (isinfl ((long double) NAN) == 0);
  CHECK (isinf (HUGE_VAL) == 1);
  CHECK (isinf (-HUGE_VAL) == -1);
  CHECK (isinf (3.2) == 0);
  CHECK (isinf ((double) NAN) == 0);
  CHECK (isnanl (HUGE_VALL) == 0);
  CHECK (isnanl (3.2L) == 0);
  CHECK (isnanl ((long double) NAN) != 0);
  CHECK (isnan (HUGE_VAL) == 0);
  CHECK (isnan (3.2) == 0);
  CHECK (isnan ((double) NAN) != 0);
  CHECK3 (j0, 0.75, 0.864242275);
  CHECK3 (j1, 0.75, 0.349243602);
  CHECK4 (jn, 3.0, 2.0, 0.12894324947);
  CHECK4 (ldexp, 0.8, 4, 12.8);
  signgam = -2;
  CHECK2 (lgammal (0.7L), 0.260867246531666514L);
  CHECK (signgam == 1);
  signgam = -2;
  CHECK2 (lgamma (0.7), 0.260867246531666514);
  CHECK (signgam == 1);
  i = -2;
  CHECK2 (lgammal_r (0.7L, &i), 0.260867246531666514L);
  CHECK (i == 1);
  i = -2;
  CHECK2 (lgamma_r (0.7, &i), 0.260867246531666514);
  CHECK (i == 1);
  CHECK3 (llrint, 1071930.0008, 1071930);
  CHECK3 (llround, 1071930.0008, 1071930);
  CHECK3 (log10, 0.75, -0.124938736608);
  CHECK3 (log1p, -0.25, -0.28768207245178);
  CHECK3 (log2, 0.75, -.4150374992788);
  CHECK3 (logb, -2000, 10);
  CHECK3 (log, 0.75, -0.28768207245);
  CHECK3 (lrint, 1071930.0008, 1071930);
  CHECK3 (lround, 1071930.0008, 1071930);
  CHECK4 (nexttoward, 9, 9, 9);
  CHECK (nexttowardf (18.f, 18.L) == 18.f);
  l2 = 16.0L;
  CHECK2 (modfl (89.5L, &l2), 0.5L);
  CHECK (l2 == 89.0L);
  d1 = 16.0;
  CHECK2 (modf (89.5, &d1), 0.5);
  CHECK (d1 == 89.0);
  l1 = nanl ("01234");
  CHECK (isnan (l1) != 0);
  d1 = nan ("01234");
  CHECK (isnan (d1) != 0);
  CHECK3 (nearbyint, 1.5, 2.0);
  CHECK4 (nextafter, 9, 9, 9);
  CHECK3 (pow10, 0.75, 5.6234132519);
  CHECK4 (pow, 256, 8, 0x1p64);
  CHECK4 (remainder, 1.625, -1.0, -0.375);
  i = 56;
  CHECK2 (remquol (-1.625L, -1.0L, &i), 0.375L);
  CHECK (i == 2);
  i = 56;
  CHECK2 (remquo (-1.625, -1.0, &i), 0.375);
  CHECK (i == 2);
  CHECK3 (rint, 1071930.0008, 1071930);
  CHECK3 (round, 1071930.0008, 1071930);
  CHECK4 (scalb, -0.854375, 5, -27.34);
  CHECK4 (scalbln, 0.8, 4, 12.8);
  CHECK4 (scalbn, -0.854375, 5, -27.34);
  CHECK (signbit (12.1L) == 0);
  CHECK (signbit (-18.4L) != 0);
  CHECK (signbit (12.1) == 0);
  CHECK (signbit (-18.4) != 0);
  CHECK3 (significand, 8.0, 1.0);
  sincosl (0.75L, &l1, &l2);
  CHECK2 (l1, 0.68163876002333417);
  CHECK2 (l2, 0.73168886887382088);
  sincos (0.75, &d1, &d2);
  CHECK2 (d1, 0.68163876002333417);
  CHECK2 (d2, 0.73168886887382088);
  CHECK3 (sinh, 0.75, 0.8223167319358);
  CHECK3 (sin, 0.75, 0.681638760023334);
  CHECK3 (sqrt, 0.75, 0.8660254037844386);
  CHECK3 (tanh, -1.0, -0.761594155955764888);
  CHECK3 (tan, 0.75, 0.93159645994407246);
  CHECK3 (tgamma, 1.2, 0.91816874239976);
  CHECK3 (trunc, 4294967296.625, 4294967296.0);
  CHECK3 (y0, 10.0, 0.05567116728);
  CHECK3 (y1, 10.0, 0.24901542420695);
  CHECK4 (yn, 10, 2.0, -129184.54220803928);
}

void
test2 (va_list *pap, ...)
{
  va_list ap, apl[50];
  int i;

  va_start (ap, pap);
  for (i = 0; i < 50; i++)
    va_copy (apl[i], ap);
  test (apl, pap);
  for (i = 0; i < 50; i++)
    va_end (apl[i]);
  va_end (ap);
}

void
test3 (int dummy, ...)
{
  va_list ap, apl[50];
  int i;

  va_start (ap, dummy);
  for (i = 0; i < 50; i++)
    va_copy (apl[i], ap);
  test2 (apl, 3.25L, 7834.5L, 3.75, 7835.5);
  for (i = 0; i < 50; i++)
    va_end (apl[i]);
  va_end (ap);
}

int
main (void)
{
  test3 (0, &l1, &l2, &d1, &d2);
  return failures != 0;
}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-02-02 15:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-02 15:23 [PATCH] Fix nexttowardl if compiling new program against new glibc headers with -mlong-double-64 Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).