Skip to content

Commit

Permalink
linux X64 target
Browse files Browse the repository at this point in the history
  • Loading branch information
belyaev-mikhail committed Oct 2, 2020
1 parent 62d6e23 commit 1910862
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ kotlin {
}
}
}
linuxX64()

sourceSets {
all {
Expand Down
13 changes: 13 additions & 0 deletions src/linuxX64Main/kotlin/ru/spbstu/wheels/BitsNative.kt
Original file line number Diff line number Diff line change
@@ -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
}
10 changes: 10 additions & 0 deletions src/linuxX64Main/kotlin/ru/spbstu/wheels/NoStackThrowable.kt
Original file line number Diff line number Diff line change
@@ -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)
}
5 changes: 5 additions & 0 deletions src/linuxX64Main/kotlin/ru/spbstu/wheels/identityHashCode.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package ru.spbstu.wheels

import kotlin.native.identityHashCode

actual fun identityHashCode(value: Any?): Int = value.identityHashCode()

0 comments on commit 1910862

Please sign in to comment.