From 6943fb3aed8bf23681f7cb0277667c33098a3b07 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 9 Feb 2015 17:38:52 -0800 Subject: [PATCH 1/2] added cpu_windows.c --- Makefile | 2 ++ build.json | 1 + src/core/support/cpu_windows.c | 52 +++++++++++++++++++++++++++ vsprojects/vs2013/gpr.vcxproj | 2 ++ vsprojects/vs2013/gpr.vcxproj.filters | 3 ++ 5 files changed, 60 insertions(+) create mode 100644 src/core/support/cpu_windows.c diff --git a/Makefile b/Makefile index 7f4bee71f68..a5b3978109e 100644 --- a/Makefile +++ b/Makefile @@ -1684,6 +1684,7 @@ LIBGPR_SRC = \ src/core/support/cmdline.c \ src/core/support/cpu_linux.c \ src/core/support/cpu_posix.c \ + src/core/support/cpu_windows.c \ src/core/support/env_linux.c \ src/core/support/env_posix.c \ src/core/support/env_win32.c \ @@ -1776,6 +1777,7 @@ objs/$(CONFIG)/src/core/support/cancellable.o: objs/$(CONFIG)/src/core/support/cmdline.o: objs/$(CONFIG)/src/core/support/cpu_linux.o: objs/$(CONFIG)/src/core/support/cpu_posix.o: +objs/$(CONFIG)/src/core/support/cpu_windows.o: objs/$(CONFIG)/src/core/support/env_linux.o: objs/$(CONFIG)/src/core/support/env_posix.o: objs/$(CONFIG)/src/core/support/env_win32.o: diff --git a/build.json b/build.json index bbff314aa26..ca41c8dcb39 100644 --- a/build.json +++ b/build.json @@ -252,6 +252,7 @@ "src/core/support/cmdline.c", "src/core/support/cpu_linux.c", "src/core/support/cpu_posix.c", + "src/core/support/cpu_windows.c", "src/core/support/env_linux.c", "src/core/support/env_posix.c", "src/core/support/env_win32.c", diff --git a/src/core/support/cpu_windows.c b/src/core/support/cpu_windows.c new file mode 100644 index 00000000000..092606336e6 --- /dev/null +++ b/src/core/support/cpu_windows.c @@ -0,0 +1,52 @@ +/* +* +* Copyright 2014, Google Inc. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are +* met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above +* copyright notice, this list of conditions and the following disclaimer +* in the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Google Inc. nor the names of its +* contributors may be used to endorse or promote products derived from +* this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +#include + +#ifdef GPR_WIN32 + +#include "src/core/support/cpu.h" + +#include + +unsigned gpr_cpu_num_cores(void) { + /* TODO: implement */ + return 1; +} + +unsigned gpr_cpu_current_cpu(void) { + /* TODO: implement */ + return 1; +} + +#endif /* GPR_WIN32 */ diff --git a/vsprojects/vs2013/gpr.vcxproj b/vsprojects/vs2013/gpr.vcxproj index e54029390da..264543ad731 100644 --- a/vsprojects/vs2013/gpr.vcxproj +++ b/vsprojects/vs2013/gpr.vcxproj @@ -115,6 +115,8 @@ + + diff --git a/vsprojects/vs2013/gpr.vcxproj.filters b/vsprojects/vs2013/gpr.vcxproj.filters index 20e4e07c49d..1e908a5ba51 100644 --- a/vsprojects/vs2013/gpr.vcxproj.filters +++ b/vsprojects/vs2013/gpr.vcxproj.filters @@ -16,6 +16,9 @@ src\core\support + + src\core\support + src\core\support From 2cdacb8d2e128bf05c7d0157b7c386b69f1b9930 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 11 Feb 2015 15:31:49 -0800 Subject: [PATCH 2/2] added log messages for cpu_windows.c --- src/core/support/cpu_windows.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/support/cpu_windows.c b/src/core/support/cpu_windows.c index 092606336e6..c533f9d554b 100644 --- a/src/core/support/cpu_windows.c +++ b/src/core/support/cpu_windows.c @@ -40,13 +40,15 @@ #include unsigned gpr_cpu_num_cores(void) { - /* TODO: implement */ + /* TODO(jtattermusch): implement */ + gpr_log(GPR_ERROR, "Cannot determine number of CPUs: assuming 1"); return 1; } unsigned gpr_cpu_current_cpu(void) { - /* TODO: implement */ - return 1; + /* TODO(jtattermusch): implement */ + gpr_log(GPR_ERROR, "Cannot determine current CPU"); + return 0; } #endif /* GPR_WIN32 */