Merge pull request #24 from nicolasnoble/win32

Various win32 fixes.
pull/25/head
Craig Tiller 10 years ago
commit dd330d6d68
  1. 5
      include/grpc/support/port_platform.h
  2. 9
      src/core/support/log_win32.c
  3. 2
      src/core/support/time.c
  4. 2
      templates/vsprojects/vs2013/build_and_run_tests.bat.template
  5. 16
      test/core/util/test_config.c
  6. 2
      vsprojects/vs2013/build_and_run_tests.bat

@ -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
@ -60,6 +62,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
@ -70,6 +73,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 */
@ -86,6 +90,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 */

@ -36,12 +36,13 @@
#ifdef GPR_WIN32
#include <grpc/support/log.h>
#include <grpc/support/alloc.h>
#include <stdio.h>
#include <stdarg.h>
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);
}

@ -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;
}

@ -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}

@ -33,11 +33,25 @@
#include "test/core/util/test_config.h"
#include <grpc/support/port_platform.h>
#include <stdlib.h>
#if GPR_GETPID_IN_UNISTD_H
#include <unistd.h>
static int seed() {
return getpid();
}
#endif
#if GPR_GETPID_IN_PROCESS_H
#include <process.h>
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());
}

@ -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

Loading…
Cancel
Save