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")));
14 typedef __SIZE_TYPE__
size_t;
15 typedef unsigned long long uint64_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";
32 __gen_tempname (char *tmpl
, int kind
)
36 static uint64_t value
;
37 uint64_t random_time_bits
;
40 int save_errno
= __libc_errno
;
42 unsigned int attempts_min
= 62 * 62 * 62;
43 unsigned int attempts
= attempts_min
< 238328 ? 238328 : attempts_min
;
46 if (len
< 6 || strcmp(&tmpl
[len
- 6], "XXXXXX"))
48 (__libc_errno
= (22));
52 XXXXXX
= &tmpl
[len
- 6];
54 for (count
= 0; count
< attempts
; value
+= 7777, ++count
)
58 XXXXXX
[0] = letters
[v
% 62];
60 XXXXXX
[1] = letters
[v
% 62];
62 XXXXXX
[2] = letters
[v
% 62];
64 XXXXXX
[3] = letters
[v
% 62];
66 XXXXXX
[4] = letters
[v
% 62];
68 XXXXXX
[5] = letters
[v
% 62];
73 fd
= __open (tmpl
, 02 | 01000 | 04000, 0400 | 0200);
77 fd
= __open64 (tmpl
, 02 | 01000 | 04000, 0400 | 0200);
81 fd
= __mkdir (tmpl
, 0400 | 0200 | 0100);
85 if (__lxstat64 (2, tmpl
, &st
) < 0)
87 if (__libc_errno
== 2)
89 (__libc_errno
= (save_errno
));
101 (__libc_errno
= (save_errno
));
104 else if (__libc_errno
!= 17)
108 (__libc_errno
= (17));