mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-07-23 05:19:42 +00:00
Fix for CONC-521
On macOS, the ucontext functions require _XOPEN_SOURCE to be defined before including ucontext.h. (Any value is fine, but it's supposed to be a POSIX-defined number, and 600 seems like the most common choice.) These functions are required for MYSQL_OPT_NONBLOCK to work on non-x86 platforms, e.g. Apple's M1 chip. This change sets _XOPEN_SOURCE to 600 on Apple platforms during CMake's feature detection and before including <ucontext.h> in ma_context.h. Thanks to Evan Miller for reporting this bug and providing the fix.
This commit is contained in:
@ -49,6 +49,9 @@ CHECK_INCLUDE_FILES (sys/un.h HAVE_SYS_UN_H)
|
||||
CHECK_INCLUDE_FILES (unistd.h HAVE_UNISTD_H)
|
||||
CHECK_INCLUDE_FILES (utime.h HAVE_UTIME_H)
|
||||
|
||||
IF(APPLE)
|
||||
SET(CMAKE_REQUIRED_DEFINITIONS -D_XOPEN_SOURCE=600)
|
||||
ENDIF()
|
||||
CHECK_INCLUDE_FILES (ucontext.h HAVE_FILE_UCONTEXT_H)
|
||||
IF(NOT HAVE_FILE_UCONTEXT_H)
|
||||
CHECK_INCLUDE_FILES (sys/ucontext.h HAVE_FILE_UCONTEXT_H)
|
||||
|
@ -52,6 +52,9 @@ struct my_context {
|
||||
|
||||
|
||||
#ifdef MY_CONTEXT_USE_UCONTEXT
|
||||
#if defined(__APPLE__) && !defined(_XOPEN_SOURCE)
|
||||
#define _XOPEN_SOURCE 600
|
||||
#endif
|
||||
#include <ucontext.h>
|
||||
|
||||
struct my_context {
|
||||
|
Reference in New Issue
Block a user