darcs patch: s6_addr32 is undefined on darwin. Added an AC check a...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

darcs patch: s6_addr32 is undefined on darwin. Added an AC check a...

Thomas Schilling-2
Fri Jun 22 18:58:52 CEST 2007  Thomas Schilling <[hidden email]>
  * s6_addr32 is undefined on darwin.  Added an AC check and a definition taken from the NetBSD sources.


New patches:

[s6_addr32 is undefined on darwin.  Added an AC check and a definition taken from the NetBSD sources.
Thomas Schilling <[hidden email]>**20070622165852] {
hunk ./configure.ac 42
+dnl --------------------------------------------------
+dnl * test for s6_addr32
+dnl --------------------------------------------------
+AC_MSG_CHECKING(for s6_addr32 in netinet6/in6.h)
+AC_EGREP_HEADER(s6_addr32, netinet6/in6.h,
+ [ AC_DEFINE([HAVE_S6_ADDR32], [1], [Define to 1 if s6_addr32 is available.]) AC_MSG_RESULT(yes) ],
+ AC_MSG_RESULT(no))
+
+
hunk ./include/HsNet.h 78
+#endif
+#ifndef HAVE_S6_ADDR32
+# define s6_addr32 __u6_addr.__u6_addr32
}

Context:

[Fix further build problems when IPv6 isn't available
Simon Marlow <[hidden email]>**20070604105407]
[Try a hopefully more portable test for RFC 3493 API compatibility.
Bryan O'Sullivan <[hidden email]>**20070602050225]
[Fix build failure if IPv6 is not available.
Bryan O'Sullivan <[hidden email]>**20070601160943]
[Fixed support for platforms with IPv6 but no AI_ADDRCONFIG
Michael D. Adams <[hidden email]>**20070604153642]
[--configure-option and --ghc-option are now provided by Cabal
Ross Paterson <[hidden email]>**20070604115612]
[Invoke the preprocessor portably.
Bryan O'Sullivan <[hidden email]>**20070408171912]
[Add IPv6 support to Network.
Bryan O'Sullivan <[hidden email]>**20070404223751
 
 The public API remains unchanged; it can now transparently handle IPv6
 addresses and sockets.
]
[Add IPv6 support to Network.Socket.
Bryan O'Sullivan <[hidden email]>**20070404222036
 
 The only public API changes are to Network.Socket, which has the following
 exported names added (no existing names have been removed):
 
     -- IPv6 address components
     HostAddress6
     FlowInfo
     ScopeID
 
     -- Name -> address lookup
     getAddrInfo
     AddrInfo
     AddrInfoFlag
     defaultHints
 
     -- Address -> name lookup
     getNameInfo
     NameInfoFlag
 
 The SockAddr type acquires a new branch, SockAddr6.  (This could cause
 new "non-exhaustive matches" warnings when compiling pre-existing client
 code that pattern-matches on SockAddr values.  However, it will not
 cause runtime pattern failure errors in clients using the pre-existing
 IPv4 entry points, as they will never see IPv6 addresses.)
 
 This change moves a few type names from Network.BSD to Network.Socket:
 
     HostName
     ServiceName
 
 These names are still re-exported from Network.BSD, so pre-existing code
 should not be affected.
]
[Remove Makefile and package.conf.in (used in the old GHC build system)
Ian Lynagh <[hidden email]>**20070524145815]
[add includes: field
Simon Marlow <[hidden email]>**20070517095001]
[TAG GHC 6.6.1 release
Ian Lynagh <[hidden email]>**20070428195851]
Patch bundle hash:
d34d8f7388edf4c649153cf7dc873b9c76443545

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: darcs patch: s6_addr32 is undefined on darwin. Added an AC check a...

Ian Lynagh
On Sat, Jun 23, 2007 at 03:12:38PM -0700, Thomas Schilling wrote:
> Fri Jun 22 18:58:52 CEST 2007  Thomas Schilling <[hidden email]>
>   * s6_addr32 is undefined on darwin.  Added an AC check and a definition taken from the NetBSD sources.

This breaks the build on Debian amd64 Linux:

ifBuildable/ifBuildable network setup/Setup makefile -f GNUmakefile
Reading parameters from /home/ian/ghc/darcs/build2/libraries/network/network.bui
ldinfo
Preprocessing library network-2.0.1...
In file included from BSD.hsc:17:
include/HsNet.h:80:1: warning: "s6_addr32" redefined
In file included from include/HsNet.h:77,
                 from BSD.hsc:17:
/usr/include/netinet/in.h:203:1: warning: this is the location of the previous d
efinition
In file included from Socket.hsc:22:
include/HsNet.h:80:1: warning: "s6_addr32" redefined
In file included from include/HsNet.h:77,
                 from Socket.hsc:22:
/usr/include/netinet/in.h:203:1: warning: this is the location of the previous d
efinition
Socket.hsc: In function ‘main’:
Socket.hsc:431: error: ‘struct in6_addr’ has no member named ‘__u6_addr’
Socket.hsc:432: error: ‘struct in6_addr’ has no member named ‘__u6_addr’
Socket.hsc:433: error: ‘struct in6_addr’ has no member named ‘__u6_addr’
Socket.hsc:434: error: ‘struct in6_addr’ has no member named ‘__u6_addr’
Socket.hsc:438: error: ‘struct in6_addr’ has no member named ‘__u6_addr’
Socket.hsc:439: error: ‘struct in6_addr’ has no member named ‘__u6_addr’
Socket.hsc:440: error: ‘struct in6_addr’ has no member named ‘__u6_addr’
Socket.hsc:441: error: ‘struct in6_addr’ has no member named ‘__u6_addr’
compiling dist/build/Network/Socket_hsc_make.c failed
command was: gcc -c -D__GLASGOW_HASKELL__=607 -I/home/ian/ghc/darcs/build2/inclu
des -Iinclude -DCALLCONV=ccall dist/build/Network/Socket_hsc_make.c -o dist/buil
d/Network/Socket_hsc_make.o
make: *** [network/GNUmakefile] Error 1


Thanks
Ian

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: darcs patch: s6_addr32 is undefined on darwin. Added an AC check a...

Thomas Schilling-2
Uh.  It might be that the autoconf check doesn't work, or is  
implementod the wrong way.  What is the output of configure?

Anyways, I think the safest approach would be to just check for  
darwin.  But I couldn't find out how to do that in a portable and  
reliable way.  Ideas?

/ Thomas

On 27 jun 2007, at 13.25, Ian Lynagh wrote:

> On Sat, Jun 23, 2007 at 03:12:38PM -0700, Thomas Schilling wrote:
>> Fri Jun 22 18:58:52 CEST 2007  Thomas Schilling <[hidden email]>
>>   * s6_addr32 is undefined on darwin.  Added an AC check and a  
>> definition taken from the NetBSD sources.
>
> This breaks the build on Debian amd64 Linux:
>
> ifBuildable/ifBuildable network setup/Setup makefile -f GNUmakefile
> Reading parameters from /home/ian/ghc/darcs/build2/libraries/
> network/network.bui
> ldinfo
> Preprocessing library network-2.0.1...
> In file included from BSD.hsc:17:
> include/HsNet.h:80:1: warning: "s6_addr32" redefined
> In file included from include/HsNet.h:77,
>                  from BSD.hsc:17:
> /usr/include/netinet/in.h:203:1: warning: this is the location of  
> the previous d
> efinition
> In file included from Socket.hsc:22:
> include/HsNet.h:80:1: warning: "s6_addr32" redefined
> In file included from include/HsNet.h:77,
>                  from Socket.hsc:22:
> /usr/include/netinet/in.h:203:1: warning: this is the location of  
> the previous d
> efinition
> Socket.hsc: In function ‘main’:
> Socket.hsc:431: error: ‘struct in6_addr’ has no member named  
> ‘__u6_addr’
> Socket.hsc:432: error: ‘struct in6_addr’ has no member named  
> ‘__u6_addr’
> Socket.hsc:433: error: ‘struct in6_addr’ has no member named  
> ‘__u6_addr’
> Socket.hsc:434: error: ‘struct in6_addr’ has no member named  
> ‘__u6_addr’
> Socket.hsc:438: error: ‘struct in6_addr’ has no member named  
> ‘__u6_addr’
> Socket.hsc:439: error: ‘struct in6_addr’ has no member named  
> ‘__u6_addr’
> Socket.hsc:440: error: ‘struct in6_addr’ has no member named  
> ‘__u6_addr’
> Socket.hsc:441: error: ‘struct in6_addr’ has no member named  
> ‘__u6_addr’
> compiling dist/build/Network/Socket_hsc_make.c failed
> command was: gcc -c -D__GLASGOW_HASKELL__=607 -I/home/ian/ghc/darcs/
> build2/inclu
> des -Iinclude -DCALLCONV=ccall dist/build/Network/Socket_hsc_make.c  
> -o dist/buil
> d/Network/Socket_hsc_make.o
> make: *** [network/GNUmakefile] Error 1
>
>
> Thanks
> Ian
>

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: darcs patch: s6_addr32 is undefined on darwin. Added an AC check a...

Ian Lynagh
On Wed, Jun 27, 2007 at 01:43:30PM +0200, Thomas Schilling wrote:
> Uh.  It might be that the autoconf check doesn't work, or is  
> implementod the wrong way.  What is the output of configure?

[...]
checking for in_addr_t in netinet/in.h... yes
checking for s6_addr32 in netinet6/in6.h... no
checking for getaddrinfo... yes
[...]

I have no netinet6 directory, and all my in6.h's are in linux
directories. It looks like my netinet/in.h does define s6_addr32, but
that doesn't mean that's portable of course.


Thanks
Ian

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: darcs patch: s6_addr32 is undefined on darwin. Added an AC check a...

Thomas Schilling-2

On 27 jun 2007, at 13.50, Ian Lynagh wrote:

> On Wed, Jun 27, 2007 at 01:43:30PM +0200, Thomas Schilling wrote:
>> Uh.  It might be that the autoconf check doesn't work, or is
>> implementod the wrong way.  What is the output of configure?
>
> [...]
> checking for in_addr_t in netinet/in.h... yes
> checking for s6_addr32 in netinet6/in6.h... no
> checking for getaddrinfo... yes
> [...]
>
> I have no netinet6 directory, and all my in6.h's are in linux
> directories. It looks like my netinet/in.h does define s6_addr32, but
> that doesn't mean that's portable of course.

Ok, so there's the quick'n'dirty and the clean[tm] fix.

- quick'n'dirty: Also grep for s6_addr32 in netinet/in.h .
   A possibly cleaner way is to use:

    AC_CHECK_DECL(s6_addr32)

   I'm a complete autoconf newbie, so this it what seems most  
appropriate, according to the list at

   http://www.gnu.org/software/autoconf/manual/autoconf-2.57/ 
html_chapter/autoconf_3.html#SEC9

- clean: remove the use of s6_addr32 in the sources and use the  
portable s6_addr, as discussed earlier on this list.

/ Thomas
_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: darcs patch: s6_addr32 is undefined on darwin. Added an AC check a...

Bryan O'Sullivan
In reply to this post by Ian Lynagh
Ian Lynagh wrote:

> This breaks the build on Debian amd64 Linux:

Here's a patch that should be more portable.  It gets rid of all mention
of s6_addr32, fixes a broken autoconf test, and adds some more AI_*
flags that are required for correct functioning on some platforms (e.g.
recent Linux/glibc).

Please give it a try, and let me know how it works for you.

        <b


New patches:

[Make IPv6 address handling more portable and robust.
Bryan O'Sullivan <[hidden email]>**20070627182816
 
 1.  No longer rely on the in6_addr structure's s6_addr32 field, which
     is not available on many platforms.  Use s6_addr instead.
 
 2.  Add a number of AI_* flags that are required by RFC 3493.  Not all
     of these flags are implemented on all systems, but on systems
     where they *are* implemented, we get runtime exceptions if we
     don't make them available.
 
 3.  To let users check whether a particular AI_* flag is implemented,
     we introduce the addrInfoFlagImplemented function.
 
 4.  Fix the autoconf macro used to check for AI_* flag availability.
     The previous check wasn't portable, and caused flags to appear not
     to be present when they really were.
] {
hunk ./Network/Socket.hsc 75
+    addrInfoFlagImplemented,-- :: AddrInfoFlag -> Bool
hunk ./Network/Socket.hsc 427
+-- The peek32 and poke32 functions work around the fact that the RFCs
+-- don't require 32-bit-wide address fields to be present.  We can
+-- only portably rely on an 8-bit field, s6_addr.
+
+s6_addr_offset = (#offset struct in6_addr, s6_addr)
+
+peek32 :: Ptr a -> Int -> IO Word32
+
+peek32 p i = do
+    let i' = i * 4
+        peekByte n = peekByteOff p (s6_addr_offset + i' + n) :: IO Word8
+        a `sl` i = fromIntegral a `shiftL` i
+    a0 <- peekByte 0
+    a1 <- peekByte 1
+    a2 <- peekByte 2
+    a3 <- peekByte 3
+    return ((a0 `sl` 24) .|. (a1 `sl` 16) .|. (a2 `sl` 8) .|. (a3 `sl` 0))
+
+poke32 :: Ptr a -> Int -> Word32 -> IO ()
+
+poke32 p i a = do
+    let i' = i * 4
+        pokeByte n = pokeByteOff p (s6_addr_offset + i' + n)
+        a `sr` i = fromIntegral (a `shiftR` i) :: Word8
+    pokeByte 0 (a `sr` 24)
+    pokeByte 1 (a `sr` 16)
+    pokeByte 2 (a `sr`  8)
+    pokeByte 3 (a `sr`  0)
+
hunk ./Network/Socket.hsc 461
-        a <- (#peek struct in6_addr, s6_addr32[0]) p
-        b <- (#peek struct in6_addr, s6_addr32[1]) p
-        c <- (#peek struct in6_addr, s6_addr32[2]) p
-        d <- (#peek struct in6_addr, s6_addr32[3]) p
+        a <- peek32 p 0
+        b <- peek32 p 1
+        c <- peek32 p 2
+        d <- peek32 p 3
hunk ./Network/Socket.hsc 468
-        (#poke struct in6_addr, s6_addr32[0]) p a
-        (#poke struct in6_addr, s6_addr32[1]) p b
-        (#poke struct in6_addr, s6_addr32[2]) p c
-        (#poke struct in6_addr, s6_addr32[3]) p d
+        poke32 p 0 a
+        poke32 p 1 b
+        poke32 p 2 c
+        poke32 p 3 d
hunk ./Network/Socket.hsc 2110
+    | AI_ALL
hunk ./Network/Socket.hsc 2113
+    | AI_NUMERICSERV
hunk ./Network/Socket.hsc 2115
+    | AI_V4MAPPED
hunk ./Network/Socket.hsc 2124
-#if defined(HAVE_AI_ADDRCONFIG)
+#if defined(HAVE_DECL_AI_ADDRCONFIG)
hunk ./Network/Socket.hsc 2129
+#if defined(HAVE_DECL_AI_ALL)
+     (AI_ALL, #const AI_ALL),
+#else
+     (AI_ALL, 0),
+#endif
hunk ./Network/Socket.hsc 2136
-     (AI_PASSIVE, #const AI_PASSIVE)]
+#if defined(HAVE_DECL_AI_NUMERICSERV)
+     (AI_NUMERICSERV, #const AI_NUMERICSERV),
+#else
+     (AI_NUMERICSERV, 0),
+#endif
+     (AI_PASSIVE, #const AI_PASSIVE),
+#if defined(HAVE_DECL_AI_V4MAPPED)
+     (AI_V4MAPPED, #const AI_V4MAPPED)
+#else
+     (AI_V4MAPPED, 0)
+#endif
+    ]
+
+-- | Indicate whether the given 'AddrInfoFlag' will have any effect on
+-- this system.
+addrInfoFlagImplemented :: AddrInfoFlag -> Bool
+addrInfoFlagImplemented f = packBits aiFlagMapping [f] /= 0
hunk ./Network/Socket.hsc 2270
---      attempted.
+--     attempted.
+--
+-- /Note/: Although the following flags are required by RFC 3493, they
+-- may not have an effect on all platforms, because the underlying
+-- network stack may not support them.  To see whether a flag from the
+-- list below will have any effect, call 'addrInfoFlagImplemented'.
+--
+--   [@AI_NUMERICSERV@] The 'ServiceName' argument /must/ be a port
+--     number in string form, and service name lookups will not be
+--     attempted.
+--
+--   [@AI_ADDRCONFIG@] The list of returned 'AddrInfo' values will
+--     only contain IPv4 addresses if the local system has at least
+--     one IPv4 interface configured, and likewise for IPv6.
hunk ./Network/Socket.hsc 2285
---   [@AI_ADDRCONFIG@] The list of returned 'AddrInfo' values will only
---     contain IPv4 addresses if the local system has at least one
---     IPv4 interface configured, and likewise for IPv6.
+--   [@AI_V4MAPPED@] If an IPv6 lookup is performed, and no IPv6
+--     addresses are found, IPv6-mapped IPv4 addresses will be
+--     returned.
hunk ./Network/Socket.hsc 2289
+--   [@AI_ALL@] If 'AI_ALL' is specified, return all matching IPv6 and
+--     IPv4 addresses.  Otherwise, this flag has no effect.
+--    
hunk ./configure.ac 47
-dnl --------------------------------------------------
-dnl * test for AI_ADDRCONFIG (Not all IPv6 implementations have it)
-dnl --------------------------------------------------
-AC_MSG_CHECKING(for AI_ADDRCONFIG in netdb.h)
-AC_EGREP_HEADER(AI_ADDRCONFIG, netdb.h,
- [ AC_DEFINE([HAVE_AI_ADDRCONFIG], [1], [Define to 1 if AI_ADDRCONFIG is available.]) AC_MSG_RESULT(yes) ],
- AC_MSG_RESULT(no))
+dnl -------------------------------------------------------
+dnl * test for AI_* flags that not all implementations have
+dnl -------------------------------------------------------
+AC_CHECK_DECLS([AI_ADDRCONFIG, AI_ALL, AI_NUMERICSERV, AI_V4MAPPED], , ,
+ [#include <netdb.h>])
}

Context:

[Fix further build problems when IPv6 isn't available
Simon Marlow <[hidden email]>**20070604105407]
[Try a hopefully more portable test for RFC 3493 API compatibility.
Bryan O'Sullivan <[hidden email]>**20070602050225]
[Fix build failure if IPv6 is not available.
Bryan O'Sullivan <[hidden email]>**20070601160943]
[Fixed support for platforms with IPv6 but no AI_ADDRCONFIG
Michael D. Adams <[hidden email]>**20070604153642]
[--configure-option and --ghc-option are now provided by Cabal
Ross Paterson <[hidden email]>**20070604115612]
[Invoke the preprocessor portably.
Bryan O'Sullivan <[hidden email]>**20070408171912]
[Add IPv6 support to Network.
Bryan O'Sullivan <[hidden email]>**20070404223751
 
 The public API remains unchanged; it can now transparently handle IPv6
 addresses and sockets.
]
[Add IPv6 support to Network.Socket.
Bryan O'Sullivan <[hidden email]>**20070404222036
 
 The only public API changes are to Network.Socket, which has the following
 exported names added (no existing names have been removed):
 
     -- IPv6 address components
     HostAddress6
     FlowInfo
     ScopeID
 
     -- Name -> address lookup
     getAddrInfo
     AddrInfo
     AddrInfoFlag
     defaultHints
 
     -- Address -> name lookup
     getNameInfo
     NameInfoFlag
 
 The SockAddr type acquires a new branch, SockAddr6.  (This could cause
 new "non-exhaustive matches" warnings when compiling pre-existing client
 code that pattern-matches on SockAddr values.  However, it will not
 cause runtime pattern failure errors in clients using the pre-existing
 IPv4 entry points, as they will never see IPv6 addresses.)
 
 This change moves a few type names from Network.BSD to Network.Socket:
 
     HostName
     ServiceName
 
 These names are still re-exported from Network.BSD, so pre-existing code
 should not be affected.
]
[Remove Makefile and package.conf.in (used in the old GHC build system)
Ian Lynagh <[hidden email]>**20070524145815]
[add includes: field
Simon Marlow <[hidden email]>**20070517095001]
[TAG GHC 6.6.1 release
Ian Lynagh <[hidden email]>**20070428195851]
Patch bundle hash:
d4bd5adde3966023956746ac9be0ba87428f86e9

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Updated cross-platform IPv6 support

Bryan O'Sullivan
Bryan O'Sullivan wrote:

> Here's a patch that should be more portable.  It gets rid of all mention
> of s6_addr32, fixes a broken autoconf test, and adds some more AI_*
> flags that are required for correct functioning on some platforms (e.g.
> recent Linux/glibc).

I've had a chance to test it out on OS X.  It required a little more
tweaking, but now works nicely.  The same code also works on Fedora 7
and Debian Etch.

You can get the results here:

darcs get --partial http://darcs.serpentine.com/network

        <b
_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Updated cross-platform IPv6 support

Ian Lynagh
On Wed, Jun 27, 2007 at 02:44:00PM -0700, Bryan O'Sullivan wrote:
>
> darcs get --partial http://darcs.serpentine.com/network

Patches pushed; thanks!


Ian

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Updated cross-platform IPv6 support

Bryan O'Sullivan
Ian Lynagh wrote:

>> darcs get --partial http://darcs.serpentine.com/network
>
> Patches pushed;

Thank you!

        <b

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries