diff --git a/build.gradle.kts b/build.gradle.kts index fd93fc1..b14e086 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -47,6 +47,7 @@ kotlin { } } } + linuxX64() sourceSets { all { diff --git a/src/linuxX64Main/kotlin/ru/spbstu/wheels/BitsNative.kt b/src/linuxX64Main/kotlin/ru/spbstu/wheels/BitsNative.kt new file mode 100644 index 0000000..0743590 --- /dev/null +++ b/src/linuxX64Main/kotlin/ru/spbstu/wheels/BitsNative.kt @@ -0,0 +1,13 @@ +package ru.spbstu.wheels + +@PublishedApi +internal actual fun Int.reverseBits(): Int { + var i = this + // HD, Figure 7-1 + i = (i and 0x55555555) shl 1 or ((i ushr 1) and 0x55555555) + i = (i and 0x33333333) shl 2 or ((i ushr 2) and 0x33333333) + i = (i and 0x0f0f0f0f) shl 4 or ((i ushr 4) and 0x0f0f0f0f) + i = (i shl 24) or ((i and 0xff00) shl 8) or + ((i ushr 8) and 0xff00) or (i ushr 24) + return i +} diff --git a/src/linuxX64Main/kotlin/ru/spbstu/wheels/NoStackThrowable.kt b/src/linuxX64Main/kotlin/ru/spbstu/wheels/NoStackThrowable.kt new file mode 100644 index 0000000..af91e23 --- /dev/null +++ b/src/linuxX64Main/kotlin/ru/spbstu/wheels/NoStackThrowable.kt @@ -0,0 +1,10 @@ +package ru.spbstu.wheels + +// seems like there is no way of avoiding collecting stack trace on native now +actual open class NoStackThrowable actual constructor(message: String?, cause: Throwable?) : Throwable() { + actual constructor() : this(null, null) + + actual constructor(message: String) : this(message, null) + + actual constructor(cause: Throwable) : this(cause.message, cause) +} \ No newline at end of file diff --git a/src/linuxX64Main/kotlin/ru/spbstu/wheels/identityHashCode.kt b/src/linuxX64Main/kotlin/ru/spbstu/wheels/identityHashCode.kt new file mode 100644 index 0000000..90869e0 --- /dev/null +++ b/src/linuxX64Main/kotlin/ru/spbstu/wheels/identityHashCode.kt @@ -0,0 +1,5 @@ +package ru.spbstu.wheels + +import kotlin.native.identityHashCode + +actual fun identityHashCode(value: Any?): Int = value.identityHashCode() \ No newline at end of file