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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [tls/] [opt-5.c] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* { 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.  */
7
 
8
extern __thread int __libc_errno __attribute__ ((tls_model ("initial-exec")));
9
 
10
struct stat64
11
  {
12
    long dummy[4];
13
  };
14
typedef __SIZE_TYPE__ size_t;
15
typedef unsigned long long uint64_t;
16
typedef int __mode_t;
17
 
18
extern size_t strlen (__const char *__s) __attribute__ ((__pure__));
19
extern int strcmp (__const char *__s1, __const char *__s2)
20
     __attribute__ ((__pure__));
21
 
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) ;
27
 
28
static const char letters[] =
29
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
30
 
31
int
32
__gen_tempname (char *tmpl, int kind)
33
{
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;
44
 
45
  len = strlen (tmpl);
46
  if (len < 6 || strcmp(&tmpl[len - 6], "XXXXXX"))
47
    {
48
      (__libc_errno = (22));
49
      return -1;
50
    }
51
 
52
  XXXXXX = &tmpl[len - 6];
53
 
54
  for (count = 0; count < attempts; value += 7777, ++count)
55
    {
56
      uint64_t v = value;
57
 
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];
69
 
70
      switch (kind)
71
        {
72
        case 0:
73
          fd = __open (tmpl, 02 | 01000 | 04000, 0400 | 0200);
74
          break;
75
 
76
        case 1:
77
          fd = __open64 (tmpl, 02 | 01000 | 04000, 0400 | 0200);
78
          break;
79
 
80
        case 2:
81
          fd = __mkdir (tmpl, 0400 | 0200 | 0100);
82
          break;
83
 
84
        case 3:
85
          if (__lxstat64 (2, tmpl, &st) < 0)
86
            {
87
              if (__libc_errno == 2)
88
                {
89
                  (__libc_errno = (save_errno));
90
                  return 0;
91
                }
92
              else
93
 
94
                return -1;
95
            }
96
          continue;
97
        }
98
 
99
      if (fd >= 0)
100
        {
101
          (__libc_errno = (save_errno));
102
          return fd;
103
        }
104
      else if (__libc_errno != 17)
105
        return -1;
106
    }
107
 
108
  (__libc_errno = (17));
109
  return -1;
110
}

powered by: WebSVN 2.1.0

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