]> granicus.if.org Git - php/commitdiff
Avoid possible clash with mysql, but still make it work for BSD's.
authorMelvyn Sopacua <msopacua@php.net>
Sun, 27 Oct 2002 11:56:06 +0000 (11:56 +0000)
committerMelvyn Sopacua <msopacua@php.net>
Sun, 27 Oct 2002 11:56:06 +0000 (11:56 +0000)
Struct verified to be compatible with Linux, FreeBSD, BSDi, AIX 4.3.3 and
Solaris 5.7.

ext/sysvmsg/config.m4
ext/sysvmsg/php_sysvmsg.h
ext/sysvmsg/sysvmsg.c

index 05235f998e8ad58ea2acc66b7038bba882e4602f..28f03e76d9484014285019bdcc40aaef5dc84dd8 100644 (file)
@@ -4,32 +4,6 @@ PHP_ARG_ENABLE(sysvmsg,whether to enable System V IPC support,
 [  --enable-sysvmsg        Enable sysvmsg support])
 
 if test "$PHP_SYSVMSG" != "no"; then
-  AC_MSG_CHECKING([whether sys/msg.h defines struct msgbuf or mymsg])
-  AC_TRY_COMPILE(
-   [#include <sys/types.h>
-    #include <sys/ipc.h>
-    #include <sys/msg.h>],
-   [size_t i;
-
-     i = sizeof(struct msgbuf);
-    return 1;],
-   [AC_MSG_RESULT(msgbuf)],
-   [AC_TRY_COMPILE(
-     [#include <sys/types.h>
-      #include <sys/ipc.h>
-      #include <sys/msg.h>
-     ],
-     [size_t i;
-
-     i = sizeof(struct mymsg);
-      return 1;
-     ],
-     [AC_DEFINE(msgbuf, mymsg, [msgbuf is called mymsg])
-      AC_MSG_RESULT(mymsg)
-     ],
-     [AC_MSG_ERROR([none. Cannot make sysvmsg module])
-     ])
-   ])
   AC_DEFINE(HAVE_SYSVMSG, 1, [ ])
   PHP_NEW_EXTENSION(sysvmsg, sysvmsg.c, $ext_shared)
 fi
index 3d78bc051a5d6af0c9e4f61a9e7599078ffddf3b..ca72f0a3fc397a5569f7731650634b1f37428fda 100644 (file)
@@ -55,6 +55,11 @@ typedef struct {
        long id;
 } sysvmsg_queue_t;
 
+struct php_msgbuf {
+       long mtype;
+       char mtext[1];
+};
+
 #endif /* HAVE_SYSVMSG */
 
 #endif /* PHP_SYSVMSG_H */
index b30ce9930d679ef8c671af4c3a69c451da9400fd..4c0ecd996f7f6181abc74c62d09542c0848cd2ab 100644 (file)
@@ -262,7 +262,7 @@ PHP_FUNCTION(msg_receive)
        long realflags = 0;
        zend_bool do_unserialize = 1;
        sysvmsg_queue_t *mq = NULL;
-       struct msgbuf *messagebuffer = NULL; /* buffer to transmit */
+       struct php_msgbuf *messagebuffer = NULL; /* buffer to transmit */
        int result;
        
        RETVAL_FALSE;
@@ -289,7 +289,7 @@ PHP_FUNCTION(msg_receive)
        
        ZEND_FETCH_RESOURCE(mq, sysvmsg_queue_t *, &queue, -1, "sysvmsg queue", le_sysvmsg);
 
-       messagebuffer = (struct msgbuf*)emalloc(sizeof(struct msgbuf) + maxsize);
+       messagebuffer = (struct php_msgbuf*)emalloc(sizeof(struct php_msgbuf) + maxsize);
        
        result = msgrcv(mq->id, messagebuffer, maxsize, desiredmsgtype, realflags);
                
@@ -340,7 +340,7 @@ PHP_FUNCTION(msg_send)
        long msgtype;
        zend_bool do_serialize = 1, blocking = 1;
        sysvmsg_queue_t * mq = NULL;
-       struct msgbuf * messagebuffer = NULL; /* buffer to transmit */
+       struct php_msgbuf * messagebuffer = NULL; /* buffer to transmit */
        int result;
        int message_len = 0;
        
@@ -360,15 +360,15 @@ PHP_FUNCTION(msg_send)
                php_var_serialize(&msg_var, &message, &var_hash TSRMLS_CC);
                PHP_VAR_SERIALIZE_DESTROY(var_hash);
                
-               /* NB: msgbuf is 1 char bigger than a long, so there is no need to
+               /* NB: php_msgbuf is 1 char bigger than a long, so there is no need to
                 * allocate the extra byte. */
-               messagebuffer = emalloc(sizeof(struct msgbuf) + msg_var.len);
+               messagebuffer = emalloc(sizeof(struct php_msgbuf) + msg_var.len);
                memcpy(messagebuffer->mtext, msg_var.c, msg_var.len + 1);
                message_len = msg_var.len;
                smart_str_free(&msg_var);
        } else {
                convert_to_string_ex(&message);
-               messagebuffer = emalloc(sizeof(struct msgbuf) + Z_STRLEN_P(message));
+               messagebuffer = emalloc(sizeof(struct php_msgbuf) + Z_STRLEN_P(message));
                memcpy(messagebuffer->mtext, Z_STRVAL_P(message), Z_STRLEN_P(message) + 1);
                message_len = Z_STRLEN_P(message);
        }