Hi,

attached is a patch that checks wether sem_ctl accepts a pointer as an
argument. It doesn't do that, on BSD/OS (maybe others?) systems.
Patch works on BSD/OS 4.x, and verified on BSD/OS 4.2, with sample code
on the manual notes.

Met vriendelijke groeten / With kind regards,

IDG.nl
Melvyn Sopacua
WebMaster
Index: ext/sysvsem/config.m4
===================================================================
RCS file: /repository/php4/ext/sysvsem/config.m4,v
retrieving revision 1.5
diff -u -r1.5 config.m4
--- ext/sysvsem/config.m4       12 Mar 2002 16:36:40 -0000      1.5
+++ ext/sysvsem/config.m4       8 Jul 2002 17:51:03 -0000
@@ -23,6 +23,28 @@
  )
  if test "$php_cv_semun" = "yes"; then
    AC_DEFINE(HAVE_SEMUN, 1, [ ])
+   AC_CACHE_CHECK(whether semctl accepts a pointer as 4th 
+argument,php_cv_semctl_pointer,
+     AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/sem.h>
+     ],
+     [int semid;
+int semnum;
+union semun x;
+
+semctl(semid, semnum, IPC_STAT, &x);
+     ],[
+       php_cv_semctl_pointer=yes
+     ],[
+       php_cv_semctl_pointer=no
+     ])
+   )
+   if test "$php_cv_semctl_pointer" = "yes"; then
+     AC_DEFINE(HAVE_SEMCTL_POINTER, 1, [ ])
+   else
+     AC_DEFINE(HAVE_SEMCTL_POINTER, 0, [ ])
+   fi
  else
    AC_DEFINE(HAVE_SEMUN, 0, [ ])
  fi
Index: ext/sysvsem/sysvsem.c
===================================================================
RCS file: /repository/php4/ext/sysvsem/sysvsem.c,v
retrieving revision 1.40
diff -u -r1.40 sysvsem.c
--- ext/sysvsem/sysvsem.c       17 May 2002 12:33:49 -0000      1.40
+++ ext/sysvsem/sysvsem.c       8 Jul 2002 17:51:03 -0000
@@ -379,8 +379,12 @@
 
 #if HAVE_SEMUN
        un.buf = &buf;
+#if HAVE_SEMCTL_POINTER
        if(semctl(sem_ptr->semid, 0, IPC_STAT, &un) < 0) {
 #else
+       if(semctl(sem_ptr->semid, 0, IPC_STAT, un) < 0 ) {
+#endif
+#else
        if(semctl(sem_ptr->semid, 0, IPC_STAT, NULL) < 0) {
 #endif
                php_error(E_WARNING, "%d is not a existing SysV Semaphore Id", id);
@@ -388,7 +392,11 @@
        }
 
 #if HAVE_SEMUN
+#if HAVE_SEMCTL_POINTER
        if(semctl(sem_ptr->semid, 0, IPC_RMID, &un) < 0) {
+#else
+       if(semctl(sem_ptr->semid, 0, IPC_RMID, un) < 0 ) {
+#endif
 #else
        if(semctl(sem_ptr->semid, 0, IPC_RMID, NULL) < 0) {
 #endif
-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to