OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [torture/] [stackalign/] [vararg-2.c] - Blame information for rev 300

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 298 jeremybenn
/* { dg-do run } */
2
 
3
#include <stdarg.h>
4
#include "check.h"
5
 
6
#ifndef ALIGNMENT
7
#define ALIGNMENT       64
8
#endif
9
 
10
typedef int aligned __attribute__((aligned(ALIGNMENT)));
11
 
12
int global;
13
 
14
void
15
bar (char *p, int size)
16
{
17
  __builtin_strncpy (p, "good", size);
18
}
19
 
20
void
21
test (va_list arg)
22
{
23
  char *p;
24
  aligned i;
25
  int size;
26
  double x;
27
 
28
  size = va_arg (arg, int);
29
  if (size != 5)
30
    abort ();
31
 
32
  p = __builtin_alloca (size + 1);
33
 
34
  x = va_arg (arg, double);
35
  if (x != 5.0)
36
    abort ();
37
 
38
  bar (p, size);
39
  if (__builtin_strncmp (p, "good", size) != 0)
40
    {
41
#ifdef DEBUG
42
      p[size] = '\0';
43
      printf ("Failed: %s != good\n", p);
44
#endif
45
      abort ();
46
    }
47
 
48
  if (check_int (&i,  __alignof__(i)) != i)
49
    abort ();
50
}
51
 
52
void
53
foo (const char *fmt, ...)
54
{
55
  va_list arg;
56
  va_start (arg, fmt);
57
  test (arg);
58
  va_end (arg);
59
}
60
int
61
main()
62
{
63
  foo ("foo", 5, 5.0);
64
  return 0;
65
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.