Module Name:    src
Committed By:   christos
Date:           Wed Oct  7 00:34:37 UTC 2015

Modified Files:
        src/external/cddl/osnet/dist/lib/libdtrace/common: dt_open.c

Log Message:
Adjust for NetBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 \
    src/external/cddl/osnet/dist/lib/libdtrace/common/dt_open.c

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

Modified files:

Index: src/external/cddl/osnet/dist/lib/libdtrace/common/dt_open.c
diff -u src/external/cddl/osnet/dist/lib/libdtrace/common/dt_open.c:1.7 src/external/cddl/osnet/dist/lib/libdtrace/common/dt_open.c:1.8
--- src/external/cddl/osnet/dist/lib/libdtrace/common/dt_open.c:1.7	Mon Oct  5 13:47:37 2015
+++ src/external/cddl/osnet/dist/lib/libdtrace/common/dt_open.c	Tue Oct  6 20:34:37 2015
@@ -1309,9 +1309,23 @@ alloc:
 	char *p;
 	size_t len = sizeof(bootfile);
 
+#ifdef __FreeBSD__
+#define DEFKERNEL	"kernel"
+#define BOOTFILE	"kern.bootfile"
+#define THREAD		"struct thread"
+#define MUTEX		"struct mtx"
+#define RWLOCK		"struct rwlock"
+#endif
+#ifdef __NetBSD__
+#define DEFKERNEL	"netbsd"
+#define BOOTFILE	"machdep.booted_kernel"
+#define THREAD		"struct lwp"
+#define MUTEX		"struct kmutex"
+#define RWLOCK		"struct krwlock"
+#endif
 	/* This call shouldn't fail, but use a default just in case. */
-	if (sysctlbyname("kern.bootfile", bootfile, &len, NULL, 0) != 0)
-		strlcpy(bootfile, "kernel", sizeof(bootfile));
+	if (sysctlbyname(BOOTFILE, bootfile, &len, NULL, 0) != 0)
+		strlcpy(bootfile, DEFKERNEL, sizeof(bootfile));
 
 	if ((p = strrchr(bootfile, '/')) != NULL)
 		p++;
@@ -1321,10 +1335,11 @@ alloc:
 	/*
 	 * Format the global variables based on the kernel module name.
 	 */
-	snprintf(curthread_str, sizeof(curthread_str), "%s`struct thread *",p);
-	snprintf(intmtx_str, sizeof(intmtx_str), "int(%s`struct mtx *)",p);
-	snprintf(threadmtx_str, sizeof(threadmtx_str), "struct thread *(%s`struct mtx *)",p);
-	snprintf(rwlock_str, sizeof(rwlock_str), "int(%s`struct rwlock *)",p);
+	snprintf(curthread_str, sizeof(curthread_str), "%s`%s *", p, THREAD);
+	snprintf(intmtx_str, sizeof(intmtx_str), "int(%s`%s *)", p, MUTEX);
+	snprintf(threadmtx_str, sizeof(threadmtx_str), "%s *(%s`%s *)",
+	    THREAD, p, MUTEX);
+	snprintf(rwlock_str, sizeof(rwlock_str), "int(%s`%s *)", p, RWLOCK);
 	snprintf(sxlock_str, sizeof(sxlock_str), "int(%s`struct sxlock *)",p);
 	}
 #endif

Reply via email to