Skip to content

Commit

Permalink
Support mingwX64 target
Browse files Browse the repository at this point in the history
  • Loading branch information
DLochmelis33 committed Jul 21, 2024
1 parent 5f54955 commit 44d0abb
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 10 deletions.
1 change: 1 addition & 0 deletions cli/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ kotlin {
// linuxArm64(),
macosX64(),
macosArm64(),
mingwX64(),
)
nativeTargets.forEach { target ->
target.binaries {
Expand Down
4 changes: 2 additions & 2 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ plugins {
kotlin {
val nativeTargets = listOf(
linuxX64(),
// 1) no machine currently available 2) CLI library does not support
// linuxArm64(),
linuxArm64(),
macosX64(),
macosArm64(),
mingwX64(),
)

jvm {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.jetbrains.litmuskt

import platform.posix.sysconf
import platform.posix._SC_NPROCESSORS_ONLN

actual fun cpuCount(): Int = sysconf(_SC_NPROCESSORS_ONLN).toInt()
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.jetbrains.litmuskt

import platform.posix.sysconf
import platform.posix._SC_NPROCESSORS_ONLN

actual fun cpuCount(): Int = sysconf(_SC_NPROCESSORS_ONLN).toInt()
17 changes: 17 additions & 0 deletions core/src/mingwMain/kotlin/org/jetbrains/litmuskt/NativeUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.jetbrains.litmuskt

import kotlinx.cinterop.ExperimentalForeignApi
import kotlinx.cinterop.alloc
import kotlinx.cinterop.memScoped
import kotlinx.cinterop.ptr
import platform.windows.GetSystemInfo
import platform.windows.SYSTEM_INFO

actual val affinityManager: AffinityManager? = null

@OptIn(ExperimentalForeignApi::class)
actual fun cpuCount(): Int = memScoped {
val systemInfo = alloc<SYSTEM_INFO>()
GetSystemInfo(systemInfo.ptr)
systemInfo.dwNumberOfProcessors.toInt()
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@ package org.jetbrains.litmuskt

import kotlinx.cinterop.ExperimentalForeignApi
import kotlinx.cinterop.toKString
import platform.posix._SC_NPROCESSORS_ONLN
import platform.posix.errno
import platform.posix.strerror
import platform.posix.sysconf

actual fun cpuCount(): Int = sysconf(_SC_NPROCESSORS_ONLN).toInt()

@OptIn(ExperimentalForeignApi::class)
fun Int.syscallCheck() {
Expand Down
2 changes: 1 addition & 1 deletion jcstress/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>1.9.20</version>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.jetbrains.litmuskt</groupId>
Expand Down
7 changes: 4 additions & 3 deletions testsuite/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ plugins {
}

kotlin {
// targets have to be the same as in :cli (because it depends on this subproject)
linuxX64()
// linuxArm64()
linuxArm64()
macosX64()
macosArm64()
mingwX64()

jvm {
withJava()
}
Expand All @@ -25,7 +26,7 @@ kotlin {

// ======== ksp ========

val kspTasks = setOf("kspJvm", "kspLinuxX64", "kspMacosX64", "kspMacosArm64")
val kspTasks = setOf("kspJvm", "kspLinuxX64", "kspMacosX64", "kspMacosArm64", "kspMingwX64")

dependencies {
for (kspTask in kspTasks) {
Expand Down

0 comments on commit 44d0abb

Please sign in to comment.