]> granicus.if.org Git - php/commitdiff
add code to check if we know flock definition on this system
authorStanislav Malyshev <stas@php.net>
Mon, 25 Mar 2013 03:11:28 +0000 (20:11 -0700)
committerStanislav Malyshev <stas@php.net>
Mon, 25 Mar 2013 03:11:28 +0000 (20:11 -0700)
In order to configure detect it and not fail the compile.
Not an ideal solution, suggestions are welcome on how to improve it.

ext/opcache/config.m4

index cbf7d5a19c08c388b402a2690f48c99318e63002..70cd4e9ecc62d39e6e755ab82abf7303a1865859 100644 (file)
@@ -325,6 +325,39 @@ int main() {
     AC_DEFINE(HAVE_SHM_MMAP_FILE, 1, [Define if you have mmap() SHM support])
     msg=yes,msg=no,msg=no)
   AC_MSG_RESULT([$msg])
+
+  AC_MSG_CHECKING(for known struct flock definition)
+  dnl Copied from ZendAccelerator.h
+  AC_TRY_RUN([
+#include <fcntl.h>
+#include <stdlib.h>
+
+#ifndef ZEND_WIN32
+extern int lock_file;
+
+# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || (defined(__APPLE__) && defined(__MACH__)/* Darwin */) || defined(__OpenBSD__) || defined(__NetBSD__)
+#  define FLOCK_STRUCTURE(name, type, whence, start, len) \
+                struct flock name = {start, len, -1, type, whence}
+# elif defined(__svr4__)
+#  define FLOCK_STRUCTURE(name, type, whence, start, len) \
+                struct flock name = {type, whence, start, len}
+# elif defined(__linux__) || defined(__hpux)
+#  define FLOCK_STRUCTURE(name, type, whence, start, len) \
+                struct flock name = {type, whence, start, len, 0}
+# elif defined(_AIX)
+#  if defined(_LARGE_FILES) || defined(__64BIT__)
+#   define FLOCK_STRUCTURE(name, type, whence, start, len) \
+                struct flock name = {type, whence, 0, 0, 0, start, len }
+#  else
+#   define FLOCK_STRUCTURE(name, type, whence, start, len) \
+                struct flock name = {type, whence, start, len}
+#  endif
+# else
+#  error "Don't know how to define struct flock"
+# endif
+#endif
+void main() {}
+], [], [AC_MSG_ERROR([Don't know how to define struct flock on this system[,] set --enable-opcache=no])], [])
   
   PHP_NEW_EXTENSION(opcache,
        ZendAccelerator.c \