Skip to content

Instantly share code, notes, and snippets.

@kornilova203
Last active July 18, 2018 16:34
Show Gist options
  • Save kornilova203/ada9cb7a2a3c5822c19686023d9c6b1c to your computer and use it in GitHub Desktop.
Save kornilova203/ada9cb7a2a3c5822c19686023d9c6b1c to your computer and use it in GitHub Desktop.
Scala Native bindings for signal.h generated on macOS
import scala.scalanative._
import scala.scalanative.native._
@native.extern
object signal {
type __uint32_t = native.CUnsignedInt
type __darwin_size_t = native.CUnsignedLong
type __darwin_sigset_t = __uint32_t
type struct___darwin_pthread_handler_rec = native.CStruct3[native.CFunctionPtr1[native.Ptr[Byte], Unit], native.Ptr[Byte], native.Ptr[native.CArray[Byte, native.Nat.Digit[native.Nat._2, native.Nat._4]]]]
type struct__opaque_pthread_t = native.CStruct3[native.CLong, native.Ptr[struct___darwin_pthread_handler_rec], native.CArray[native.CChar, native.Nat.Digit[native.Nat._8, native.Nat.Digit[native.Nat._1, native.Nat.Digit[native.Nat._7, native.Nat._6]]]]]
type struct___darwin_sigaltstack = native.CStruct3[native.Ptr[Byte], __darwin_size_t, native.CInt]
type stack_t = struct___darwin_sigaltstack
type pid_t = native.CInt
type sigset_t = __darwin_sigset_t
type union___sigaction_u = native.CArray[Byte, native.Nat._8]
type struct_sigaction = native.CStruct3[union___sigaction_u, sigset_t, native.CInt]
type struct_sigvec = native.CStruct3[native.CFunctionPtr1[native.CInt, Unit], native.CInt, native.CInt]
val sys_signame: native.CArray[native.CString, native.Nat.Digit[native.Nat._3, native.Nat._2]] = native.extern
val sys_siglist: native.CArray[native.CString, native.Nat.Digit[native.Nat._3, native.Nat._2]] = native.extern
def raise(anonymous0: native.CInt): native.CInt = native.extern
def bsd_signal(anonymous0: native.CInt, anonymous1: native.CFunctionPtr1[native.CInt, Unit]): native.CFunctionPtr1[native.CInt, Unit] = native.extern
def kill(anonymous0: pid_t, anonymous1: native.CInt): native.CInt = native.extern
def killpg(anonymous0: pid_t, anonymous1: native.CInt): native.CInt = native.extern
def pthread_kill(anonymous0: native.Ptr[struct__opaque_pthread_t], anonymous1: native.CInt): native.CInt = native.extern
def pthread_sigmask(anonymous0: native.CInt, anonymous1: native.Ptr[sigset_t], anonymous2: native.Ptr[sigset_t]): native.CInt = native.extern
def sigaction(anonymous0: native.CInt, anonymous1: native.Ptr[struct_sigaction], anonymous2: native.Ptr[struct_sigaction]): native.CInt = native.extern
def sigaddset(anonymous0: native.Ptr[sigset_t], anonymous1: native.CInt): native.CInt = native.extern
def sigaltstack(anonymous0: native.Ptr[stack_t], anonymous1: native.Ptr[stack_t]): native.CInt = native.extern
def sigdelset(anonymous0: native.Ptr[sigset_t], anonymous1: native.CInt): native.CInt = native.extern
def sigemptyset(anonymous0: native.Ptr[sigset_t]): native.CInt = native.extern
def sigfillset(anonymous0: native.Ptr[sigset_t]): native.CInt = native.extern
def sighold(anonymous0: native.CInt): native.CInt = native.extern
def sigignore(anonymous0: native.CInt): native.CInt = native.extern
def siginterrupt(anonymous0: native.CInt, anonymous1: native.CInt): native.CInt = native.extern
def sigismember(anonymous0: native.Ptr[sigset_t], anonymous1: native.CInt): native.CInt = native.extern
def sigpause(anonymous0: native.CInt): native.CInt = native.extern
def sigpending(anonymous0: native.Ptr[sigset_t]): native.CInt = native.extern
def sigprocmask(anonymous0: native.CInt, anonymous1: native.Ptr[sigset_t], anonymous2: native.Ptr[sigset_t]): native.CInt = native.extern
def sigrelse(anonymous0: native.CInt): native.CInt = native.extern
def sigset(anonymous0: native.CInt, anonymous1: native.CFunctionPtr1[native.CInt, Unit]): native.CFunctionPtr1[native.CInt, Unit] = native.extern
def sigsuspend(anonymous0: native.Ptr[sigset_t]): native.CInt = native.extern
def sigwait(anonymous0: native.Ptr[sigset_t], anonymous1: native.Ptr[native.CInt]): native.CInt = native.extern
def psignal(anonymous0: native.CUnsignedInt, anonymous1: native.CString): Unit = native.extern
def sigblock(anonymous0: native.CInt): native.CInt = native.extern
def sigsetmask(anonymous0: native.CInt): native.CInt = native.extern
def sigvec(anonymous0: native.CInt, anonymous1: native.Ptr[struct_sigvec], anonymous2: native.Ptr[struct_sigvec]): native.CInt = native.extern
}
import signal._
object signalHelpers {
implicit class struct___darwin_pthread_handler_rec_ops(val p: native.Ptr[struct___darwin_pthread_handler_rec]) extends AnyVal {
def __routine: native.CFunctionPtr1[native.Ptr[Byte], Unit] = !p._1
def __routine_=(value: native.CFunctionPtr1[native.Ptr[Byte], Unit]): Unit = !p._1 = value
def __arg: native.Ptr[Byte] = !p._2
def __arg_=(value: native.Ptr[Byte]): Unit = !p._2 = value
def __next: native.Ptr[native.CArray[Byte, native.Nat.Digit[native.Nat._2, native.Nat._4]]] = !p._3
def __next_=(value: native.Ptr[native.CArray[Byte, native.Nat.Digit[native.Nat._2, native.Nat._4]]]): Unit = !p._3 = value
}
def struct___darwin_pthread_handler_rec()(implicit z: native.Zone): native.Ptr[struct___darwin_pthread_handler_rec] = native.alloc[struct___darwin_pthread_handler_rec]
implicit class struct__opaque_pthread_t_ops(val p: native.Ptr[struct__opaque_pthread_t]) extends AnyVal {
def __sig: native.CLong = !p._1
def __sig_=(value: native.CLong): Unit = !p._1 = value
def __cleanup_stack: native.Ptr[struct___darwin_pthread_handler_rec] = !p._2
def __cleanup_stack_=(value: native.Ptr[struct___darwin_pthread_handler_rec]): Unit = !p._2 = value
def __opaque: native.Ptr[native.CArray[native.CChar, native.Nat.Digit[native.Nat._8, native.Nat.Digit[native.Nat._1, native.Nat.Digit[native.Nat._7, native.Nat._6]]]]] = p._3
def __opaque_=(value: native.Ptr[native.CArray[native.CChar, native.Nat.Digit[native.Nat._8, native.Nat.Digit[native.Nat._1, native.Nat.Digit[native.Nat._7, native.Nat._6]]]]]): Unit = !p._3 = !value
}
def struct__opaque_pthread_t()(implicit z: native.Zone): native.Ptr[struct__opaque_pthread_t] = native.alloc[struct__opaque_pthread_t]
implicit class struct___darwin_sigaltstack_ops(val p: native.Ptr[struct___darwin_sigaltstack]) extends AnyVal {
def ss_sp: native.Ptr[Byte] = !p._1
def ss_sp_=(value: native.Ptr[Byte]): Unit = !p._1 = value
def ss_size: __darwin_size_t = !p._2
def ss_size_=(value: __darwin_size_t): Unit = !p._2 = value
def ss_flags: native.CInt = !p._3
def ss_flags_=(value: native.CInt): Unit = !p._3 = value
}
def struct___darwin_sigaltstack()(implicit z: native.Zone): native.Ptr[struct___darwin_sigaltstack] = native.alloc[struct___darwin_sigaltstack]
implicit class struct_sigaction_ops(val p: native.Ptr[struct_sigaction]) extends AnyVal {
def __sigaction_u: native.Ptr[union___sigaction_u] = p._1
def __sigaction_u_=(value: native.Ptr[union___sigaction_u]): Unit = !p._1 = !value
def sa_mask: sigset_t = !p._2
def sa_mask_=(value: sigset_t): Unit = !p._2 = value
def sa_flags: native.CInt = !p._3
def sa_flags_=(value: native.CInt): Unit = !p._3 = value
}
def struct_sigaction()(implicit z: native.Zone): native.Ptr[struct_sigaction] = native.alloc[struct_sigaction]
implicit class struct_sigvec_ops(val p: native.Ptr[struct_sigvec]) extends AnyVal {
def sv_handler: native.CFunctionPtr1[native.CInt, Unit] = !p._1
def sv_handler_=(value: native.CFunctionPtr1[native.CInt, Unit]): Unit = !p._1 = value
def sv_mask: native.CInt = !p._2
def sv_mask_=(value: native.CInt): Unit = !p._2 = value
def sv_flags: native.CInt = !p._3
def sv_flags_=(value: native.CInt): Unit = !p._3 = value
}
def struct_sigvec()(implicit z: native.Zone): native.Ptr[struct_sigvec] = native.alloc[struct_sigvec]
implicit class union___sigaction_u_pos(val p: native.Ptr[union___sigaction_u]) extends AnyVal {
def __sa_handler: native.Ptr[native.CFunctionPtr1[native.CInt, Unit]] = p.cast[native.Ptr[native.CFunctionPtr1[native.CInt, Unit]]]
def __sa_handler_=(value: native.CFunctionPtr1[native.CInt, Unit]): Unit = !p.cast[native.Ptr[native.CFunctionPtr1[native.CInt, Unit]]] = value
// def __sa_sigaction: native.Ptr[native.CFunctionPtr3[native.CInt, native.Ptr[struct___siginfo], native.Ptr[Byte], Unit]] = p.cast[native.Ptr[native.CFunctionPtr3[native.CInt, native.Ptr[struct___siginfo], native.Ptr[Byte], Unit]]]
// def __sa_sigaction_=(value: native.CFunctionPtr3[native.CInt, native.Ptr[struct___siginfo], native.Ptr[Byte], Unit]): Unit = !p.cast[native.Ptr[native.CFunctionPtr3[native.CInt, native.Ptr[struct___siginfo], native.Ptr[Byte], Unit]]] = value
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment