Files
kotlin-fork/backend.native/tests/interop/basics/3.kt
T
Alexander Gorshenev 334d2f0ee6 Remote test execution for cross compiled tests. Run it like:
$ ./gradlew backend.native:tests:run \
    -Premote=user@111.22.33.444 -Ptest_target=raspberrypi

The new gradle command line options:

    -Pbuild_flags  renamed -Pkonanc_flags.
    -Ptest_flags   provides compiler flags to the test builds.
    -Ptest_target  properly sets up compiler as well as interop
                   to cross compile tests.
    -Premote       specifies remote host and login.
2017-03-27 15:14:57 +03:00

30 lines
746 B
Kotlin

import kotlinx.cinterop.*
fun main(args: Array<String>) {
memScoped {
val count = 5
val values = allocArray<CInt32Var>(count)
values[0].value = 14
values[1].value = 12
values[2].value = 9
values[3].value = 13
values[4].value = 8
cstdlib.qsort(values[0].ptr, count.toLong(), CInt32Var.size, staticCFunction(::comparator))
for (i in 0 .. count - 1) {
print(values[i].value)
print(" ")
}
println()
}
}
private fun comparator(a: COpaquePointer?, b: COpaquePointer?): Int {
val aValue = a!!.reinterpret<CInt32Var>().pointed.value
val bValue = b!!.reinterpret<CInt32Var>().pointed.value
return (aValue - bValue)
}