OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [torture/] [stackalign/] [vararg-2.c] - Blame information for rev 801

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

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

powered by: WebSVN 2.1.0

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