Skip to content

Commit c4d5db4

Browse files
committed
[Stdlib] Change _swift_stdlib_random SPI to swift_stdlib_random API.
1 parent 5f17b45 commit c4d5db4

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

stdlib/public/SwiftShims/Random.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
namespace swift { extern "C" {
2929
#endif
3030

31-
SWIFT_RUNTIME_STDLIB_SPI
32-
void _swift_stdlib_random(void *buf, __swift_size_t nbytes);
31+
SWIFT_RUNTIME_STDLIB_API
32+
void swift_stdlib_random(void *buf, __swift_size_t nbytes);
3333

3434
#ifdef __cplusplus
3535
}} // extern "C", namespace swift

stdlib/public/core/Random.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,14 @@ public struct SystemRandomNumberGenerator : RandomNumberGenerator {
164164
@inlinable
165165
public mutating func next() -> UInt64 {
166166
var random: UInt64 = 0
167-
_swift_stdlib_random(&random, MemoryLayout<UInt64>.size)
167+
swift_stdlib_random(&random, MemoryLayout<UInt64>.size)
168168
return random
169169
}
170170

171171
@inlinable
172172
public mutating func _fill(bytes buffer: UnsafeMutableRawBufferPointer) {
173173
if !buffer.isEmpty {
174-
_swift_stdlib_random(buffer.baseAddress!, buffer.count)
174+
swift_stdlib_random(buffer.baseAddress!, buffer.count)
175175
}
176176
}
177177
}

stdlib/public/stubs/GlobalObjects.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ static swift::_SwiftHashingParameters initializeHashingParameters() {
115115
return { 0, 0, true };
116116
}
117117
__swift_uint64_t seed0 = 0, seed1 = 0;
118-
swift::_swift_stdlib_random(&seed0, sizeof(seed0));
119-
swift::_swift_stdlib_random(&seed1, sizeof(seed1));
118+
swift::swift_stdlib_random(&seed0, sizeof(seed0));
119+
swift::swift_stdlib_random(&seed1, sizeof(seed1));
120120
return { seed0, seed1, false };
121121
}
122122

stdlib/public/stubs/Random.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
// _swift_stdlib_random
13+
// swift_stdlib_random
1414
//
1515
// Should the implementation of this function add a new platform/change for a
1616
// platform, make sure to also update the documentation regarding platform
@@ -40,16 +40,16 @@
4040

4141
#if defined(__APPLE__)
4242

43-
SWIFT_RUNTIME_STDLIB_SPI
44-
void swift::_swift_stdlib_random(void *buf, __swift_size_t nbytes) {
43+
SWIFT_RUNTIME_STDLIB_API
44+
void swift::swift_stdlib_random(void *buf, __swift_size_t nbytes) {
4545
arc4random_buf(buf, nbytes);
4646
}
4747

4848
#elif defined(_WIN32) && !defined(__CYGWIN__)
49-
#warning TODO: Test _swift_stdlib_random on Windows
49+
#warning TODO: Test swift_stdlib_random on Windows
5050

51-
SWIFT_RUNTIME_STDLIB_SPI
52-
void swift::_swift_stdlib_random(void *buf, __swift_size_t nbytes) {
51+
SWIFT_RUNTIME_STDLIB_API
52+
void swift::swift_stdlib_random(void *buf, __swift_size_t nbytes) {
5353
NTSTATUS status = BCryptGenRandom(nullptr,
5454
static_cast<PUCHAR>(buf),
5555
static_cast<ULONG>(nbytes),
@@ -68,8 +68,8 @@ void swift::_swift_stdlib_random(void *buf, __swift_size_t nbytes) {
6868
result; \
6969
})
7070

71-
SWIFT_RUNTIME_STDLIB_SPI
72-
void swift::_swift_stdlib_random(void *buf, __swift_size_t nbytes) {
71+
SWIFT_RUNTIME_STDLIB_API
72+
void swift::swift_stdlib_random(void *buf, __swift_size_t nbytes) {
7373
while (nbytes > 0) {
7474
__swift_ssize_t actual_nbytes = -1;
7575

0 commit comments

Comments
 (0)