| libmariadb: Fix async api by linking to libucontext |
| The asynchronous API of libmariadb uses cooperative multi threading |
| by using the system calls |
| * makecontext |
| * swapcontext |
| * getcontext |
| * setcontext |
| of the ucontext.h C-API. |
| |
| Thus additionally link libmariadb to libucontext which is a library |
| providing these system calls on platforms not supporting them out of |
| the box - like musl based platforms. |
| --- a/libmariadb/CMakeLists.txt |
| +++ b/libmariadb/CMakeLists.txt |
| @@ -458,7 +458,7 @@ ELSE() |
| SET_TARGET_PROPERTIES(libmariadb PROPERTIES LINKER_LANGUAGE C) |
| ENDIF() |
| |
| -TARGET_LINK_LIBRARIES(libmariadb LINK_PRIVATE ${SYSTEM_LIBS} ${CRYPTO_LIBS}) |
| +TARGET_LINK_LIBRARIES(libmariadb LINK_PRIVATE ${SYSTEM_LIBS} ${CRYPTO_LIBS} ${LIBUCONTEXT_POSIX} ${LIBUCONTEXT}) |
| |
| SIGN_TARGET(libmariadb) |
| |
| --- a/CMakeLists.txt |
| +++ b/CMakeLists.txt |
| @@ -251,6 +251,14 @@ IF(UNIX) |
| SEARCH_LIBRARY(LIBPTHREAD pthread_getspecific "pthread;pthreads") |
| SEARCH_LIBRARY(LIBNSL gethostbyname_r "nsl_r;nsl") |
| SEARCH_LIBRARY(LIBSOCKET setsockopt socket) |
| + SEARCH_LIBRARY(LIBUCONTEXT libucontext_swapcontext libucontext.a) |
| + SEARCH_LIBRARY(LIBUCONTEXT_POSIX swapcontext libucontext_posix.a) |
| + IF (NOT HAVE_LIBUCONTEXT_POSIX OR NOT HAVE_LIBUCONTEXT) |
| + UNSET(HAVE_LIBUCONTEXT) |
| + UNSET(LIBUCONTEXT) |
| + UNSET(HAVE_LIBUCONTEXT_POSIX) |
| + UNSET(LIBUCONTEXT_POSIX) |
| + ENDIF() |
| FIND_PACKAGE(Threads) |
| SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${LIBNSL} ${LIBBIND} ${LIBICONV} ${ZLIB_LIBRARY} |
| ${LIBSOCKET} ${CMAKE_DL_LIBS} ${LIBM} ${LIBPTHREAD}) |
| --- a/include/ma_config.h.in |
| +++ b/include/ma_config.h.in |
| @@ -28,6 +28,7 @@ |
| #cmakedefine HAVE_SYS_UN_H 1 |
| #cmakedefine HAVE_UNISTD_H 1 |
| #cmakedefine HAVE_UCONTEXT_H 1 |
| +#cmakedefine HAVE_LIBUCONTEXT_POSIX 1 |
| |
| /* |
| * function definitions - processed in LibmysqlFunctions.txt |
| --- a/include/ma_context.h |
| +++ b/include/ma_context.h |
| @@ -32,7 +32,7 @@ |
| #define MY_CONTEXT_USE_X86_64_GCC_ASM |
| #elif defined(__GNUC__) && __GNUC__ >= 3 && defined(__i386__) |
| #define MY_CONTEXT_USE_I386_GCC_ASM |
| -#elif defined(HAVE_UCONTEXT_H) |
| +#elif defined(HAVE_UCONTEXT_H) || defined(HAVE_LIBUCONTEXT_POSIX) |
| #define MY_CONTEXT_USE_UCONTEXT |
| #else |
| #define MY_CONTEXT_DISABLE |