| @@ -44,27 +44,30 @@ namespace std _GLIBCXX_VISIBILITY(defaul | | | @@ -44,27 +44,30 @@ namespace std _GLIBCXX_VISIBILITY(defaul |
44 | { | | 44 | { |
45 | const char* __nptr = __str.c_str(); | | 45 | const char* __nptr = __str.c_str(); |
46 | char* __endptr; | | 46 | char* __endptr; |
47 | __ret = std::strtoul(__nptr, &__endptr, 0); | | 47 | __ret = std::strtoul(__nptr, &__endptr, 0); |
48 | if (*__nptr == '\0' || *__endptr != '\0') | | 48 | if (*__nptr == '\0' || *__endptr != '\0') |
49 | std::__throw_runtime_error(__N("random_device::_M_strtoul" | | 49 | std::__throw_runtime_error(__N("random_device::_M_strtoul" |
50 | "(const std::string&)")); | | 50 | "(const std::string&)")); |
51 | } | | 51 | } |
52 | return __ret; | | 52 | return __ret; |
53 | } | | 53 | } |
54 | | | 54 | |
55 | #if (defined __i386__ || defined __x86_64__) && defined _GLIBCXX_X86_RDRAND | | 55 | #if (defined __i386__ || defined __x86_64__) && defined _GLIBCXX_X86_RDRAND |
56 | unsigned int | | 56 | unsigned int |
| | | 57 | __attribute__ ((noinline)) |
| | | 58 | # ifndef __clang__ |
57 | __attribute__ ((target("rdrnd"))) | | 59 | __attribute__ ((target("rdrnd"))) |
| | | 60 | # endif |
58 | __x86_rdrand(void) | | 61 | __x86_rdrand(void) |
59 | { | | 62 | { |
60 | unsigned int retries = 100; | | 63 | unsigned int retries = 100; |
61 | unsigned int val; | | 64 | unsigned int val; |
62 | | | 65 | |
63 | while (__builtin_ia32_rdrand32_step(&val) == 0) | | 66 | while (__builtin_ia32_rdrand32_step(&val) == 0) |
64 | if (--retries == 0) | | 67 | if (--retries == 0) |
65 | std::__throw_runtime_error(__N("random_device::__x86_rdrand(void)")); | | 68 | std::__throw_runtime_error(__N("random_device::__x86_rdrand(void)")); |
66 | | | 69 | |
67 | return val; | | 70 | return val; |
68 | } | | 71 | } |
69 | #endif | | 72 | #endif |
70 | } | | 73 | } |