commit 998bb26a11e94089a1688673cb30bf9b4016ea7a Author: Vasily Chekalkin Date: Sat Mar 28 08:01:55 2009 +1100 Change Parrot_io_socket to return INTVAL as all other functions diff --git a/examples/io/httpd.pir b/examples/io/httpd.pir index 01a596c..3970d37 100644 --- a/examples/io/httpd.pir +++ b/examples/io/httpd.pir @@ -111,13 +111,12 @@ The code was heavily hacked by bernhard and leo. port = 1234 # TODO provide sys/socket constants - .local pmc sock - sock = new 'Socket' - listener = sock.'socket'(2, 1, 6) # PF_INET, SOCK_STREAM, tcp + listener = new 'Socket' + listener.'socket'(2, 1, 6) # PF_INET, SOCK_STREAM, tcp unless listener goto ERR_NO_SOCKET # Pack a sockaddr_in structure with IP and port - address = sock.'sockaddr'(host, port) + address = listener.'sockaddr'(host, port) ret = listener.'bind'(address) if ret == -1 goto ERR_bind $S0 = port diff --git a/include/parrot/io.h b/include/parrot/io.h index 2efc85b..54fcaaf 100644 --- a/include/parrot/io.h +++ b/include/parrot/io.h @@ -829,7 +829,7 @@ INTVAL Parrot_io_send(PARROT_INTERP, ARGMOD(PMC *pmc), ARGMOD(STRING *buf)) PARROT_EXPORT PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL -PMC * Parrot_io_socket(PARROT_INTERP, +INTVAL Parrot_io_socket(PARROT_INTERP, ARGMOD_NULLOK(PMC * socket), INTVAL fam, INTVAL type, diff --git a/include/parrot/io_unix.h b/include/parrot/io_unix.h index 307f94c..90a3c7e 100644 --- a/include/parrot/io_unix.h +++ b/include/parrot/io_unix.h @@ -220,7 +220,7 @@ PMC * Parrot_io_sockaddr_in(PARROT_INTERP, ARGIN(STRING *addr), INTVAL port) PARROT_WARN_UNUSED_RESULT PARROT_CAN_RETURN_NULL -PMC * Parrot_io_socket_unix(PARROT_INTERP, +INTVAL Parrot_io_socket_unix(PARROT_INTERP, ARGIN(PMC *s), int fam, int type, diff --git a/include/parrot/io_win32.h b/include/parrot/io_win32.h index b39d8fd..489c819 100644 --- a/include/parrot/io_win32.h +++ b/include/parrot/io_win32.h @@ -199,7 +199,7 @@ PMC * Parrot_io_sockaddr_in(PARROT_INTERP, ARGIN(STRING *addr), INTVAL port) PARROT_WARN_UNUSED_RESULT PARROT_CAN_RETURN_NULL -PMC * Parrot_io_socket_win32(PARROT_INTERP, +INTVAL Parrot_io_socket_win32(PARROT_INTERP, ARGIN(PMC * s), int fam, int type, diff --git a/src/io/socket_api.c b/src/io/socket_api.c index d148018..976a0cb 100644 --- a/src/io/socket_api.c +++ b/src/io/socket_api.c @@ -69,7 +69,7 @@ Parrot_io_poll(PARROT_INTERP, ARGMOD(PMC *pmc), INTVAL which, INTVAL sec, INTVAL /* -=item C +=item C Creates and returns a socket using the specified address family, socket type, and protocol number. Check the returned PMC with a boolean test to see whether @@ -82,7 +82,7 @@ the socket was successfully created. PARROT_EXPORT PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL -PMC * +INTVAL Parrot_io_socket(PARROT_INTERP, ARGMOD_NULLOK(PMC * socket), INTVAL fam, INTVAL type, INTVAL proto) { diff --git a/src/io/socket_unix.c b/src/io/socket_unix.c index 1362e62..f716281 100644 --- a/src/io/socket_unix.c +++ b/src/io/socket_unix.c @@ -115,7 +115,7 @@ Parrot_io_sockaddr_in(PARROT_INTERP, ARGIN(STRING *addr), INTVAL port) /* -=item C +=item C Uses C to create a socket with the specified address family, socket type and protocol number. @@ -126,7 +126,7 @@ socket type and protocol number. PARROT_WARN_UNUSED_RESULT PARROT_CAN_RETURN_NULL -PMC * +INTVAL Parrot_io_socket_unix(PARROT_INTERP, ARGIN(PMC *s), int fam, int type, int proto) { ASSERT_ARGS(Parrot_io_socket_unix) @@ -136,9 +136,9 @@ Parrot_io_socket_unix(PARROT_INTERP, ARGIN(PMC *s), int fam, int type, int proto setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &i, sizeof (i)); Parrot_io_set_os_handle(interp, s, sock); SOCKADDR_REMOTE(s)->sin_family = fam; - return s; + return 0; } - return PMCNULL; + return -1; } /* diff --git a/src/io/socket_win32.c b/src/io/socket_win32.c index b458313..4879e99 100644 --- a/src/io/socket_win32.c +++ b/src/io/socket_win32.c @@ -61,7 +61,7 @@ static void get_sockaddr_in(PARROT_INTERP, /* -=item C +=item C Uses C to create a socket with the specified address family, socket type and protocol number. @@ -72,7 +72,7 @@ socket type and protocol number. PARROT_WARN_UNUSED_RESULT PARROT_CAN_RETURN_NULL -PMC * +INTVAL Parrot_io_socket_win32(PARROT_INTERP, ARGIN(PMC * s), int fam, int type, int proto) { ASSERT_ARGS(Parrot_io_socket_win32) @@ -82,9 +82,9 @@ Parrot_io_socket_win32(PARROT_INTERP, ARGIN(PMC * s), int fam, int type, int pro setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &i, sizeof (i)); Parrot_io_set_os_handle(interp, s, sock); SOCKADDR_REMOTE(io)->sin_family = fam; - return io; + return 0; } - return PMCNULL; + return -1; } /*