|
9 | 9 | // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
10 | 10 | //
|
11 | 11 | //===----------------------------------------------------------------------===//
|
12 |
| -// XFAIL: linux |
| 12 | + |
13 | 13 | // RUN: %empty-directory(%t)
|
14 | 14 | // RUN: %target-build-swift -swift-version 4 -o %t/a.out %s
|
15 | 15 | // RUN: %target-run %t/a.out
|
16 | 16 | // REQUIRES: executable_test
|
17 | 17 | // REQUIRES: CPU=x86_64
|
18 | 18 |
|
19 | 19 | import StdlibUnittest
|
| 20 | +#if os(Windows) |
| 21 | +import MSVCRT |
| 22 | +#elseif os(Linux) || os(Android) |
| 23 | +import Glibc |
| 24 | +#elseif os(iOS) || os(macOS) || os(tvOS) || os(watchOS) |
20 | 25 | import Darwin
|
| 26 | +#endif |
21 | 27 |
|
22 | 28 | extension FixedWidthInteger {
|
23 | 29 | /// Returns the high and low parts of a potentially overflowing addition.
|
@@ -154,9 +160,9 @@ public struct _BigInt<Word: FixedWidthInteger & UnsignedInteger> :
|
154 | 160 | static func _randomWord() -> Word {
|
155 | 161 | // This handles up to a 64-bit word
|
156 | 162 | if Word.bitWidth > UInt32.bitWidth {
|
157 |
| - return Word(arc4random()) << 32 | Word(arc4random()) |
| 163 | + return Word(UInt32.random(in: 0...UInt32.max)) << 32 | Word(UInt32.random(in: 0...UInt32.max)) |
158 | 164 | } else {
|
159 |
| - return Word(truncatingIfNeeded: arc4random()) |
| 165 | + return Word(truncatingIfNeeded: UInt32.random(in: 0...UInt32.max)) |
160 | 166 | }
|
161 | 167 | }
|
162 | 168 |
|
@@ -1450,7 +1456,7 @@ func testBinaryInit<T: BinaryInteger>(_ x: T) -> BigInt {
|
1450 | 1456 | }
|
1451 | 1457 |
|
1452 | 1458 | func randomBitLength() -> Int {
|
1453 |
| - return Int(arc4random_uniform(1000) + 2) |
| 1459 | + return Int.random(in: 2...1000) |
1454 | 1460 | }
|
1455 | 1461 |
|
1456 | 1462 | var BitTests = TestSuite("Bit")
|
|
0 commit comments