This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
POSIX: Check fds against negatives.
[perl5.git] / ext / POSIX / typemap
1 Mode_t                  T_NV
2 pid_t                   T_NV
3 Uid_t                   T_NV
4 Time_t                  T_NV
5 Gid_t                   T_NV
6 Uid_t                   T_NV
7 Off_t                   T_NV
8 Dev_t                   T_NV
9 NV                      T_NV
10 fd                      T_IV
11 speed_t                 T_IV
12 tcflag_t                T_IV
13 cc_t                    T_IV
14 POSIX::SigSet           T_OPAQUEPTROBJ
15 POSIX::Termios          T_OPAQUEPTROBJ
16 POSIX::SigAction        T_HVREF
17 POSIX::SigNo            T_SIGNO
18 POSIX::Fd               T_FD
19
20 INPUT
21 T_OPAQUEPTROBJ
22         {
23             SV * sv = $arg;
24             if (SvROK(sv) && sv_derived_from(sv, \"${ntype}\"))
25                 $var = ($type)SvPV_nolen(SvRV(sv));
26             else
27                 croak(\"%s: %s is not of type %s\",
28                             ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
29                         \"$var\", \"$ntype\");
30         }
31
32 T_SIGNO
33         if ((sig = SvIV($arg)) < 0) {
34            croak(\"%s: Negative signals are not allowed %d\",
35                 ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
36                                    sig);
37         }
38
39 T_FD
40         if ((fd = (int)SvIV($arg)) < 0) {
41              SETERRNO(EBADF, RMS_IFI);
42              XSRETURN_IV(-1);
43         }
44
45 OUTPUT
46 T_OPAQUEPTROBJ
47         sv_setref_pvn($arg, \"${ntype}\", (const char*)$var, sizeof(*$var));