Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / gcc.c-torture / execute / strlen-1.c
blobc29592b8b88791d9f7a380edfc81f268b62f891d
1 /* Copyright (C) 2002 Free Software Foundation.
3 Test strlen with various combinations of pointer alignments and lengths to
4 make sure any optimizations in the library are correct.
6 Written by Michael Meissner, March 9, 2002. */
8 #include <string.h>
9 #include <stddef.h>
11 #ifndef MAX_OFFSET
12 #define MAX_OFFSET (sizeof (long long))
13 #endif
15 #ifndef MAX_TEST
16 #define MAX_TEST (8 * sizeof (long long))
17 #endif
19 #ifndef MAX_EXTRA
20 #define MAX_EXTRA (sizeof (long long))
21 #endif
23 #define MAX_LENGTH (MAX_OFFSET + MAX_TEST + MAX_EXTRA + 1)
25 static union {
26 char buf[MAX_LENGTH];
27 long long align_int;
28 long double align_fp;
29 } u;
31 main ()
33 size_t off, len, len2, i;
34 char *p;
36 for (off = 0; off < MAX_OFFSET; off++)
37 for (len = 0; len < MAX_TEST; len++)
39 p = u.buf;
40 for (i = 0; i < off; i++)
41 *p++ = '\0';
43 for (i = 0; i < len; i++)
44 *p++ = 'a';
46 *p++ = '\0';
47 for (i = 0; i < MAX_EXTRA; i++)
48 *p++ = 'b';
50 p = u.buf + off;
51 len2 = strlen (p);
52 if (len != len2)
53 abort ();
56 exit (0);