[perl #80674] Fix compilation with very old versions of glibc
authorDavid Leadbeater <dgl@dgl.cx>
Fri, 17 Dec 2010 04:14:40 +0000 (20:14 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 17 Dec 2010 04:41:39 +0000 (20:41 -0800)
__priority_which_t does not exist on glibc 2.1.

sin6_scope is not present in the set of kernel headers my copy of glibc 2.1 is
using. (The presence of sin6_scope in sockaddr_in6 should maybe be a Configure
test.)

blead now compiles on a positively ancient box -- although the Socket tests
fail.

ext/Socket/Socket.xs
pp_sys.c

index dcf6715..c1225ff 100644 (file)
@@ -477,7 +477,9 @@ pack_sockaddr_in6(port, sin6_addr, scope_id=0, flowinfo=0)
        sin6.sin6_port = htons(port);
        sin6.sin6_flowinfo = htonl(flowinfo);
        Copy(addrbytes, &sin6.sin6_addr, sizeof(sin6.sin6_addr), char);
+#if !defined(__GLIBC__) || (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)
        sin6.sin6_scope_id = scope_id;
+#endif
        ST(0) = newSVpvn_flags((char *)&sin6, sizeof(sin6), SVs_TEMP);
 #else
        ST(0) = (SV*)not_here("pack_sockaddr_in6");
@@ -505,7 +507,11 @@ unpack_sockaddr_in6(sin6_sv)
        EXTEND(SP, 4);
        mPUSHi(ntohs(sin6.sin6_port));
        mPUSHp((char *)&sin6.sin6_addr, sizeof(sin6.sin6_addr));
+#if !defined(__GLIBC__) || (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)
        mPUSHi(sin6.sin6_scope_id);
+#else
+       mPUSHi(0);
+#endif
        mPUSHi(ntohl(sin6.sin6_flowinfo));
 #else
        ST(0) = (SV*)not_here("pack_sockaddr_in6");
index 89e131c..d54b44e 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -4473,7 +4473,7 @@ PP(pp_setpgrp)
 #endif
 }
 
-#ifdef __GLIBC__
+#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3) || (__GLIBC__ > 2))
 #  define PRIORITY_WHICH_T(which) (__priority_which_t)which
 #else
 #  define PRIORITY_WHICH_T(which) which