Skip to content

Commit b71e456

Browse files
committed
IPPROTO_* are not defined as macro in bionic.
they are values of an enum. used an already existent extconf workaround to define macro to enum values.
1 parent 23866ac commit b71e456

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

ext/socket/extconf.rb

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -457,13 +457,19 @@ def %(s) s || self end
457457

458458
have_header("sys/un.h")
459459
have_header("sys/uio.h")
460-
have_type("struct in_pktinfo", headers) {|src|
461-
src.sub(%r'^/\*top\*/', '\1'"\n#if defined(IPPROTO_IP) && defined(IP_PKTINFO)") <<
462-
"#else\n" << "#error\n" << ">>>>>> no in_pktinfo <<<<<<\n" << "#endif\n"
460+
461+
462+
# workaround for recent Windows SDK
463+
$defs << "-DIPPROTO_IPV6=IPPROTO_IPV6" if $defs.include?("-DHAVE_CONST_IPPROTO_IPV6") && !have_macro("IPPROTO_IPV6")
464+
$defs << "-DIPPROTO_IP=IPPROTO_IP" if $defs.include?("-DHAVE_CONST_IPPROTO_IP") && !have_macro("IPPROTO_IP")
465+
466+
have_type("struct in_pktinfo", headers, $defs.join(" ")) {|src|
467+
src.sub(%r'^/\*top\*/', '\1'"\n#if defined(IPPROTO_IP) && defined(IP_PKTINFO)") <<
468+
"#else\n" << "#error\n" << ">>>>>> no in_pktinfo <<<<<<\n" << "#endif\n"
463469
} and have_struct_member("struct in_pktinfo", "ipi_spec_dst", headers)
464-
have_type("struct in6_pktinfo", headers) {|src|
465-
src.sub(%r'^/\*top\*/', '\1'"\n#if defined(IPPROTO_IPV6) && defined(IPV6_PKTINFO)") <<
466-
"#else\n" << "#error\n" << ">>>>>> no in6_pktinfo <<<<<<\n" << "#endif\n"
470+
have_type("struct in6_pktinfo", headers, $defs.join(" ")) {|src|
471+
src.sub(%r'^/\*top\*/', '\1'"\n#if defined(IPPROTO_IPV6) && defined(IPV6_PKTINFO)") <<
472+
"#else\n" << "#error\n" << ">>>>>> no in6_pktinfo <<<<<<\n" << "#endif\n"
467473
}
468474

469475
have_type("struct sockcred", headers)
@@ -480,9 +486,6 @@ def %(s) s || self end
480486
have_type("struct ip_mreqn", headers) # Linux 2.4
481487
have_type("struct ipv6_mreq", headers) # RFC 3493
482488

483-
# workaround for recent Windows SDK
484-
$defs << "-DIPPROTO_IPV6=IPPROTO_IPV6" if $defs.include?("-DHAVE_CONST_IPPROTO_IPV6") && !have_macro("IPPROTO_IPV6")
485-
486489
$distcleanfiles << "constants.h" << "constdefs.*"
487490

488491
if have_func(test_func)

0 commit comments

Comments
 (0)