summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/builtins/lib/printf.c
blob: 4be7578d124763af0cb5a96324c9c29a7195c9d4 (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
37
38
#include <stdio.h>
#include <stdarg.h>
extern void abort (void);
extern int inside_main;

__attribute__ ((__noinline__))
int
printf (const char *string, ...)
{
  va_list ap;
  int r;
#ifdef __OPTIMIZE__
  if (inside_main)
    abort();
#endif
  va_start (ap, string);
  r = vprintf (string, ap);
  va_end (ap);
  return r;
}


/* Locking stdio doesn't matter for the purposes of this test.  */
__attribute__ ((__noinline__))
int
printf_unlocked (const char *string, ...)
{
  va_list ap;
  int r;
#ifdef __OPTIMIZE__
  if (inside_main)
    abort();
#endif
  va_start (ap, string);
  r = vprintf (string, ap);
  va_end (ap);
  return r;
}