File capnproto-0.5.3-big-endian-async-unix.patch of Package capnproto

Description:  Fix UnixEventPort value on 32-bit big endian arch
 toRegularSiginfo attempts to convert signalfd_siginfo.ssi_ptr (a 64-bit
 integer across all architectures) to a pointer. On 32-bit big endian
 architectures, sival_int/sival_ptr will be stored in the high 32-bits
 of the ssi_ptr value.

 Prior to this change, the value was "lost" as we cast away the high
 bits of ssi_ptr in the conversion to a 32-bit pointer.

 This fixes AsyncUnixTest::SignalWith{,Pointer}Value on affected archs.

Author: Tom Lee <>
Last-Update: 2015-11-07
This patch header follows DEP-3:
--- a/
+++ b/
@@ -52,6 +52,19 @@
+               [CXXFLAGS="$CXXFLAGS -D_KJ_BIGENDIAN=0"],
+               [AC_MSG_WARN([could not determine system endianness: assuming little endian])
+                CXXFLAGS="$CXXFLAGS -D_KJ_BIGENDIAN=0"])
+AC_MSG_CHECKING([architecture pointer size])
+AS_IF([test "x$ac_cv_sizeof_voidp" = "x8"],
+       AC_MSG_RESULT([64-bit])],
+       AC_MSG_RESULT([32-bit])])
 AS_CASE("${host_os}", *mingw*, [
     # We don't use pthreads on MinGW.
--- a/src/kj/async-unix.c++
+++ b/src/kj/async-unix.c++
@@ -458,7 +458,11 @@
         // we write the pointer, we'll end up with the right value for the int? Presumably the
         // two fields of signalfd_siginfo are actually extracted from one of these unions
         // originally, so actually contain redundant data? Better write some tests...
+#if _KJ_BIGENDIAN && !_KJ_64BIT
+        result.si_ptr = reinterpret_cast<void*>(static_cast<uintptr_t>(siginfo.ssi_ptr >> 32));
         result.si_ptr = reinterpret_cast<void*>(static_cast<uintptr_t>(siginfo.ssi_ptr));
       case SI_TIMER: