Toby
04/08/2021, 1:27 PMlong ns;
struct timespec spec;
clock_gettime(CLOCK_REALTIME, &spec);
ns = spec.tv_nsec;
I came up with this Kotlin/Native syntax but I can't access the tv_nsec member of the timespec struct and this is the only working code so far:
val spec: CValuesRef<timespec>? = null
clock_gettime(CLOCK_REALTIME, spec)
to actually access the output, I would need the following code (right)?:
var ns: Long
val spec: CValuesRef<timespec>? = null
clock_gettime(CLOCK_REALTIME, spec)
ns = spec.tv_nsec
So, how do I correctly do this?mbonnin
04/08/2021, 1:31 PMmemScoped
: https://kotlinlang.org/api/latest/jvm/stdlib/kotlinx.cinterop/mem-scoped.htmlmbonnin
04/08/2021, 1:36 PMmemScoped {
val spec = alloc<timespec>()
clock_gettime(CLOCK_REALTIME, spec.ptr)
}
mbonnin
04/08/2021, 1:36 PMToby
04/08/2021, 1:53 PM