From 6ba50fde9cafa22640ecac28c91d241a55c6dce9 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Tue, 13 Jan 2015 19:25:37 -0800 Subject: [PATCH 1/3] Fixing time.c for win32 - MIN_INT can't work with 0x80000000 under win32. --- src/core/support/time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/support/time.c b/src/core/support/time.c index 0e88c65be0c..97243318fda 100644 --- a/src/core/support/time.c +++ b/src/core/support/time.c @@ -259,7 +259,7 @@ gpr_int32 gpr_time_to_millis(gpr_timespec t) { } else if (t.tv_sec <= -2147483) { /* TODO(ctiller): correct handling here (it's so far in the past do we care?) */ - return -2147483648; + return -2147483647; } else { return t.tv_sec * GPR_MS_PER_SEC + t.tv_nsec / GPR_NS_PER_MS; } From 848e74441e1cdfe027290e1daf286e243f4b22c1 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Tue, 13 Jan 2015 19:27:02 -0800 Subject: [PATCH 2/3] Fixing log_win32.c --- src/core/support/log_win32.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core/support/log_win32.c b/src/core/support/log_win32.c index ae5f23a90dc..dc8c1d0785a 100644 --- a/src/core/support/log_win32.c +++ b/src/core/support/log_win32.c @@ -36,12 +36,13 @@ #ifdef GPR_WIN32 #include +#include #include #include void gpr_log(const char *file, int line, gpr_log_severity severity, - const char *message) { - const char *message = NULL; + const char *format, ...) { + char *message = NULL; va_list args; int ret; @@ -53,7 +54,7 @@ void gpr_log(const char *file, int line, gpr_log_severity severity, message = NULL; } else { /* Allocate a new buffer, with space for the NUL terminator. */ - strp_buflen = (size_t)ret + 1; + size_t strp_buflen = (size_t)ret + 1; message = gpr_malloc(strp_buflen); /* Print to the buffer. */ @@ -73,7 +74,7 @@ void gpr_log(const char *file, int line, gpr_log_severity severity, /* Simple starter implementation */ void gpr_default_log(gpr_log_func_args *args) { - fprintf(stderr, "%s %s:%d: %s\n", gpr_log_severity_string(severity), + fprintf(stderr, "%s %s:%d: %s\n", gpr_log_severity_string(args->severity), args->file, args->line, args->message); } From 80d68c09c4ca7769c6c667eefa22769f37fac76d Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Tue, 13 Jan 2015 20:14:43 -0800 Subject: [PATCH 3/3] Fixing test_config.c Now all the gpr tests build and run under win32. --- include/grpc/support/port_platform.h | 5 +++++ .../vs2013/build_and_run_tests.bat.template | 2 +- test/core/util/test_config.c | 16 +++++++++++++++- vsprojects/vs2013/build_and_run_tests.bat | 2 +- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/include/grpc/support/port_platform.h b/include/grpc/support/port_platform.h index 9c999b9c811..9100f6e513c 100644 --- a/include/grpc/support/port_platform.h +++ b/include/grpc/support/port_platform.h @@ -45,9 +45,11 @@ #if defined(_WIN64) || defined(WIN64) #define GPR_WIN32 1 #define GPR_ARCH_64 1 +#define GPR_GETPID_IN_PROCESS_H 1 #elif defined(_WIN32) || defined(WIN32) #define GPR_ARCH_32 1 #define GPR_WIN32 1 +#define GPR_GETPID_IN_PROCESS_H 1 #elif defined(ANDROID) || defined(__ANDROID__) #define GPR_ANDROID 1 #define GPR_ARCH_32 1 @@ -61,6 +63,7 @@ #define GPR_POSIX_STRING 1 #define GPR_POSIX_SYNC 1 #define GPR_POSIX_TIME 1 +#define GPR_GETPID_IN_UNISTD_H 1 #elif defined(__linux__) #define GPR_CPU_LINUX 1 #define GPR_GCC_ATOMIC 1 @@ -72,6 +75,7 @@ #define GPR_POSIX_STRING 1 #define GPR_POSIX_SYNC 1 #define GPR_POSIX_TIME 1 +#define GPR_GETPID_IN_UNISTD_H 1 #ifdef _LP64 #define GPR_ARCH_64 1 #else /* _LP64 */ @@ -89,6 +93,7 @@ #define GPR_POSIX_STRING 1 #define GPR_POSIX_SYNC 1 #define GPR_POSIX_TIME 1 +#define GPR_GETPID_IN_UNISTD_H 1 #ifdef _LP64 #define GPR_ARCH_64 1 #else /* _LP64 */ diff --git a/templates/vsprojects/vs2013/build_and_run_tests.bat.template b/templates/vsprojects/vs2013/build_and_run_tests.bat.template index 8679bee3fc3..4a15e01c522 100644 --- a/templates/vsprojects/vs2013/build_and_run_tests.bat.template +++ b/templates/vsprojects/vs2013/build_and_run_tests.bat.template @@ -13,7 +13,7 @@ @rem Build the library dependencies first MSBuild.exe gpr.vcxproj /p:Configuration=Debug -MSBuild.exe grpc_test_util.vcxproj /p:Configuration=Debug +MSBuild.exe gpr_test_util.vcxproj /p:Configuration=Debug mkdir ${test_bin_dir} diff --git a/test/core/util/test_config.c b/test/core/util/test_config.c index fc5de9bbefb..ab2c0d80a99 100644 --- a/test/core/util/test_config.c +++ b/test/core/util/test_config.c @@ -33,11 +33,25 @@ #include "test/core/util/test_config.h" +#include #include + +#if GPR_GETPID_IN_UNISTD_H #include +static int seed() { + return getpid(); +} +#endif + +#if GPR_GETPID_IN_PROCESS_H +#include +static int seed(void) { + return _getpid(); +} +#endif void grpc_test_init(int argc, char **argv) { /* seed rng with pid, so we don't end up with the same random numbers as a concurrently running test binary */ - srand(getpid()); + srand(seed()); } diff --git a/vsprojects/vs2013/build_and_run_tests.bat b/vsprojects/vs2013/build_and_run_tests.bat index 06e9776d862..3e36dcf6002 100644 --- a/vsprojects/vs2013/build_and_run_tests.bat +++ b/vsprojects/vs2013/build_and_run_tests.bat @@ -5,7 +5,7 @@ @rem Build the library dependencies first MSBuild.exe gpr.vcxproj /p:Configuration=Debug -MSBuild.exe grpc_test_util.vcxproj /p:Configuration=Debug +MSBuild.exe gpr_test_util.vcxproj /p:Configuration=Debug mkdir test_bin