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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [memset-1.c] - Blame information for rev 149

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

Line No. Rev Author Line
1 149 jeremybenn
/* Copyright (C) 2002  Free Software Foundation.
2
 
3
   Test memset with various combinations of pointer alignments and lengths to
4
   make sure any optimizations in the library are correct.
5
 
6
   Written by Michael Meissner, March 9, 2002.  */
7
 
8
#include <string.h>
9
 
10
#ifndef MAX_OFFSET
11
#define MAX_OFFSET (sizeof (long long))
12
#endif
13
 
14
#ifndef MAX_COPY
15
#define MAX_COPY (10 * sizeof (long long))
16
#endif
17
 
18
#ifndef MAX_EXTRA
19
#define MAX_EXTRA (sizeof (long long))
20
#endif
21
 
22
#define MAX_LENGTH (MAX_OFFSET + MAX_COPY + MAX_EXTRA)
23
 
24
static union {
25
  char buf[MAX_LENGTH];
26
  long long align_int;
27
  long double align_fp;
28
} u;
29
 
30
char A = 'A';
31
 
32
main ()
33
{
34
  int off, len, i;
35
  char *p, *q;
36
 
37
  for (off = 0; off < MAX_OFFSET; off++)
38
    for (len = 1; len < MAX_COPY; len++)
39
      {
40
        for (i = 0; i < MAX_LENGTH; i++)
41
          u.buf[i] = 'a';
42
 
43
        p = memset (u.buf + off, '\0', len);
44
        if (p != u.buf + off)
45
          abort ();
46
 
47
        q = u.buf;
48
        for (i = 0; i < off; i++, q++)
49
          if (*q != 'a')
50
            abort ();
51
 
52
        for (i = 0; i < len; i++, q++)
53
          if (*q != '\0')
54
            abort ();
55
 
56
        for (i = 0; i < MAX_EXTRA; i++, q++)
57
          if (*q != 'a')
58
            abort ();
59
 
60
        p = memset (u.buf + off, A, len);
61
        if (p != u.buf + off)
62
          abort ();
63
 
64
        q = u.buf;
65
        for (i = 0; i < off; i++, q++)
66
          if (*q != 'a')
67
            abort ();
68
 
69
        for (i = 0; i < len; i++, q++)
70
          if (*q != 'A')
71
            abort ();
72
 
73
        for (i = 0; i < MAX_EXTRA; i++, q++)
74
          if (*q != 'a')
75
            abort ();
76
 
77
        p = memset (u.buf + off, 'B', len);
78
        if (p != u.buf + off)
79
          abort ();
80
 
81
        q = u.buf;
82
        for (i = 0; i < off; i++, q++)
83
          if (*q != 'a')
84
            abort ();
85
 
86
        for (i = 0; i < len; i++, q++)
87
          if (*q != 'B')
88
            abort ();
89
 
90
        for (i = 0; i < MAX_EXTRA; i++, q++)
91
          if (*q != 'a')
92
            abort ();
93
      }
94
 
95
  exit (0);
96
}

powered by: WebSVN 2.1.0

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