From Code to Community: Sponsoring The Perl and Raku Conference 2025 Learn more

TYPEMAP
Fd T_FD
struct signalfd_siginfo T_SIGFDINFO
sigset_t* T_SIGSET
signo_t T_SIGNO
siginfo_t T_SIGINFO
struct timespec T_TIMESPEC
INPUT
T_FD
$var = PerlIO_fileno(IoOFP(sv_2io(SvRV($arg))))
T_SIGSET
if (SvROK($arg)) {
if (!sv_derived_from($arg, \"POSIX::SigSet\")) {
Perl_croak(aTHX_ \"$var is not of type POSIX::SigSet\");
} else {
" . ( $] >= 5.015002 ?
"$var = (sigset_t *) SvPV_nolen(SvRV($arg));\n"
: "
IV tmp = SvIV((SV*)SvRV($arg));
$var = INT2PTR(sigset_t*, tmp);\n"
) . "
}
} else if (SvOK($arg)) {
int signo = (SvIOK($arg) || looks_like_number($arg)) && SvIV($arg) ? SvIV($arg) : whichsig(SvPV_nolen($arg));
SV* buffer = sv_2mortal(newSVpvn(\"\", 0));
sv_grow(buffer, sizeof(sigset_t));
$var = (sigset_t*)SvPV_nolen(buffer);
sigemptyset($var);
sigaddset($var, signo);
} else {
$var = NULL;
}
T_SIGNO
$var = (SvIOK($arg) || looks_like_number($arg)) && SvIV($arg) ? SvIV($arg) : whichsig(SvPV_nolen($arg));
T_TIMESPEC
{
NV input = SvNV($arg);
$var.tv_sec = (time_t) floor(input);
$var.tv_nsec = (long) ((input - $var.tv_sec) * 1000000000);
}
OUTPUT
T_SIGFDINFO
{
HV* ret = newHV();
hv_stores(ret, \"signo\", newSViv($var.ssi_signo));
hv_stores(ret, \"code\", newSViv($var.ssi_code));
hv_stores(ret, \"errno\", newSViv($var.ssi_errno));
hv_stores(ret, \"pid\", newSVuv($var.ssi_pid));
hv_stores(ret, \"uid\", newSVuv($var.ssi_uid));
hv_stores(ret, \"fd\", newSViv($var.ssi_fd));
hv_stores(ret, \"tid\", newSVuv($var.ssi_tid));
hv_stores(ret, \"band\", newSVuv($var.ssi_band));
hv_stores(ret, \"overrun\", newSVuv($var.ssi_overrun));
hv_stores(ret, \"trapno\", newSVuv($var.ssi_trapno));
hv_stores(ret, \"status\", newSViv($var.ssi_status));
hv_stores(ret, \"value\", newSViv($var.ssi_int));
hv_stores(ret, \"ptr\", newSVuv(PTR2UV($var.ssi_ptr)));
hv_stores(ret, \"addr\", newSVuv(PTR2UV($var.ssi_addr)));
$arg = newRV_noinc((SV*)ret);
}
T_TIMESPEC
$var.tv_sec + $var.tv_nsec / 1000000000.0;
T_SIGINFO
{
HV* ret = newHV();
hv_stores(ret, \"signo\", newSViv($var.si_signo));
hv_stores(ret, \"code\", newSViv($var.si_code));
hv_stores(ret, \"errno\", newSViv($var.si_errno));
hv_stores(ret, \"pid\", newSViv($var.si_pid));
hv_stores(ret, \"uid\", newSViv($var.si_uid));
hv_stores(ret, \"status\", newSViv($var.si_status));
hv_stores(ret, \"band\", newSViv($var.si_band));
hv_stores(ret, "fd", newSViv($var.si_fd));
hv_stores(ret, \"value\", newSViv($var.si_value.sival_int));
hv_stores(ret, \"ptr\", newSVuv(PTR2UV($var.si_value.sival_ptr)));
hv_stores(ret, \"addr\", newSVuv(PTR2UV($var.si_addr)));
$arg = newRV_noinc((SV*)ret);
}