Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Android missing pthread_setcancelstate and pthread_cancel #4986

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -722,8 +722,14 @@ if (HDF5_ENABLE_HDFS)
if (HDFS_FOUND)
set (H5_HAVE_LIBHDFS 1)
set (H5_HAVE_HDFS_H 1)
if (NOT MSVC)
list (APPEND LINK_LIBS -pthread)
if (NOT MSVC AND NOT ANDROID)
list (APPEND LINK_LIBS -pthread)
elseif(ANDROID)
message(STATUS "Enabled HDFS adding cancelthread support library for Android")
find_library(cancelthread_LIBRARY NAMES cancelthread libcancelthread)
find_path(cancelthread_INCLUDE_DIR NAMES "bthread.h")
set (HDF5_SRC_INCLUDE_DIRS ${HDF5_SRC_INCLUDE_DIRS} ${cancelthread_INCLUDE_DIR})
link_libraries(${cancelthread_LIBRARY})
endif ()
else ()
set (HDF5_ENABLE_HDFS OFF CACHE BOOL "Enable HDFS" FORCE)
Expand Down Expand Up @@ -849,6 +855,14 @@ if (HDF5_ENABLE_SUBFILING_VFD)
message (FATAL_ERROR "Subfiling requires thread operations support")
endif ()

if(ANDROID)
message(STATUS "Enabled Parallel HDF5 Subfiling VFD adding cancelthread support library for Android")
find_library(cancelthread_LIBRARY NAMES cancelthread libcancelthread)
find_path(cancelthread_INCLUDE_DIR NAMES "bthread.h")
set (HDF5_SRC_INCLUDE_DIRS ${HDF5_SRC_INCLUDE_DIRS} ${cancelthread_INCLUDE_DIR})
link_libraries(${cancelthread_LIBRARY})
endif()

set (H5_HAVE_SUBFILING_VFD 1)
# IOC VFD is currently only built when subfiling is enabled
set (H5_HAVE_IOC_VFD 1)
Expand Down Expand Up @@ -982,6 +996,14 @@ if (HDF5_ENABLE_THREADSAFE)
message (FATAL_ERROR " **** thread-safety option requires a threading package and none was found **** ")
endif ()

if(ANDROID)
message(STATUS "Enabled thread-safety adding cancelthread support library for Android")
find_library(cancelthread_LIBRARY NAMES cancelthread libcancelthread)
find_path(cancelthread_INCLUDE_DIR NAMES "bthread.h")
set (HDF5_SRC_INCLUDE_DIRS ${HDF5_SRC_INCLUDE_DIRS} ${cancelthread_INCLUDE_DIR})
link_libraries(${cancelthread_LIBRARY})
endif()

set (H5_HAVE_THREADSAFE 1)
endif ()

Expand Down
5 changes: 5 additions & 0 deletions src/H5private.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
/* Pthreads */
#if defined(H5_HAVE_PTHREAD_H)
#include <pthread.h>

#if defined(__ANDROID__)
#include <bthread.h>
#endif

#endif
#endif

Expand Down