Ticket #1724: getprotobyname-dynop.patch

File getprotobyname-dynop.patch, 5.5 KB (added by ocharles, 11 years ago)
  • src/dynoplibs/Rules.in

     
    126126 
    127127src/dynoplibs/io_ops.c: src/dynoplibs/io.ops $(OPS2C) 
    128128        $(OPS2C) --dynamic src/dynoplibs/io.ops --quiet 
     129 
     130######################### 
     131 
     132$(DYNEXT_DIR)/socket_ops$(LOAD_EXT): src/dynoplibs/socket_ops$(O) $(LIBPARROT) 
     133        $(LD) @ld_out@$@ src/dynoplibs/socket_ops$(O) $(LINKARGS) 
     134#IF(win32):     if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;2 
     135#IF(cygwin or hpux):    $(CHMOD) 0775 $@ 
     136 
     137src/dynoplibs/socket_ops$(O): $(DYNOP_O_DEPS) \ 
     138    src/dynoplibs/socket_ops.c src/dynoplibs/socket_ops.h 
     139 
     140src/dynoplibs/socket_ops.h: src/dynoplibs/socket_ops.c 
     141 
     142src/dynoplibs/socket_ops.c: src/dynoplibs/socket.ops $(OPS2C) 
     143        $(OPS2C) --dynamic src/dynoplibs/socket.ops --quiet 
  • src/dynoplibs/Defines.in

     
    77    $(DYNEXT_DIR)/debug_ops$(LOAD_EXT) \ 
    88    $(DYNEXT_DIR)/sys_ops$(LOAD_EXT) \ 
    99    $(DYNEXT_DIR)/io_ops$(LOAD_EXT) \ 
     10    $(DYNEXT_DIR)/socket_ops$(LOAD_EXT) \ 
    1011 
    1112DYNOPLIBS_CLEANUPS = \ 
    1213    src/dynoplibs/*.c \ 
  • src/io/socket_api.c

     
    353353 
    354354    return new_io; 
    355355} 
     356 
     357PARROT_EXPORT 
     358PARROT_WARN_UNUSED_RESULT 
     359INTVAL 
     360Parrot_io_get_proto_by_name(PARROT_INTERP, ARGIN(STRING * name)) 
     361{ 
     362    ASSERT_ARGS(Parrot_io_get_proto_by_name) 
     363     
     364    return PIO_GET_PROTO_BY_NAME(interp, name); 
     365} 
     366 
    356367/* 
    357368 
    358369=back 
  • src/io/socket_unix.c

     
    3535#ifdef PIO_OS_UNIX 
    3636 
    3737#  include <sys/socket.h> 
     38#  include <netdb.h> 
    3839 
    3940/* HEADERIZER HFILE: include/parrot/io_unix.h */ 
    4041 
     
    479480    sa->sin_port = htons(port); 
    480481} 
    481482 
     483/* 
    482484 
     485=item C<INTVAL Parrot_io_get_proto_by_name(PARROT_INTERP, STRING * name)> 
     486 
     487Return a protocol number based on the name of a protocol 
     488 
     489=cut 
     490 
     491*/ 
     492 
     493PARROT_WARN_UNUSED_RESULT 
     494INTVAL 
     495Parrot_io_get_proto_by_name_unix(PARROT_INTERP, ARGIN(STRING *name)) 
     496{ 
     497    ASSERT_ARGS(Parrot_io_get_proto_by_name_unix) 
     498 
     499    char            * const s        = Parrot_str_to_cstring(interp, name); 
     500    struct protoent * const protoent = getprotobyname(s); 
     501    int                     proto_number; 
     502 
     503    Parrot_str_free_cstring(s); 
     504    proto_number = protoent->p_proto; 
     505    return proto_number; 
     506} 
     507 
    483508#endif /* PIO_OS_UNIX */ 
    484509 
    485510/* 
  • CREDITS

     
    787787N: OOLLEY kj 
    788788D: Miscellaneous cleanup and PDD07-conformance 
    789789 
     790N: Oliver Charles 
     791D: Initial patch to add 'getprotobyname' as a dynamic op 
     792U: ocharles 
     793E: oliver@ocharles.org.uk 
     794 
    790795N: Ovid 
    791796D: Rename 'pbc_to_c' to 'pbc_to_exe' 
    792797 
  • include/parrot/io_unix.h

     
    198198        __attribute__nonnull__(3) 
    199199        FUNC_MODIFIES(*socket); 
    200200 
     201PARROT_WARN_UNUSED_RESULT 
     202INTVAL Parrot_io_get_proto_by_name_unix(PARROT_INTERP, ARGIN(STRING *name)) 
     203        __attribute__nonnull__(1) 
     204        __attribute__nonnull__(2); 
     205 
    201206INTVAL Parrot_io_listen_unix(SHIM_INTERP, ARGMOD(PMC *socket), INTVAL sec) 
    202207        __attribute__nonnull__(2) 
    203208        FUNC_MODIFIES(*socket); 
     
    254259       PARROT_ASSERT_ARG(interp) \ 
    255260    , PARROT_ASSERT_ARG(socket) \ 
    256261    , PARROT_ASSERT_ARG(r)) 
     262#define ASSERT_ARGS_Parrot_io_get_proto_by_name_unix \ 
     263     __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 
     264       PARROT_ASSERT_ARG(interp) \ 
     265    , PARROT_ASSERT_ARG(name)) 
    257266#define ASSERT_ARGS_Parrot_io_listen_unix __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 
    258267       PARROT_ASSERT_ARG(socket)) 
    259268#define ASSERT_ARGS_Parrot_io_poll_unix __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 
     
    313322    Parrot_io_listen_unix((interp), (pmc), (backlog)) 
    314323#define PIO_ACCEPT(interp, pmc) \ 
    315324    Parrot_io_accept_unix((interp), (pmc)) 
     325#define PIO_GET_PROTO_BY_NAME(interp, name) \ 
     326    Parrot_io_get_proto_by_name_unix((interp), (name)) 
    316327 
    317328#endif /* PARROT_IO_UNIX_H_GUARD */ 
    318329 
  • include/parrot/io.h

     
    825825 
    826826PARROT_EXPORT 
    827827PARROT_WARN_UNUSED_RESULT 
     828INTVAL Parrot_io_get_proto_by_name(PARROT_INTERP, ARGIN(STRING * name)) 
     829        __attribute__nonnull__(1) 
     830        __attribute__nonnull__(2); 
     831 
     832PARROT_EXPORT 
     833PARROT_WARN_UNUSED_RESULT 
    828834INTVAL Parrot_io_listen(PARROT_INTERP, ARGMOD(PMC *pmc), INTVAL backlog) 
    829835        __attribute__nonnull__(1) 
    830836        __attribute__nonnull__(2) 
     
    892898       PARROT_ASSERT_ARG(interp) \ 
    893899    , PARROT_ASSERT_ARG(pmc) \ 
    894900    , PARROT_ASSERT_ARG(address)) 
     901#define ASSERT_ARGS_Parrot_io_get_proto_by_name __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 
     902       PARROT_ASSERT_ARG(interp) \ 
     903    , PARROT_ASSERT_ARG(name)) 
    895904#define ASSERT_ARGS_Parrot_io_listen __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 
    896905       PARROT_ASSERT_ARG(interp) \ 
    897906    , PARROT_ASSERT_ARG(pmc))