Skip to content

Instantly share code, notes, and snippets.

@kornilova203
Created July 18, 2018 16:35
Show Gist options
  • Save kornilova203/cfda2297e9a72ed14e69feb309197a98 to your computer and use it in GitHub Desktop.
Save kornilova203/cfda2297e9a72ed14e69feb309197a98 to your computer and use it in GitHub Desktop.
Scala Native bindings for signal.h generated on Ubuntu
import scala.scalanative._
import scala.scalanative.native._
@native.extern
object signal {
type __uid_t = native.CUnsignedInt
type __pid_t = native.CInt
type __time_t = native.CLong
type __syscall_slong_t = native.CLong
type struct___sigset_t = native.CStruct1[native.CArray[native.CUnsignedLong, native.Nat.Digit[native.Nat._1, native.Nat._6]]]
type __sigset_t = struct___sigset_t
type sigset_t = __sigset_t
type pid_t = __pid_t
type uid_t = __uid_t
type struct_timespec = native.CStruct2[__time_t, __syscall_slong_t]
type union_sigval = native.CArray[Byte, native.Nat._8]
type struct_siginfo_t = native.CStruct5[native.CInt, native.CInt, native.CInt, native.CInt, native.CArray[Byte, native.Nat.Digit[native.Nat._1, native.Nat.Digit[native.Nat._1, native.Nat._2]]]]
type siginfo_t = struct_siginfo_t
type __sighandler_t = native.CFunctionPtr1[native.CInt, Unit]
type sig_t = native.CFunctionPtr1[native.CInt, Unit]
type struct_sigaction = native.CStruct4[native.CArray[Byte, native.Nat._8], __sigset_t, native.CInt, native.CFunctionPtr0[Unit]]
type struct_sigcontext = native.CArray[Byte, native.Nat.Digit[native.Nat._2, native.Nat.Digit[native.Nat._5, native.Nat._6]]]
type struct_stack_t = native.CStruct3[native.Ptr[Byte], native.CInt, native.CSize]
type stack_t = struct_stack_t
type struct_sigstack = native.CStruct2[native.Ptr[Byte], native.CInt]
val _sys_siglist: native.CArray[native.CString, native.Nat.Digit[native.Nat._6, native.Nat._5]] = native.extern
val sys_siglist: native.CArray[native.CString, native.Nat.Digit[native.Nat._6, native.Nat._5]] = native.extern
def __sysv_signal(__sig: native.CInt, __handler: native.CFunctionPtr1[native.CInt, Unit]): native.CFunctionPtr1[native.CInt, Unit] = native.extern
def signal(__sig: native.CInt, __handler: native.CFunctionPtr1[native.CInt, Unit]): native.CFunctionPtr1[native.CInt, Unit] = native.extern
def kill(__pid: __pid_t, __sig: native.CInt): native.CInt = native.extern
def killpg(__pgrp: __pid_t, __sig: native.CInt): native.CInt = native.extern
def raise(__sig: native.CInt): native.CInt = native.extern
def ssignal(__sig: native.CInt, __handler: native.CFunctionPtr1[native.CInt, Unit]): native.CFunctionPtr1[native.CInt, Unit] = native.extern
def gsignal(__sig: native.CInt): native.CInt = native.extern
def psignal(__sig: native.CInt, __s: native.CString): Unit = native.extern
def psiginfo(__pinfo: native.Ptr[siginfo_t], __s: native.CString): Unit = native.extern
def sigblock(__mask: native.CInt): native.CInt = native.extern
def sigsetmask(__mask: native.CInt): native.CInt = native.extern
def siggetmask(): native.CInt = native.extern
def sigemptyset(__set: native.Ptr[sigset_t]): native.CInt = native.extern
def sigfillset(__set: native.Ptr[sigset_t]): native.CInt = native.extern
def sigaddset(__set: native.Ptr[sigset_t], __signo: native.CInt): native.CInt = native.extern
def sigdelset(__set: native.Ptr[sigset_t], __signo: native.CInt): native.CInt = native.extern
def sigismember(__set: native.Ptr[sigset_t], __signo: native.CInt): native.CInt = native.extern
def sigprocmask(__how: native.CInt, __set: native.Ptr[sigset_t], __oset: native.Ptr[sigset_t]): native.CInt = native.extern
def sigsuspend(__set: native.Ptr[sigset_t]): native.CInt = native.extern
def sigaction(__sig: native.CInt, __act: native.Ptr[struct_sigaction], __oact: native.Ptr[struct_sigaction]): native.CInt = native.extern
def sigpending(__set: native.Ptr[sigset_t]): native.CInt = native.extern
def sigwait(__set: native.Ptr[sigset_t], __sig: native.Ptr[native.CInt]): native.CInt = native.extern
def sigwaitinfo(__set: native.Ptr[sigset_t], __info: native.Ptr[siginfo_t]): native.CInt = native.extern
def sigtimedwait(__set: native.Ptr[sigset_t], __info: native.Ptr[siginfo_t], __timeout: native.Ptr[struct_timespec]): native.CInt = native.extern
def sigreturn(__scp: native.Ptr[struct_sigcontext]): native.CInt = native.extern
def siginterrupt(__sig: native.CInt, __interrupt: native.CInt): native.CInt = native.extern
def sigaltstack(__ss: native.Ptr[stack_t], __oss: native.Ptr[stack_t]): native.CInt = native.extern
def sigstack(__ss: native.Ptr[struct_sigstack], __oss: native.Ptr[struct_sigstack]): native.CInt = native.extern
def __libc_current_sigrtmin(): native.CInt = native.extern
def __libc_current_sigrtmax(): native.CInt = native.extern
}
import signal._
object signalHelpers {
implicit class struct___sigset_t_ops(val p: native.Ptr[struct___sigset_t]) extends AnyVal {
def __val: native.Ptr[native.CArray[native.CUnsignedLong, native.Nat.Digit[native.Nat._1, native.Nat._6]]] = p._1
def __val_=(value: native.Ptr[native.CArray[native.CUnsignedLong, native.Nat.Digit[native.Nat._1, native.Nat._6]]]): Unit = !p._1 = !value
}
def struct___sigset_t()(implicit z: native.Zone): native.Ptr[struct___sigset_t] = native.alloc[struct___sigset_t]
implicit class struct_timespec_ops(val p: native.Ptr[struct_timespec]) extends AnyVal {
def tv_sec: __time_t = !p._1
def tv_sec_=(value: __time_t): Unit = !p._1 = value
def tv_nsec: __syscall_slong_t = !p._2
def tv_nsec_=(value: __syscall_slong_t): Unit = !p._2 = value
}
def struct_timespec()(implicit z: native.Zone): native.Ptr[struct_timespec] = native.alloc[struct_timespec]
implicit class struct_siginfo_t_ops(val p: native.Ptr[struct_siginfo_t]) extends AnyVal {
def si_signo: native.CInt = !p._1
def si_signo_=(value: native.CInt): Unit = !p._1 = value
def si_errno: native.CInt = !p._2
def si_errno_=(value: native.CInt): Unit = !p._2 = value
def si_code: native.CInt = !p._3
def si_code_=(value: native.CInt): Unit = !p._3 = value
def __pad0: native.CInt = !p._4
def __pad0_=(value: native.CInt): Unit = !p._4 = value
def _sifields: native.Ptr[native.CArray[Byte, native.Nat.Digit[native.Nat._1, native.Nat.Digit[native.Nat._1, native.Nat._2]]]] = p._5
def _sifields_=(value: native.Ptr[native.CArray[Byte, native.Nat.Digit[native.Nat._1, native.Nat.Digit[native.Nat._1, native.Nat._2]]]]): Unit = !p._5 = !value
}
def struct_siginfo_t()(implicit z: native.Zone): native.Ptr[struct_siginfo_t] = native.alloc[struct_siginfo_t]
implicit class struct_sigaction_ops(val p: native.Ptr[struct_sigaction]) extends AnyVal {
def __sigaction_handler: native.Ptr[native.CArray[Byte, native.Nat._8]] = p._1
def __sigaction_handler_=(value: native.Ptr[native.CArray[Byte, native.Nat._8]]): Unit = !p._1 = !value
def sa_mask: native.Ptr[__sigset_t] = p._2
def sa_mask_=(value: native.Ptr[__sigset_t]): Unit = !p._2 = !value
def sa_flags: native.CInt = !p._3
def sa_flags_=(value: native.CInt): Unit = !p._3 = value
def sa_restorer: native.CFunctionPtr0[Unit] = !p._4
def sa_restorer_=(value: native.CFunctionPtr0[Unit]): Unit = !p._4 = value
}
def struct_sigaction()(implicit z: native.Zone): native.Ptr[struct_sigaction] = native.alloc[struct_sigaction]
implicit class struct_stack_t_ops(val p: native.Ptr[struct_stack_t]) extends AnyVal {
def ss_sp: native.Ptr[Byte] = !p._1
def ss_sp_=(value: native.Ptr[Byte]): Unit = !p._1 = value
def ss_flags: native.CInt = !p._2
def ss_flags_=(value: native.CInt): Unit = !p._2 = value
def ss_size: native.CSize = !p._3
def ss_size_=(value: native.CSize): Unit = !p._3 = value
}
def struct_stack_t()(implicit z: native.Zone): native.Ptr[struct_stack_t] = native.alloc[struct_stack_t]
implicit class struct_sigstack_ops(val p: native.Ptr[struct_sigstack]) extends AnyVal {
def ss_sp: native.Ptr[Byte] = !p._1
def ss_sp_=(value: native.Ptr[Byte]): Unit = !p._1 = value
def ss_onstack: native.CInt = !p._2
def ss_onstack_=(value: native.CInt): Unit = !p._2 = value
}
def struct_sigstack()(implicit z: native.Zone): native.Ptr[struct_sigstack] = native.alloc[struct_sigstack]
implicit class union_sigval_pos(val p: native.Ptr[union_sigval]) extends AnyVal {
def sival_int: native.Ptr[native.CInt] = p.cast[native.Ptr[native.CInt]]
def sival_int_=(value: native.CInt): Unit = !p.cast[native.Ptr[native.CInt]] = value
def sival_ptr: native.Ptr[native.Ptr[Byte]] = p.cast[native.Ptr[native.Ptr[Byte]]]
def sival_ptr_=(value: native.Ptr[Byte]): Unit = !p.cast[native.Ptr[native.Ptr[Byte]]] = value
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment