summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
Diffstat (limited to 'win32')
-rw-r--r--win32/build/buildconf.js2
-rw-r--r--win32/build/config.w3213
-rw-r--r--win32/build/config.w32.h.in2
-rw-r--r--win32/build/confutils.js36
-rw-r--r--win32/dllmain.c18
-rw-r--r--win32/ftok.c2
-rw-r--r--win32/getrusage.c2
-rw-r--r--win32/ioutil.h2
-rw-r--r--win32/ipc.h8
-rw-r--r--win32/nice.c83
-rw-r--r--win32/nice.h25
-rw-r--r--win32/time.c15
-rw-r--r--win32/time.h2
13 files changed, 182 insertions, 28 deletions
diff --git a/win32/build/buildconf.js b/win32/build/buildconf.js
index d7975d0139..b7e964e3e7 100644
--- a/win32/build/buildconf.js
+++ b/win32/build/buildconf.js
@@ -257,4 +257,4 @@ C.WriteBlankLines(1);
C.Write(file_get_contents("win32/build/configure.tail"));
B.WriteLine("@echo off");
-B.WriteLine("cscript /nologo configure.js %*");
+B.WriteLine("cscript /nologo configure.js %*"); \ No newline at end of file
diff --git a/win32/build/config.w32 b/win32/build/config.w32
index 5c892899bb..682f1bd274 100644
--- a/win32/build/config.w32
+++ b/win32/build/config.w32
@@ -63,6 +63,9 @@ toolset_setup_common_cflags();
ARG_WITH('mp', 'Tell Visual Studio use up to [n,auto,disable] processes for compilation', 'auto');
var PHP_MP_DISABLED = true;
if (VS_TOOLSET && PHP_MP != 'disable') {
+ if(PHP_DEBUG == 'yes') {
+ STDOUT.WriteLine('WARNING: Debug builds cannot be built using multi processing');
+ } else {
// no from disable-all
if(PHP_MP == 'auto' || PHP_MP == 'no') {
ADD_FLAG('CFLAGS', ' /MP ');
@@ -75,6 +78,7 @@ if (VS_TOOLSET && PHP_MP != 'disable') {
STDOUT.WriteLine('WARNING: Invalid argument for MP: ' + PHP_MP);
}
}
+ }
}
if (!PHP_MP_DISABLED) {
@@ -151,7 +155,6 @@ ADD_SOURCES("main", "main.c snprintf.c spprintf.c getopt.c fopen_wrappers.c \
strlcat.c mergesort.c reentrancy.c php_variables.c php_ticks.c network.c \
php_open_temporary_file.c output.c internal_functions.c php_sprintf.c");
ADD_FLAG("CFLAGS_BD_MAIN", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
-ADD_SOURCES("win32", "inet.c fnmatch.c sockets.c");
AC_DEFINE('HAVE_STRNLEN', 1);
@@ -161,7 +164,8 @@ ADD_FLAG("CFLAGS_BD_MAIN_STREAMS", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
ADD_SOURCES("win32", "dllmain.c glob.c readdir.c \
registry.c select.c sendmail.c time.c winutil.c wsyslog.c globals.c \
- getrusage.c ftok.c ioutil.c codepage.c");
+ getrusage.c ftok.c ioutil.c codepage.c nice.c \
+ inet.c fnmatch.c sockets.c");
ADD_FLAG("CFLAGS_BD_WIN32", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
@@ -294,3 +298,8 @@ toolset_setup_codegen_arch();
ARG_WITH("all-shared", "Force all the non obligatory extensions to be shared", "no");
+// Config profiles (--with-config-profile=<name>) will save a certain config to php-src/config.<name>.bat
+// so that it can be executed like: cofig.<name> instead of a long list of parameters
+//
+// Note, nice as a name is disallowed and will generate a warning and skip saving
+ARG_WITH('config-profile', 'Name of the configuration profile to save this to in php-src/config.name.bat', 'no'); \ No newline at end of file
diff --git a/win32/build/config.w32.h.in b/win32/build/config.w32.h.in
index 2a8297a144..e871088f15 100644
--- a/win32/build/config.w32.h.in
+++ b/win32/build/config.w32.h.in
@@ -175,3 +175,5 @@
#define HAVE_GETRUSAGE
#define HAVE_FTOK 1
+
+#define HAVE_NICE
diff --git a/win32/build/confutils.js b/win32/build/confutils.js
index a534b1eeb8..451954406f 100644
--- a/win32/build/confutils.js
+++ b/win32/build/confutils.js
@@ -103,7 +103,7 @@ var PHP_VERSION = 7;
var PHP_MINOR_VERSION = 1;
var PHP_RELEASE_VERSION = 0;
var PHP_EXTRA_VERSION = "";
-var PHP_VERSION_STRING = "7.1.0";
+var PHP_VERSION_STRING = "7.2.0";
/* Get version numbers and DEFINE as a string */
function get_version_numbers()
@@ -337,6 +337,7 @@ function conf_process_args()
for (i = 0; i < args.length; i++) {
arg = args(i);
nice += ' "' + arg + '"';
+
if (arg == "--help") {
configure_help_mode = true;
break;
@@ -437,7 +438,7 @@ can be built that way. \
'pcre-regex', 'fastcgi', 'force-cgi-redirect',
'path-info-check', 'zts', 'ipv6', 'memory-limit',
'zend-multibyte', 'fd-setsize', 'memory-manager',
- 't1lib', 'pgi', 'pgo', 'all-shared'
+ 'pgi', 'pgo', 'all-shared', 'config-profile'
);
var force;
@@ -518,10 +519,31 @@ can be built that way. \
MFO = FSO.CreateTextFile("Makefile.objects", true);
- STDOUT.WriteLine("Saving configure options to config.nice.bat");
- var nicefile = FSO.CreateTextFile("config.nice.bat", true);
- nicefile.WriteLine(nice + " %*");
- nicefile.Close();
+ var profile = false;
+
+ if (PHP_CONFIG_PROFILE != 'no') {
+ if (PHP_CONFIG_PROFILE.toLowerCase() == 'nice') {
+ WARNING('Config profile name cannot be named \'nice\'');
+ } else {
+ var config_profile = FSO.CreateTextFile('config.' + PHP_CONFIG_PROFILE + '.bat', true);
+
+ config_profile.WriteLine('@echo off');
+ config_profile.WriteLine(nice + ' %*');
+ config_profile.Close();
+
+ profile = true;
+ }
+ }
+
+ // Only generate an updated config.nice.bat file if a profile was not used
+ if (!profile) {
+ STDOUT.WriteLine("Saving configure options to config.nice.bat");
+
+ var nicefile = FSO.CreateTextFile("config.nice.bat", true);
+ nicefile.WriteLine('@echo off');
+ nicefile.WriteLine(nice + " %*");
+ nicefile.Close();
+ }
AC_DEFINE('CONFIGURE_COMMAND', nice, "Configure line");
}
@@ -929,7 +951,7 @@ function CHECK_HEADER_ADD_INCLUDE(header_name, flag_name, path_to_check, use_env
if (typeof(add_to_flag_only) != "undefined") {
ADD_FLAG(flag_name, "/DHAVE_" + sym + "=" + have);
- } else {
+ } else if (!configure_hdr.Exists('HAVE_' + sym)) {
AC_DEFINE("HAVE_" + sym, have, "have the " + header_name + " header file");
}
diff --git a/win32/dllmain.c b/win32/dllmain.c
index 37408f1e76..ab4f105528 100644
--- a/win32/dllmain.c
+++ b/win32/dllmain.c
@@ -40,11 +40,19 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID dummy)
switch (reason)
{
case DLL_PROCESS_ATTACH:
- ret = ret && php_win32_init_gettimeofday();
- if (!ret) {
- fprintf(stderr, "gettimeofday() initialization failed");
- return ret;
- }
+ /*
+ * We do not need to check the return value of php_win32_init_gettimeofday()
+ * because the symbol bare minimum symbol we need is always available on our
+ * lowest supported platform.
+ *
+ * On Windows 8 or greater, we use a more precise symbol to obtain the system
+ * time, which is dynamically. The fallback allows us to proper support
+ * Vista/7/Server 2003 R2/Server 2008/Server 2008 R2.
+ *
+ * Instead simply initialize the global in win32/time.c for gettimeofday()
+ * use later on
+ */
+ php_win32_init_gettimeofday();
ret = ret && php_win32_ioutil_init();
if (!ret) {
diff --git a/win32/ftok.c b/win32/ftok.c
index 842da78192..4c35017060 100644
--- a/win32/ftok.c
+++ b/win32/ftok.c
@@ -22,7 +22,7 @@
#include <sys/stat.h>
-PHPAPI key_t
+PHP_WIN32_IPC_API key_t
ftok(const char *pathname, int proj_id)
{
HANDLE fh;
diff --git a/win32/getrusage.c b/win32/getrusage.c
index d719bcde26..3267ac63ad 100644
--- a/win32/getrusage.c
+++ b/win32/getrusage.c
@@ -26,7 +26,7 @@
* and have been modified to work with PHP.
*/
-static void usage_to_timeval(FILETIME *ft, struct timeval *tv)
+static zend_always_inline void usage_to_timeval(FILETIME *ft, struct timeval *tv)
{
ULARGE_INTEGER time;
diff --git a/win32/ioutil.h b/win32/ioutil.h
index 15c8f0e339..6699d78a14 100644
--- a/win32/ioutil.h
+++ b/win32/ioutil.h
@@ -466,7 +466,7 @@ __forceinline static char *php_win32_ioutil_getcwd(char *buf, int len)
/* If buf was NULL, the result has to be freed outside here. */
buf = tmp_bufa;
} else {
- if (tmp_bufa_len + 1 > len) {
+ if (tmp_bufa_len + 1 > (size_t)len) {
free(tmp_bufa);
SET_ERRNO_FROM_WIN32_CODE(ERROR_INSUFFICIENT_BUFFER);
return NULL;
diff --git a/win32/ipc.h b/win32/ipc.h
index cafcf4f85e..0d7cc47e8c 100644
--- a/win32/ipc.h
+++ b/win32/ipc.h
@@ -19,11 +19,15 @@
#ifndef PHP_WIN32_IPC_H
#define PHP_WIN32_IPC_H 1
-#include "php.h"
+#ifdef PHP_EXPORTS
+# define PHP_WIN32_IPC_API __declspec(dllexport)
+#else
+# define PHP_WIN32_IPC_API __declspec(dllimport)
+#endif
typedef int key_t;
-PHPAPI key_t ftok(const char *path, int id);
+PHP_WIN32_IPC_API key_t ftok(const char *path, int id);
#endif /* PHP_WIN32_IPC_H */
diff --git a/win32/nice.c b/win32/nice.c
new file mode 100644
index 0000000000..db26cc1aa6
--- /dev/null
+++ b/win32/nice.c
@@ -0,0 +1,83 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 7 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2016 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Kalle Sommer Nielsen <kalle@php.net> |
+ +----------------------------------------------------------------------+
+ */
+
+#include <php.h>
+#include "nice.h"
+
+/*
+ * Basic Windows implementation for the nice() function.
+ *
+ * This implementation uses SetPriorityClass() as a backend for defining
+ * a process priority.
+ *
+ * The following values of inc, defines the value sent to SetPriorityClass():
+ *
+ * +-----------------------+-----------------------------+
+ * | Expression | Priority type |
+ * +-----------------------+-----------------------------+
+ * | priority < -14 | REALTIME_PRIORITY_CLASS |
+ * +-----------------------+-----------------------------+
+ * | priority < -9 | HIGH_PRIORITY_CLASS |
+ * +-----------------------+-----------------------------+
+ * | priority < -4 | ABOVE_NORMAL_PRIORITY_CLASS |
+ * +-----------------------+-----------------------------+
+ * | priority > 4 | BELOW_NORMAL_PRIORITY_CLASS |
+ * +-----------------------+-----------------------------+
+ * | priority > 9 | IDLE_PRIORITY_CLASS |
+ * +-----------------------+-----------------------------+
+ *
+ * If a value is between -4 and 4 (inclusive), then the priority will be set
+ * to NORMAL_PRIORITY_CLASS.
+ *
+ * These values tries to mimic that of the UNIX version of nice().
+ *
+ * This is applied to the main process, not per thread, although this could
+ * be implemented using SetThreadPriority() at one point.
+ */
+
+PHPAPI int nice(zend_long p)
+{
+ DWORD dwFlag = NORMAL_PRIORITY_CLASS;
+
+ if (p < -14) {
+ dwFlag = REALTIME_PRIORITY_CLASS;
+ } else if (p < -9) {
+ dwFlag = HIGH_PRIORITY_CLASS;
+ } else if (p < -4) {
+ dwFlag = ABOVE_NORMAL_PRIORITY_CLASS;
+ } else if (p > 9) {
+ dwFlag = IDLE_PRIORITY_CLASS;
+ } else if (p > 4) {
+ dwFlag = BELOW_NORMAL_PRIORITY_CLASS;
+ }
+
+ if (!SetPriorityClass(GetCurrentProcess(), dwFlag)) {
+ return -1;
+ }
+
+ return 0;
+}
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: sw=4 ts=4 fdm=marker
+ * vim<600: sw=4 ts=4
+ */
diff --git a/win32/nice.h b/win32/nice.h
new file mode 100644
index 0000000000..037949f3bf
--- /dev/null
+++ b/win32/nice.h
@@ -0,0 +1,25 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 7 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2016 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Kalle Sommer Nielsen <kalle@php.net> |
+ +----------------------------------------------------------------------+
+ */
+
+#ifndef HAVE_NICE_H
+# define HAVE_NICE_H
+
+PHPAPI int nice(zend_long);
+
+#endif
+
diff --git a/win32/time.c b/win32/time.c
index dfcc46a59b..a0ed1b344e 100644
--- a/win32/time.c
+++ b/win32/time.c
@@ -39,20 +39,21 @@ static zend_always_inline MyGetSystemTimeAsFileTime get_time_func(void)
/* Max possible resolution <1us, win8/server2012 */
timefunc = (MyGetSystemTimeAsFileTime)GetProcAddress(hMod, "GetSystemTimePreciseAsFileTime");
- if(!timefunc) {
- /* 100ns blocks since 01-Jan-1641 */
- timefunc = (MyGetSystemTimeAsFileTime)GetProcAddress(hMod, "GetSystemTimeAsFileTime");
- }
+ /* Lower the refcount */
+ FreeLibrary(hMod);
+ }
+
+ if(!timefunc) {
+ /* 100ns blocks since 01-Jan-1641 */
+ timefunc = (MyGetSystemTimeAsFileTime) GetSystemTimeAsFileTime;
}
return timefunc;
}
-BOOL php_win32_init_gettimeofday(void)
+void php_win32_init_gettimeofday(void)
{
timefunc = get_time_func();
-
- return (NULL != timefunc);
}
#endif
diff --git a/win32/time.h b/win32/time.h
index b46c1675ca..865e299aa9 100644
--- a/win32/time.h
+++ b/win32/time.h
@@ -55,7 +55,7 @@ PHPAPI int usleep(unsigned int useconds);
#ifdef PHP_EXPORTS
/* This symbols are needed only for the DllMain, but should not be exported
or be available when used with PHP binaries. */
-BOOL php_win32_init_gettimeofday(void);
+void php_win32_init_gettimeofday(void);
#endif
#endif