pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

google-benchmark: Add NetBSD bits



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Fri Nov 17 02:13:30 2017 +0100
Changeset:	e9863079241c695a4afa5186914d513fc5cae577

Modified Files:
	google-benchmark/distinfo
Added Files:
	google-benchmark/patches/patch-src_internal__macros.h
	google-benchmark/patches/patch-src_sysinfo.cc
	google-benchmark/patches/patch-src_timers.cc

Log Message:
google-benchmark: Add NetBSD bits

Sponsored by <The NetBSD Foundation>

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=e9863079241c695a4afa5186914d513fc5cae577

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 google-benchmark/distinfo                          |  3 ++
 .../patches/patch-src_internal__macros.h           | 13 ++++++
 google-benchmark/patches/patch-src_sysinfo.cc      | 51 ++++++++++++++++++++++
 google-benchmark/patches/patch-src_timers.cc       | 13 ++++++
 4 files changed, 80 insertions(+)

diffs:
diff --git a/google-benchmark/distinfo b/google-benchmark/distinfo
index b787e83479..b513275d75 100644
--- a/google-benchmark/distinfo
+++ b/google-benchmark/distinfo
@@ -4,3 +4,6 @@ SHA1 (benchmark-1.3.0.tar.gz) = ea74b9d99327f7ef8150dc7c683e6155fa29ef3c
 RMD160 (benchmark-1.3.0.tar.gz) = 456d2d6125d77cbf847764a45eedca53c315aea6
 SHA512 (benchmark-1.3.0.tar.gz) = 272775e4dbd0ecc65a2a3a64f24e79682b630929dea3af47349329ac8b796341f1197458a67c9aac0e514857ebe7cbc191d18f6fd2c0aea3242562e69d8a6849
 Size (benchmark-1.3.0.tar.gz) = 105485 bytes
+SHA1 (patch-src_internal__macros.h) = 3076cd5dab9399a536e76ba53c9cc247150b8300
+SHA1 (patch-src_sysinfo.cc) = 289548f2aceb1afdc7dcba7fc6aed5e75c3ce330
+SHA1 (patch-src_timers.cc) = a709bba78c097132c6331c436f02a4d059e747eb
diff --git a/google-benchmark/patches/patch-src_internal__macros.h b/google-benchmark/patches/patch-src_internal__macros.h
new file mode 100644
index 0000000000..397e2469e4
--- /dev/null
+++ b/google-benchmark/patches/patch-src_internal__macros.h
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/internal_macros.h.orig	2017-11-03 17:00:29.000000000 +0000
++++ src/internal_macros.h
+@@ -39,6 +39,8 @@
+   #endif
+ #elif defined(__FreeBSD__)
+ #define BENCHMARK_OS_FREEBSD 1
++#elif defined(__NetBSD__)
++#define BENCHMARK_OS_NETBSD 1
+ #elif defined(__linux__)
+ #define BENCHMARK_OS_LINUX 1
+ #elif defined(__native_client__)
diff --git a/google-benchmark/patches/patch-src_sysinfo.cc b/google-benchmark/patches/patch-src_sysinfo.cc
new file mode 100644
index 0000000000..7e1f2b97b2
--- /dev/null
+++ b/google-benchmark/patches/patch-src_sysinfo.cc
@@ -0,0 +1,51 @@
+$NetBSD$
+
+--- src/sysinfo.cc.orig	2017-11-03 17:00:29.000000000 +0000
++++ src/sysinfo.cc
+@@ -25,7 +25,7 @@
+ #include <sys/time.h>
+ #include <sys/types.h>  // this header must be included before 'sys/sysctl.h' to avoid compilation error on FreeBSD
+ #include <unistd.h>
+-#if defined BENCHMARK_OS_FREEBSD || defined BENCHMARK_OS_MACOSX
++#if defined BENCHMARK_OS_FREEBSD || defined BENCHMARK_OS_MACOSX || defined BENCHMARK_OS_NETBSD
+ #include <sys/sysctl.h>
+ #endif
+ #endif
+@@ -230,7 +230,9 @@ void InitializeSystemInfo() {
+     cpuinfo_num_cpus = num_cpus;
+   }
+ 
+-#elif defined BENCHMARK_OS_FREEBSD
++#elif defined BENCHMARK_OS_FREEBSD || defined BENCHMARK_OS_NETBSD
++// FreeBSD notes
++// =============
+ // For this sysctl to work, the machine must be configured without
+ // SMP, APIC, or APM support.  hz should be 64-bit in freebsd 7.0
+ // and later.  Before that, it's a 32-bit quantity (and gives the
+@@ -242,7 +244,7 @@ void InitializeSystemInfo() {
+ // To FreeBSD 6.3 (it's the same in 6-STABLE):
+ //  http://fxr.watson.org/fxr/source/i386/i386/tsc.c?v=RELENG6#L131
+ //  139         error = sysctl_handle_int(oidp, &freq, sizeof(freq), req);
+-#if __FreeBSD__ >= 7
++#if (__FreeBSD__ >= 7) || defined(__NetBSD__)
+   uint64_t hz = 0;
+ #else
+   unsigned int hz = 0;
+@@ -256,8 +258,16 @@ void InitializeSystemInfo() {
+   } else {
+     cpuinfo_cycles_per_second = hz;
+   }
+-// TODO: also figure out cpuinfo_num_cpus
+ 
++  int32_t num_cpus = 0;
++  size_t size = sizeof(num_cpus);
++  if (::sysctlbyname("hw.ncpu", &num_cpus, &size, nullptr, 0) == 0 &&
++      (size == sizeof(num_cpus))) {
++    cpuinfo_num_cpus = num_cpus;
++  } else {
++    fprintf(stderr, "%s\n", strerror(errno));
++    std::exit(EXIT_FAILURE);
++  }
+ #elif defined BENCHMARK_OS_WINDOWS
+   // In NT, read MHz from the registry. If we fail to do so or we're in win9x
+   // then make a crude estimate.
diff --git a/google-benchmark/patches/patch-src_timers.cc b/google-benchmark/patches/patch-src_timers.cc
new file mode 100644
index 0000000000..9e7156eff1
--- /dev/null
+++ b/google-benchmark/patches/patch-src_timers.cc
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/timers.cc.orig	2017-11-03 17:00:29.000000000 +0000
++++ src/timers.cc
+@@ -25,7 +25,7 @@
+ #include <sys/time.h>
+ #include <sys/types.h>  // this header must be included before 'sys/sysctl.h' to avoid compilation error on FreeBSD
+ #include <unistd.h>
+-#if defined BENCHMARK_OS_FREEBSD || defined BENCHMARK_OS_MACOSX
++#if defined BENCHMARK_OS_FREEBSD || defined BENCHMARK_OS_MACOSX || defined BENCHMARK_OS_NETBSD
+ #include <sys/sysctl.h>
+ #endif
+ #if defined(BENCHMARK_OS_MACOSX)


Home | Main Index | Thread Index | Old Index