diff options
author | Nicholas Clark <nick@ccl4.org> | 2011-01-08 15:56:22 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2011-01-09 17:28:17 +0000 |
commit | 7627e6d0fe772ac90fce9e03fea273109521e261 (patch) | |
tree | 9317d21d802d44a74aa30b150729dc10a3662835 /pp_sys.c | |
parent | 60504e186da3226f64f36cdc4c9e700993e6f372 (diff) | |
download | perl-7627e6d0fe772ac90fce9e03fea273109521e261.tar.gz |
Generate "Unsupported socket function" stubs using PL_ppaddr.
Instead of having each socket op conditionally compile as either the
implementation or a DIE() depending on #HAS_SOCKET
1: remove the conditional code from the ops themselves
2: only compile the ops if HAS_SOCKET is defined
3: general conditional code for the intialisation of PL_ppaddr - as appropriate
either the ops, or Perl_unimplemented_op
4: Amend Perl_unimplemented_op to generate the appropriate DIE() for socket
ops (ie not the "panic"... message)
Whilst this complicates the support code in regen/opcode.pl, it's already a
net saving of 5 lines in the C code.
Diffstat (limited to 'pp_sys.c')
-rw-r--r-- | pp_sys.c | 45 |
1 files changed, 10 insertions, 35 deletions
@@ -1680,9 +1680,6 @@ PP(pp_sysread) PUSHs(TARG); RETURN; } -#else - if (PL_op->op_type == OP_RECV) - DIE(aTHX_ PL_no_sock_func, "recv"); #endif if (DO_UTF8(bufsv)) { /* offset adjust in characters not bytes */ @@ -1892,8 +1889,8 @@ PP(pp_syswrite) } } - if (op_type == OP_SEND) { #ifdef HAS_SOCKET + if (op_type == OP_SEND) { const int flags = SvIVx(*++MARK); if (SP > MARK) { STRLEN mlen; @@ -1905,10 +1902,10 @@ PP(pp_syswrite) retval = PerlSock_send(PerlIO_fileno(IoIFP(io)), buffer, blen, flags); } -#else - DIE(aTHX_ PL_no_sock_func, "send"); + } + else #endif - } else { + { Size_t length = 0; /* This length is in characters. */ STRLEN blen_chars; IV offset; @@ -2366,9 +2363,10 @@ PP(pp_flock) /* Sockets. */ +#ifdef HAS_SOCKET + PP(pp_socket) { -#ifdef HAS_SOCKET dVAR; dSP; const int protocol = POPi; const int type = POPi; @@ -2410,10 +2408,8 @@ PP(pp_socket) #endif RETPUSHYES; -#else - DIE(aTHX_ PL_no_sock_func, "socket"); -#endif } +#endif PP(pp_sockpair) { @@ -2470,9 +2466,10 @@ PP(pp_sockpair) #endif } +#ifdef HAS_SOCKET + PP(pp_bind) { -#ifdef HAS_SOCKET dVAR; dSP; SV * const addrsv = POPs; /* OK, so on what platform does bind modify addr? */ @@ -2499,14 +2496,10 @@ nuts: report_evil_fh(gv); SETERRNO(EBADF,SS_IVCHAN); RETPUSHUNDEF; -#else - DIE(aTHX_ PL_no_sock_func, PL_op_desc[PL_op->op_type]); -#endif } PP(pp_listen) { -#ifdef HAS_SOCKET dVAR; dSP; const int backlog = POPi; GV * const gv = MUTABLE_GV(POPs); @@ -2524,14 +2517,10 @@ nuts: report_evil_fh(gv); SETERRNO(EBADF,SS_IVCHAN); RETPUSHUNDEF; -#else - DIE(aTHX_ PL_no_sock_func, "listen"); -#endif } PP(pp_accept) { -#ifdef HAS_SOCKET dVAR; dSP; dTARGET; register IO *nstio; register IO *gstio; @@ -2602,14 +2591,10 @@ nuts: badexit: RETPUSHUNDEF; -#else - DIE(aTHX_ PL_no_sock_func, "accept"); -#endif } PP(pp_shutdown) { -#ifdef HAS_SOCKET dVAR; dSP; dTARGET; const int how = POPi; GV * const gv = MUTABLE_GV(POPs); @@ -2625,14 +2610,10 @@ nuts: report_evil_fh(gv); SETERRNO(EBADF,SS_IVCHAN); RETPUSHUNDEF; -#else - DIE(aTHX_ PL_no_sock_func, "shutdown"); -#endif } PP(pp_ssockopt) { -#ifdef HAS_SOCKET dVAR; dSP; const int optype = PL_op->op_type; SV * const sv = (optype == OP_GSOCKOPT) ? sv_2mortal(newSV(257)) : POPs; @@ -2701,14 +2682,10 @@ nuts: nuts2: RETPUSHUNDEF; -#else - DIE(aTHX_ PL_no_sock_func, PL_op_desc[PL_op->op_type]); -#endif } PP(pp_getpeername) { -#ifdef HAS_SOCKET dVAR; dSP; const int optype = PL_op->op_type; GV * const gv = MUTABLE_GV(POPs); @@ -2763,11 +2740,9 @@ nuts: SETERRNO(EBADF,SS_IVCHAN); nuts2: RETPUSHUNDEF; +} -#else - DIE(aTHX_ PL_no_sock_func, PL_op_desc[PL_op->op_type]); #endif -} /* Stat calls. */ |