[gnet-dev] Build with Sun compiler



Attached are some changes I had to make in order to be able to compile
gnet-2.0.1 with the Sun C compiler instead of gcc. Perhaps you'll find
them useful.

Most changes are related to the fact that a (condition ? exp : exp)
expression is not an lvalue in C and hence can not be used in the left
hand side of an assignment. GCC seems to allow this but it is not
standard C.

Cheers,
-Ives
______________________________________________________________________
Ives Aerts                      Sony Visual Products Europe - Brussels
Ives Aerts sonycom com                    http://www.vpe-b.sonycom.com
`Apparantly, 1 in 5 people are Chinese. There are 5 people in my
 family, so it must be one of them.'                    (Tommy Cooper)
Only in gnet-2.0.1.new/: gnet-2.0.1
diff -aur gnet-2.0.1/gnet-2.0.pc.in gnet-2.0.1.new/gnet-2.0.pc.in
--- gnet-2.0.1/gnet-2.0.pc.in	Sat Apr 12 21:40:43 2003
+++ gnet-2.0.1.new/gnet-2.0.pc.in	Fri Apr 25 17:12:27 2003
@@ -6,5 +6,5 @@
 Name: Gnet
 Description: A network compatibility layer library
 Version: @VERSION@
-Libs: -L${libdir} -lgnet- GNET_MAJOR_VERSION@  GNET_MINOR_VERSION@ @GLIB_LIBS@ @GTHREAD_LIBS@
+Libs: -R${libdir} -L${libdir} -lgnet- GNET_MAJOR_VERSION@  GNET_MINOR_VERSION@ @GLIB_LIBS@ @GTHREAD_LIBS@
 Cflags: -I${includedir}/gnet- GNET_MAJOR_VERSION@  GNET_MINOR_VERSION@ -I${libdir}/gnet- GNET_MAJOR_VERSION@  GNET_MINOR_VERSION@/include/ @GLIB_CFLAGS@ @GTHREAD_CFLAGS@
Only in gnet-2.0.1: gnet.spec
diff -aur gnet-2.0.1/src/gnet-private.c gnet-2.0.1.new/src/gnet-private.c
--- gnet-2.0.1/src/gnet-private.c	Fri Apr 18 20:51:45 2003
+++ gnet-2.0.1.new/src/gnet-private.c	Fri Apr 25 17:40:30 2003
@@ -41,7 +41,7 @@
     {
       family = GNET_INETADDR_FAMILY(iface);
       *sa = iface->sa;
-      GNET_SOCKADDR_PORT(*sa) = g_htons(port);
+      GNET_SOCKADDR_PORT_SET(*sa, g_htons(port));
     }
   else
     {
diff -aur gnet-2.0.1/src/gnet-private.h gnet-2.0.1.new/src/gnet-private.h
--- gnet-2.0.1/src/gnet-private.h	Fri Apr 18 20:51:45 2003
+++ gnet-2.0.1.new/src/gnet-private.h	Fri Apr 25 18:22:14 2003
@@ -132,12 +132,20 @@
 #define GNET_SOCKADDR_ADDR32(s,n)(((s).ss_family == AF_INET)?\
                                   ((struct sockaddr_in*)&s)->sin_addr.s_addr:\
                                   *(guint32*)&((struct sockaddr_in6*)&s)->sin6_addr.s6_addr[(n)*4])
+#define GNET_SOCKADDR_ADDR32_SET(s,n,a) if ((s).ss_family == AF_INET) \
+                                          ((struct sockaddr_in*)&s)->sin_addr.s_addr = a; \
+                                        else \
+                                          *(guint32*)&((struct sockaddr_in6*)&s)->sin6_addr.s6_addr[(n)*4] = a;
 #define GNET_SOCKADDR_ADDRLEN(s) (((s).ss_family == AF_INET)?\
 				 sizeof(struct in_addr):\
 				 sizeof(struct in6_addr))
 #define GNET_SOCKADDR_PORT(s)	(((s).ss_family == AF_INET)?\
                                   ((struct sockaddr_in*)&s)->sin_port:\
                                   ((struct sockaddr_in6*)&s)->sin6_port)
+#define GNET_SOCKADDR_PORT_SET(s, p)	if ((s).ss_family == AF_INET)\
+                                          ((struct sockaddr_in*)&(s))->sin_port = p;\
+                                        else \
+                                          ((struct sockaddr_in6*)&(s))->sin6_port = p;
 #define GNET_SOCKADDR_LEN(s)	(((s).ss_family == AF_INET)?\
                                   sizeof(struct sockaddr_in):\
                                   sizeof(struct sockaddr_in6))
@@ -167,6 +175,7 @@
 #define GNET_INETADDR_ADDR32(i,n)   GNET_SOCKADDR_ADDR32((i)->sa,(n))
 #define GNET_INETADDR_ADDRLEN(i)    GNET_SOCKADDR_ADDRLEN((i)->sa)
 #define GNET_INETADDR_PORT(i)       GNET_SOCKADDR_PORT((i)->sa)
+#define GNET_INETADDR_PORT_SET(i, p)	GNET_SOCKADDR_PORT_SET((i)->sa, p)
 #define GNET_INETADDR_LEN(i)        GNET_SOCKADDR_LEN((i)->sa)
 #define GNET_INETADDR_SET_SS_LEN(i) GNET_SOCKADDR_SET_SS_LEN((i)->sa)
 
diff -aur gnet-2.0.1/src/inetaddr.c gnet-2.0.1.new/src/inetaddr.c
--- gnet-2.0.1/src/inetaddr.c	Fri Apr 18 20:51:46 2003
+++ gnet-2.0.1.new/src/inetaddr.c	Fri Apr 25 17:51:51 2003
@@ -582,7 +582,7 @@
   ia = (GInetAddr*) ialist->data;
   ialist = g_list_remove (ialist, ia);
 
-  GNET_INETADDR_PORT(ia) = g_htons(port);
+  GNET_INETADDR_PORT_SET(ia, g_htons(port));
 
   ialist_free (ialist);
 
@@ -618,7 +618,7 @@
   for (i = ialist; i != NULL; i = i->next)
     {
       GInetAddr* ia = (GInetAddr*) i->data;
-      GNET_INETADDR_PORT(ia) = g_htons(port);
+      GNET_INETADDR_PORT_SET(ia, g_htons(port));
     }
 
   return ialist;
@@ -1044,7 +1044,7 @@
       for (i = ialist; i != NULL; i = i->next)
 	{
 	  GInetAddr* ia = (GInetAddr*) i->data;
-	  GNET_INETADDR_PORT(ia) = g_htons(state->port);
+          GNET_INETADDR_PORT_SET(ia, g_htons(state->port));
 	}
 
       /* Save the list */
@@ -2205,7 +2205,7 @@
 #endif
   GNET_INETADDR_SET_SS_LEN(inetaddr);
   memcpy (GNET_INETADDR_ADDRP(inetaddr), bytes, length);
-  GNET_INETADDR_PORT(inetaddr) = port;
+  GNET_INETADDR_PORT_SET(inetaddr, port);
 }
 
 
@@ -2268,7 +2268,7 @@
 {
   g_return_if_fail(inetaddr != NULL);
 
-  GNET_INETADDR_PORT(inetaddr) = g_htons(port);
+  GNET_INETADDR_PORT(inetaddr, g_htons(port));
 }
 
 
diff -aur gnet-2.0.1/src/udp.c gnet-2.0.1.new/src/udp.c
--- gnet-2.0.1/src/udp.c	Fri Apr 18 20:51:47 2003
+++ gnet-2.0.1.new/src/udp.c	Fri Apr 25 18:20:05 2003
@@ -263,11 +263,11 @@
 	{
           sa.ss_family = AF_INET6;
 	  GNET_SOCKADDR_SET_SS_LEN(sa);
-          GNET_SOCKADDR_PORT(sa) = GNET_INETADDR_PORT(dst);
-          GNET_SOCKADDR_ADDR32(sa, 0) = 0;
-          GNET_SOCKADDR_ADDR32(sa, 1) = 0;
-          GNET_SOCKADDR_ADDR32(sa, 2) = g_htonl(0xffff);
-          GNET_SOCKADDR_ADDR32(sa, 3) = GNET_INETADDR_ADDR32(dst, 0);
+          GNET_SOCKADDR_PORT_SET(sa, GNET_INETADDR_PORT(dst));
+          GNET_SOCKADDR_ADDR32_SET(sa, 0, 0);
+          GNET_SOCKADDR_ADDR32_SET(sa, 1, 0);
+          GNET_SOCKADDR_ADDR32_SET(sa, 2, g_htonl(0xffff));
+          GNET_SOCKADDR_ADDR32_SET(sa, 3, GNET_INETADDR_ADDR32(dst, 0));
 	}
 
       /* If dst is IPv6, map to IPv4 if possible */
@@ -277,8 +277,8 @@
 	{
           sa.ss_family = AF_INET;
 	  GNET_SOCKADDR_SET_SS_LEN(sa);
-          GNET_SOCKADDR_PORT(sa) = GNET_INETADDR_PORT(dst);
-          GNET_SOCKADDR_ADDR32(sa, 0) = GNET_INETADDR_ADDR32(dst, 3);
+          GNET_SOCKADDR_PORT_SET(sa, GNET_INETADDR_PORT(dst));
+          GNET_SOCKADDR_ADDR32_SET(sa, 0, GNET_INETADDR_ADDR32(dst, 3));
 	}
       else
         return -1;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]