Apply NetBSD changes to DTrace.

Ok with core@.
This commit is contained in:
darran 2010-02-21 01:46:32 +00:00
parent 19f4d68d7a
commit 01c9547e57
161 changed files with 3137 additions and 1456 deletions

6
external/cddl/osnet/Makefile.inc vendored Normal file
View File

@ -0,0 +1,6 @@
# $FreeBSD: src/cddl/Makefile.inc,v 1.6.2.1 2009/08/03 08:13:06 kensmith Exp $
OSNETDIR= ${NETBSDSRCDIR}/external/cddl/osnet
OPENSOLARIS_USR_DISTDIR=${OSNETDIR}/dist
OPENSOLARIS_SYS_DISTDIR=${OSNETDIR}/dist

View File

@ -1,3 +1,5 @@
/* $NetBSD: cyclic_machdep.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*-
* Copyright 2007 John Birrell <jb@FreeBSD.org>
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: cyclic.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*
* CDDL HEADER START
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: cyclic_test.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*-
* Copyright 2007 John Birrell <jb@FreeBSD.org>
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: cyclic_machdep.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*-
* Copyright 2006-2008 John Birrell <jb@FreeBSD.org>
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: dtmalloc.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*
* CDDL HEADER START
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: dis_tables.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*
* CDDL HEADER START
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: dis_tables.h,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*
* CDDL HEADER START
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: dtrace_asm.S,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*
* CDDL HEADER START
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: dtrace_isa.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*
* CDDL HEADER START
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: dtrace_subr.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*
* CDDL HEADER START
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: instr_size.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*
* CDDL HEADER START
*

View File

@ -1,3 +1,4 @@
/* $NetBSD: dtrace_anon.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*
* CDDL HEADER START
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: dtrace_cddl.h,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*
* CDDL HEADER START
*
@ -84,25 +86,25 @@ typedef struct kdtrace_thread {
* that the separation on FreeBSD is a licensing constraint designed to
* keep the GENERIC kernel BSD licensed.
*/
#define t_dtrace_vtime td_dtrace->td_dtrace_vtime
#define t_dtrace_start td_dtrace->td_dtrace_start
#define t_dtrace_stop td_dtrace->td_dtrace_stop
#define t_dtrace_sig td_dtrace->td_dtrace_sig
#define t_predcache td_dtrace->td_predcache
#define t_dtrace_vtime l_dtrace->td_dtrace_vtime
#define t_dtrace_start l_dtrace->td_dtrace_start
#define t_dtrace_stop l_dtrace->td_dtrace_stop
#define t_dtrace_sig l_dtrace->td_dtrace_sig
#define t_predcache l_dtrace->td_predcache
#define p_dtrace_helpers p_dtrace->p_dtrace_helpers
/*
* Definitions for fields in struct proc which are named differntly in FreeBSD.
*/
#define p_cred p_ucred
//#define p_cred p_ucred
#define p_parent p_pptr
/*
* Definitions for fields in struct thread which are named differntly in FreeBSD.
* Definitions for fields in struct thread which are named differntly in NetBSD.
*/
#define t_procp td_proc
#define t_tid td_tid
#define t_did td_tid
#define t_procp l_proc
#define t_tid l_lid
#define t_did l_lid
int priv_policy(const cred_t *, int, boolean_t, int, const char *);

View File

@ -1,3 +1,5 @@
/* $NetBSD: dtrace_clone.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*-
* Copyright (C) 2006 John Birrell <jb@freebsd.org>.
* All rights reserved.

View File

@ -1,3 +1,5 @@
/* $NetBSD: dtrace_debug.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*-
* Copyright (C) 2008 John Birrell <jb@freebsd.org>.
* All rights reserved.
@ -29,6 +31,9 @@
*
*/
static char const hex2ascii_data[] = "0123456789abcdefghijklmnopqrstuvwxyz";
#define hex2ascii(hex) (hex2ascii_data[hex])
#ifdef DEBUG
#if defined(__amd64__)
@ -82,11 +87,11 @@ struct dtrace_debug_data {
char *first;
char *last;
char *next;
} dtrace_debug_data[MAXCPU];
} dtrace_debug_data[MAXCPUS];
static char dtrace_debug_bufr[DTRACE_DEBUG_BUFR_SIZE];
static volatile u_long dtrace_debug_flag[MAXCPU];
static volatile u_long dtrace_debug_flag[MAXCPUS];
static void
dtrace_debug_lock(int cpu)
@ -107,12 +112,11 @@ dtrace_debug_init(void *dummy)
{
int i;
struct dtrace_debug_data *d;
CPU_INFO_ITERATOR cpuind;
struct cpu_info *cinfo;
for (i = 0; i <= mp_maxid; i++) {
if (pcpu_find(i) == NULL)
continue;
d = &dtrace_debug_data[i];
for (CPU_INFO_FOREACH(cpuind, cinfo)) {
d = &dtrace_debug_data[cpu_index(cinfo)];
if (d->first == NULL) {
d->first = d->bufr;
@ -123,24 +127,25 @@ dtrace_debug_init(void *dummy)
}
}
SYSINIT(dtrace_debug_init, SI_SUB_KDTRACE, SI_ORDER_ANY, dtrace_debug_init, NULL);
SYSINIT(dtrace_debug_smpinit, SI_SUB_SMP, SI_ORDER_ANY, dtrace_debug_init, NULL);
//SYSINIT(dtrace_debug_init, SI_SUB_KDTRACE, SI_ORDER_ANY, dtrace_debug_init, NULL);
//SYSINIT(dtrace_debug_smpinit, SI_SUB_SMP, SI_ORDER_ANY, dtrace_debug_init, NULL);
static void
dtrace_debug_output(void)
{
char *p;
int i;
struct dtrace_debug_data *d;
uintptr_t count;
CPU_INFO_ITERATOR cpuind;
struct cpu_info *cinfo;
cpuid_t cpuid;
for (i = 0; i <= mp_maxid; i++) {
if (pcpu_find(i) == NULL)
continue;
for (CPU_INFO_FOREACH(cpuind, cinfo)) {
cpuid = cpu_index(cinfo);
dtrace_debug_lock(i);
dtrace_debug_lock(cpuid);
d = &dtrace_debug_data[i];
d = &dtrace_debug_data[cpuid];
count = 0;
@ -168,7 +173,7 @@ dtrace_debug_output(void)
d->first = d->bufr;
d->next = d->bufr;
dtrace_debug_unlock(i);
dtrace_debug_unlock(cpuid);
if (count > 0) {
char *last = dtrace_debug_bufr + count;
@ -199,7 +204,7 @@ dtrace_debug_output(void)
static __inline void
dtrace_debug__putc(char c)
{
struct dtrace_debug_data *d = &dtrace_debug_data[curcpu];
struct dtrace_debug_data *d = &dtrace_debug_data[cpu_number()];
*d->next++ = c;
@ -218,24 +223,24 @@ dtrace_debug__putc(char c)
static void __used
dtrace_debug_putc(char c)
{
dtrace_debug_lock(curcpu);
dtrace_debug_lock(cpu_number());
dtrace_debug__putc(c);
dtrace_debug_unlock(curcpu);
dtrace_debug_unlock(cpu_number());
}
static void __used
dtrace_debug_puts(const char *s)
{
dtrace_debug_lock(curcpu);
dtrace_debug_lock(cpu_number());
while (*s != '\0')
dtrace_debug__putc(*s++);
dtrace_debug__putc('\0');
dtrace_debug_unlock(curcpu);
dtrace_debug_unlock(cpu_number());
}
/*
@ -576,7 +581,7 @@ dtrace_debug_printf(const char *fmt, ...)
{
va_list ap;
dtrace_debug_lock(curcpu);
dtrace_debug_lock(cpu_number());
va_start(ap, fmt);
@ -584,7 +589,7 @@ dtrace_debug_printf(const char *fmt, ...)
va_end(ap);
dtrace_debug_unlock(curcpu);
dtrace_debug_unlock(cpu_number());
}
#else

View File

@ -1,3 +1,5 @@
/* $NetBSD: dtrace_hacks.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/* $FreeBSD: src/sys/cddl/dev/dtrace/dtrace_hacks.c,v 1.1.4.1 2009/08/03 08:13:06 kensmith Exp $ */
/* XXX Hacks.... */
@ -6,6 +8,8 @@ dtrace_cacheid_t dtrace_predcache_id;
int panic_quiesce;
char panic_stack[PANICSTKSIZE];
cpu_core_t cpu_core[MAXCPUS];
boolean_t
priv_policy_only(const cred_t *a, int b, boolean_t c)
{

View File

@ -1,3 +1,5 @@
/* $NetBSD: dtrace_ioctl.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*
* CDDL HEADER START
*
@ -22,23 +24,18 @@
*
*/
static int dtrace_verbose_ioctl;
SYSCTL_INT(_debug_dtrace, OID_AUTO, verbose_ioctl, CTLFLAG_RW, &dtrace_verbose_ioctl, 0, "");
static int dtrace_verbose_ioctl=0;
//SYSCTL_INT(_debug_dtrace, OID_AUTO, verbose_ioctl, CTLFLAG_RW, &dtrace_verbose_ioctl, 0, "");
#define DTRACE_IOCTL_PRINTF(fmt, ...) if (dtrace_verbose_ioctl) printf(fmt, ## __VA_ARGS__ )
/* ARGSUSED */
static int
dtrace_ioctl(struct cdev *dev, u_long cmd, caddr_t addr,
int flags __unused, struct thread *td)
dtrace_ioctl(struct file *fp, u_long cmd, void *addr)
{
#if __FreeBSD_version < 800039
dtrace_state_t *state = dev->si_drv1;
#else
dtrace_state_t *state;
devfs_get_cdevpriv((void **) &state);
#endif
dtrace_state_t *state = (dtrace_state_t *)fp->f_data;
int error = 0;
if (state == NULL)
return (EINVAL);
@ -168,11 +165,9 @@ dtrace_ioctl(struct cdev *dev, u_long cmd, caddr_t addr,
__func__,__LINE__,
cmd == DTRACEIOC_AGGSNAP ?
"DTRACEIOC_AGGSNAP":"DTRACEIOC_BUFSNAP",
curcpu, desc.dtbd_cpu);
cpu_number(), desc.dtbd_cpu);
if (desc.dtbd_cpu < 0 || desc.dtbd_cpu >= NCPU)
return (ENOENT);
if (pcpu_find(desc.dtbd_cpu) == NULL)
if (desc.dtbd_cpu < 0 || desc.dtbd_cpu >= ncpu)
return (ENOENT);
mutex_enter(&dtrace_lock);
@ -366,7 +361,7 @@ dtrace_ioctl(struct cdev *dev, u_long cmd, caddr_t addr,
return (EBUSY);
}
if (dtrace_dof_slurp(dof, vstate, td->td_ucred, &enab, 0, B_TRUE) != 0) {
if (dtrace_dof_slurp(dof, vstate, curlwp->l_cred, &enab, 0, B_TRUE) != 0) {
mutex_exit(&dtrace_lock);
mutex_exit(&cpu_lock);
dtrace_dof_destroy(dof);
@ -610,7 +605,7 @@ dtrace_ioctl(struct cdev *dev, u_long cmd, caddr_t addr,
pkey.dtpk_id = DTRACE_IDNONE;
}
dtrace_cred2priv(td->td_ucred, &priv, &uid, &zoneid);
dtrace_cred2priv(curlwp->l_cred, &priv, &uid, &zoneid);
mutex_enter(&dtrace_lock);
@ -696,8 +691,10 @@ dtrace_ioctl(struct cdev *dev, u_long cmd, caddr_t addr,
case DTRACEIOC_STATUS: {
dtrace_status_t *stat = (dtrace_status_t *) addr;
dtrace_dstate_t *dstate;
int i, j;
int j;
uint64_t nerrs;
CPU_INFO_ITERATOR cpuind;
struct cpu_info *cinfo;
DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_STATUS\n",__func__,__LINE__);
@ -725,28 +722,25 @@ dtrace_ioctl(struct cdev *dev, u_long cmd, caddr_t addr,
nerrs = state->dts_errors;
dstate = &state->dts_vstate.dtvs_dynvars;
for (i = 0; i < NCPU; i++) {
#if !defined(sun)
if (pcpu_find(i) == NULL)
continue;
#endif
dtrace_dstate_percpu_t *dcpu = &dstate->dtds_percpu[i];
for (CPU_INFO_FOREACH(cpuind, cinfo)) {
int ci = cpu_index(cinfo);
dtrace_dstate_percpu_t *dcpu = &dstate->dtds_percpu[ci];
stat->dtst_dyndrops += dcpu->dtdsc_drops;
stat->dtst_dyndrops_dirty += dcpu->dtdsc_dirty_drops;
stat->dtst_dyndrops_rinsing += dcpu->dtdsc_rinsing_drops;
if (state->dts_buffer[i].dtb_flags & DTRACEBUF_FULL)
if (state->dts_buffer[ci].dtb_flags & DTRACEBUF_FULL)
stat->dtst_filled++;
nerrs += state->dts_buffer[i].dtb_errors;
nerrs += state->dts_buffer[ci].dtb_errors;
for (j = 0; j < state->dts_nspeculations; j++) {
dtrace_speculation_t *spec;
dtrace_buffer_t *buf;
spec = &state->dts_speculations[j];
buf = &spec->dtsp_buffer[i];
buf = &spec->dtsp_buffer[ci];
stat->dtst_specdrops += buf->dtb_xamot_drops;
}
}

View File

@ -1,3 +1,5 @@
/* $NetBSD: dtrace_load.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*
* CDDL HEADER START
*
@ -22,30 +24,25 @@
*
*/
static void
dtrace_ap_start(void *dummy)
{
int i;
static void dtrace_debug_init(void *);
static void dtrace_anon_init(void *dummy);
void dtrace_gethrtime_init(void *);
mutex_enter(&cpu_lock);
int dtrace_helptrace_size=0;
/* Setup the rest of the CPUs. */
for (i = 1; i <= mp_maxid; i++) {
if (pcpu_find(i) == NULL)
continue;
(void) dtrace_cpu_setup(CPU_CONFIG, i);
}
mutex_exit(&cpu_lock);
}
SYSINIT(dtrace_ap_start, SI_SUB_SMP, SI_ORDER_ANY, dtrace_ap_start, NULL);
#ifndef mutex_init
#define mutex_init(a, b, c, d) mutex_init(a, c, IPL_NONE)
#endif
static void
dtrace_load(void *dummy)
{
dtrace_provider_id_t id;
CPU_INFO_ITERATOR cpuind;
struct cpu_info *cinfo;
dtrace_debug_init(NULL);
dtrace_gethrtime_init(NULL);
/* Hook into the trap handler. */
dtrace_trap_func = dtrace_trap;
@ -81,7 +78,8 @@ dtrace_load(void *dummy)
ASSERT(MUTEX_HELD(&cpu_lock));
dtrace_arena = new_unrhdr(1, INT_MAX, &dtrace_unr_mtx);
dtrace_arena = vmem_create("dtrace", 1, INT_MAX, 1,
NULL, NULL, NULL, 0, VM_SLEEP, IPL_NONE);
dtrace_state_cache = kmem_cache_create("dtrace_state_cache",
sizeof (dtrace_dstate_percpu_t) * NCPU, DTRACE_STATE_ALIGN,
@ -142,6 +140,7 @@ dtrace_load(void *dummy)
dtrace_helptrace_buffer =
kmem_zalloc(dtrace_helptrace_bufsize, KM_SLEEP);
dtrace_helptrace_next = 0;
dtrace_helptrace_size = dtrace_helptrace_bufsize;
}
mutex_exit(&dtrace_lock);
@ -149,18 +148,15 @@ dtrace_load(void *dummy)
mutex_enter(&cpu_lock);
/* Setup the boot CPU */
(void) dtrace_cpu_setup(CPU_CONFIG, 0);
/* Setup the CPUs */
for (CPU_INFO_FOREACH(cpuind, cinfo)) {
(void) dtrace_cpu_setup(CPU_CONFIG, cpu_index(cinfo));
}
mutex_exit(&cpu_lock);
#if __FreeBSD_version < 800039
/* Enable device cloning. */
clone_setup(&dtrace_clones);
/* Setup device cloning events. */
eh_tag = EVENTHANDLER_REGISTER(dev_clone, dtrace_clone, 0, 1000);
#else
dtrace_anon_init(NULL);
#if 0
dtrace_dev = make_dev(&dtrace_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "dtrace/dtrace");
#endif

View File

@ -1,3 +1,5 @@
/* $NetBSD: dtrace_modevent.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*
* CDDL HEADER START
*
@ -24,24 +26,20 @@
/* ARGSUSED */
static int
dtrace_modevent(module_t mod __unused, int type, void *data __unused)
dtrace_modcmd(modcmd_t cmd, void *data)
{
int bmajor = -1, cmajor = -1;
int error = 0;
switch (type) {
case MOD_LOAD:
break;
case MOD_UNLOAD:
break;
case MOD_SHUTDOWN:
break;
switch (cmd) {
case MODULE_CMD_INIT:
dtrace_load(NULL);
return devsw_attach("dtrace", NULL, &bmajor,
&dtrace_cdevsw, &cmajor);
case MODULE_CMD_FINI:
dtrace_unload();
return devsw_detach(NULL, &dtrace_cdevsw);
default:
error = EOPNOTSUPP;
break;
return ENOTTY;
}
return (error);
}

View File

@ -1,3 +1,5 @@
/* $NetBSD: dtrace_sysctl.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*
* CDDL HEADER START
*
@ -23,9 +25,12 @@
*/
int dtrace_debug = 0;
#if 0
TUNABLE_INT("debug.dtrace.debug", &dtrace_debug);
SYSCTL_INT(_debug_dtrace, OID_AUTO, debug, CTLFLAG_RW, &dtrace_debug, 0, "");
#endif
#if 0 /* XXX TBD sysctl */
/* Report registered DTrace providers. */
static int
sysctl_dtrace_providers(SYSCTL_HANDLER_ARGS)
@ -79,4 +84,4 @@ sysctl_dtrace_providers(SYSCTL_HANDLER_ARGS)
SYSCTL_PROC(_debug_dtrace, OID_AUTO, providers, CTLTYPE_STRING | CTLFLAG_RD,
0, 0, sysctl_dtrace_providers, "A", "");
#endif

View File

@ -1,3 +1,5 @@
/* $NetBSD: dtrace_test.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*-
* Copyright 2008 John Birrell <jb@FreeBSD.org>
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: dtrace_unload.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*
* CDDL HEADER START
*
@ -22,29 +24,15 @@
*
*/
extern int dtrace_probes_size;
extern int dtrace_helptrace_size;
static int
dtrace_unload()
{
dtrace_state_t *state;
int error = 0;
#if __FreeBSD_version < 800039
/*
* Check if there is still an event handler callback
* registered.
*/
if (eh_tag != 0) {
/* De-register the device cloning event handler. */
EVENTHANDLER_DEREGISTER(dev_clone, eh_tag);
eh_tag = 0;
/* Stop device cloning. */
clone_cleanup(&dtrace_clones);
}
#else
destroy_dev(dtrace_dev);
#endif
mutex_enter(&dtrace_provider_lock);
mutex_enter(&dtrace_lock);
mutex_enter(&cpu_lock);
@ -82,12 +70,12 @@ dtrace_unload()
mutex_exit(&cpu_lock);
if (dtrace_helptrace_enabled) {
kmem_free(dtrace_helptrace_buffer, 0);
kmem_free(dtrace_helptrace_buffer, dtrace_helptrace_size);
dtrace_helptrace_buffer = NULL;
}
if (dtrace_probes != NULL) {
kmem_free(dtrace_probes, 0);
kmem_free(dtrace_probes, dtrace_probes_size);
dtrace_probes = NULL;
dtrace_nprobes = 0;
}
@ -101,7 +89,7 @@ dtrace_unload()
kmem_cache_destroy(dtrace_state_cache);
delete_unrhdr(dtrace_arena);
vmem_destroy(dtrace_arena);
if (dtrace_toxrange != NULL) {
kmem_free(dtrace_toxrange, 0);

View File

@ -1,3 +1,5 @@
/* $NetBSD: dtrace_vtime.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*
* CDDL HEADER START
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: dis_tables.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*
* CDDL HEADER START
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: dis_tables.h,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*
* CDDL HEADER START
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: dtrace_asm.S,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*
* CDDL HEADER START
*
@ -28,14 +30,10 @@
#define _ASM
#include <machine/asmacros.h>
#include <sys/cpuvar_defs.h>
#include <sys/dtrace.h>
#include <machine/asm.h>
#include "assym.s"
.globl calltrap
.type calltrap,@function
ENTRY(dtrace_invop_start)
pushl %eax /* push %eax -- may be return value */
@ -56,7 +54,7 @@
* those values.
*/
addl $12, %esp
ALTENTRY(dtrace_invop_callsite)
// ALTENTRY(dtrace_invop_callsite)
cmpl $DTRACE_INVOP_PUSHL_EBP, %eax
je invop_push
cmpl $DTRACE_INVOP_POPL_EBP, %eax
@ -172,7 +170,19 @@ uint32_t dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new)
*/
ENTRY(dtrace_cas32)
ALTENTRY(dtrace_casptr)
movl 4(%esp), %edx
movl 8(%esp), %eax
movl 12(%esp), %ecx
lock
cmpxchgl %ecx, (%edx)
ret
END(dtrace_cas32)
/*
uint32_t dtrace_casptr(uint32_t *target, uint32_t cmp, uint32_t new)
*/
ENTRY(dtrace_casptr)
movl 4(%esp), %edx
movl 8(%esp), %eax
movl 12(%esp), %ecx
@ -180,7 +190,7 @@ uint32_t dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new)
cmpxchgl %ecx, (%edx)
ret
END(dtrace_casptr)
END(dtrace_cas32)
/*
uintptr_t dtrace_caller(int aframes)

View File

@ -1,3 +1,5 @@
/* $NetBSD: dtrace_isa.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*
* CDDL HEADER START
*
@ -30,22 +32,28 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/stack.h>
#include <sys/pcpu.h>
//#include <sys/pcpu.h>
#include <machine/md_var.h>
#include <machine/stack.h>
//#include <machine/md_var.h>
//#include <machine/stack.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/pmap.h>
//#include <vm/vm.h>
#include <machine/vmparam.h>
#include <machine/pmap.h>
extern uintptr_t kernbase;
uintptr_t kernelbase = (uintptr_t) &kernbase;
uintptr_t kernelbase = (uintptr_t)KERNBASE;
#define INKERNEL(va) (((vm_offset_t)(va)) >= USRSTACK && \
((vm_offset_t)(va)) < VM_MAX_KERNEL_ADDRESS)
struct i386_frame {
struct i386_frame *f_frame;
int f_retaddr;
int f_arg0;
};
typedef unsigned long vm_offset_t;
uint8_t dtrace_fuword8_nocheck(void *);
uint16_t dtrace_fuword16_nocheck(void *);
uint32_t dtrace_fuword32_nocheck(void *);
@ -59,7 +67,11 @@ dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, int aframes,
register_t ebp;
struct i386_frame *frame;
vm_offset_t callpc;
pc_t caller = (pc_t) solaris_cpu[curcpu].cpu_dtrace_caller;
#if 0 /* XXX TBD needs solaris_cpu (for fbt) */
pc_t caller = (pc_t) solaris_cpu[cpu_number()].cpu_dtrace_caller;
#else
pc_t caller = (pc_t) 0;
#endif
if (intrpc != 0)
pcstack[depth++] = (pc_t) intrpc;
@ -90,7 +102,7 @@ dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, int aframes,
if (frame->f_frame <= frame ||
(vm_offset_t)frame->f_frame >=
(vm_offset_t)ebp + KSTACK_PAGES * PAGE_SIZE)
(vm_offset_t)ebp + KSTACK_SIZE)
break;
frame = frame->f_frame;
}
@ -109,7 +121,7 @@ dtrace_getustack_common(uint64_t *pcstack, int pcstack_limit, uintptr_t pc,
proc_t *p = curproc;
uintptr_t oldcontext = lwp->lwp_oldcontext;
volatile uint16_t *flags =
(volatile uint16_t *)&cpu_core[curcpu].cpuc_dtrace_flags;
(volatile uint16_t *)&cpu_core[cpu_number()].cpuc_dtrace_flags;
size_t s1, s2;
int ret = 0;
@ -186,7 +198,7 @@ dtrace_getupcstack(uint64_t *pcstack, int pcstack_limit)
struct regs *rp;
uintptr_t pc, sp;
volatile uint16_t *flags =
(volatile uint16_t *)&cpu_core[curcpu].cpuc_dtrace_flags;
(volatile uint16_t *)&cpu_core[cpu_number()].cpuc_dtrace_flags;
int n;
if (*flags & CPU_DTRACE_FAULT)
@ -247,7 +259,7 @@ dtrace_getufpstack(uint64_t *pcstack, uint64_t *fpstack, int pcstack_limit)
struct regs *rp;
uintptr_t pc, sp, oldcontext;
volatile uint16_t *flags =
(volatile uint16_t *)&cpu_core[curcpu].cpuc_dtrace_flags;
(volatile uint16_t *)&cpu_core[cpu_number()].cpuc_dtrace_flags;
size_t s1, s2;
if (*flags & CPU_DTRACE_FAULT)
@ -355,8 +367,9 @@ dtrace_getarg(int arg, int aframes)
uintptr_t val;
struct i386_frame *fp = (struct i386_frame *)dtrace_getfp();
uintptr_t *stack;
int i;
#if 0 /* XXX TBD needs ALTENTRY in dtrace_asm.S */
int i;
for (i = 1; i <= aframes; i++) {
fp = fp->f_frame;
@ -372,8 +385,8 @@ dtrace_getarg(int arg, int aframes)
stack = ((uintptr_t **)&fp[1])[1] + 1;
goto load;
}
}
#endif
/*
* We know that we did not come through a trap to get into
@ -414,7 +427,7 @@ dtrace_getstackdepth(int aframes)
depth++;
if (frame->f_frame <= frame ||
(vm_offset_t)frame->f_frame >=
(vm_offset_t)ebp + KSTACK_PAGES * PAGE_SIZE)
(vm_offset_t)ebp + KSTACK_SIZE)
break;
frame = frame->f_frame;
}
@ -538,7 +551,7 @@ dtrace_copycheck(uintptr_t uaddr, uintptr_t kaddr, size_t size)
if (uaddr + size >= kernelbase || uaddr + size < uaddr) {
DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
cpu_core[curcpu].cpuc_dtrace_illval = uaddr;
cpu_core[cpu_number()].cpuc_dtrace_illval = uaddr;
return (0);
}
@ -582,7 +595,7 @@ dtrace_fuword8(void *uaddr)
{
if ((uintptr_t)uaddr >= kernelbase) {
DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr;
cpu_core[cpu_number()].cpuc_dtrace_illval = (uintptr_t)uaddr;
return (0);
}
return (dtrace_fuword8_nocheck(uaddr));
@ -593,7 +606,7 @@ dtrace_fuword16(void *uaddr)
{
if ((uintptr_t)uaddr >= kernelbase) {
DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr;
cpu_core[cpu_number()].cpuc_dtrace_illval = (uintptr_t)uaddr;
return (0);
}
return (dtrace_fuword16_nocheck(uaddr));
@ -604,7 +617,7 @@ dtrace_fuword32(void *uaddr)
{
if ((uintptr_t)uaddr >= kernelbase) {
DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr;
cpu_core[cpu_number()].cpuc_dtrace_illval = (uintptr_t)uaddr;
return (0);
}
return (dtrace_fuword32_nocheck(uaddr));
@ -615,7 +628,7 @@ dtrace_fuword64(void *uaddr)
{
if ((uintptr_t)uaddr >= kernelbase) {
DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr;
cpu_core[cpu_number()].cpuc_dtrace_illval = (uintptr_t)uaddr;
return (0);
}
return (dtrace_fuword64_nocheck(uaddr));

View File

@ -1,3 +1,5 @@
/* $NetBSD: dtrace_subr.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*
* CDDL HEADER START
*
@ -33,12 +35,18 @@
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/kmem.h>
#include <sys/smp.h>
#include <sys/xcall.h>
#include <sys/cpu.h>
#include <sys/cpuvar.h>
//#include <sys/smp.h>
#include <sys/dtrace_impl.h>
#include <sys/dtrace_bsd.h>
#include <machine/cpu.h>
#include <machine/clock.h>
#include <machine/frame.h>
#include <vm/pmap.h>
#include <uvm/uvm_pglist.h>
#include <uvm/uvm_prot.h>
#include <uvm/uvm_pmap.h>
extern uintptr_t kernelbase;
extern uintptr_t dtrace_in_probe_addr;
@ -110,31 +118,32 @@ dtrace_toxic_ranges(void (*func)(uintptr_t base, uintptr_t limit))
(*func)(0, kernelbase);
}
static void
xcall_func(void *arg0, void *arg1)
{
dtrace_xcall_t func = arg0;
(*func)(arg1);
}
void
dtrace_xcall(processorid_t cpu, dtrace_xcall_t func, void *arg)
{
cpumask_t cpus;
uint64_t where;
critical_enter();
if (cpu == DTRACE_CPUALL) {
where = xc_broadcast(0, xcall_func, func, arg);
} else {
struct cpu_info *cinfo = cpu_lookup(cpu);
if (cpu == DTRACE_CPUALL)
cpus = all_cpus;
else
cpus = (cpumask_t) (1 << cpu);
/* If the current CPU is in the set, call the function directly: */
if ((cpus & (1 << curcpu)) != 0) {
(*func)(arg);
/* Mask the current CPU from the set */
cpus &= ~(1 << curcpu);
KASSERT(cinfo != NULL);
where = xc_unicast(0, xcall_func, func, arg, cinfo);
}
xc_wait(where);
/* If there are any CPUs in the set, cross-call to those CPUs */
if (cpus != 0)
smp_rendezvous_cpus(cpus, NULL, func, smp_no_rendevous_barrier, arg);
critical_exit();
/* XXX Q. Do we really need the other cpus to wait also?
* (see solaris:xc_sync())
*/
}
static void
@ -365,12 +374,21 @@ dtrace_safe_defer_signal(void)
static int64_t tgt_cpu_tsc;
static int64_t hst_cpu_tsc;
static int64_t tsc_skew[MAXCPU];
static int64_t tsc_skew[MAXCPUS];
static uint64_t nsec_scale;
/* See below for the explanation of this macro. */
#define SCALE_SHIFT 28
static __inline uint64_t
dtrace_rdtsc(void)
{
uint64_t rv;
__asm __volatile("rdtsc" : "=A" (rv));
return (rv);
}
static void
dtrace_gethrtime_init_sync(void *arg)
{
@ -385,7 +403,7 @@ dtrace_gethrtime_init_sync(void *arg)
if (cpu == curcpu) {
int i;
for (i = 0; i < 1000000000; i++)
tgt_cpu_tsc = rdtsc();
tgt_cpu_tsc = dtrace_rdtsc();
tgt_cpu_tsc = 0;
}
#endif
@ -396,18 +414,19 @@ dtrace_gethrtime_init_cpu(void *arg)
{
uintptr_t cpu = (uintptr_t) arg;
if (cpu == curcpu)
tgt_cpu_tsc = rdtsc();
if (cpu == cpu_number())
tgt_cpu_tsc = dtrace_rdtsc();
else
hst_cpu_tsc = rdtsc();
hst_cpu_tsc = dtrace_rdtsc();
}
static void
void
dtrace_gethrtime_init(void *arg)
{
uint64_t tsc_f;
cpumask_t map;
int i;
CPU_INFO_ITERATOR cpuind;
struct cpu_info *cinfo = curcpu();
cpuid_t cur_cpuid = cpu_number(); /* current cpu id */
/*
* Get TSC frequency known at this moment.
@ -415,7 +434,7 @@ dtrace_gethrtime_init(void *arg)
* Otherwise tick->time conversion will be inaccurate, but
* will preserve monotonic property of TSC.
*/
tsc_f = tsc_freq;
tsc_f = cpu_frequency(cinfo);
/*
* The following line checks that nsec_scale calculated below
@ -423,7 +442,8 @@ dtrace_gethrtime_init(void *arg)
* another 32-bit integer without overflowing 64-bit.
* Thus minimum supported TSC frequency is 62.5MHz.
*/
KASSERT(tsc_f > (NANOSEC >> (32 - SCALE_SHIFT)), ("TSC frequency is too low"));
//KASSERT(tsc_f > (NANOSEC >> (32 - SCALE_SHIFT)), ("TSC frequency is too low"));
KASSERT(tsc_f > (NANOSEC >> (32 - SCALE_SHIFT)));
/*
* We scale up NANOSEC/tsc_f ratio to preserve as much precision
@ -437,8 +457,15 @@ dtrace_gethrtime_init(void *arg)
nsec_scale = ((uint64_t)NANOSEC << SCALE_SHIFT) / tsc_f;
/* The current CPU is the reference one. */
tsc_skew[curcpu] = 0;
tsc_skew[cur_cpuid] = 0;
for (CPU_INFO_FOREACH(cpuind, cinfo)) {
/* use skew relative to cpu 0 */
tsc_skew[cpu_index(cinfo)] = cinfo->ci_data.cpu_cc_skew;
}
/* Already handled in x86/tsc.c for ci_data.cpu_cc_skew */
#if 0
for (i = 0; i <= mp_maxid; i++) {
if (i == curcpu)
continue;
@ -456,10 +483,9 @@ dtrace_gethrtime_init(void *arg)
tsc_skew[i] = tgt_cpu_tsc - hst_cpu_tsc;
}
#endif
}
SYSINIT(dtrace_gethrtime_init, SI_SUB_SMP, SI_ORDER_ANY, dtrace_gethrtime_init, NULL);
/*
* DTrace needs a high resolution time function which can
* be called from a probe context and guaranteed not to have
@ -480,7 +506,7 @@ dtrace_gethrtime()
* (see nsec_scale calculations) taking into account 32-bit shift of
* the higher half and finally add.
*/
tsc = rdtsc() + tsc_skew[curcpu];
tsc = dtrace_rdtsc() + tsc_skew[cpu_number()];
lo = tsc;
hi = tsc >> 32;
return (((lo * nsec_scale) >> SCALE_SHIFT) +
@ -498,6 +524,8 @@ dtrace_gethrestime(void)
int
dtrace_trap(struct trapframe *frame, u_int type)
{
cpuid_t cpuid = cpu_number(); /* current cpu id */
/*
* A trap can occur while DTrace executes a probe. Before
* executing the probe, DTrace blocks re-scheduling and sets
@ -508,7 +536,7 @@ dtrace_trap(struct trapframe *frame, u_int type)
* Check if DTrace has enabled 'no-fault' mode:
*
*/
if ((cpu_core[curcpu].cpuc_dtrace_flags & CPU_DTRACE_NOFAULT) != 0) {
if ((cpu_core[cpuid].cpuc_dtrace_flags & CPU_DTRACE_NOFAULT) != 0) {
/*
* There are only a couple of trap types that are expected.
* All the rest will be handled in the usual way.
@ -517,7 +545,7 @@ dtrace_trap(struct trapframe *frame, u_int type)
/* General protection fault. */
case T_PROTFLT:
/* Flag an illegal operation. */
cpu_core[curcpu].cpuc_dtrace_flags |= CPU_DTRACE_ILLOP;
cpu_core[cpuid].cpuc_dtrace_flags |= CPU_DTRACE_ILLOP;
/*
* Offset the instruction pointer to the instruction
@ -528,8 +556,8 @@ dtrace_trap(struct trapframe *frame, u_int type)
/* Page fault. */
case T_PAGEFLT:
/* Flag a bad address. */
cpu_core[curcpu].cpuc_dtrace_flags |= CPU_DTRACE_BADADDR;
cpu_core[curcpu].cpuc_dtrace_illval = rcr2();
cpu_core[cpuid].cpuc_dtrace_flags |= CPU_DTRACE_BADADDR;
cpu_core[cpuid].cpuc_dtrace_illval = rcr2();
/*
* Offset the instruction pointer to the instruction

View File

@ -1,3 +1,5 @@
/* $NetBSD: instr_size.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*
* CDDL HEADER START
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: fbt.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*
* CDDL HEADER START
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: lockstat.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*
* CDDL HEADER START
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: profile.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*
* CDDL HEADER START
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: prototype.c,v 1.2 2010/02/21 01:46:32 darran Exp $ */
/*
* This file is freeware. You are free to use it and add your own
* license.

View File

@ -1,3 +1,5 @@
/* $NetBSD: sdt.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
/*
* CDDL HEADER START
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: systrace.c,v 1.2 2010/02/21 01:46:34 darran Exp $ */
/*
* CDDL HEADER START
*

View File

@ -60,10 +60,10 @@ ctf_create(int *errp)
if (hash == NULL)
return (ctf_set_open_errno(errp, EAGAIN));
cts.cts_name = _CTF_SECTION;
cts.cts_name = (char *)_CTF_SECTION;
cts.cts_type = SHT_PROGBITS;
cts.cts_flags = 0;
cts.cts_data = &hdr;
cts.cts_data = (ctf_header_t *)&hdr;
cts.cts_size = sizeof (hdr);
cts.cts_entsize = 1;
cts.cts_offset = 0;
@ -364,7 +364,7 @@ ctf_update(ctf_file_t *fp)
* is successful, we then switch nfp and fp and free the old container.
*/
ctf_data_protect(buf, size);
cts.cts_name = _CTF_SECTION;
cts.cts_name = (char *)_CTF_SECTION;
cts.cts_type = SHT_PROGBITS;
cts.cts_flags = 0;
cts.cts_data = buf;

View File

@ -694,11 +694,11 @@ ctf_bufopen(const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
fp->ctf_strtab.cts_name = ctf_strdup(fp->ctf_strtab.cts_name);
if (fp->ctf_data.cts_name == NULL)
fp->ctf_data.cts_name = _CTF_NULLSTR;
fp->ctf_data.cts_name = (char *)_CTF_NULLSTR;
if (fp->ctf_symtab.cts_name == NULL)
fp->ctf_symtab.cts_name = _CTF_NULLSTR;
fp->ctf_symtab.cts_name = (char *)_CTF_NULLSTR;
if (fp->ctf_strtab.cts_name == NULL)
fp->ctf_strtab.cts_name = _CTF_NULLSTR;
fp->ctf_strtab.cts_name = (char *)_CTF_NULLSTR;
fp->ctf_str[CTF_STRTAB_0].cts_strs = (const char *)buf + hp.cth_stroff;
fp->ctf_str[CTF_STRTAB_0].cts_len = hp.cth_strlen;

View File

@ -252,7 +252,7 @@ ctf_fdopen(int fd, int *errp)
if (ctfsect.cts_data == MAP_FAILED)
return (ctf_set_open_errno(errp, errno));
ctfsect.cts_name = _CTF_SECTION;
ctfsect.cts_name = (char *)_CTF_SECTION;
ctfsect.cts_type = SHT_PROGBITS;
ctfsect.cts_flags = SHF_ALLOC;
ctfsect.cts_size = (size_t)st.st_size;

View File

@ -251,6 +251,7 @@ dt_aggregate_quantizedcmp(int64_t *lhs, int64_t *rhs)
static void
dt_aggregate_usym(dtrace_hdl_t *dtp, uint64_t *data)
{
#if 0 /* XXX TBD needs libproc */
uint64_t pid = data[0];
uint64_t *pc = &data[1];
struct ps_prochandle *P;
@ -273,11 +274,15 @@ dt_aggregate_usym(dtrace_hdl_t *dtp, uint64_t *data)
dt_proc_unlock(dtp, P);
dt_proc_release(dtp, P);
#else
printf("XXX %s not implemented\n", __func__);
#endif
}
static void
dt_aggregate_umod(dtrace_hdl_t *dtp, uint64_t *data)
{
#if 0 /* XXX TBD needs libproc */
uint64_t pid = data[0];
uint64_t *pc = &data[1];
struct ps_prochandle *P;
@ -300,6 +305,9 @@ dt_aggregate_umod(dtrace_hdl_t *dtp, uint64_t *data)
dt_proc_unlock(dtp, P);
dt_proc_release(dtp, P);
#else
printf("XXX %s not implemented\n", __func__);
#endif
}
static void

View File

@ -905,6 +905,7 @@ int
dt_print_ustack(dtrace_hdl_t *dtp, FILE *fp, const char *format,
caddr_t addr, uint64_t arg)
{
#if 0 /* XXX TBD needs libproc */
/* LINTED - alignment */
uint64_t *pc = (uint64_t *)addr;
uint32_t depth = DTRACE_USTACK_NFRAMES(arg);
@ -1048,11 +1049,16 @@ dt_print_ustack(dtrace_hdl_t *dtp, FILE *fp, const char *format,
}
return (err);
#else
printf("XXX %s not implemented\n", __func__);
return ENODEV;
#endif
}
static int
dt_print_usym(dtrace_hdl_t *dtp, FILE *fp, caddr_t addr, dtrace_actkind_t act)
{
#if 0 /* XXX TBD needs libproc */
/* LINTED - alignment */
uint64_t pid = ((uint64_t *)addr)[0];
/* LINTED - alignment */
@ -1088,11 +1094,16 @@ dt_print_usym(dtrace_hdl_t *dtp, FILE *fp, caddr_t addr, dtrace_actkind_t act)
} while ((len = dtrace_uaddr2str(dtp, pid, pc, s, n)) >= n);
return (dt_printf(dtp, fp, format, s));
#else
printf("XXX %s not implemented\n", __func__);
return ENODEV;
#endif
}
int
dt_print_umod(dtrace_hdl_t *dtp, FILE *fp, const char *format, caddr_t addr)
{
#if 0 /* XXX TBD needs libproc */
/* LINTED - alignment */
uint64_t pid = ((uint64_t *)addr)[0];
/* LINTED - alignment */
@ -1135,6 +1146,10 @@ dt_print_umod(dtrace_hdl_t *dtp, FILE *fp, const char *format, caddr_t addr)
}
return (err);
#else
printf("XXX %s not implemented\n", __func__);
return -1;
#endif
}
int

View File

@ -25,6 +25,7 @@
#pragma ident "%Z%%M% %I% %E% SMI"
#define ELFSIZE ARCH_ELFSIZE /* XXX debug */
#include <sys/types.h>
#if defined(sun)
#include <sys/modctl.h>
@ -37,6 +38,7 @@
#include <sys/param.h>
#include <sys/linker.h>
#include <sys/stat.h>
#include <sys/sysctl.h>
#endif
#include <unistd.h>
@ -825,11 +827,7 @@ dt_module_modelname(dt_module_t *dmp)
* including the path.
*/
static void
#if defined(sun)
dt_module_update(dtrace_hdl_t *dtp, const char *name)
#else
dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat)
#endif
{
char fname[MAXPATHLEN];
struct stat64 st;
@ -847,11 +845,38 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat)
"%s/%s/object", OBJFS_ROOT, name);
#else
GElf_Phdr ph;
char name[MAXPATHLEN];
int i = 0;
int i;
int mib_osrel[2] = { CTL_KERN, KERN_OSRELEASE };
int mib_mach[2] = { CTL_HW, HW_MACHINE };
char osrel[64];
char machine[64];
size_t len;
(void) strlcpy(name, k_stat->name, sizeof(name));
(void) strlcpy(fname, k_stat->pathname, sizeof(fname));
printf("dt_module_update: %s\n", name); /* XXX debug */
if (strcmp("netbsd",name) == 0) {
/* want the kernel */
strncpy(fname, "/netbsd", sizeof(fname));
} else {
/* build stand module path from system */
len = sizeof(osrel);
if (sysctl(mib_osrel, 2, osrel, &len, NULL, 0) == -1) {
dt_dprintf("sysctl osrel failed: %s\n",
strerror(errno));
return;
}
len = sizeof(machine);
if (sysctl(mib_mach, 2, machine, &len, NULL, 0) == -1) {
dt_dprintf("sysctl machine failed: %s\n",
strerror(errno));
return;
}
(void) snprintf(fname, sizeof (fname),
"/stand/%s/%s/%s.kmod", machine, osrel, name, name);
}
#endif
if ((fd = open(fname, O_RDONLY)) == -1 || fstat64(fd, &st) == -1 ||
@ -928,6 +953,7 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat)
dmp->dm_modid = (int)OBJFS_MODID(st.st_ino);
#else
#if defined(__i386__)
#if 0 /* XXX TBD needs module support */
/*
* Find the first load section and figure out the relocation
* offset for the symbols. The kernel module will not need
@ -940,6 +966,7 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat)
}
}
#endif
#endif
#endif
if (dmp->dm_info.objfs_info_primary)
@ -993,6 +1020,9 @@ dtrace_update(dtrace_hdl_t *dtp)
if (kldstat(fileid, &k_stat) == 0)
dt_module_update(dtp, &k_stat);
}
#else
/* XXX just the kernel for now */
dt_module_update(dtp, "netbsd");
#endif
/*

View File

@ -788,9 +788,11 @@ _dtrace_init(void)
}
#endif
#if defined(__i386__)
#if 0 /* XXX TBD - no NetBSD equivalent? */
/* make long doubles 64 bits -sson */
(void) fpsetprec(FP_PE);
#endif
#endif
}
static dtrace_hdl_t *
@ -1233,6 +1235,7 @@ alloc:
int i;
size_t len = sizeof(bootfile);
#if 0 /* XXX debug */
/* 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));
@ -1241,6 +1244,9 @@ alloc:
p++;
else
p = bootfile;
#else
p = "netbsd";
#endif
/*
* Format the global variables based on the kernel module name.

View File

@ -790,6 +790,8 @@ dt_options_load(dtrace_hdl_t *dtp)
size_t offs;
int i;
printf("dt_options_load() entry \n"); /* XXX debug */
/*
* To load the option values, we need to ask the kernel to provide its
* DOF, which we'll sift through to look for OPTDESC sections.
@ -845,6 +847,7 @@ dt_options_load(dtrace_hdl_t *dtp)
dtp->dt_options[opt->dofo_option] = opt->dofo_value;
}
printf("dt_options_load() exit \n"); /* XXX debug */
return (0);
}

View File

@ -108,6 +108,7 @@ dt_pid_error(dtrace_hdl_t *dtp, dt_pcb_t *pcb, dt_proc_t *dpr,
static int
dt_pid_per_sym(dt_pid_probe_t *pp, const GElf_Sym *symp, const char *func)
{
#if 0 /* XXX TBD needs libproc */
dtrace_hdl_t *dtp = pp->dpp_dtp;
dt_pcb_t *pcb = pp->dpp_pcb;
dt_proc_t *dpr = pp->dpp_dpr;
@ -223,6 +224,10 @@ dt_pid_per_sym(dt_pid_probe_t *pp, const GElf_Sym *symp, const char *func)
dt_free(dtp, ftp);
return (0);
#else
printf("XXX %s not implemented\n", __func__);
return ENODEV;
#endif
}
static int
@ -263,6 +268,7 @@ dt_pid_sym_filt(void *arg, const GElf_Sym *symp, const char *func)
static int
dt_pid_per_mod(void *arg, const prmap_t *pmp, const char *obj)
{
#if 0 /* XXX TBD needs libproc */
dt_pid_probe_t *pp = arg;
dtrace_hdl_t *dtp = pp->dpp_dtp;
dt_pcb_t *pcb = pp->dpp_pcb;
@ -421,6 +427,10 @@ dt_pid_per_mod(void *arg, const prmap_t *pmp, const char *obj)
}
return (0);
#else
printf("XXX %s not implemented\n", __func__);
return ENODEV;
#endif
}
static int
@ -507,6 +517,7 @@ static int
dt_pid_create_pid_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp,
dt_pcb_t *pcb, dt_proc_t *dpr)
{
#if 0 /* XXX TBD needs libproc */
dt_pid_probe_t pp;
int ret = 0;
@ -588,11 +599,16 @@ dt_pid_create_pid_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp,
#endif
return (ret);
#else
printf("XXX %s not implemented\n", __func__);
return ENODEV;
#endif
}
static int
dt_pid_usdt_mapping(void *data, const prmap_t *pmp, const char *oname)
{
#if 0 /* XXX TBD needs libproc */
struct ps_prochandle *P = data;
GElf_Sym sym;
#if defined(sun)
@ -664,12 +680,17 @@ dt_pid_usdt_mapping(void *data, const prmap_t *pmp, const char *oname)
#endif
return (0);
#else
printf("XXX %s not implemented\n", __func__);
return ENODEV;
#endif
}
static int
dt_pid_create_usdt_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp,
dt_pcb_t *pcb, dt_proc_t *dpr)
{
#if 0 /* XXX TBD needs libproc */
struct ps_prochandle *P = dpr->dpr_proc;
int ret = 0;
@ -695,6 +716,10 @@ dt_pid_create_usdt_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp,
(void) dt_pid_fix_mod(pdp, P);
return (ret);
#else
printf("XXX %s not implemented\n", __func__);
return ENODEV;
#endif
}
static pid_t
@ -730,6 +755,7 @@ dt_pid_get_pid(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, dt_pcb_t *pcb,
int
dt_pid_create_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, dt_pcb_t *pcb)
{
#if 0 /* XXX TBD needs libproc */
char provname[DTRACE_PROVNAMELEN];
struct ps_prochandle *P;
dt_proc_t *dpr;
@ -804,6 +830,10 @@ dt_pid_create_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, dt_pcb_t *pcb)
}
return (err ? -1 : 0);
#else
printf("XXX %s not implemented\n", __func__);
return -1;
#endif
}
int

View File

@ -91,6 +91,89 @@
#include <dt_pid.h>
#include <dt_impl.h>
/* XXX TBD needs libproc */
/* Stub proc functions for now */
int
proc_setflags(struct proc_handle *phdl, int mask)
{
printf("dtrace: XXX %s not implemented\n", __func__);
return EINVAL;
}
int
proc_create(const char *file, char * const *argv, proc_child_func *pcf,
void *child_arg, struct proc_handle **pphdl)
{
printf("dtrace: XXX %s not implemented\n", __func__);
return EINVAL;
}
int
proc_detach(struct proc_handle *phdl)
{
printf("dtrace: XXX %s not implemented\n", __func__);
return EINVAL;
}
int
proc_getflags(struct proc_handle *phdl)
{
printf("dtrace: XXX %s not implemented\n", __func__);
return -1;
}
int
proc_wait(struct proc_handle *phdl)
{
printf("dtrace: XXX %s not implemented\n", __func__);
return EINVAL;
}
pid_t
proc_getpid(struct proc_handle *phdl)
{
printf("dtrace: XXX %s not implemented\n", __func__);
return -1;
}
int
proc_attach(pid_t pid, int flags, struct proc_handle **pphdl)
{
printf("dtrace: XXX %s not implemented\n", __func__);
return EINVAL;
}
int
proc_state(struct proc_handle *phdl)
{
printf("dtrace: XXX %s not implemented\n", __func__);
return -1;
}
int
proc_clearflags(struct proc_handle *phdl, int mask)
{
printf("dtrace: XXX %s not implemented\n", __func__);
return EINVAL;
}
int
proc_continue(struct proc_handle *phdl)
{
printf("dtrace: XXX %s not implemented\n", __func__);
return EINVAL;
}
#define IS_SYS_EXEC(w) (w == SYS_exec || w == SYS_execve)
#define IS_SYS_FORK(w) (w == SYS_vfork || w == SYS_fork1 || \
w == SYS_forkall || w == SYS_forksys)

View File

@ -948,6 +948,7 @@ int
dtrace_uaddr2str(dtrace_hdl_t *dtp, pid_t pid,
uint64_t addr, char *str, int nbytes)
{
#if 0 /* XXX TBD needs libproc */
char name[PATH_MAX], objname[PATH_MAX], c[PATH_MAX * 2];
struct ps_prochandle *P = NULL;
GElf_Sym sym;
@ -994,4 +995,8 @@ dtrace_uaddr2str(dtrace_hdl_t *dtp, pid_t pid,
dt_proc_release(dtp, P);
return (dt_string2str(c, str, nbytes));
#else
printf("XXX %s not implemented\n", __func__);
return 0;
#endif
}

View File

@ -30,6 +30,7 @@
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/dtrace.h>
typedef processorid_t test_processor_id_t;
#include <stdarg.h>
#include <stdio.h>
#include <gelf.h>

View File

@ -33,6 +33,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "alist.h"
#include "memory.h"

View File

@ -364,7 +364,7 @@ wip_save_work(workqueue_t *wq, wip_t *slot, int slotnum)
pthread_mutex_lock(&wq->wq_donequeue_lock);
while (wq->wq_lastdonebatch + 1 < slot->wip_batchid)
pthread_cond_wait(&slot->wip_cv, &wq->wq_donequeue_lock);
pthread_cond_wait(&slot->wip_cv, &wq->wq_donequeue_lock);
assert(wq->wq_lastdonebatch + 1 == slot->wip_batchid);
fifo_add(wq->wq_donequeue, slot->wip_td);
@ -650,6 +650,7 @@ wq_init(workqueue_t *wq, int nfiles)
wq->wq_wip = xcalloc(sizeof (wip_t) * nslots);
wq->wq_nwipslots = nslots;
wq->wq_nthreads = MIN(sysconf(_SC_NPROCESSORS_ONLN) * 3 / 2, nslots);
wq->wq_thread = xmalloc(sizeof (pthread_t) * wq->wq_nthreads);
if (getenv("CTFMERGE_INPUT_THROTTLE"))
throttle = atoi(getenv("CTFMERGE_INPUT_THROTTLE"));
@ -664,6 +665,7 @@ wq_init(workqueue_t *wq, int nfiles)
for (i = 0; i < nslots; i++) {
pthread_mutex_init(&wq->wq_wip[i].wip_lock, NULL);
pthread_cond_init(&wq->wq_wip[i].wip_cv, NULL);
wq->wq_wip[i].wip_batchid = wq->wq_next_batchid++;
}
@ -703,8 +705,8 @@ start_threads(workqueue_t *wq)
pthread_sigmask(SIG_BLOCK, &sets, NULL);
for (i = 0; i < wq->wq_nthreads; i++) {
pthread_create(&thrid, NULL, (void *(*)(void *))worker_thread,
wq);
pthread_create(&wq->wq_thread[i], NULL,
(void *(*)(void *))worker_thread, wq);
}
#if defined(sun)
@ -719,6 +721,17 @@ start_threads(workqueue_t *wq)
pthread_sigmask(SIG_UNBLOCK, &sets, NULL);
}
static void
join_threads(workqueue_t *wq)
{
int i;
for (i = 0; i < wq->wq_nthreads; i++) {
pthread_join(wq->wq_thread[i], NULL);
}
}
static int
strcompare(const void *p1, const void *p2)
{
@ -728,10 +741,18 @@ strcompare(const void *p1, const void *p2)
return (strcmp(s1, s2));
}
/*
* Core work queue structure; passed to worker threads on thread creation
* as the main point of coordination. Allocate as a static structure; we
* could have put this into a local variable in main, but passing a pointer
* into your stack to another thread is fragile at best and leads to some
* hard-to-debug failure modes.
*/
static workqueue_t wq;
int
main(int argc, char **argv)
{
workqueue_t wq;
tdata_t *mstrtd, *savetd;
char *uniqfile = NULL, *uniqlabel = NULL;
char *withfile = NULL;
@ -913,6 +934,8 @@ main(int argc, char **argv)
pthread_cond_wait(&wq.wq_alldone_cv, &wq.wq_queue_lock);
pthread_mutex_unlock(&wq.wq_queue_lock);
join_threads(&wq);
/*
* All requested files have been merged, with the resulting tree in
* mstrtd. savetd is the tree that will be placed into the output file.

View File

@ -78,6 +78,8 @@ typedef struct workqueue {
int wq_nomorefiles;
pthread_t *wq_thread;
barrier_t wq_bar1;
barrier_t wq_bar2;
} workqueue_t;

View File

@ -1043,7 +1043,16 @@ die_sou_resolve(tdesc_t *tdp, tdesc_t **tdpp __unused, void *private)
continue;
if (mt->t_type == ARRAY && mt->t_ardef->ad_nelems == 0)
continue;
if (mt->t_type == STRUCT &&
mt->t_members != NULL &&
mt->t_members->ml_type->t_type == ARRAY &&
mt->t_members->ml_type->t_ardef->ad_nelems == 0) {
/* struct with zero sized array */
continue;
}
printf("%s unresolved type = %d (%s)\n", tdesc_name(tdp),
mt->t_type, tdesc_name(mt));
dw->dw_nunres++;
return (1);
}
@ -1798,8 +1807,13 @@ dw_read(tdata_t *td, Elf *elf, char *filename __unused)
}
if ((rc = dwarf_next_cu_header(dw.dw_dw, &hdrlen, &vers, &abboff,
&addrsz, &nxthdr, &dw.dw_err)) != DW_DLV_OK)
&addrsz, &nxthdr, &dw.dw_err)) != DW_DLV_OK) {
if (rc == DW_DLV_NO_ENTRY) {
/* no compilation unit in the DWARF section */
return 0;
}
terminate("rc = %d %s\n", rc, dwarf_errmsg(&dw.dw_err));
}
if ((cu = die_sibling(&dw, NULL)) == NULL)
terminate("file does not contain dwarf type data "

View File

@ -472,7 +472,7 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname,
int pad;
int i;
if (gelf_newehdr(dst, gelf_getclass(src)) == NULL)
if (gelf_newehdr(dst, gelf_getclass(src)) == 0)
elfterminate(dstname, "Cannot copy ehdr to temp file");
gelf_getehdr(src, &sehdr);
memcpy(&dehdr, &sehdr, sizeof (GElf_Ehdr));
@ -488,7 +488,7 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname,
*/
if (sehdr.e_phnum != 0) {
(void) elf_flagelf(dst, ELF_C_SET, ELF_F_LAYOUT);
if (gelf_newphdr(dst, sehdr.e_phnum) == NULL)
if (gelf_newphdr(dst, sehdr.e_phnum) == 0)
elfterminate(dstname, "Cannot make phdrs in temp file");
for (i = 0; i < sehdr.e_phnum; i++) {
@ -579,8 +579,9 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname,
elfterminate(dstname, "Cannot update sect %s", sname);
#endif
if ((sdata = elf_getdata(sscn, NULL)) == NULL)
if ((sdata = elf_getdata(sscn, NULL)) == NULL) {
elfterminate(srcname, "Cannot get sect %s data", sname);
}
if ((ddata = elf_newdata(dscn)) == NULL)
elfterminate(dstname, "Can't make sect %s data", sname);
#if defined(sun)
@ -644,7 +645,7 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname,
}
#if !defined(sun)
if (ddata->d_buf == NULL) {
if ((ddata->d_buf == NULL) && (sdata->d_buf != NULL)) {
ddata->d_buf = xmalloc(shdr.sh_size);
bcopy(sdata->d_buf, ddata->d_buf, shdr.sh_size);
}

File diff suppressed because it is too large Load Diff

View File

@ -49,6 +49,7 @@ extern "C" {
#include <sys/types.h>
#include <sys/modctl.h>
#include <sys/processor.h>
#include <sys/proc.h>
#if defined(sun)
#include <sys/systm.h>
#else
@ -59,7 +60,9 @@ extern "C" {
typedef int model_t;
#endif
#include <sys/ctf_api.h>
#if 0
#include <sys/cyclic.h>
#endif
#if defined(sun)
#include <sys/int_limits.h>
#else
@ -2013,9 +2016,12 @@ typedef struct dof_helper {
* instrument the kernel arbitrarily should be sure to not instrument these
* routines.
*/
typedef dtrace_modctl_t *mymodctl_p;
typedef struct dtrace_pops {
void (*dtps_provide)(void *arg, dtrace_probedesc_t *spec);
void (*dtps_provide_module)(void *arg, modctl_t *mp);
void (*dtps_provide_module)(void *arg, dtrace_modctl_t *mp);
void (*dtps_enable)(void *arg, dtrace_id_t id, void *parg);
void (*dtps_disable)(void *arg, dtrace_id_t id, void *parg);
void (*dtps_suspend)(void *arg, dtrace_id_t id, void *parg);
@ -2239,8 +2245,8 @@ extern void dtrace_membar_producer(void);
extern void dtrace_membar_consumer(void);
extern void (*dtrace_cpu_init)(processorid_t);
extern void (*dtrace_modload)(modctl_t *);
extern void (*dtrace_modunload)(modctl_t *);
extern void (*dtrace_modload)(dtrace_modctl_t *);
extern void (*dtrace_modunload)(dtrace_modctl_t *);
extern void (*dtrace_helpers_cleanup)(void);
extern void (*dtrace_helpers_fork)(proc_t *parent, proc_t *child);
extern void (*dtrace_cpustart_init)(void);
@ -2253,12 +2259,12 @@ extern dtrace_cacheid_t dtrace_predcache_id;
#if defined(sun)
extern hrtime_t dtrace_gethrtime(void);
#else
void dtrace_debug_printf(const char *, ...) __printflike(1, 2);
void dtrace_debug_printf(const char *, ...);
#endif
extern void dtrace_sync(void);
extern void dtrace_toxic_ranges(void (*)(uintptr_t, uintptr_t));
extern void dtrace_xcall(processorid_t, dtrace_xcall_t, void *);
extern void dtrace_vpanic(const char *, __va_list);
extern void dtrace_vpanic(const char *, _BSD_VA_LIST_);
extern void dtrace_panic(const char *, ...);
extern int dtrace_safe_defer_signal(void);
@ -2280,13 +2286,13 @@ extern void dtrace_getfsr(uint64_t *);
#endif
#define DTRACE_CPUFLAG_ISSET(flag) \
(cpu_core[curcpu].cpuc_dtrace_flags & (flag))
(cpu_core[curcpu_id].cpuc_dtrace_flags & (flag))
#define DTRACE_CPUFLAG_SET(flag) \
(cpu_core[curcpu].cpuc_dtrace_flags |= (flag))
(cpu_core[curcpu_id].cpuc_dtrace_flags |= (flag))
#define DTRACE_CPUFLAG_CLEAR(flag) \
(cpu_core[curcpu].cpuc_dtrace_flags &= ~(flag))
(cpu_core[curcpu_id].cpuc_dtrace_flags &= ~(flag))
#endif /* _KERNEL */

View File

@ -1109,11 +1109,7 @@ typedef struct dtrace_cred {
* dtrace_state structure.
*/
struct dtrace_state {
#if defined(sun)
dev_t dts_dev; /* device */
#else
struct cdev *dts_dev; /* device */
#endif
int dts_necbs; /* total number of ECBs */
dtrace_ecb_t **dts_ecbs; /* array of ECBs */
dtrace_epid_t dts_epid; /* next EPID to allocate */
@ -1127,11 +1123,7 @@ struct dtrace_state {
int dts_nspeculations; /* number of speculations */
int dts_naggregations; /* number of aggregations */
dtrace_aggregation_t **dts_aggregations; /* aggregation array */
#if defined(sun)
vmem_t *dts_aggid_arena; /* arena for aggregation IDs */
#else
struct unrhdr *dts_aggid_arena; /* arena for aggregation IDs */
#endif
uint64_t dts_errors; /* total number of errors */
uint32_t dts_speculations_busy; /* number of spec. busy */
uint32_t dts_speculations_unavail; /* number of spec unavail */

View File

@ -36,6 +36,7 @@
#include <sys/types.h>
#include <sys/procset.h>
#include <sys/pset.h>
#ifdef __cplusplus
extern "C" {
@ -53,7 +54,7 @@ typedef uint16_t lgrpid_t;
/*
* Type for processor name (CPU number).
*/
typedef int processorid_t;
//typedef int processorid_t;
typedef int chipid_t;
/*

View File

@ -1,3 +1,5 @@
/* $NetBSD: alloca.h,v 1.3 2010/02/21 01:46:34 darran Exp $ */
/*
* Copyright (C) 2007 John Birrell <jb@freebsd.org>
* All rights reserved.
@ -23,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/cddl/compat/opensolaris/include/alloca.h,v 1.2.4.1 2009/08/03 08:13:06 kensmith Exp $
* $FreeBSD: src/compat/opensolaris/include/alloca.h,v 1.1 2007/11/28 21:40:07 jb Exp $
*
*/

View File

@ -1,3 +1,5 @@
/* $NetBSD: assert.h,v 1.2 2010/02/21 01:46:34 darran Exp $ */
/*-
* Copyright (c) 2009 Pawel Jakub Dawidek <pjd@FreeBSD.org>
* All rights reserved.

View File

@ -1,3 +1,5 @@
/* $NetBSD: devid.h,v 1.3 2010/02/21 01:46:34 darran Exp $ */
/*
* CDDL HEADER START
*
@ -18,8 +20,6 @@
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
* $FreeBSD: src/cddl/compat/opensolaris/include/devid.h,v 1.4.2.1 2009/08/03 08:13:06 kensmith Exp $
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
@ -33,6 +33,8 @@
#include <sys/disk.h>
#include <stdlib.h>
#define DISK_IDENT_SIZE 128
typedef struct ddi_devid {
char devid[DISK_IDENT_SIZE];
} ddi_devid_t;

View File

@ -1,3 +1,5 @@
/* $NetBSD: dtrace.h,v 1.2 2010/02/21 01:46:34 darran Exp $ */
/*
* Copyright (C) 2008 John Birrell <jb@freebsd.org>
* All rights reserved.

View File

@ -1,3 +1,5 @@
/* $NetBSD: fcntl.h,v 1.3 2010/02/21 01:46:34 darran Exp $ */
/*
* Copyright (C) 2007 John Birrell <jb@freebsd.org>
* All rights reserved.
@ -23,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/cddl/compat/opensolaris/include/fcntl.h,v 1.2.4.1 2009/08/03 08:13:06 kensmith Exp $
* $FreeBSD: src/compat/opensolaris/include/fcntl.h,v 1.1 2007/11/28 21:40:07 jb Exp $
*
*/

View File

@ -1,3 +1,5 @@
/* $NetBSD: fsshare.h,v 1.3 2010/02/21 01:46:34 darran Exp $ */
/*-
* Copyright (c) 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org>
* All rights reserved.
@ -23,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/cddl/compat/opensolaris/include/fsshare.h,v 1.2.4.1 2009/08/03 08:13:06 kensmith Exp $
* $FreeBSD: src/compat/opensolaris/include/fsshare.h,v 1.1 2007/04/06 01:08:58 pjd Exp $
*/
#ifndef _OPENSOLARIS_FSSHARE_H_

View File

@ -1,4 +1,33 @@
/* $FreeBSD: src/cddl/compat/opensolaris/include/libintl.h,v 1.3.2.1 2009/08/03 08:13:06 kensmith Exp $ */
/* $NetBSD: libintl.h,v 1.3 2010/02/21 01:46:34 darran Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Andrew Doran.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY 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.
*/
#ifndef _LIBINTL_H_
#define _LIBINTL_H_

View File

@ -1,3 +1,5 @@
/* $NetBSD: libproc.h,v 1.2 2010/02/21 01:46:34 darran Exp $ */
/*
* Copyright (C) 2008 John Birrell <jb@freebsd.org>
* All rights reserved.
@ -41,6 +43,24 @@
#define PGRAB_RDONLY O_RDONLY
#define PGRAB_FORCE 0
struct proc_handle;
typedef void (*proc_child_func)(void *);
/* Values returned by proc_state(). */
#define PS_IDLE 1
#define PS_STOP 2
#define PS_RUN 3
#define PS_UNDEAD 4
#define PS_DEAD 5
#define PS_LOST 6
typedef struct prmap {
uintptr_t pr_vaddr; /* Virtual address. */
} prmap_t;
#if 0
#include_next <libproc.h>
#endif
#endif

View File

@ -1,3 +1,5 @@
/* $NetBSD: libshare.h,v 1.2 2010/02/21 01:46:34 darran Exp $ */
/*-
* Copyright (c) 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org>
* All rights reserved.

View File

@ -1,4 +1,33 @@
/* $FreeBSD: src/cddl/compat/opensolaris/include/mnttab.h,v 1.4.2.1 2009/08/03 08:13:06 kensmith Exp $ */
/* $NetBSD: mnttab.h,v 1.3 2010/02/21 01:46:34 darran Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Andrew Doran.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY 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.
*/
#ifndef _OPENSOLARIS_MNTTAB_H_
#define _OPENSOLARIS_MNTTAB_H_
@ -9,8 +38,6 @@
#define MNTTAB _PATH_DEVNULL
#define MNT_LINE_MAX 1024
#define umount2(p, f) unmount(p, f)
struct mnttab {
char *mnt_special;
char *mnt_mountp;

View File

@ -1,19 +1,46 @@
/* $FreeBSD: src/cddl/compat/opensolaris/include/priv.h,v 1.3.2.1 2009/08/03 08:13:06 kensmith Exp $ */
/* $NetBSD: priv.h,v 1.3 2010/02/21 01:46:34 darran Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Andrew Doran.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY 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.
*/
#ifndef _OPENSOLARIS_PRIV_H_
#define _OPENSOLARIS_PRIV_H_
#include <sys/types.h>
#include <sys/priv_names.h>
#include <unistd.h>
#include <assert.h>
#define PRIV_SYS_CONFIG 0
static __inline int
priv_ineffect(priv)
priv_ineffect(const char *name)
{
assert(priv == PRIV_SYS_CONFIG);
return (geteuid() == 0);
}

View File

@ -1,4 +1,33 @@
/* $FreeBSD: src/cddl/compat/opensolaris/include/solaris.h,v 1.3.2.1 2009/08/03 08:13:06 kensmith Exp $ */
/* $NetBSD: solaris.h,v 1.3 2010/02/21 01:46:34 darran Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Andrew Doran.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY 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.
*/
#ifndef _SOLARIS_H_
#define _SOLARIS_H_

View File

@ -1,3 +1,5 @@
/* $NetBSD: stdio.h,v 1.3 2010/02/21 01:46:34 darran Exp $ */
/*
* Copyright (C) 2007 John Birrell <jb@freebsd.org>
* All rights reserved.
@ -23,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/cddl/compat/opensolaris/include/stdio.h,v 1.2.4.1 2009/08/03 08:13:06 kensmith Exp $
* $FreeBSD: src/compat/opensolaris/include/stdio.h,v 1.1 2007/11/28 21:40:07 jb Exp $
*
*/

View File

@ -1,3 +1,5 @@
/* $NetBSD: stdlib.h,v 1.3 2010/02/21 01:46:34 darran Exp $ */
/*
* Copyright (C) 2007 John Birrell <jb@freebsd.org>
* All rights reserved.
@ -23,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/cddl/compat/opensolaris/include/stdlib.h,v 1.2.4.1 2009/08/03 08:13:06 kensmith Exp $
* $FreeBSD: src/compat/opensolaris/include/stdlib.h,v 1.1 2007/11/28 21:40:07 jb Exp $
*
*/

View File

@ -1,3 +1,5 @@
/* $NetBSD: strings.h,v 1.3 2010/02/21 01:46:34 darran Exp $ */
/*
* Copyright (C) 2007 John Birrell <jb@freebsd.org>
* All rights reserved.
@ -23,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/cddl/compat/opensolaris/include/strings.h,v 1.2.4.1 2009/08/03 08:13:06 kensmith Exp $
* $FreeBSD: src/compat/opensolaris/include/strings.h,v 1.1 2007/11/28 21:40:07 jb Exp $
*
*/

View File

@ -1,3 +1,5 @@
/* $NetBSD: unistd.h,v 1.3 2010/02/21 01:46:34 darran Exp $ */
/*
* Copyright (C) 2007 John Birrell <jb@freebsd.org>
* All rights reserved.
@ -23,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/cddl/compat/opensolaris/include/unistd.h,v 1.2.4.1 2009/08/03 08:13:06 kensmith Exp $
* $FreeBSD: src/compat/opensolaris/include/unistd.h,v 1.1 2007/11/28 21:40:07 jb Exp $
*
*/

View File

@ -1,4 +1,33 @@
/* $FreeBSD: src/cddl/compat/opensolaris/include/zone.h,v 1.3.2.1 2009/08/03 08:13:06 kensmith Exp $ */
/* $NetBSD: zone.h,v 1.3 2010/02/21 01:46:34 darran Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Andrew Doran.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY 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.
*/
#ifndef _ZONE_H_
#define _ZONE_H_

View File

@ -1,22 +1,19 @@
# $FreeBSD: src/cddl/lib/Makefile,v 1.9.2.1 2009/08/03 08:13:06 kensmith Exp $
# $NetBSD: Makefile,v 1.3 2010/02/21 01:46:34 darran Exp $
#
#
.include <bsd.own.mk>
SUBDIR= drti \
libavl \
libctf \
libdtrace \
libnvpair \
libumem \
libuutil \
${_libzfs} \
${_libzpool}
.if ${MK_ZFS} != "no"
_libzfs= libzfs
.if ${MK_LIBTHR} != "no"
_libzpool= libzpool
.if (defined(MKDTRACE) && ${MKDTRACE} != "no")
SUBDIR+= libdtrace
SUBDIR+= libctf
.endif
.if !defined(MKZFS) || ${MKZFS} != "no"
SUBDIR+= libavl
SUBDIR+= libnvpair
SUBDIR+= libumem
SUBDIR+= libuutil
SUBDIR+= libzfs
SUBDIR+= libzpool
.endif
.include <bsd.subdir.mk>

View File

@ -1,6 +1,4 @@
# $FreeBSD: src/cddl/lib/Makefile.inc,v 1.3.2.1 2009/08/03 08:13:06 kensmith Exp $
# $NetBSD: Makefile.inc,v 1.3 2010/02/21 01:46:34 darran Exp $
SHLIBDIR?= /lib
SHLIB_MAJOR?= 2
.include "../Makefile.inc"
MKLINT=no
MKLINTLIB=no

View File

@ -1,10 +1,9 @@
# $FreeBSD: src/cddl/lib/libavl/Makefile,v 1.3.2.1 2009/08/03 08:13:06 kensmith Exp $
# $NetBSD: Makefile,v 1.3 2010/02/21 01:46:35 darran Exp $
.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/avl
.PATH: ${.CURDIR}/../../dist/common/avl
LIB= avl
SRCS= avl.c
CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris
CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common
.include "../../Makefile.zfs"
.include <bsd.lib.mk>

View File

@ -1,9 +1,10 @@
# $NetBSD: Makefile,v 1.2 2010/02/21 01:46:35 darran Exp $
# $FreeBSD: src/cddl/lib/libctf/Makefile,v 1.2.2.1 2009/08/03 08:13:06 kensmith Exp $
.include "../../Makefile.inc"
LIB= ctf
SHLIB_MAJOR= 2
SRCS= ctf_create.c \
ctf_decl.c \
@ -23,8 +24,8 @@ SRCS= ctf_create.c \
CFLAGS+= -DCTF_OLD_VERSIONS
CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \
-I${.CURDIR}/../../../cddl/compat/opensolaris/include \
CFLAGS+= -I${OSNETDIR}/sys \
-I${OSNETDIR}/include \
-I${OPENSOLARIS_USR_DISTDIR}/head \
-I${OPENSOLARIS_USR_DISTDIR}/common/ctf \
-I${OPENSOLARIS_USR_DISTDIR}/lib/libctf/common \

View File

@ -0,0 +1,6 @@
# $NetBSD: shlib_version,v 1.1 2010/02/21 01:46:35 darran Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
#
major=2
minor=0

View File

@ -1,11 +1,12 @@
# $NetBSD: Makefile,v 1.2 2010/02/21 01:46:35 darran Exp $
# $FreeBSD: src/cddl/lib/libdtrace/Makefile,v 1.2.2.1 2009/08/03 08:13:06 kensmith Exp $
.include "../../Makefile.inc"
LIB= dtrace
SHLIB_MAJOR= 2
WARNS= 1
#WARNS= 1
SRCS= dt_aggregate.c \
dt_as.c \
@ -55,13 +56,15 @@ DSRCS= errno.d \
.PATH: ${OPENSOLARIS_USR_DISTDIR}/lib/libgen/common
CFLAGS+= -I${.OBJDIR} \
-I${.CURDIR}/../../../sys/cddl/compat/opensolaris \
-I${.CURDIR}/../../../cddl/compat/opensolaris/include \
-I${OSNETDIR}/sys \
-I${OSNETDIR}/include \
-I${OPENSOLARIS_USR_DISTDIR}/head \
-I${OPENSOLARIS_USR_DISTDIR}/lib/libctf/common \
-I${OPENSOLARIS_USR_DISTDIR}/lib/libdtrace/common \
-I${OPENSOLARIS_SYS_DISTDIR}/uts/common
# XXX need new libelf (not GPL)
#CFLAGS+= -DYYDEBUG
.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64"
@ -77,7 +80,7 @@ LFLAGS+=-l
YFLAGS+=-d
CLEANFILES= dt_errtags.c dt_names.c
CLEANFILES= dt_errtags.c dt_names.c dt_grammar.h
dt_errtags.c:
sh ${OPENSOLARIS_USR_DISTDIR}/lib/libdtrace/common/mkerrtags.sh < ${OPENSOLARIS_USR_DISTDIR}/lib/libdtrace/common/dt_errtags.h > dt_errtags.c
@ -87,11 +90,11 @@ dt_names.c:
beforedepend: dt_errtags.c dt_names.c
beforeinstall:
.if exists(${DESTDIR}/usr/lib/dtrace)
.for file in ${DSRCS}
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} ${.CURDIR}/${file} ${DESTDIR}/usr/lib/dtrace
.endfor
.endif
#beforeinstall:
#.if exists(${DESTDIR}/usr/lib/dtrace)
#.for file in ${DSRCS}
# ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} ${.CURDIR}/${file} ${DESTDIR}/usr/lib/dtrace
#.endfor
#.endif
.include <bsd.lib.mk>

View File

@ -1,3 +1,5 @@
/* $NetBSD: errno.d,v 1.2 2010/02/21 01:46:35 darran Exp $ */
/*
* CDDL HEADER START
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: net.d,v 1.2 2010/02/21 01:46:35 darran Exp $ */
/*
* CDDL HEADER START
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: nfs.d,v 1.2 2010/02/21 01:46:35 darran Exp $ */
/*
* CDDL HEADER START
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: psinfo.d,v 1.2 2010/02/21 01:46:35 darran Exp $ */
/*
* CDDL HEADER START
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: sched.d,v 1.2 2010/02/21 01:46:35 darran Exp $ */
/*
* CDDL HEADER START
*

View File

@ -0,0 +1,6 @@
# $NetBSD: shlib_version,v 1.1 2010/02/21 01:46:35 darran Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
#
major=2
minor=0

View File

@ -1,3 +1,5 @@
/* $NetBSD: signal.d,v 1.2 2010/02/21 01:46:35 darran Exp $ */
/*
* CDDL HEADER START
*

View File

@ -1,3 +1,5 @@
/* $NetBSD: unistd.d,v 1.2 2010/02/21 01:46:35 darran Exp $ */
/*
* CDDL HEADER START
*

View File

@ -1,18 +1,17 @@
# $FreeBSD: src/cddl/lib/libnvpair/Makefile,v 1.4.2.2 2009/08/17 08:09:46 pjd Exp $
# $NetBSD: Makefile,v 1.4 2010/02/21 01:46:35 darran Exp $
.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libnvpair
.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/nvpair
.PATH: ${.CURDIR}/../../dist/lib/libnvpair
.PATH: ${.CURDIR}/../../dist/common/nvpair
LIB= nvpair
SRCS= libnvpair.c \
nvpair_alloc_system.c \
nvpair_alloc_fixed.c \
nvpair.c
SRCS= lib_nvpair.c nvpair_alloc_system.c nvpair_alloc_fixed.c nvpair.c
CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/include
CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris
CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common
CFLAGS+= -I${.CURDIR}/../../../sys
lib_nvpair.c: libnvpair.c
@rm -f ${.TARGET}
@ln -s ${.ALLSRC} ${.TARGET}
CLEANFILES+=lib_nvpair.c
.include "../../Makefile.zfs"
.include <bsd.lib.mk>

View File

@ -1,9 +1,7 @@
# $FreeBSD: src/cddl/lib/libumem/Makefile,v 1.3.2.1 2009/08/03 08:13:06 kensmith Exp $
.PATH: ${.CURDIR}/../../../cddl/compat/opensolaris/lib/libumem
# $NetBSD: Makefile,v 1.3 2010/02/21 01:46:35 darran Exp $
LIB= umem
SRCS= umem.c
CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/lib/libumem
.include "../../Makefile.zfs"
.include <bsd.lib.mk>

View File

@ -1,25 +1,13 @@
# $FreeBSD: src/cddl/lib/libuutil/Makefile,v 1.3.2.1 2009/08/03 08:13:06 kensmith Exp $
# $NetBSD: Makefile,v 1.3 2010/02/21 01:46:35 darran Exp $
.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libuutil/common
.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/avl
.PATH: ${.CURDIR}/../../dist/lib/libuutil/common
.PATH: ${.CURDIR}/../../dist/common/avl
LIB= uutil
SRCS= avl.c \
uu_alloc.c \
uu_avl.c \
uu_dprintf.c \
uu_ident.c \
uu_list.c \
uu_misc.c \
uu_open.c \
uu_pname.c \
uu_strtoint.c
SRCS= avl.c uu_alloc.c uu_avl.c uu_dprintf.c uu_ident.c uu_list.c \
uu_misc.c uu_open.c uu_pname.c uu_strtoint.c
CFLAGS+= -DNATIVE_BUILD
CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libuutil/common
CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris
CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common
CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/include
CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/head
.include "../../Makefile.zfs"
.include <bsd.lib.mk>

View File

@ -1,51 +1,30 @@
# $FreeBSD: src/cddl/lib/libzfs/Makefile,v 1.5.2.1 2009/08/03 08:13:06 kensmith Exp $
# $NetBSD: Makefile,v 1.3 2010/02/21 01:46:35 darran Exp $
.PATH: ${.CURDIR}/../../../cddl/compat/opensolaris/misc
.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs
.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs
.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzfs/common
.PATH: ${.CURDIR}/../../dist/common/zfs
.PATH: ${.CURDIR}/../../dist/common/fs/zfs
.PATH: ${.CURDIR}/../../dist/lib/libzfs/common
LIB= zfs
DPADD= ${LIBUTIL}
LDADD= -lutil
SRCS= deviceid.c \
fsshare.c \
mkdirp.c \
mnttab.c \
zmount.c \
zone.c
# Local
SRCS= deviceid.c mnttab.c mkdirp.c zmount.c fsshare.c zone.c efi.c ucred.c
SRCS+= zfs_deleg.c \
zfs_namecheck.c \
zfs_prop.c \
zpool_prop.c \
zprop_common.c \
libzfs_dataset.c \
libzfs_util.c \
libzfs_graph.c \
libzfs_mount.c \
libzfs_pool.c \
libzfs_changelist.c \
libzfs_config.c \
libzfs_import.c \
libzfs_sendrecv.c \
libzfs_status.c
# Sun
SRCS+= zfs_namecheck.c zprop_common.c zfs_prop.c zpool_prop.c
SRCS+= zfs_deleg.c zfs_comutil.c
SRCS+= libzfs_dataset.c libzfs_util.c libzfs_graph.c libzfs_mount.c
SRCS+= libzfs_pool.c libzfs_changelist.c libzfs_config.c libzfs_import.c
SRCS+= libzfs_status.c libzfs_sendrecv.c
CFLAGS+= -DZFS_NO_ACL
CFLAGS+= -I${.CURDIR}/../../../sbin/mount
CFLAGS+= -I${.CURDIR}/../../../cddl/lib/libumem
CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris
CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/include
CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/lib/libumem
CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzpool/common
CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs
CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs
CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/sys
CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/head
CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common
CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libnvpair
CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libuutil/common
CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzfs/common
CPPFLAGS+= -I${NETBSDSRCDIR}/sbin/mount
# Avoid conflict with libprop
CPPFLAGS+= -D_PROPLIB_ZFS_CONFLICT
# Avoid internal header conflicts
CPPFLAGS+= -D_ZFS_CONTEXT_NO_VERIFY
.include "../../Makefile.zfs"
.include <bsd.lib.mk>

View File

@ -1,63 +1,36 @@
# $FreeBSD: src/cddl/lib/libzpool/Makefile,v 1.9.2.1 2009/08/03 08:13:06 kensmith Exp $
# $NetBSD: Makefile,v 1.4 2010/02/21 01:46:35 darran Exp $
.include "${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/Makefile.files"
.include "${.CURDIR}/../../dist/uts/common/Makefile.files"
.include "../../Makefile.zfs"
# ZFS_COMMON_SRCS
.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs
# ZFS_SHARED_SRCS
.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs
# KERNEL_SRCS
.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzpool/common
# LIST_SRCS
.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/os
# ATOMIC_SRCS
.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "ia64"
.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/atomic/${MACHINE_ARCH}
ATOMIC_SRCS= opensolaris_atomic.S
.else
.PATH: ${.CURDIR}/../../../sys/cddl/compat/opensolaris/kern
ATOMIC_SRCS= opensolaris_atomic.c
.endif
# UNICODE_SRCS
.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/unicode
.PATH: ${.CURDIR}/../../dist/common/zfs
.PATH: ${.CURDIR}/../../dist/common/unicode
.PATH: ${.CURDIR}/../../dist/lib/libzpool/common
.PATH: ${.CURDIR}/../../dist/uts/common/fs/zfs
.PATH: ${.CURDIR}/../../dist/uts/common/os
LIB= zpool
ZFS_COMMON_SRCS= ${ZFS_COMMON_OBJS:C/.o$/.c/} vdev_file.c
ZFS_SHARED_SRCS= ${ZFS_SHARED_OBJS:C/.o$/.c/}
KERNEL_SRCS= kernel.c taskq.c util.c
LIST_SRCS= list.c
UNICODE_SRCS= u8_textprep.c
SRCS= ${ZFS_COMMON_SRCS} ${ZFS_SHARED_SRCS} \
${KERNEL_SRCS} ${LIST_SRCS} ${ATOMIC_SRCS} \
${UNICODE_SRCS}
CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris
CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/include
CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/lib/libumem
CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzpool/common
CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/sys
CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs
CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs
CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common
CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/head
CFLAGS+= -I${.CURDIR}/../../../cddl/lib/libumem
CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libnvpair
# XXX: pthread doesn't have mutex_owned() equivalent, so we need to look
# into libthr private structures. That's sooo evil, but it's only for
# ZFS debugging tools needs.
CFLAGS+= -DWANTS_MUTEX_OWNED
CFLAGS+= -I${.CURDIR}/../../../lib/libpthread/thread
CFLAGS+= -I${.CURDIR}/../../../lib/libpthread/sys
CFLAGS+= -I${.CURDIR}/../../../lib/libthr/arch/${MACHINE_ARCH}/include
DPADD= ${LIBPTHREAD} ${LIBZ}
LDADD= -lpthread -lz
CPPFLAGS+= -std=c99
# atomic.S doesn't like profiling.
NO_PROFILE=
# Local stuff
SRCS= kernel.c kernel2.c
# Sun stuff
SRCS+= ${ZFS_COMMON_OBJS:C/.o$/.c/}
SRCS+= ${ZFS_SHARED_OBJS:C/.o$/.c/}
SRCS+= taskq.c util.c list.o u8_textprep.o
# Add opensolaris atomic functions and use fakedones if we do not support them
.if ${MACHINE_ARCH} == "i386"
CPPFLAGS+= -D__HAVE_ATOMIC64_OPS # add NetBSD 64 add operations on i386
.PATH: ${NETBSDSRCDIR}/common/lib/libc/atomic
SRCS+= atomic_add_64_cas.c atomic_add_64_nv_cas.c atomic_inc_64_add.c atomic_dec_64_add.c
.endif
print:
echo ${LIST_SRCS} ${LIST_OBJS}
CSTD= c99
.include <bsd.lib.mk>

View File

@ -1,12 +1,9 @@
/* $NetBSD: processor.h,v 1.1 2009/08/07 20:57:58 haad Exp $ */
/* $NetBSD: elf.h,v 1.1 2010/02/21 01:46:35 darran Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Andrew Doran.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -28,3 +25,14 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _ELF_H_
#define _ELF_H_
#if HAVE_NBTOOL_CONFIG_H
#include <nbinclude/sys/exec_elf.h>
#else
#include <sys/exec_elf.h>
#endif
#endif

View File

@ -1,3 +1,5 @@
/* $NetBSD: endian.h,v 1.2 2010/02/21 01:46:35 darran Exp $ */
/*-
* Copyright (c) 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org>
* All rights reserved.

View File

@ -1,3 +1,5 @@
/* $NetBSD: acl.h,v 1.2 2010/02/21 01:46:35 darran Exp $ */
/*-
* Copyright (c) 2008, 2009 Edward Tomasz Napierała <trasz@FreeBSD.org>
* All rights reserved.

View File

@ -1,3 +1,5 @@
/* $NetBSD: acl_common.h,v 1.2 2010/02/21 01:46:36 darran Exp $ */
/*
* CDDL HEADER START
*

View File

@ -1,7 +1,12 @@
/* $NetBSD: atomic.h,v 1.3 2010/02/21 01:46:35 darran Exp $ */
/*-
* Copyright (c) 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org>
* Copyright (c) 2009 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Andrew Doran.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -11,118 +16,69 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY 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.
*
* $FreeBSD: src/sys/cddl/compat/opensolaris/sys/atomic.h,v 1.6.2.1 2009/08/03 08:13:06 kensmith Exp $
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY 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.
*/
#ifndef _OPENSOLARIS_SYS_ATOMIC_H_
#define _OPENSOLARIS_SYS_ATOMIC_H_
#ifndef _CDDL_SYS_ATOMIC_H_
#define _CDDL_SYS_ATOMIC_H_
#include <sys/types.h>
#include <machine/atomic.h>
#include_next <sys/atomic.h>
#define casptr(_a, _b, _c) \
atomic_cmpset_ptr((volatile uintptr_t *)(_a), (uintptr_t)(_b), (uintptr_t) (_c))
#define cas32 atomic_cmpset_32
#define casptr(_a, _b, _c) \
atomic_cas_ptr((volatile uint64_t *) _a, _b, _c);
#ifndef __LP64__
extern void atomic_add_64(volatile uint64_t *target, int64_t delta);
extern void atomic_dec_64(volatile uint64_t *target);
extern void *atomic_cas_ptr(volatile void *target, void *cmp, void *newval);
#endif
#ifndef __sparc64__
extern uint64_t atomic_cas_64(volatile uint64_t *target, uint64_t cmp,
uint64_t newval);
#endif
extern uint64_t atomic_add_64_nv(volatile uint64_t *target, int64_t delta);
extern uint8_t atomic_or_8_nv(volatile uint8_t *target, uint8_t value);
extern void membar_producer(void);
#if defined(__sparc64__) || defined(__powerpc__) || defined(__arm__) || \
defined(__mips__)
extern void atomic_or_8(volatile uint8_t *target, uint8_t value);
static __inline void
atomic_or_8(volatile uint8_t *ptr, uint8_t val)
{
uint32_t mask;
#if _BYTE_ORDER == _LITTLE_ENDIAN
switch ((uintptr_t)ptr & 3) {
case 0:
mask = (uint32_t)val;
break;
case 1:
mask = (uint32_t)val << 8;
break;
case 2:
mask = (uint32_t)val << 16;
break;
case 3:
mask = (uint32_t)val << 24;
break;
}
#elif _BYTE_ORDER == _BIG_ENDIAN
switch ((uintptr_t)ptr & 3) {
case 3:
mask = (uint32_t)val;
break;
case 2:
mask = (uint32_t)val << 8;
break;
case 1:
mask = (uint32_t)val << 16;
break;
case 0:
mask = (uint32_t)val << 24;
break;
}
#else
static __inline void
atomic_or_8(volatile uint8_t *target, uint8_t value)
{
atomic_set_8(target, value);
}
#error What byte order?
#endif
static __inline uint32_t
atomic_add_32_nv(volatile uint32_t *target, int32_t delta)
{
return (atomic_fetchadd_32(target, delta) + delta);
atomic_or_32((uint32_t *)((uintptr_t)ptr & (uintptr_t)~3ULL), mask);
}
static __inline u_int
atomic_add_int_nv(volatile u_int *target, int delta)
{
return (atomic_add_32_nv(target, delta));
}
static __inline void
atomic_dec_32(volatile uint32_t *target)
{
atomic_subtract_32(target, 1);
}
static __inline uint32_t
atomic_dec_32_nv(volatile uint32_t *target)
{
return (atomic_fetchadd_32(target, -1) - 1);
}
#ifdef __LP64__
static __inline void
atomic_dec_64(volatile uint64_t *target)
{
atomic_subtract_64(target, 1);
}
#endif
static __inline void
atomic_inc_32(volatile uint32_t *target)
{
atomic_add_32(target, 1);
}
static __inline uint32_t
atomic_inc_32_nv(volatile uint32_t *target)
{
return (atomic_add_32_nv(target, 1));
}
static __inline void
atomic_inc_64(volatile uint64_t *target)
{
atomic_add_64(target, 1);
}
static __inline uint64_t
atomic_inc_64_nv(volatile uint64_t *target)
{
return (atomic_add_64_nv(target, 1));
}
#ifdef __LP64__
static __inline void *
atomic_cas_ptr(volatile void *target, void *cmp, void *newval)
{
return ((void *)atomic_cas_64((volatile uint64_t *)target, (uint64_t)cmp,
(uint64_t)newval));
}
#endif
#endif /* !_OPENSOLARIS_SYS_ATOMIC_H_ */
#endif /* _CDDL_SYS_ATOMIC_H */

View File

@ -1,3 +1,5 @@
/* $NetBSD: bitmap.h,v 1.3 2010/02/21 01:46:35 darran Exp $ */
/*
* CDDL HEADER START
*
@ -17,8 +19,6 @@
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
* $FreeBSD: src/sys/cddl/compat/opensolaris/sys/bitmap.h,v 1.3.4.1 2009/08/03 08:13:06 kensmith Exp $
*/
/*

View File

@ -1,3 +1,5 @@
/* $NetBSD: byteorder.h,v 1.3 2010/02/21 01:46:35 darran Exp $ */
/*
* CDDL HEADER START
*
@ -17,8 +19,6 @@
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
* $FreeBSD: src/sys/cddl/compat/opensolaris/sys/byteorder.h,v 1.3.2.1 2009/08/03 08:13:06 kensmith Exp $
*/
/*

Some files were not shown because too many files have changed in this diff Show More