pkgsrc-WIP-changes archive

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

nats-server: Implement NetBSD-specific bits



Module Name:	pkgsrc-wip
Committed By:	Juraj Lutter <otis%NetBSD.org@localhost>
Pushed By:	otis
Date:		Tue Oct 13 00:03:24 2020 +0200
Changeset:	883b8c2551abaa00cec952b8ce81066cdc133ae5

Modified Files:
	nats-server/distinfo
Added Files:
	nats-server/patches/patch-server_pse_pse__netbsd.go

Log Message:
nats-server: Implement NetBSD-specific bits

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

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

diffstat:
 nats-server/distinfo                               |  1 +
 .../patches/patch-server_pse_pse__netbsd.go        | 95 ++++++++++++++++++++++
 2 files changed, 96 insertions(+)

diffs:
diff --git a/nats-server/distinfo b/nats-server/distinfo
index ee02bf550a..fe8936a7e8 100644
--- a/nats-server/distinfo
+++ b/nats-server/distinfo
@@ -164,3 +164,4 @@ SHA1 (nats-server-2.1.8.tar.gz) = d24f3ef4e681dacb553bc2d0f83f12765c4a0267
 RMD160 (nats-server-2.1.8.tar.gz) = a7420c674018189dec8d878d7c9f11b5d538679f
 SHA512 (nats-server-2.1.8.tar.gz) = 2614a1fdb0d34ab8ca557f9282c92ddea5ab5cc53ee25f866b24941c133bb91f81983646c19929f7fdb498feeabab100e43cd65441497fd64eab234d48262706
 Size (nats-server-2.1.8.tar.gz) = 967790 bytes
+SHA1 (patch-server_pse_pse__netbsd.go) = 9f69352a0a6f976e51488d4693bc7701dd551506
diff --git a/nats-server/patches/patch-server_pse_pse__netbsd.go b/nats-server/patches/patch-server_pse_pse__netbsd.go
new file mode 100644
index 0000000000..c4cae82459
--- /dev/null
+++ b/nats-server/patches/patch-server_pse_pse__netbsd.go
@@ -0,0 +1,95 @@
+$NetBSD$
+
+Implement NetBSD specific functions.
+
+--- server/pse/pse_netbsd.go.orig	2020-10-12 21:03:54.012750981 +0000
++++ server/pse/pse_netbsd.go
+@@ -0,0 +1,88 @@
++// +build netbsd
++// Copyright 2015-2018 The NATS Authors
++// Licensed under the Apache License, Version 2.0 (the "License");
++// you may not use this file except in compliance with the License.
++// You may obtain a copy of the License at
++//
++// http://www.apache.org/licenses/LICENSE-2.0
++//
++// Unless required by applicable law or agreed to in writing, software
++// distributed under the License is distributed on an "AS IS" BASIS,
++// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++// See the License for the specific language governing permissions and
++// limitations under the License.
++//
++// NetBSD support (c) 2020 Juraj Lutter <otis%NetBSD.org@localhost>
++
++package pse
++
++/*
++#include <sys/types.h>
++#include <sys/sysctl.h>
++#include <errno.h>
++#include <stddef.h>
++#include <unistd.h>
++
++long pagetok(long size)
++{
++    int pageshift, pagesize;
++
++    pagesize = getpagesize();
++    pageshift = 0;
++
++    while (pagesize > 1) {
++        pageshift++;
++        pagesize >>= 1;
++    }
++
++    return (size << pageshift);
++}
++
++int getusage(double *pcpu, unsigned int *rss, unsigned int *vss)
++{
++    int mib[6], ret;
++    size_t len;
++    struct kinfo_proc2 kp;
++
++    mib[0] = CTL_KERN;
++    mib[1] = KERN_PROC2;
++    mib[2] = KERN_PROC_PID;
++    mib[3] = getpid();
++    mib[4] = sizeof(kp);
++    mib[5] = 1;
++
++    len = sizeof(kp);
++    ret = sysctl(mib, 6, &kp, &len, NULL, 0);
++    if (ret != 0) {
++        return (errno);
++    }
++
++    *rss = pagetok(kp.p_vm_rssize);
++    *vss = kp.p_vm_vsize;
++    *pcpu = kp.p_pctcpu;
++
++    return 0;
++}
++
++*/
++import "C"
++
++import (
++	"syscall"
++)
++
++// This is a placeholder for now.
++func ProcUsage(pcpu *float64, rss, vss *int64) error {
++	var r, v C.uint
++	var c C.double
++
++	if ret := C.getusage(&c, &r, &v); ret != 0 {
++		return syscall.Errno(ret)
++	}
++
++	*pcpu = float64(c)
++	*rss = int64(r)
++	*vss = int64(v)
++
++	return nil
++}


Home | Main Index | Thread Index | Old Index