Skip to content
Open
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
72 changes: 43 additions & 29 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,51 @@ if test "$PHP_SYNC" != "no"; then
SAVED_LIBS="$LIBS"
LIBS="$LIBS -pthread -lrt"

AC_TRY_LINK([
#include <fcntl.h>
#include <sys/mman.h>
], [
int fp = shm_open("", O_RDWR | O_CREAT | O_EXCL, 0666);
], [
have_shm_open=yes
AC_MSG_RESULT([yes])

PHP_ADD_LIBRARY(rt,,SYNC_SHARED_LIBADD)
PHP_SUBST(SYNC_SHARED_LIBADD)
], [
AC_MSG_RESULT([no (attempting fallback)])

dnl # Fallback attempt to link without -lrt.
AC_MSG_CHECKING([for shm_open in -pthread])

LIBS="$SAVED_LIBS -pthread"

AC_TRY_LINK([
#include <fcntl.h>
#include <sys/mman.h>
], [
int fp = shm_open("", O_RDWR | O_CREAT | O_EXCL, 0666);
], [
AC_LINK_IFELSE([
AC_LANG_PROGRAM(
[[
#include <fcntl.h>
#include <sys/mman.h>
]],
[[
int fp = shm_open("", O_RDWR | O_CREAT | O_EXCL, 0666);
]]
)],
[
have_shm_open=yes
AC_MSG_RESULT([yes])
], [
AC_MSG_ERROR([shm_open() is not available on this platform])
])
])

PHP_ADD_LIBRARY(rt,,SYNC_SHARED_LIBADD)
PHP_SUBST(SYNC_SHARED_LIBADD)
],
[
AC_MSG_RESULT([no (attempting fallback)])

dnl # Fallback attempt to link without -lrt.
AC_MSG_CHECKING([for shm_open in -pthread])

LIBS="$SAVED_LIBS -pthread"

AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[
#include <fcntl.h>
#include <sys/mman.h>
]],
[[
int fp = shm_open("", O_RDWR | O_CREAT | O_EXCL, 0666);
]]
)],
[
have_shm_open=yes
AC_MSG_RESULT([yes])
],
[
AC_MSG_ERROR([shm_open() is not available on this platform])
]
)
]
)

dnl # Finish defining the basic extension support.
AC_DEFINE(HAVE_SYNC, 1, [Whether you have synchronization object support])
Expand Down