aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/powerpc/float128-longdouble-stdio.c
blob: 39e59d949f9f10586758d128faf5aa4efd3cf417 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* { dg-require-effective-target ppc_float128_hw } */
/* { dg-options "-mdejagnu-cpu=power9 -O2 -mlong-double-128 -Wno-psabi -mabi=ieeelongdouble" } */

/* Test if switching long double to IEEE 128-bit maps the printf and scanf
   function names correctly.  We leave off the \M in matching the calls, so
   power10 will match using bl foo@notoc.  */

#include <stdlib.h>

volatile long double x = 1.0L;
volatile long double y, z;

int
main (void)
{
  char buffer[100];

  /* { dg-final { scan-assembler {\mbl __sprintfieee128} } }  */
  __builtin_sprintf (buffer, "%Lg", x);

  /* { dg-final { scan-assembler {\mbl __printfieee128} } }  */
  __builtin_printf ("x is %Lg [%s]\n", x, buffer);

  /* { dg-final { scan-assembler {\mbl __isoc99_sscanfieee128} } }  */
  __builtin_sscanf (buffer, "%Lg", &y);

  __builtin_printf ("Type 1.0: ");

  /* { dg-final { scan-assembler {\mbl __isoc99_scanfieee128} } }  */
  __builtin_scanf ("%Lg", &z);

  if (x != y || x != z)
    abort ();

  return 0;
}