Skip to content

Commit f904830

Browse files
committed
Added support for GNU Hurd. (Svante Signell)
1 parent ea0f832 commit f904830

File tree

4 files changed

+69
-40
lines changed

4 files changed

+69
-40
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ PHP NEWS
2626
imap). (ryotakatsuki at gmail dot com)
2727

2828
- OPcache:
29+
. Added support for GNU Hurd. (Svante Signell)
2930
. Added function opcache_compile_file() to load PHP scripts into cache
3031
without execution. (Julien)
3132
. Fixed bug #65665 (Exception not properly caught when opcache enabled).

ext/opcache/ZendAccelerator.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@
8080
# endif
8181
# include <direct.h>
8282
#else
83+
# ifndef MAXPATHLEN
84+
# define MAXPATHLEN 4096
85+
# endif
8386
# include <sys/param.h>
8487
#endif
8588

@@ -100,7 +103,7 @@ extern int lock_file;
100103
# elif defined(__svr4__)
101104
# define FLOCK_STRUCTURE(name, type, whence, start, len) \
102105
struct flock name = {type, whence, start, len}
103-
# elif defined(__linux__) || defined(__hpux)
106+
# elif defined(__linux__) || defined(__hpux) || defined(__GNU__)
104107
# define FLOCK_STRUCTURE(name, type, whence, start, len) \
105108
struct flock name = {type, whence, start, len, 0}
106109
# elif defined(_AIX)
@@ -111,6 +114,12 @@ extern int lock_file;
111114
# define FLOCK_STRUCTURE(name, type, whence, start, len) \
112115
struct flock name = {type, whence, start, len}
113116
# endif
117+
# elif defined(HAVE_FLOCK_BSD)
118+
# define FLOCK_STRUCTURE(name, type, whence, start, len) \
119+
struct flock name = {start, len, -1, type, whence}
120+
# elif defined(HAVE_FLOCK_LINUX)
121+
# define FLOCK_STRUCTURE(name, type, whence, start, len) \
122+
struct flock name = {type, whence, start, len}
114123
# else
115124
# error "Don't know how to define struct flock"
116125
# endif

ext/opcache/config.m4

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -326,40 +326,42 @@ int main() {
326326
msg=yes,msg=no,msg=no)
327327
AC_MSG_RESULT([$msg])
328328

329-
AC_MSG_CHECKING(for known struct flock definition)
330-
dnl Copied from ZendAccelerator.h
331-
AC_TRY_RUN([
332-
#include <fcntl.h>
333-
#include <stdlib.h>
334-
335-
#ifndef ZEND_WIN32
336-
extern int lock_file;
337-
338-
# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || (defined(__APPLE__) && defined(__MACH__)/* Darwin */) || defined(__OpenBSD__) || defined(__NetBSD__)
339-
# define FLOCK_STRUCTURE(name, type, whence, start, len) \
340-
struct flock name = {start, len, -1, type, whence}
341-
# elif defined(__svr4__)
342-
# define FLOCK_STRUCTURE(name, type, whence, start, len) \
343-
struct flock name = {type, whence, start, len}
344-
# elif defined(__linux__) || defined(__hpux)
345-
# define FLOCK_STRUCTURE(name, type, whence, start, len) \
346-
struct flock name = {type, whence, start, len, 0}
347-
# elif defined(_AIX)
348-
# if defined(_LARGE_FILES) || defined(__64BIT__)
349-
# define FLOCK_STRUCTURE(name, type, whence, start, len) \
350-
struct flock name = {type, whence, 0, 0, 0, start, len }
351-
# else
352-
# define FLOCK_STRUCTURE(name, type, whence, start, len) \
353-
struct flock name = {type, whence, start, len}
354-
# endif
355-
# else
356-
# error "Don't know how to define struct flock"
357-
# endif
358-
#endif
359-
int main() { return 0; }
360-
],
361-
[AC_MSG_RESULT([done])],
362-
[AC_MSG_ERROR([Don't know how to define struct flock on this system[,] set --enable-opcache=no])], [])
329+
flock_type=unknown
330+
AC_MSG_CHECKING("whether flock struct is linux ordered")
331+
AC_TRY_RUN([
332+
#include <fcntl.h>
333+
struct flock lock = { 1, 2, 3, 4, 5 };
334+
int main() {
335+
if(lock.l_type == 1 && lock.l_whence == 2 && lock.l_start == 3 && lock.l_len == 4) {
336+
return 0;
337+
}
338+
return 1;
339+
}
340+
], [
341+
flock_type=linux
342+
AC_DEFINE([HAVE_FLOCK_LINUX], [], [Struct flock is Linux-type])
343+
AC_MSG_RESULT("yes")
344+
], AC_MSG_RESULT("no") )
345+
346+
AC_MSG_CHECKING("whether flock struct is BSD ordered")
347+
AC_TRY_RUN([
348+
#include <fcntl.h>
349+
struct flock lock = { 1, 2, 3, 4, 5 };
350+
int main() {
351+
if(lock.l_start == 1 && lock.l_len == 2 && lock.l_type == 4 && lock.l_whence == 5) {
352+
return 0;
353+
}
354+
return 1;
355+
}
356+
], [
357+
flock_type=bsd
358+
AC_DEFINE([HAVE_FLOCK_BSD], [], [Struct flock is BSD-type])
359+
AC_MSG_RESULT("yes")
360+
], AC_MSG_RESULT("no") )
361+
362+
if test "$flock_type" == "unknown"; then
363+
AC_MSG_ERROR([Don't know how to define struct flock on this system[,] set --enable-opcache=no])
364+
fi
363365

364366
PHP_NEW_EXTENSION(opcache,
365367
ZendAccelerator.c \

sapi/cgi/cgi_main.c

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ static const opt_struct OPTIONS[] = {
154154
{'?', 0, "usage"},/* help alias (both '?' and 'usage') */
155155
{'v', 0, "version"},
156156
{'z', 1, "zend-extension"},
157+
{'W', 1, "warmup"},
157158
{'T', 1, "timing"},
158159
{'-', 0, NULL} /* end of args */
159160
};
@@ -1754,6 +1755,7 @@ int main(int argc, char *argv[])
17541755
int fcgi_fd = 0;
17551756
fcgi_request *request = NULL;
17561757
int repeats = 1;
1758+
int warmup_repeats = 0;
17571759
int benchmark = 0;
17581760
#if HAVE_GETTIMEOFDAY
17591761
struct timeval start, end;
@@ -2103,6 +2105,9 @@ consult the installation file that came with this distribution, or visit \n\
21032105
time(&start);
21042106
#endif
21052107
break;
2108+
case 'W':
2109+
warmup_repeats = atoi(php_optarg);
2110+
break;
21062111
case 'h':
21072112
case '?':
21082113
if (request) {
@@ -2516,12 +2521,24 @@ consult the installation file that came with this distribution, or visit \n\
25162521

25172522
if (!fastcgi) {
25182523
if (benchmark) {
2519-
repeats--;
2520-
if (repeats > 0) {
2521-
script_file = NULL;
2522-
php_optind = orig_optind;
2523-
php_optarg = orig_optarg;
2524+
if (warmup_repeats) {
2525+
warmup_repeats--;
2526+
if (!warmup_repeats) {
2527+
#ifdef HAVE_GETTIMEOFDAY
2528+
gettimeofday(&start, NULL);
2529+
#else
2530+
time(&start);
2531+
#endif
2532+
}
25242533
continue;
2534+
} else {
2535+
repeats--;
2536+
if (repeats > 0) {
2537+
script_file = NULL;
2538+
php_optind = orig_optind;
2539+
php_optarg = orig_optarg;
2540+
continue;
2541+
}
25252542
}
25262543
}
25272544
break;

0 commit comments

Comments
 (0)