diff --git a/ext/sysvsem/config.m4 b/ext/sysvsem/config.m4 index 5cbc06ce9c33c..a6533ce7c2605 100644 --- a/ext/sysvsem/config.m4 +++ b/ext/sysvsem/config.m4 @@ -4,22 +4,9 @@ PHP_ARG_ENABLE([sysvsem], [Enable System V semaphore support])]) if test "$PHP_SYSVSEM" != "no"; then - PHP_NEW_EXTENSION(sysvsem, sysvsem.c, $ext_shared) - AC_DEFINE(HAVE_SYSVSEM, 1, [ ]) - AC_CACHE_CHECK(for union semun,php_cv_semun, - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#include -#include -#include - ]], [[union semun x;]])],[ - php_cv_semun=yes - ],[ - php_cv_semun=no - ]) - ) - if test "$php_cv_semun" = "yes"; then - AC_DEFINE(HAVE_SEMUN, 1, [ ]) - else - AC_DEFINE(HAVE_SEMUN, 0, [ ]) - fi + PHP_NEW_EXTENSION(sysvsem, sysvsem.c, $ext_shared) + AC_DEFINE(HAVE_SYSVSEM, 1, [ ]) + AC_CHECK_TYPES([union semun],,,[#include + #include + #include ]) fi diff --git a/ext/sysvsem/sysvsem.c b/ext/sysvsem/sysvsem.c index d9369dfa9f6f1..107db3e31efb8 100644 --- a/ext/sysvsem/sysvsem.c +++ b/ext/sysvsem/sysvsem.c @@ -32,18 +32,13 @@ #include "php_sysvsem.h" #include "ext/standard/info.h" -#if !HAVE_SEMUN - +#ifndef HAVE_UNION_SEMUN union semun { int val; /* value for SETVAL */ struct semid_ds *buf; /* buffer for IPC_STAT, IPC_SET */ unsigned short int *array; /* array for GETALL, SETALL */ struct seminfo *__buf; /* buffer for IPC_INFO */ }; - -#undef HAVE_SEMUN -#define HAVE_SEMUN 1 - #endif /* {{{ sysvsem_module_entry */ @@ -173,12 +168,6 @@ PHP_MINFO_FUNCTION(sysvsem) } /* }}} */ -#define SETVAL_WANTS_PTR - -#if defined(_AIX) -#undef SETVAL_WANTS_PTR -#endif - /* {{{ Return an id for the semaphore with the given key, and allow max_acquire (default 1) processes to acquire it simultaneously */ PHP_FUNCTION(sem_get) { @@ -247,24 +236,11 @@ PHP_FUNCTION(sem_get) /* If we are the only user, then take this opportunity to set the max. */ if (count == 1) { -#if HAVE_SEMUN - /* This is correct for Linux which has union semun. */ union semun semarg; semarg.val = max_acquire; if (semctl(semid, SYSVSEM_SEM, SETVAL, semarg) == -1) { php_error_docref(NULL, E_WARNING, "Failed for key 0x" ZEND_XLONG_FMT ": %s", key, strerror(errno)); } -#elif defined(SETVAL_WANTS_PTR) - /* This is correct for Solaris 2.6 which does not have union semun. */ - if (semctl(semid, SYSVSEM_SEM, SETVAL, &max_acquire) == -1) { - php_error_docref(NULL, E_WARNING, "Failed for key 0x%lx: %s", key, strerror(errno)); - } -#else - /* This works for i.e. AIX */ - if (semctl(semid, SYSVSEM_SEM, SETVAL, max_acquire) == -1) { - php_error_docref(NULL, E_WARNING, "Failed for key 0x%lx: %s", key, strerror(errno)); - } -#endif } /* Set semaphore 1 back to zero. */ @@ -357,10 +333,8 @@ PHP_FUNCTION(sem_remove) { zval *arg_id; sysvsem_sem *sem_ptr; -#if HAVE_SEMUN union semun un; struct semid_ds buf; -#endif if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &arg_id, sysvsem_ce) == FAILURE) { RETURN_THROWS(); @@ -368,21 +342,13 @@ PHP_FUNCTION(sem_remove) sem_ptr = Z_SYSVSEM_P(arg_id); -#if HAVE_SEMUN un.buf = &buf; if (semctl(sem_ptr->semid, 0, IPC_STAT, un) < 0) { -#else - if (semctl(sem_ptr->semid, 0, IPC_STAT, NULL) < 0) { -#endif php_error_docref(NULL, E_WARNING, "SysV semaphore for key 0x%x does not (any longer) exist", sem_ptr->key); RETURN_FALSE; } -#if HAVE_SEMUN if (semctl(sem_ptr->semid, 0, IPC_RMID, un) < 0) { -#else - if (semctl(sem_ptr->semid, 0, IPC_RMID, NULL) < 0) { -#endif php_error_docref(NULL, E_WARNING, "Failed for SysV semaphore for key 0x%x: %s", sem_ptr->key, strerror(errno)); RETURN_FALSE; }