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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [strlen-1.c] - Blame information for rev 711

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

Line No. Rev Author Line
1 688 jeremybenn
/* Copyright (C) 2002  Free Software Foundation.
2
 
3
   Test strlen 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
#include <stddef.h>
10
 
11
#ifndef MAX_OFFSET
12
#define MAX_OFFSET (sizeof (long long))
13
#endif
14
 
15
#ifndef MAX_TEST
16
#define MAX_TEST (8 * sizeof (long long))
17
#endif
18
 
19
#ifndef MAX_EXTRA
20
#define MAX_EXTRA (sizeof (long long))
21
#endif
22
 
23
#define MAX_LENGTH (MAX_OFFSET + MAX_TEST + MAX_EXTRA + 1)
24
 
25
static union {
26
  char buf[MAX_LENGTH];
27
  long long align_int;
28
  long double align_fp;
29
} u;
30
 
31
main ()
32
{
33
  size_t off, len, len2, i;
34
  char *p;
35
 
36
  for (off = 0; off < MAX_OFFSET; off++)
37
    for (len = 0; len < MAX_TEST; len++)
38
      {
39
        p = u.buf;
40
        for (i = 0; i < off; i++)
41
          *p++ = '\0';
42
 
43
        for (i = 0; i < len; i++)
44
          *p++ = 'a';
45
 
46
        *p++ = '\0';
47
        for (i = 0; i < MAX_EXTRA; i++)
48
          *p++ = 'b';
49
 
50
        p = u.buf + off;
51
        len2 = strlen (p);
52
        if (len != len2)
53
          abort ();
54
      }
55
 
56
  exit (0);
57
}

powered by: WebSVN 2.1.0

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