Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / gcc.dg / tls / opt-5.c
blob0604f3253c11cc50e2fd428ac6f242bbafe5ff90
1 /* { dg-do compile } */
2 /* { dg-options "-O2" } */
3 /* { dg-require-effective-target tls } */
4 /* Sched1 moved {load_tp} pattern between strlen call and the copy
5 of the hard return value to its pseudo. This resulted in a
6 reload abort, since the hard register was not spillable. */
8 extern __thread int __libc_errno __attribute__ ((tls_model ("initial-exec")));
10 struct stat64
12 long dummy[4];
14 typedef __SIZE_TYPE__ size_t;
15 typedef unsigned long long uint64_t;
16 typedef int __mode_t;
18 extern size_t strlen (__const char *__s) __attribute__ ((__pure__));
19 extern int strcmp (__const char *__s1, __const char *__s2)
20 __attribute__ ((__pure__));
22 extern int __open64 (__const char *__file, int __oflag, ...);
23 extern int __open (__const char *__file, int __oflag, ...);
24 extern int __mkdir (__const char *__path, __mode_t __mode);
25 extern int __lxstat64 (int __ver, __const char *__filename,
26 struct stat64 *__stat_buf) ;
28 static const char letters[] =
29 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
31 int
32 __gen_tempname (char *tmpl, int kind)
34 int len;
35 char *XXXXXX;
36 static uint64_t value;
37 uint64_t random_time_bits;
38 unsigned int count;
39 int fd = -1;
40 int save_errno = __libc_errno;
41 struct stat64 st;
42 unsigned int attempts_min = 62 * 62 * 62;
43 unsigned int attempts = attempts_min < 238328 ? 238328 : attempts_min;
45 len = strlen (tmpl);
46 if (len < 6 || strcmp(&tmpl[len - 6], "XXXXXX"))
48 (__libc_errno = (22));
49 return -1;
52 XXXXXX = &tmpl[len - 6];
54 for (count = 0; count < attempts; value += 7777, ++count)
56 uint64_t v = value;
58 XXXXXX[0] = letters[v % 62];
59 v /= 62;
60 XXXXXX[1] = letters[v % 62];
61 v /= 62;
62 XXXXXX[2] = letters[v % 62];
63 v /= 62;
64 XXXXXX[3] = letters[v % 62];
65 v /= 62;
66 XXXXXX[4] = letters[v % 62];
67 v /= 62;
68 XXXXXX[5] = letters[v % 62];
70 switch (kind)
72 case 0:
73 fd = __open (tmpl, 02 | 01000 | 04000, 0400 | 0200);
74 break;
76 case 1:
77 fd = __open64 (tmpl, 02 | 01000 | 04000, 0400 | 0200);
78 break;
80 case 2:
81 fd = __mkdir (tmpl, 0400 | 0200 | 0100);
82 break;
84 case 3:
85 if (__lxstat64 (2, tmpl, &st) < 0)
87 if (__libc_errno == 2)
89 (__libc_errno = (save_errno));
90 return 0;
92 else
94 return -1;
96 continue;
99 if (fd >= 0)
101 (__libc_errno = (save_errno));
102 return fd;
104 else if (__libc_errno != 17)
105 return -1;
108 (__libc_errno = (17));
109 return -1;