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-1.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
foo (const char *fmt, ...)
23
{
24
  va_list arg;
25
  char *p;
26
  aligned i;
27
  int size;
28
  double x;
29
 
30
  va_start (arg, fmt);
31
  size = va_arg (arg, int);
32
  if (size != 5)
33
    abort ();
34
  p = __builtin_alloca (size + 1);
35
 
36
  x = va_arg (arg, double);
37
  if (x != 5.0)
38
    abort ();
39
 
40
  bar (p, size);
41
  if (__builtin_strncmp (p, "good", size) != 0)
42
    {
43
#ifdef DEBUG
44
      p[size] = '\0';
45
      printf ("Failed: %s != good\n", p);
46
#endif
47
      abort ();
48
    }
49
 
50
  if (check_int (&i,  __alignof__(i)) != i)
51
    abort ();
52
  va_end (arg);
53
}
54
 
55
int
56
main()
57
{
58
  foo ("foo", 5, 5.0);
59
  return 0;
60
}

powered by: WebSVN 2.1.0

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