[K/N] Mark Platform-related API with ExperimentalNativeApi
As part of stabilizing Native stdlib.
This commit is contained in:
committed by
Space Team
parent
f04d01cf21
commit
ad5593e68a
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
package kotlin.native
|
||||
|
||||
import kotlin.experimental.ExperimentalNativeApi
|
||||
import kotlin.native.internal.GCUnsafeCall
|
||||
import kotlin.native.internal.TypedIntrinsic
|
||||
import kotlin.native.internal.IntrinsicType
|
||||
@@ -11,6 +12,7 @@ import kotlin.native.internal.IntrinsicType
|
||||
/**
|
||||
* Operating system family.
|
||||
*/
|
||||
@ExperimentalNativeApi
|
||||
public enum class OsFamily {
|
||||
UNKNOWN,
|
||||
MACOSX,
|
||||
@@ -26,6 +28,7 @@ public enum class OsFamily {
|
||||
/**
|
||||
* Central Processor Unit architecture.
|
||||
*/
|
||||
@ExperimentalNativeApi
|
||||
public enum class CpuArchitecture(val bitness: Int) {
|
||||
UNKNOWN(-1),
|
||||
ARM32(32),
|
||||
@@ -41,6 +44,7 @@ public enum class CpuArchitecture(val bitness: Int) {
|
||||
* Memory model.
|
||||
*/
|
||||
// NOTE: Must match `MemoryModel` in `Memory.h`
|
||||
@ExperimentalNativeApi
|
||||
public enum class MemoryModel {
|
||||
STRICT,
|
||||
RELAXED,
|
||||
@@ -50,6 +54,7 @@ public enum class MemoryModel {
|
||||
/**
|
||||
* Object describing the current platform program executes upon.
|
||||
*/
|
||||
@ExperimentalNativeApi
|
||||
public object Platform {
|
||||
/**
|
||||
* Check if current architecture allows unaligned access to wider than byte locations.
|
||||
@@ -125,7 +130,6 @@ public object Platform {
|
||||
* `KOTLIN_NATIVE_AVAILABLE_PROCESSORS` environment variable. When the variable is set and contains a value that is not
|
||||
* positive [Int], [IllegalStateException] will be thrown.
|
||||
*/
|
||||
@ExperimentalStdlibApi
|
||||
public fun getAvailableProcessors() : Int {
|
||||
val fromEnv = Platform_getAvailableProcessorsEnv()
|
||||
if (fromEnv == null) {
|
||||
|
||||
@@ -33,6 +33,7 @@ public class MutableData constructor(capacity: Int = 16) {
|
||||
|
||||
private var buffer_ = ByteArray(capacity).apply { share() }
|
||||
private var buffer: ByteArray
|
||||
@OptIn(ExperimentalNativeApi::class)
|
||||
get() =
|
||||
when (kotlin.native.Platform.memoryModel) {
|
||||
kotlin.native.MemoryModel.EXPERIMENTAL -> buffer_
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
package kotlin.native.concurrent
|
||||
|
||||
import kotlin.experimental.ExperimentalNativeApi
|
||||
import kotlin.native.internal.ExportForCppRuntime
|
||||
import kotlin.native.internal.Frozen
|
||||
import kotlin.native.internal.VolatileLambda
|
||||
@@ -137,6 +138,7 @@ public value class Worker @PublishedApi internal constructor(val id: Int) {
|
||||
* @throws [IllegalArgumentException] on negative values of [afterMicroseconds].
|
||||
* @throws [IllegalStateException] if [operation] parameter is not frozen and worker is not current.
|
||||
*/
|
||||
@OptIn(ExperimentalNativeApi::class)
|
||||
public fun executeAfter(afterMicroseconds: Long = 0, operation: () -> Unit): Unit {
|
||||
val current = currentInternal()
|
||||
if (Platform.memoryModel != MemoryModel.EXPERIMENTAL && current != id && !operation.isFrozen) throw IllegalStateException("Job for another worker must be frozen")
|
||||
|
||||
Reference in New Issue
Block a user