We recently released the sharp v1.0.0 of angelos-project-errno, a package used for handling errno numbers in stdlibc. These numbers can be read in Kotlin/Native but not reset because of the compiler using a val
instead of var
.
Because of this it is hard, if not impossible to work with POSIX functions properly, especially when it may be required to reset errno
before making a system function call.
For this purpose we developed a tiny framework to look for posix error handling using simple error predicate functions. Those functions are easy to use higher-order functions that may throw a PosixError
exception telling the errno
constant with error message and implemented errno code.
For this to work we had to utilize both JNI for the Jvm side of KMP, and cinterop for the native side thereof. In both cases a PosixError is thrown with proper message telling the nature of the problem. This type of micro framework design lets developers work close to the original methods used in POSIX implementations and at the same time handle as much logic as possible in Kotlin, and as little as possible in C/C++.
Thereby being able to focus on learning only one universal programming language for allround use, everything from hidden servers to modern mobile applications and other similar uses.
Top comments (0)