Skip to content

Commit eaebe61

Browse files
committed
Add the required OptIn annotations
1 parent 5a4992f commit eaebe61

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

core/linux/src/TimeZoneNative.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,16 @@ internal actual class RegionTimeZone(private val tzid: TimeZoneRules, actual ove
5757
actual override fun offsetAtImpl(instant: Instant): UtcOffset = tzid.infoAtInstant(instant)
5858
}
5959

60+
@OptIn(kotlinx.cinterop.UnsafeNumber::class)
6061
internal actual fun currentTime(): Instant = memScoped {
6162
val tm = alloc<timespec>()
6263
val error = clock_gettime(CLOCK_REALTIME, tm.ptr)
6364
if (error != 0) {
6465
val errorStr: String = strerror(errno)?.toKString() ?: "Unknown error"
6566
throw IllegalStateException("Could not obtain the current clock readings from the system: $errorStr")
6667
}
67-
val seconds: Long = tm.tv_sec
68-
val nanoseconds: Int = tm.tv_nsec.toInt()
68+
val seconds: Long = tm.tv_sec.convert<Long>()
69+
val nanoseconds: Int = tm.tv_nsec.convert<Int>()
6970
try {
7071
require(nanoseconds in 0 until NANOS_PER_ONE)
7172
return Instant(seconds, nanoseconds)

core/nix/src/internal/filesystem.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package kotlinx.datetime.internal
88
import kotlinx.cinterop.*
99
import platform.posix.*
1010

11+
@OptIn(kotlinx.cinterop.UnsafeNumber::class)
1112
internal class Path(val isAbsolute: Boolean, val components: List<String>) {
1213
fun check(): PathInfo? = memScoped {
1314
val stat = alloc<stat>()
@@ -81,7 +82,7 @@ internal fun Path.traverseDirectory(exclude: Set<String> = emptySet(), stripLead
8182
}
8283
}
8384

84-
85+
@OptIn(kotlinx.cinterop.UnsafeNumber::class)
8586
internal fun Path.readBytes(): ByteArray {
8687
val handler = fopen(this.toString(), "rb") ?: throw RuntimeException("Cannot open file $this")
8788
try {

0 commit comments

Comments
 (0)