commit 998bb26a11e94089a1688673cb30bf9b4016ea7a
Author: Vasily Chekalkin <bacek@bacek.com>
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
|
b
|
|
111 | 111 | port = 1234 |
112 | 112 | |
113 | 113 | # TODO provide sys/socket constants |
114 | | .local pmc sock |
115 | | sock = new 'Socket' |
116 | | listener = sock.'socket'(2, 1, 6) # PF_INET, SOCK_STREAM, tcp |
| 114 | listener = new 'Socket' |
| 115 | listener.'socket'(2, 1, 6) # PF_INET, SOCK_STREAM, tcp |
117 | 116 | unless listener goto ERR_NO_SOCKET |
118 | 117 | |
119 | 118 | # Pack a sockaddr_in structure with IP and port |
120 | | address = sock.'sockaddr'(host, port) |
| 119 | address = listener.'sockaddr'(host, port) |
121 | 120 | ret = listener.'bind'(address) |
122 | 121 | if ret == -1 goto ERR_bind |
123 | 122 | $S0 = port |
diff --git a/include/parrot/io.h b/include/parrot/io.h
index 2efc85b..54fcaaf 100644
a
|
b
|
|
829 | 829 | PARROT_EXPORT |
830 | 830 | PARROT_WARN_UNUSED_RESULT |
831 | 831 | PARROT_CANNOT_RETURN_NULL |
832 | | PMC * Parrot_io_socket(PARROT_INTERP, |
| 832 | INTVAL Parrot_io_socket(PARROT_INTERP, |
833 | 833 | ARGMOD_NULLOK(PMC * socket), |
834 | 834 | INTVAL fam, |
835 | 835 | INTVAL type, |
diff --git a/include/parrot/io_unix.h b/include/parrot/io_unix.h
index 307f94c..90a3c7e 100644
a
|
b
|
|
220 | 220 | |
221 | 221 | PARROT_WARN_UNUSED_RESULT |
222 | 222 | PARROT_CAN_RETURN_NULL |
223 | | PMC * Parrot_io_socket_unix(PARROT_INTERP, |
| 223 | INTVAL Parrot_io_socket_unix(PARROT_INTERP, |
224 | 224 | ARGIN(PMC *s), |
225 | 225 | int fam, |
226 | 226 | int type, |
diff --git a/include/parrot/io_win32.h b/include/parrot/io_win32.h
index b39d8fd..489c819 100644
a
|
b
|
|
199 | 199 | |
200 | 200 | PARROT_WARN_UNUSED_RESULT |
201 | 201 | PARROT_CAN_RETURN_NULL |
202 | | PMC * Parrot_io_socket_win32(PARROT_INTERP, |
| 202 | INTVAL Parrot_io_socket_win32(PARROT_INTERP, |
203 | 203 | ARGIN(PMC * s), |
204 | 204 | int fam, |
205 | 205 | int type, |
diff --git a/src/io/socket_api.c b/src/io/socket_api.c
index d148018..976a0cb 100644
a
|
b
|
|
69 | 69 | |
70 | 70 | /* |
71 | 71 | |
72 | | =item C<PMC * Parrot_io_socket> |
| 72 | =item C<INTVAL Parrot_io_socket> |
73 | 73 | |
74 | 74 | Creates and returns a socket using the specified address family, socket type, |
75 | 75 | and protocol number. Check the returned PMC with a boolean test to see whether |
… |
… |
|
82 | 82 | PARROT_EXPORT |
83 | 83 | PARROT_WARN_UNUSED_RESULT |
84 | 84 | PARROT_CANNOT_RETURN_NULL |
85 | | PMC * |
| 85 | INTVAL |
86 | 86 | Parrot_io_socket(PARROT_INTERP, ARGMOD_NULLOK(PMC * socket), INTVAL fam, |
87 | 87 | INTVAL type, INTVAL proto) |
88 | 88 | { |
diff --git a/src/io/socket_unix.c b/src/io/socket_unix.c
index 1362e62..f716281 100644
a
|
b
|
|
115 | 115 | |
116 | 116 | /* |
117 | 117 | |
118 | | =item C<PMC * Parrot_io_socket_unix> |
| 118 | =item C<INTVAL Parrot_io_socket_unix> |
119 | 119 | |
120 | 120 | Uses C<socket()> to create a socket with the specified address family, |
121 | 121 | socket type and protocol number. |
… |
… |
|
126 | 126 | |
127 | 127 | PARROT_WARN_UNUSED_RESULT |
128 | 128 | PARROT_CAN_RETURN_NULL |
129 | | PMC * |
| 129 | INTVAL |
130 | 130 | Parrot_io_socket_unix(PARROT_INTERP, ARGIN(PMC *s), int fam, int type, int proto) |
131 | 131 | { |
132 | 132 | ASSERT_ARGS(Parrot_io_socket_unix) |
… |
… |
|
136 | 136 | setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &i, sizeof (i)); |
137 | 137 | Parrot_io_set_os_handle(interp, s, sock); |
138 | 138 | SOCKADDR_REMOTE(s)->sin_family = fam; |
139 | | return s; |
| 139 | return 0; |
140 | 140 | } |
141 | | return PMCNULL; |
| 141 | return -1; |
142 | 142 | } |
143 | 143 | |
144 | 144 | /* |
diff --git a/src/io/socket_win32.c b/src/io/socket_win32.c
index b458313..4879e99 100644
a
|
b
|
|
61 | 61 | |
62 | 62 | /* |
63 | 63 | |
64 | | =item C<PMC * Parrot_io_socket_win32> |
| 64 | =item C<INTVAL Parrot_io_socket_win32> |
65 | 65 | |
66 | 66 | Uses C<socket()> to create a socket with the specified address family, |
67 | 67 | socket type and protocol number. |
… |
… |
|
72 | 72 | |
73 | 73 | PARROT_WARN_UNUSED_RESULT |
74 | 74 | PARROT_CAN_RETURN_NULL |
75 | | PMC * |
| 75 | INTVAL |
76 | 76 | Parrot_io_socket_win32(PARROT_INTERP, ARGIN(PMC * s), int fam, int type, int proto) |
77 | 77 | { |
78 | 78 | ASSERT_ARGS(Parrot_io_socket_win32) |
… |
… |
|
82 | 82 | setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &i, sizeof (i)); |
83 | 83 | Parrot_io_set_os_handle(interp, s, sock); |
84 | 84 | SOCKADDR_REMOTE(io)->sin_family = fam; |
85 | | return io; |
| 85 | return 0; |
86 | 86 | } |
87 | | return PMCNULL; |
| 87 | return -1; |
88 | 88 | } |
89 | 89 | |
90 | 90 | /* |