Commit cbacb180 authored by Vitali Lovich's avatar Vitali Lovich

Fix build compatability with Android

Add missing include when building on Linux

Discovered trying to build on Android using CMake.  UIO_MAXIOV is only
exported by the linux/uio.h header which was never included.  Not sure
how normal Linux builds work.

Add missing reinterpret cast from const void* to const byte*.

Remove -pthread compile flag when building under Android.  ANDROID cmake
variable exported by android-cmake project.
parent 8a2dcdd0
...@@ -63,7 +63,11 @@ else() ...@@ -63,7 +63,11 @@ else()
# #
# We have to use -std=gnu++0x isntead of -std=c++11 because otherwise we lose # We have to use -std=gnu++0x isntead of -std=c++11 because otherwise we lose
# GNU extensions that we need. # GNU extensions that we need.
add_compile_options(-std=gnu++0x -Wall -Wextra -Wno-strict-aliasing -Wno-sign-compare -Wno-unused-parameter -pthread) add_compile_options(-std=gnu++0x -Wall -Wextra -Wno-strict-aliasing -Wno-sign-compare -Wno-unused-parameter)
if (NOT ANDROID)
add_compile_options(-pthread)
endif()
endif() endif()
# Source ======================================================================= # Source =======================================================================
......
...@@ -58,7 +58,7 @@ set(kj-std_headers ...@@ -58,7 +58,7 @@ set(kj-std_headers
) )
add_library(kj ${kj_sources}) add_library(kj ${kj_sources})
add_library(CapnProto::kj ALIAS kj) add_library(CapnProto::kj ALIAS kj)
if(UNIX) if(UNIX AND NOT ANDROID)
target_link_libraries(kj PUBLIC pthread) target_link_libraries(kj PUBLIC pthread)
endif() endif()
#make sure the lite flag propagates to all users (internal + external) of this library #make sure the lite flag propagates to all users (internal + external) of this library
......
...@@ -1229,7 +1229,7 @@ public: ...@@ -1229,7 +1229,7 @@ public:
// OK, we know the cmsghdr is valid, at least. // OK, we know the cmsghdr is valid, at least.
// Find the start of the message payload. // Find the start of the message payload.
const byte* begin = CMSG_DATA(cmsg); const byte* begin = (const byte *)CMSG_DATA(cmsg);
// Cap the message length to the available space. // Cap the message length to the available space.
const byte* end = pos + kj::min(available, cmsg->cmsg_len); const byte* end = pos + kj::min(available, cmsg->cmsg_len);
......
...@@ -44,6 +44,10 @@ ...@@ -44,6 +44,10 @@
#include <sys/types.h> #include <sys/types.h>
#endif #endif
#if !_WIN32
#include <sys/uio.h>
#endif
namespace kj { namespace kj {
namespace miniposix { namespace miniposix {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment