All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nativeMain.kotlinx.io.core.ByteOrderNative.kt Maven / Gradle / Ivy

There is a newer version: 0.1.16
Show newest version
package kotlinx.io.core

import kotlinx.cinterop.*

actual enum class ByteOrder {
    BIG_ENDIAN, LITTLE_ENDIAN;

    actual companion object {
        private val native: ByteOrder

        init {
            native = memScoped {
                val i = alloc()
                i.value = 1
                val bytes = i.reinterpret()
                if (bytes.value == 0.toByte()) BIG_ENDIAN else LITTLE_ENDIAN
            }
        }

        actual fun nativeOrder(): ByteOrder = native
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy