summaryrefslogtreecommitdiffstats
path: root/cddl
diff options
context:
space:
mode:
authorjb <jb@FreeBSD.org>2008-04-26 05:03:22 +0000
committerjb <jb@FreeBSD.org>2008-04-26 05:03:22 +0000
commit85357324f2d4096e2b4646c7e8393e9332aa1877 (patch)
tree24e6c8c83f26b0b38a2dd98068cff55b051df2e6 /cddl
parent33da69dc61c80c85dba628b9ea42f3853d6dc15e (diff)
downloadFreeBSD-src-85357324f2d4096e2b4646c7e8393e9332aa1877.zip
FreeBSD-src-85357324f2d4096e2b4646c7e8393e9332aa1877.tar.gz
* Make this file compile cleanly.
* Add FreeBSD constructor/destructor definitions.
Diffstat (limited to 'cddl')
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/drti.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c b/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c
index f8570e6..c983c5b 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c
@@ -55,7 +55,7 @@
* DTRACE_DOF_INIT_DEVNAME set the path to the helper node
*/
-static const char *devname = "/dev/dtrace/helper";
+static const char *devnamep = "/dev/dtrace/helper";
static const char *olddevname = "/devices/pseudo/dtrace@0:helper";
static const char *modname; /* Name of this load object */
@@ -85,7 +85,12 @@ dprintf(int debug, const char *fmt, ...)
va_end(ap);
}
+#if defined(sun)
#pragma init(dtrace_dof_init)
+#else
+static void dtrace_dof_init(void) __attribute__ ((constructor));
+#endif
+
static void
dtrace_dof_init(void)
{
@@ -96,8 +101,13 @@ dtrace_dof_init(void)
Elf32_Ehdr *elf;
#endif
dof_helper_t dh;
+#if defined(sun)
Link_map *lmp;
Lmid_t lmid;
+#else
+ struct link_map *lmp;
+ u_long lmid = 0;
+#endif
int fd;
const char *p;
@@ -109,10 +119,12 @@ dtrace_dof_init(void)
return;
}
+#if defined(sun)
if (dlinfo(RTLD_SELF, RTLD_DI_LMID, &lmid) == -1) {
dprintf(1, "couldn't discover link map ID\n");
return;
}
+#endif
if ((modname = strrchr(lmp->l_name, '/')) == NULL)
modname = lmp->l_name;
@@ -130,7 +142,7 @@ dtrace_dof_init(void)
elf = (void *)lmp->l_addr;
dh.dofhp_dof = (uintptr_t)dof;
- dh.dofhp_addr = elf->e_type == ET_DYN ? lmp->l_addr : 0;
+ dh.dofhp_addr = elf->e_type == ET_DYN ? (uintptr_t) lmp->l_addr : 0;
if (lmid == 0) {
(void) snprintf(dh.dofhp_mod, sizeof (dh.dofhp_mod),
@@ -141,10 +153,10 @@ dtrace_dof_init(void)
}
if ((p = getenv("DTRACE_DOF_INIT_DEVNAME")) != NULL)
- devname = p;
+ devnamep = p;
- if ((fd = open64(devname, O_RDWR)) < 0) {
- dprintf(1, "failed to open helper device %s", devname);
+ if ((fd = open64(devnamep, O_RDWR)) < 0) {
+ dprintf(1, "failed to open helper device %s", devnamep);
/*
* If the device path wasn't explicitly set, try again with
@@ -153,10 +165,10 @@ dtrace_dof_init(void)
if (p != NULL)
return;
- devname = olddevname;
+ devnamep = olddevname;
- if ((fd = open64(devname, O_RDWR)) < 0) {
- dprintf(1, "failed to open helper device %s", devname);
+ if ((fd = open64(devnamep, O_RDWR)) < 0) {
+ dprintf(1, "failed to open helper device %s", devnamep);
return;
}
}
@@ -169,14 +181,19 @@ dtrace_dof_init(void)
(void) close(fd);
}
+#if defined(sun)
#pragma fini(dtrace_dof_fini)
+#else
+static void dtrace_dof_fini(void) __attribute__ ((destructor));
+#endif
+
static void
dtrace_dof_fini(void)
{
int fd;
- if ((fd = open64(devname, O_RDWR)) < 0) {
- dprintf(1, "failed to open helper device %s", devname);
+ if ((fd = open64(devnamep, O_RDWR)) < 0) {
+ dprintf(1, "failed to open helper device %s", devnamep);
return;
}
OpenPOWER on IntegriCloud