Re: [gnet-dev] amd64 fixes
- From: Tim Müller <t i m zen co uk>
- To: Daniel Gryniewicz <dang gentoo org>
- Cc: gnet-dev lists gnetlibrary org
- Subject: Re: [gnet-dev] amd64 fixes
- Date: Mon, 19 Sep 2005 18:19:44 +0100
On Sun, 2005-09-18 at 18:18 -0400, Daniel Gryniewicz wrote:
> > -#ifndef socklen_t
> > +#ifndef __socklen_t_defined
> > # ifdef GNET_APPLE_DARWIN
> > # define socklen_t int /* socklen_t is int in Darwin */
> > # else
> >
> > in src/gnet-private.h doesn't really look right to me.
> > __socklen_t_defined is a private define, isn't it? I don't think we
> > should be using that. Why is that necessary in the first place, and why
> > does linux/amd64 differ here from linux/other-arches?
>
> On all my linux systems, both amd64 and x86, that type (socklen_t) is
> protected by __socklen_t_defined, not by socklen_t, and they're
> typedefs, not defines, so that ifndef will always succeed, so a
> redefinition error will occur on both amd64 and x86, with the result
> that -Werror will fail.
Oh, indeed, I didn't even notice. Strange though that I don't get a
warning on x86 (with glibc-2.3.5 and gcc4).
I've now added a check to configure.ac that only adds an appropriate
#define to config.h if the system doesn't already have socklen_t.
Could you try the CVS version or the attached patch to see if that fixes
it for you as well?
Cheers
-Tim
Index: configure.ac
===================================================================
RCS file: /cvs/gnome/gnet/configure.ac,v
retrieving revision 1.54
diff -u -p -r1.54 configure.ac
--- configure.ac 25 Apr 2005 17:55:45 -0000 1.54
+++ configure.ac 19 Sep 2005 17:09:01 -0000
@@ -201,6 +201,36 @@ AC_TRY_CPP([#include <linux/netlink.h>],
###############################
# Check for types
+dnl check for Unix98 socklen_t (found on
+dnl xemacs-patches mailing list, written
+dnl by Martin Buchholz)
+dnl
+dnl On Darwin(MacOSX) socklen_t needs to be
+dnl an int (see accept man page), on all other
+dnl unix systems we need a size_t.
+
+AC_MSG_CHECKING(for socklen_t)
+AC_TRY_COMPILE([
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ socklen_t x;
+], [],[
+ AC_MSG_RESULT(yes)
+],[
+ AC_TRY_COMPILE([
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ int accept (int, struct sockaddr *, size_t *);
+ ],[],[
+ AC_MSG_RESULT(size_t)
+ AC_DEFINE(socklen_t,size_t,[Defined if system has no socklen_t type])
+ ], [
+ AC_MSG_RESULT(int)
+ AC_DEFINE(socklen_t,int,[Defined if system has no socklen_t type])
+ ]
+ )
+])
+
###############################
# Check for structures
Index: src/gnet-private.h
===================================================================
RCS file: /cvs/gnome/gnet/src/gnet-private.h,v
retrieving revision 1.60
diff -u -p -r1.60 gnet-private.h
--- src/gnet-private.h 25 Apr 2005 15:39:27 -0000 1.60
+++ src/gnet-private.h 19 Sep 2005 17:09:02 -0000
@@ -82,14 +82,6 @@ struct sockaddr_storage {
#define SOCKET gint
#endif
-#ifndef socklen_t
-# ifdef GNET_APPLE_DARWIN
-# define socklen_t int /* socklen_t is int in Darwin */
-# else
-# define socklen_t size_t /* it's size_t on all other Unixes */
-# endif
-#endif
-
#define GNET_CLOSE_SOCKET(SOCKFD) close(SOCKFD)
/* Use gnet_private_io_channel_new() to create iochannels */
[
Date Prev][Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]