| Index: third_party/grpc/src/core/support/cpu_linux.c
|
| diff --git a/third_party/WebKit/Source/build/win/Precompile.h b/third_party/grpc/src/core/support/cpu_linux.c
|
| similarity index 61%
|
| copy from third_party/WebKit/Source/build/win/Precompile.h
|
| copy to third_party/grpc/src/core/support/cpu_linux.c
|
| index 8a0ff29c353fc1d30c92d27f369d7c422a579bc8..7af6a8f0090b4d14e670a6b8e5a63801381a9a6e 100644
|
| --- a/third_party/WebKit/Source/build/win/Precompile.h
|
| +++ b/third_party/grpc/src/core/support/cpu_linux.c
|
| @@ -1,5 +1,7 @@
|
| /*
|
| - * Copyright (C) 2012 Google Inc. All rights reserved.
|
| + *
|
| + * Copyright 2015, 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
|
| @@ -26,43 +28,51 @@
|
| * 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.
|
| - */
|
| -
|
| -/*
|
| - * Precompiled header for WebKit when built on Windows using
|
| - * GYP-generated project files. Not used by other build
|
| - * configurations.
|
| *
|
| - * Using precompiled headers speeds the build up significantly. On a
|
| - * fast machine (HP Z600, 12 GB of RAM), an ~18% decrease in full
|
| - * build time was measured.
|
| */
|
|
|
| -#if defined(WinPrecompile_h_)
|
| -#error You shouldn't include the precompiled header file more than once.
|
| -#endif
|
| -
|
| -#define WinPrecompile_h_
|
| +#ifndef _GNU_SOURCE
|
| +#define _GNU_SOURCE
|
| +#endif /* _GNU_SOURCE */
|
|
|
| -#define _USE_MATH_DEFINES // Make math.h behave like other platforms.
|
| +#include <grpc/support/port_platform.h>
|
|
|
| -#include <Windows.h>
|
| +#ifdef GPR_CPU_LINUX
|
|
|
| +#include <sched.h>
|
| #include <errno.h>
|
| -#include <fcntl.h>
|
| -#include <limits.h>
|
| -#include <math.h>
|
| -#include <stdarg.h>
|
| -#include <stddef.h>
|
| -#include <stdio.h>
|
| -#include <stdlib.h>
|
| +#include <unistd.h>
|
| #include <string.h>
|
| -#include <time.h>
|
|
|
| -#include <algorithm>
|
| -#include <ciso646>
|
| -#include <cmath>
|
| -#include <cstddef>
|
| -#include <limits>
|
| -#include <string>
|
| -#include <utility>
|
| +#include <grpc/support/cpu.h>
|
| +#include <grpc/support/log.h>
|
| +#include <grpc/support/sync.h>
|
| +
|
| +static int ncpus = 0;
|
| +
|
| +static void init_num_cpus() {
|
| + /* This must be signed. sysconf returns -1 when the number cannot be
|
| + determined */
|
| + ncpus = (int)sysconf(_SC_NPROCESSORS_ONLN);
|
| + if (ncpus < 1) {
|
| + gpr_log(GPR_ERROR, "Cannot determine number of CPUs: assuming 1");
|
| + ncpus = 1;
|
| + }
|
| +}
|
| +
|
| +unsigned gpr_cpu_num_cores(void) {
|
| + static gpr_once once = GPR_ONCE_INIT;
|
| + gpr_once_init(&once, init_num_cpus);
|
| + return (unsigned)ncpus;
|
| +}
|
| +
|
| +unsigned gpr_cpu_current_cpu(void) {
|
| + int cpu = sched_getcpu();
|
| + if (cpu < 0) {
|
| + gpr_log(GPR_ERROR, "Error determining current CPU: %s\n", strerror(errno));
|
| + return 0;
|
| + }
|
| + return (unsigned)cpu;
|
| +}
|
| +
|
| +#endif /* GPR_CPU_LINUX */
|
|
|