summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/socket/extconf.rb3
-rw-r--r--ext/socket/rubysocket.h10
2 files changed, 11 insertions, 2 deletions
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb
index 7c31030d72..a6bc9bb46c 100644
--- a/ext/socket/extconf.rb
+++ b/ext/socket/extconf.rb
@@ -117,8 +117,7 @@ if !have_macro("IPPROTO_IPV6", headers) && have_const("IPPROTO_IPV6", headers)
}
end
-if (have_func("sendmsg") | have_func("recvmsg")) && /64-darwin/ !~ RUBY_PLATFORM
- # CMSG_ macros are broken on 64bit darwin, because of use of __DARWIN_ALIGN.
+if have_func("sendmsg") | have_func("recvmsg")
have_struct_member('struct msghdr', 'msg_control', ['sys/types.h', 'sys/socket.h'])
have_struct_member('struct msghdr', 'msg_accrights', ['sys/types.h', 'sys/socket.h'])
end
diff --git a/ext/socket/rubysocket.h b/ext/socket/rubysocket.h
index 356e6f3b1a..60ac25fbbd 100644
--- a/ext/socket/rubysocket.h
+++ b/ext/socket/rubysocket.h
@@ -138,6 +138,16 @@ struct sockaddr_storage {
};
#endif
+#if defined __APPLE__ && defined __MACH__
+/*
+ * CMSG_ macros are broken on 64bit darwin, because __DARWIN_ALIGN
+ * aligns up to __darwin_size_t which is 64bit, but CMSG_DATA is
+ * 32bit-aligned.
+ */
+#undef __DARWIN_ALIGNBYTES
+#define __DARWIN_ALIGNBYTES (sizeof(unsigned int) - 1)
+#endif
+
#if defined(_AIX)
#ifndef CMSG_SPACE
# define CMSG_SPACE(len) (_CMSG_ALIGN(sizeof(struct cmsghdr)) + _CMSG_ALIGN(len))