Repository navigation
Add linuxX64 and linuxArm64 targets #1028
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3cc1c6f
Add linuxX64 and linuxArm64 targets
arkivanov-bot 02d77c2
Update dependencyGuard baselines for Essenty 2.7.0-alpha01
arkivanov-bot 3b1040b
Document linuxX64 and linuxArm64 in supported platforms
arkivanov-bot 016eefe
Inline lock/unlock into synchronizedImpl on linux
arkivanov-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
decompose/src/linuxMain/kotlin/com/arkivanov/decompose/Lock.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| package com.arkivanov.decompose | ||
|
|
||
| import kotlinx.cinterop.Arena | ||
| import kotlinx.cinterop.ExperimentalForeignApi | ||
| import kotlinx.cinterop.alloc | ||
| import kotlinx.cinterop.ptr | ||
| import platform.posix.PTHREAD_MUTEX_RECURSIVE | ||
| import platform.posix.pthread_mutex_destroy | ||
| import platform.posix.pthread_mutex_init | ||
| import platform.posix.pthread_mutex_lock | ||
| import platform.posix.pthread_mutex_t | ||
| import platform.posix.pthread_mutex_unlock | ||
| import platform.posix.pthread_mutexattr_destroy | ||
| import platform.posix.pthread_mutexattr_init | ||
| import platform.posix.pthread_mutexattr_settype | ||
| import platform.posix.pthread_mutexattr_t | ||
| import kotlin.experimental.ExperimentalNativeApi | ||
| import kotlin.native.ref.createCleaner | ||
|
|
||
| @OptIn(ExperimentalForeignApi::class) | ||
|
arkivanov marked this conversation as resolved.
Resolved
|
||
| internal actual class Lock actual constructor() { | ||
|
|
||
| private val arena = Arena() | ||
| private val attr = arena.alloc<pthread_mutexattr_t>() | ||
| private val mutex = arena.alloc<pthread_mutex_t>() | ||
|
|
||
| @Suppress("unused") // Must be stored in a property | ||
| @OptIn(ExperimentalNativeApi::class) | ||
| private val cleaner = createCleaner(Resources(arena, attr, mutex), Resources::destroy) | ||
|
|
||
| init { | ||
| pthread_mutexattr_init(attr.ptr) | ||
| pthread_mutexattr_settype(attr.ptr, PTHREAD_MUTEX_RECURSIVE.toInt()) | ||
| pthread_mutex_init(mutex.ptr, attr.ptr) | ||
| } | ||
|
|
||
| actual inline fun <T> synchronizedImpl(block: () -> T): T { | ||
| lock() | ||
| try { | ||
| return block() | ||
| } finally { | ||
| unlock() | ||
| } | ||
| } | ||
|
|
||
| @PublishedApi | ||
| internal fun lock() { | ||
| pthread_mutex_lock(mutex.ptr) | ||
|
arkivanov marked this conversation as resolved.
Resolved
|
||
| } | ||
|
|
||
| @PublishedApi | ||
| internal fun unlock() { | ||
| pthread_mutex_unlock(mutex.ptr) | ||
| } | ||
|
|
||
| private class Resources( | ||
| private val arena: Arena, | ||
| private val attr: pthread_mutexattr_t, | ||
| private val mutex: pthread_mutex_t, | ||
| ) { | ||
| fun destroy() { | ||
| pthread_mutex_destroy(mutex.ptr) | ||
| pthread_mutexattr_destroy(attr.ptr) | ||
| arena.clear() | ||
| } | ||
| } | ||
| } | ||
5 changes: 5 additions & 0 deletions
5
decompose/src/linuxMain/kotlin/com/arkivanov/decompose/errorhandler/PrintError.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package com.arkivanov.decompose.errorhandler | ||
|
|
||
| internal actual fun printError(exception: Exception) { | ||
| exception.printStackTrace() | ||
| } |
5 changes: 5 additions & 0 deletions
5
decompose/src/linuxMain/kotlin/com/arkivanov/decompose/mainthread/CheckMainThread.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package com.arkivanov.decompose.mainthread | ||
|
|
||
| internal actual fun checkMainThread() { | ||
| // No-op | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.