[svn:parrot] r37829 - in trunk: include/parrot src/io
Infinoid at svn.parrot.org
Infinoid at svn.parrot.org
Tue Mar 31 16:34:35 UTC 2009
Author: Infinoid
Date: Tue Mar 31 16:34:34 2009
New Revision: 37829
URL: https://trac.parrot.org/parrot/changeset/37829
Log:
[io] Make socket constants conditional. (They aren't all defined on all architectures, and should fall back to -1 where they aren't implemented)
* Also, fix a comment to make it perfectly clear that the PIO socket constants differ from the system socket constants.
* Also, fix the following warning: src/io/socket_unix.c:171: warning: ISO C90 forbids mixed declarations and code
* Also, fix the following warning: src/io/socket_win32.c:117: warning: ISO C90 forbids mixed declarations and code
Modified:
trunk/include/parrot/io.h
trunk/src/io/socket_unix.c
trunk/src/io/socket_win32.c
Modified: trunk/include/parrot/io.h
==============================================================================
--- trunk/include/parrot/io.h Tue Mar 31 16:34:30 2009 (r37828)
+++ trunk/include/parrot/io.h Tue Mar 31 16:34:34 2009 (r37829)
@@ -907,8 +907,9 @@
/*
* Enum definition of constants for Socket.socket.
- * Happens to be same for corresponding values on Linux. Other implementations
- * of socket API may have to map this values to system specific.
+ * Note that these are the *parrot* values for these defines; the system
+ * values vary from one platform to the next. See the lookup tables in
+ * socket_unix.c and socket_win32.c for the mappings.
*/
/* &gen_from_enum(socket.pasm) */
Modified: trunk/src/io/socket_unix.c
==============================================================================
--- trunk/src/io/socket_unix.c Tue Mar 31 16:34:30 2009 (r37828)
+++ trunk/src/io/socket_unix.c Tue Mar 31 16:34:34 2009 (r37829)
@@ -120,10 +120,26 @@
*/
static int pio_pf[PIO_PF_MAX+1] = {
+# ifdef PF_LOCAL
PF_LOCAL, /* PIO_PF_LOCAL */
+# else
+ -1, /* PIO_PF_LOCAL */
+# endif
+# ifdef PF_UNIX
PF_UNIX, /* PIO_PF_UNIX */
+# else
+ -1, /* PIO_PF_UNIX */
+# endif
+# ifdef PF_INET
PF_INET, /* PIO_PF_INET */
+# else
+ -1, /* PIO_PF_INET */
+# endif
+# ifdef PF_INET6
PF_INET6, /* PIO_PF_INET6 */
+# else
+ -1, /* PIO_PF_INET6 */
+# endif
};
/*
@@ -144,7 +160,7 @@
Parrot_io_socket_unix(PARROT_INTERP, ARGIN(PMC *s), int fam, int type, int proto)
{
ASSERT_ARGS(Parrot_io_socket_unix)
- int i = 1;
+ int sock, i = 1;
/* convert Parrot's family to system family */
if (fam < 0 || fam >= PIO_PF_MAX)
return -1;
@@ -152,7 +168,7 @@
if (fam < 0)
return -1;
- const int sock = socket(fam, type, proto);
+ sock = socket(fam, type, proto);
if (sock >= 0) {
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &i, sizeof (i));
Parrot_io_set_os_handle(interp, s, sock);
Modified: trunk/src/io/socket_win32.c
==============================================================================
--- trunk/src/io/socket_win32.c Tue Mar 31 16:34:30 2009 (r37828)
+++ trunk/src/io/socket_win32.c Tue Mar 31 16:34:34 2009 (r37829)
@@ -66,10 +66,26 @@
*/
static int pio_pf[PIO_PF_MAX+1] = {
+# ifdef PF_LOCAL
PF_LOCAL, /* PIO_PF_LOCAL */
+# else
+ -1, /* PIO_PF_LOCAL */
+# endif
+# ifdef PF_UNIX
PF_UNIX, /* PIO_PF_UNIX */
+# else
+ -1, /* PIO_PF_UNIX */
+# endif
+# ifdef PF_INET
PF_INET, /* PIO_PF_INET */
+# else
+ -1, /* PIO_PF_INET */
+# endif
+# ifdef PF_INET6
PF_INET6, /* PIO_PF_INET6 */
+# else
+ -1, /* PIO_PF_INET6 */
+# endif
};
/*
@@ -90,7 +106,7 @@
Parrot_io_socket_win32(PARROT_INTERP, ARGIN(PMC * s), int fam, int type, int proto)
{
ASSERT_ARGS(Parrot_io_socket_win32)
- int i = 1;
+ int sock, i = 1;
/* convert Parrot's family to system family */
if (fam < 0 || fam >= PIO_PF_MAX)
return -1;
@@ -98,7 +114,7 @@
if (fam < 0)
return -1;
- const int sock = socket(fam, type, proto);
+ sock = socket(fam, type, proto);
if (sock >= 0) {
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (const char*)&i, sizeof (i));
Parrot_io_set_os_handle(interp, s, sock);
More information about the parrot-commits
mailing list