pkgsrc-WIP-changes archive

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

chromium-new: Add untested NetBSD specific functions



Module Name:	pkgsrc-wip
Committed By:	Ryo ONODERA <ryoon%NetBSD.org@localhost>
Pushed By:	ryoon
Date:		Sun Jul 17 19:10:56 2016 +0900
Changeset:	f326c93f62e585bf3b88ccf37a7b407f5175aa7a

Modified Files:
	chromium-new/distinfo
	chromium-new/patches/patch-base_process_process__iterator__netbsd.cc
	chromium-new/patches/patch-base_process_process__metrics__netbsd.cc
	chromium-new/patches/patch-base_sys__info__netbsd.cc

Log Message:
chromium-new: Add untested NetBSD specific functions

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

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

diffstat:
 chromium-new/distinfo                              |  6 +-
 ...patch-base_process_process__iterator__netbsd.cc | 48 +++++++-------
 .../patch-base_process_process__metrics__netbsd.cc | 73 ++++++++++++++++------
 .../patches/patch-base_sys__info__netbsd.cc        | 32 ++++++++--
 4 files changed, 106 insertions(+), 53 deletions(-)

diffs:
diff --git a/chromium-new/distinfo b/chromium-new/distinfo
index 1c02f89..28f3d53 100644
--- a/chromium-new/distinfo
+++ b/chromium-new/distinfo
@@ -25,16 +25,16 @@ SHA1 (patch-base_process_memory__unittest.cc) = cda374fec64d4ed8da56fd2468ce332f
 SHA1 (patch-base_process_process__info__linux.cc) = 943fdb9b1e3810d51c1a8692d60f83ba6b9d6e0e
 SHA1 (patch-base_process_process__iterator.h) = 8de7e317b4c95308ac689e2191074fc8ada3e27a
 SHA1 (patch-base_process_process__iterator__freebsd.cc) = b24cf46d4b59e9f4dd4336d9288a6ba75bf55e4f
-SHA1 (patch-base_process_process__iterator__netbsd.cc) = 3883cb0e2b8a88bd0ad14930e512928dcc844055
+SHA1 (patch-base_process_process__iterator__netbsd.cc) = c893f74e881c9f916cdd6ce641ae764d00a2c3e7
 SHA1 (patch-base_process_process__metrics.h) = 6f5b1dabf7d717527ffbe2bb03d915b2d7cc2335
 SHA1 (patch-base_process_process__metrics__freebsd.cc) = 652ce63118ef23d96fde23746d05a2d8472b09eb
-SHA1 (patch-base_process_process__metrics__netbsd.cc) = d15b5d980182e8b436f6bcf562bae2ec38a5629e
+SHA1 (patch-base_process_process__metrics__netbsd.cc) = 48e9e0b0bc5060d8b7b4d4595b53ae4cfc178c61
 SHA1 (patch-base_process_process__metrics__posix.cc) = 79d1d0c17a1044f4247b88eead9a902061ef1c3f
 SHA1 (patch-base_process_process__posix.cc) = d78ca399d2b3b8ff1eb8f221d9a191c076cf4180
 SHA1 (patch-base_security__unittest.cc) = f4d2004a5c218d428307283251824755be84c179
 SHA1 (patch-base_strings_safe__sprintf.cc) = 9b258ad5ac5bae6ee7e2ac9dcb256ba981a78df7
 SHA1 (patch-base_sys__info__freebsd.cc) = 1a6cd2157c1b0c9e747d1bc536913f177deb7738
-SHA1 (patch-base_sys__info__netbsd.cc) = 0f546a6b29855e1f6ccfe4c85d1b3a58479ed2c4
+SHA1 (patch-base_sys__info__netbsd.cc) = a739619ac8a3743177548d700726570465f148dc
 SHA1 (patch-base_sys__info__posix.cc) = 96941a91abfc6a9fce620925081a8cb67e0b37b4
 SHA1 (patch-base_test_launcher_test__launcher.cc) = 80c81da421acd2b919f636dac92171b1f3ad259e
 SHA1 (patch-base_threading_platform__thread__linux.cc) = e503ec65860c76e983a74615bc5dc79a16a32a33
diff --git a/chromium-new/patches/patch-base_process_process__iterator__netbsd.cc b/chromium-new/patches/patch-base_process_process__iterator__netbsd.cc
index f90b218..3954086 100644
--- a/chromium-new/patches/patch-base_process_process__iterator__netbsd.cc
+++ b/chromium-new/patches/patch-base_process_process__iterator__netbsd.cc
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- base/process/process_iterator_netbsd.cc.orig	2016-07-11 13:58:09.568323557 +0000
+--- base/process/process_iterator_netbsd.cc.orig	2016-07-17 08:36:13.001685522 +0000
 +++ base/process/process_iterator_netbsd.cc
 @@ -0,0 +1,146 @@
 +// Copyright (c) 2013 The Chromium Authors. All rights reserved.
@@ -35,7 +35,7 @@ $NetBSD$
 +  printf("%s\n", __PRETTY_FUNCTION__);
 +
 +  mib[0] = CTL_KERN;
-+  mib[1] = KERN_PROC;
++  mib[1] = KERN_PROC2;
 +  mib[2] = KERN_PROC_UID;
 +  mib[3] = getuid();
 +  mib[4] = sizeof(struct kinfo_proc2);
@@ -86,58 +86,58 @@ $NetBSD$
 +
 +bool ProcessIterator::CheckForNextProcess() {
 +  std::string data;
++  for (; index_of_kinfo_proc_ < kinfo_procs_.size(); ++index_of_kinfo_proc_) {
++    kinfo_proc2& kinfo = kinfo_procs_[index_of_kinfo_proc_];
 +
-+  printf("%s\n", __PRETTY_FUNCTION__);
-+
-+  for (; index_of_kinfo_proc_ < kinfo_procs_.size(); ++ index_of_kinfo_proc_) {
-+    int mib[3];
-+    size_t len;
-+    struct kinfo_proc2 kinfo = kinfo_procs_[index_of_kinfo_proc_];
-+
++    // Skip processes just awaiting collection
 +    if ((kinfo.p_pid > 0) && (kinfo.p_stat == SZOMB))
 +      continue;
 +
-+    mib[0] = CTL_KERN;
-+    mib[1] = KERN_PROC_ARGS;
-+    mib[2] = kinfo.p_pid;
++    int mib[] = { CTL_KERN, KERN_PROC_ARGS, kinfo.p_pid };
 +
-+    len = 0;
-+    if (sysctl(mib, 3, NULL, &len, NULL, 0) < 0) {
-+      LOG(ERROR) << "failed to figure out the buffer size for a command line";
++    // Find out what size buffer we need.
++    size_t data_len = 0;
++    if (sysctl(mib, arraysize(mib), NULL, &data_len, NULL, 0) < 0) {
++      DVPLOG(1) << "failed to figure out the buffer size for a commandline";
 +      continue;
 +    }
 +
-+    data.resize(len);
-+
-+    if (sysctl(mib, 3, &data[0], &len, NULL, 0) < 0) {
-+      LOG(ERROR) << "failed to fetch a commandline";
++    data.resize(data_len);
++    if (sysctl(mib, arraysize(mib), &data[0], &data_len, NULL, 0) < 0) {
++      DVPLOG(1) << "failed to fetch a commandline";
 +      continue;
 +    }
 +
++    // |data| contains all the command line parameters of the process, separated
++    // by blocks of one or more null characters. We tokenize |data| into a
++    // vector of strings using '\0' as a delimiter and populate
++    // |entry_.cmd_line_args_|.
 +    std::string delimiters;
 +    delimiters.push_back('\0');
-+    Tokenize(data, delimiters, &entry_.cmd_line_args_);
++    entry_.cmd_line_args_ = SplitString(data, delimiters, KEEP_WHITESPACE,
++                                        SPLIT_WANT_NONEMPTY);
 +
++    // |data| starts with the full executable path followed by a null character.
++    // We search for the first instance of '\0' and extract everything before it
++    // to populate |entry_.exe_file_|.
 +    size_t exec_name_end = data.find('\0');
 +    if (exec_name_end == std::string::npos) {
-+      LOG(ERROR) << "command line data didn't match expected format";
++      DLOG(ERROR) << "command line data didn't match expected format";
 +      continue;
 +    }
 +
 +    entry_.pid_ = kinfo.p_pid;
 +    entry_.ppid_ = kinfo.p_ppid;
 +    entry_.gid_ = kinfo.p__pgid;
-+
 +    size_t last_slash = data.rfind('/', exec_name_end);
 +    if (last_slash == std::string::npos)
 +      entry_.exe_file_.assign(data, 0, exec_name_end);
 +    else
 +      entry_.exe_file_.assign(data, last_slash + 1,
 +                              exec_name_end - last_slash - 1);
-+
 +    // Start w/ the next entry next time through
 +    ++index_of_kinfo_proc_;
-+
++    // Done
 +    return true;
 +  }
 +  return false;
diff --git a/chromium-new/patches/patch-base_process_process__metrics__netbsd.cc b/chromium-new/patches/patch-base_process_process__metrics__netbsd.cc
index b46c82e..77ae964 100644
--- a/chromium-new/patches/patch-base_process_process__metrics__netbsd.cc
+++ b/chromium-new/patches/patch-base_process_process__metrics__netbsd.cc
@@ -1,8 +1,8 @@
 $NetBSD$
 
---- base/process/process_metrics_netbsd.cc.orig	2016-07-17 06:54:36.941244815 +0000
+--- base/process/process_metrics_netbsd.cc.orig	2016-07-17 08:36:13.090234675 +0000
 +++ base/process/process_metrics_netbsd.cc
-@@ -0,0 +1,168 @@
+@@ -0,0 +1,201 @@
 +// Copyright (c) 2013 The Chromium Authors. All rights reserved.
 +// Use of this source code is governed by a BSD-style license that can be
 +// found in the LICENSE file.
@@ -20,6 +20,8 @@ $NetBSD$
 +#include <unistd.h> /* getpagesize() */
 +#include <fcntl.h>  /* O_RDONLY */
 +
++#include <uvm/uvm_extern.h> /* struct vmtotal */
++
 +namespace base {
 +
 +ProcessMetrics::ProcessMetrics(ProcessHandle process)
@@ -38,23 +40,29 @@ $NetBSD$
 +  struct kinfo_proc2 info;
 +  int mib[6];
 +  size_t info_size = sizeof(info);
++  int ret;
 +
 +  mib[0] = CTL_KERN;
-+  mib[1] = KERN_PROC;
++  mib[1] = KERN_PROC2;
 +  mib[2] = KERN_PROC_PID;
 +  mib[3] = process_;
 +  mib[4] = info_size;
-+  mib[5] = 400; /* XXX */
++  mib[5] = 1;
++
++  ret = sysctl(mib, 6, &info, &info_size, NULL, 0);
++  if (ret == -1) {
++    return 0;
++  }
 +
-+  if (sysctl(mib, 6, &info, &info_size, NULL, 0) < 0)
++  if (info_size == 0) {
 +    return 0;
++  }
 +
 +  return (info.p_vm_tsize + info.p_vm_dsize + info.p_vm_ssize);
 +}
 +
 +size_t ProcessMetrics::GetPeakPagefileUsage() const {
-+        printf("%s\n", __PRETTY_FUNCTION__);
-+
++  printf("%s\n", __PRETTY_FUNCTION__);
 +  return 0;
 +}
 +
@@ -62,16 +70,23 @@ $NetBSD$
 +  struct kinfo_proc2 info;
 +  int mib[6];
 +  size_t info_size = sizeof(info);
++  int ret;
 +
 +  mib[0] = CTL_KERN;
-+  mib[1] = KERN_PROC;
++  mib[1] = KERN_PROC2;
 +  mib[2] = KERN_PROC_PID;
 +  mib[3] = process_;
 +  mib[4] = info_size;
-+  mib[5] = 400; /* XXX */
++  mib[5] = 1;
++
++  ret = sysctl(mib, 6, &info, &info_size, NULL, 0);
++  if (ret == -1) {
++    return 0;
++  }
 +
-+  if (sysctl(mib, 6, &info, &info_size, NULL, 0) < 0)
++  if (info_size == 0) {
 +    return 0;
++  }
 +
 +  return info.p_vm_rssize * getpagesize();
 +}
@@ -109,16 +124,31 @@ $NetBSD$
 +
 +double ProcessMetrics::GetCPUUsage() {
 +  struct kinfo_proc2 info;
-+  int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, process_ };
-+  size_t length = sizeof(info);
++  int mib[6];
++  size_t info_size = sizeof(info);
++  int ret;
++
++  mib[0] = CTL_KERN;
++  mib[1] = KERN_PROC2;
++  mib[2] = KERN_PROC_PID;
++  mib[3] = process_;
++  mib[4] = info_size;
++  mib[5] = 1;
++
++  ret = sysctl(mib, 6, &info, &info_size, NULL, 0);
++  if (ret == -1) {
++    return 0;
++  }
 +
-+  if (sysctl(mib, arraysize(mib), &info, &length, NULL, 0) < 0)
++  if (info_size == 0) {
 +    return 0;
++  }
 +
 +  return (info.p_pctcpu / FSCALE) * 100.0;
 +}
 +
 +bool ProcessMetrics::GetIOCounters(IoCounters* io_counters) const {
++/* ryoon: should be written */
 +  return false;
 +}
 +
@@ -127,14 +157,17 @@ $NetBSD$
 +  struct vmtotal vmtotal;
 +  unsigned long mem_total, mem_free, mem_inactive;
 +  size_t len = sizeof(vmtotal);
++  int ret;
 +
 +  printf("%s\n", __PRETTY_FUNCTION__);
 +
 +  mib[0] = CTL_VM;
 +  mib[1] = VM_METER;
 +
-+  if (sysctl(mib, 2, &vmtotal, &len, NULL, 0) < 0)
++  ret = sysctl(mib, 2, &vmtotal, &len, NULL, 0);
++  if (ret == -1) {
 +    return 0;
++  }
 +
 +  mem_total = vmtotal.t_vm;
 +  mem_free = vmtotal.t_free;
@@ -148,26 +181,26 @@ $NetBSD$
 +int GetNumberOfThreads(ProcessHandle process) {
 +  int ret;
 +  int mib[6];
-+  size_t size = sizeof(struct kinfo_proc2);
-+  struct kinfo_proc2 kproc;
++  struct kinfo_proc2 info;
++  size_t info_size = sizeof(info);
 +
 +  mib[0] = CTL_KERN;
 +  mib[1] = KERN_PROC2;
 +  mib[2] = KERN_PROC_PID;
 +  mib[3] = process;
-+  mib[4] = size;
++  mib[4] = info_size;
 +  mib[5] = 1;
 +
-+  ret = sysctl((int *)mib, 6, &kproc, &size, NULL, 0);
++  ret = sysctl(mib, 6, &info, &info_size, NULL, 0);
 +  if (ret == -1) {
 +    return 0;
 +  }
 +
-+  if (size == 0) {
++  if (info_size == 0) {
 +    return 0;
 +  }
 +
-+  return kproc.p_nlwps;
++  return info.p_nlwps;
 +}
 +
 +}  // namespace base
diff --git a/chromium-new/patches/patch-base_sys__info__netbsd.cc b/chromium-new/patches/patch-base_sys__info__netbsd.cc
index 686f5f5..2e68a69 100644
--- a/chromium-new/patches/patch-base_sys__info__netbsd.cc
+++ b/chromium-new/patches/patch-base_sys__info__netbsd.cc
@@ -1,8 +1,8 @@
 $NetBSD$
 
---- base/sys_info_netbsd.cc.orig	2016-07-11 14:49:52.785554196 +0000
+--- base/sys_info_netbsd.cc.orig	2016-07-17 08:36:13.252201679 +0000
 +++ base/sys_info_netbsd.cc
-@@ -0,0 +1,78 @@
+@@ -0,0 +1,98 @@
 +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
 +// Use of this source code is governed by a BSD-style license that can be
 +// found in the LICENSE file.
@@ -53,18 +53,38 @@ $NetBSD$
 +
 +// static
 +int64_t SysInfo::AmountOfAvailablePhysicalMemory() {
-+  return AmountOfMemory(_SC_AVPHYS_PAGES);
++  int ret;
++  int mib[2];
++  int64_t memsize;
++  unsigned long size = sizeof(memsize);
++
++  mib[0] = CTL_HW;
++  mib[1] = HW_PHYSMEM64;
++
++  ret = sysctl(mib, 2, &memsize, &size, NULL, 0);
++  if (ret == -1) {
++    return 0;
++  }
++
++  return memsize;
 +}
 +
 +// static
 +uint64_t SysInfo::MaxSharedMemorySize() {
-+  int mib[] = { CTL_KERN, KERN_SHMINFO, KERN_SHMINFO_SHMMAX };
++  int mib[3];
 +  size_t limit;
 +  size_t size = sizeof(limit);
-+  if (sysctl(mib, arraysize(mib), &limit, &size, NULL, 0) < 0) {
-+    NOTREACHED();
++  int ret;
++
++  mib[0] = CTL_KERN;
++  mib[1] = KERN_SYSVIPC;
++  mib[2] = KERN_SYSVIPC_SHMMAX;
++
++  ret = sysctl(mib, 3, &limit, &size, NULL, 0);
++  if (ret == -1) {
 +    return 0;
 +  }
++
 +  return static_cast<uint64_t>(limit);
 +}
 +


Home | Main Index | Thread Index | Old Index