summaryrefslogtreecommitdiffstats
path: root/cddl/contrib/opensolaris
diff options
context:
space:
mode:
authorjb <jb@FreeBSD.org>2008-04-26 04:01:35 +0000
committerjb <jb@FreeBSD.org>2008-04-26 04:01:35 +0000
commit17d482cf8c4ccc069ec0b163071ae7dc7d416184 (patch)
tree991b48bb736dc250125471b73aecbbb8c3354328 /cddl/contrib/opensolaris
parent134952ed1b96b079762297c69603a272fc0f4a00 (diff)
downloadFreeBSD-src-17d482cf8c4ccc069ec0b163071ae7dc7d416184.zip
FreeBSD-src-17d482cf8c4ccc069ec0b163071ae7dc7d416184.tar.gz
A lot of changes to make this code compile cleanly on FreeBSD.
Diffstat (limited to 'cddl/contrib/opensolaris')
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/common/list.c4
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/common/memory.c1
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/alist.c38
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/alist.h1
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c14
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h5
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c109
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/ctfconvert.c21
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c16
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h28
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/fixup_tdescs.c24
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/hash.c26
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/iidesc.c20
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/input.c5
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/merge.c81
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/output.c61
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c34
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/stabs.c12
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/strtab.c2
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/strtab.h2
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/tdata.c42
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/traverse.c18
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/traverse.h2
23 files changed, 342 insertions, 224 deletions
diff --git a/cddl/contrib/opensolaris/tools/ctf/common/list.c b/cddl/contrib/opensolaris/tools/ctf/common/list.c
index c01de9b..4958f27 100644
--- a/cddl/contrib/opensolaris/tools/ctf/common/list.c
+++ b/cddl/contrib/opensolaris/tools/ctf/common/list.c
@@ -70,7 +70,7 @@ slist_add(list_t **list, void *data, int (*cmp)(void *, void *))
/*ARGSUSED2*/
static int
-list_defcmp(void *d1, void *d2, void *private)
+list_defcmp(void *d1, void *d2, void *private __unused)
{
return (d1 != d2);
}
@@ -135,7 +135,7 @@ list_iter(list_t *list, int (*func)(void *, void *), void *private)
/*ARGSUSED*/
static int
-list_count_cb(void *data, void *private)
+list_count_cb(void *data __unused, void *private __unused)
{
return (1);
}
diff --git a/cddl/contrib/opensolaris/tools/ctf/common/memory.c b/cddl/contrib/opensolaris/tools/ctf/common/memory.c
index 390ff12..e16044a 100644
--- a/cddl/contrib/opensolaris/tools/ctf/common/memory.c
+++ b/cddl/contrib/opensolaris/tools/ctf/common/memory.c
@@ -35,6 +35,7 @@
#include <stdlib.h>
#include <string.h>
#include <strings.h>
+#include "memory.h"
static void
memory_bailout(void)
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/alist.c b/cddl/contrib/opensolaris/tools/ctf/cvt/alist.c
index 415a6cd..8e776dc 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/alist.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/alist.c
@@ -52,16 +52,19 @@ typedef struct alist_el {
} alist_el_t;
static int
-alist_hash(int nbuckets, alist_el_t *el)
+alist_hash(int nbuckets, void *arg)
{
+ alist_el_t *el = arg;
uintptr_t num = (uintptr_t)el->ale_name;
return (num % nbuckets);
}
static int
-alist_cmp(alist_el_t *el1, alist_el_t *el2)
+alist_cmp(void *arg1, void *arg2)
{
+ alist_el_t *el1 = arg1;
+ alist_el_t *el2 = arg2;
return ((uintptr_t)el1->ale_name != (uintptr_t)el2->ale_name);
}
@@ -84,12 +87,14 @@ alist_t *
alist_new(void (*namefree)(void *), void (*valfree)(void *))
{
return (alist_xnew(ALIST_HASH_SIZE, namefree, valfree,
- (int (*)())alist_hash, (int (*)())alist_cmp));
+ alist_hash, alist_cmp));
}
static void
-alist_free_cb(alist_el_t *el, alist_t *alist)
+alist_free_cb(void *arg1, void *arg2)
{
+ alist_el_t *el = arg1;
+ alist_t *alist = arg2;
if (alist->al_namefree)
alist->al_namefree(el->ale_name);
if (alist->al_valfree)
@@ -100,7 +105,7 @@ alist_free_cb(alist_el_t *el, alist_t *alist)
void
alist_free(alist_t *alist)
{
- hash_free(alist->al_elements, (void (*)())alist_free_cb, alist);
+ hash_free(alist->al_elements, alist_free_cb, alist);
free(alist);
}
@@ -118,14 +123,17 @@ alist_add(alist_t *alist, void *name, void *value)
int
alist_find(alist_t *alist, void *name, void **value)
{
- alist_el_t template, *ret;
+ alist_el_t template, *retx;
+ void *ret;
template.ale_name = name;
- if (!hash_find(alist->al_elements, &template, (void **)&ret))
+ if (!hash_find(alist->al_elements, &template, &ret))
return (0);
- if (value)
- *value = ret->ale_value;
+ if (value) {
+ retx = ret;
+ *value = retx->ale_value;
+ }
return (1);
}
@@ -136,8 +144,10 @@ typedef struct alist_iter_data {
} alist_iter_data_t;
static int
-alist_iter_cb(alist_el_t *el, alist_iter_data_t *aid)
+alist_iter_cb(void *arg1, void *arg2)
{
+ alist_el_t *el = arg1;
+ alist_iter_data_t *aid = arg2;
return (aid->aid_func(el->ale_name, el->ale_value, aid->aid_priv));
}
@@ -149,7 +159,7 @@ alist_iter(alist_t *alist, int (*func)(void *, void *, void *), void *private)
aid.aid_func = func;
aid.aid_priv = private;
- return (hash_iter(alist->al_elements, (int (*)())alist_iter_cb, &aid));
+ return (hash_iter(alist->al_elements, alist_iter_cb, &aid));
}
/*
@@ -171,13 +181,13 @@ alist_def_print_cb(void *key, void *value)
{
printf("Key: ");
if (alist_def_print_cb_key_int == 1)
- printf("%5d ", (int)key);
+ printf("%5lu ", (ulong_t)key);
else
printf("%s\n", (char *)key);
printf("Value: ");
if (alist_def_print_cb_value_int == 1)
- printf("%5d\n", (int)value);
+ printf("%5lu\n", (ulong_t)value);
else
printf("%s\n", (char *)key);
@@ -187,7 +197,7 @@ alist_def_print_cb(void *key, void *value)
static int
alist_dump_cb(void *node, void *private)
{
- int (*printer)(void *, void *) = (int (*)())private;
+ int (*printer)(void *, void *) = private;
alist_el_t *el = node;
printer(el->ale_name, el->ale_value);
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/alist.h b/cddl/contrib/opensolaris/tools/ctf/cvt/alist.h
index ec49df1..629e029 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/alist.h
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/alist.h
@@ -48,6 +48,7 @@ void alist_add(alist_t *, void *, void *);
int alist_find(alist_t *, void *, void **);
int alist_iter(alist_t *, int (*)(void *, void *, void *), void *);
void alist_stats(alist_t *, int);
+int alist_dump(alist_t *, int (*)(void *, void *));
#ifdef __cplusplus
}
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c b/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c
index d91fbf4..bc278b0 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c
@@ -38,7 +38,9 @@
*/
#include <pthread.h>
+#if defined(sun)
#include <synch.h>
+#endif
#include <stdio.h>
#include "barrier.h"
@@ -47,7 +49,11 @@ void
barrier_init(barrier_t *bar, int nthreads)
{
pthread_mutex_init(&bar->bar_lock, NULL);
+#if defined(sun)
sema_init(&bar->bar_sem, 0, USYNC_THREAD, NULL);
+#else
+ sem_init(&bar->bar_sem, 0, 0);
+#endif
bar->bar_numin = 0;
bar->bar_nthr = nthreads;
@@ -60,7 +66,11 @@ barrier_wait(barrier_t *bar)
if (++bar->bar_numin < bar->bar_nthr) {
pthread_mutex_unlock(&bar->bar_lock);
+#if defined(sun)
sema_wait(&bar->bar_sem);
+#else
+ sem_wait(&bar->bar_sem);
+#endif
return (0);
@@ -70,7 +80,11 @@ barrier_wait(barrier_t *bar)
/* reset for next use */
bar->bar_numin = 0;
for (i = 1; i < bar->bar_nthr; i++)
+#if defined(sun)
sema_post(&bar->bar_sem);
+#else
+ sem_post(&bar->bar_sem);
+#endif
pthread_mutex_unlock(&bar->bar_lock);
return (1);
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h b/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h
index 3a62f30..c7e6212 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h
@@ -33,7 +33,12 @@
* APIs for the barrier synchronization primitive.
*/
+#if defined(sun)
#include <synch.h>
+#else
+#include <semaphore.h>
+typedef sem_t sema_t;
+#endif
#ifdef __cplusplus
extern "C" {
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c b/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c
index 91e0f61..6a9d67a 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c
@@ -66,7 +66,7 @@ struct ctf_buf {
/*PRINTFLIKE1*/
static void
-parseterminate(char *fmt, ...)
+parseterminate(const char *fmt, ...)
{
static char msgbuf[1024]; /* sigh */
va_list ap;
@@ -78,7 +78,7 @@ parseterminate(char *fmt, ...)
terminate("%s: %s\n", curfile, msgbuf);
}
-void
+static void
ctf_buf_grow(ctf_buf_t *b)
{
off_t ptroff = b->ctb_ptr - b->ctb_base;
@@ -89,7 +89,7 @@ ctf_buf_grow(ctf_buf_t *b)
b->ctb_ptr = b->ctb_base + ptroff;
}
-ctf_buf_t *
+static ctf_buf_t *
ctf_buf_new(void)
{
ctf_buf_t *b = xcalloc(sizeof (ctf_buf_t));
@@ -100,7 +100,7 @@ ctf_buf_new(void)
return (b);
}
-void
+static void
ctf_buf_free(ctf_buf_t *b)
{
strtab_destroy(&b->ctb_strtab);
@@ -108,14 +108,14 @@ ctf_buf_free(ctf_buf_t *b)
free(b);
}
-uint_t
+static uint_t
ctf_buf_cur(ctf_buf_t *b)
{
return (b->ctb_ptr - b->ctb_base);
}
-void
-ctf_buf_write(ctf_buf_t *b, const void *p, size_t n)
+static void
+ctf_buf_write(ctf_buf_t *b, void const *p, size_t n)
{
size_t len;
@@ -127,14 +127,16 @@ ctf_buf_write(ctf_buf_t *b, const void *p, size_t n)
bcopy(p, b->ctb_ptr, len);
b->ctb_ptr += len;
- p = (char *)p + len;
+ p = (char const *)p + len;
n -= len;
}
}
static int
-write_label(labelent_t *le, ctf_buf_t *b)
+write_label(void *arg1, void *arg2)
{
+ labelent_t *le = arg1;
+ ctf_buf_t *b = arg2;
ctf_lblent_t ctl;
ctl.ctl_label = strtab_insert(&b->ctb_strtab, le->le_name);
@@ -220,8 +222,10 @@ write_unsized_type_rec(ctf_buf_t *b, ctf_type_t *ctt)
}
static int
-write_type(tdesc_t *tp, ctf_buf_t *b)
+write_type(void *arg1, void *arg2)
{
+ tdesc_t *tp = arg1;
+ ctf_buf_t *b = arg2;
elist_t *ep;
mlist_t *mp;
intr_t *ip;
@@ -392,7 +396,7 @@ write_type(tdesc_t *tp, ctf_buf_t *b)
ctt.ctt_type = tp->t_fndef->fn_ret->t_id;
write_unsized_type_rec(b, &ctt);
- for (i = 0; i < tp->t_fndef->fn_nargs; i++) {
+ for (i = 0; i < (int) tp->t_fndef->fn_nargs; i++) {
id = tp->t_fndef->fn_args[i]->t_id;
ctf_buf_write(b, &id, sizeof (id));
}
@@ -457,14 +461,14 @@ compress_start(resbuf_t *rb)
}
static ssize_t
-compress_buffer(const void *buf, size_t n, void *data)
+compress_buffer(void *buf, size_t n, void *data)
{
resbuf_t *rb = (resbuf_t *)data;
int rc;
rb->rb_zstr.next_out = (Bytef *)rb->rb_ptr;
rb->rb_zstr.avail_out = rb->rb_size - (rb->rb_ptr - rb->rb_base);
- rb->rb_zstr.next_in = (Bytef *)buf;
+ rb->rb_zstr.next_in = buf;
rb->rb_zstr.avail_in = n;
while (rb->rb_zstr.avail_in) {
@@ -526,7 +530,7 @@ pad_buffer(ctf_buf_t *buf, int align)
}
static ssize_t
-bcopy_data(const void *buf, size_t n, void *data)
+bcopy_data(void *buf, size_t n, void *data)
{
caddr_t *posp = (caddr_t *)data;
bcopy(buf, *posp, n);
@@ -601,7 +605,7 @@ ctf_gen(iiburst_t *iiburst, size_t *resszp, int do_compress)
iiburst->iib_td->td_parname);
h.cth_lbloff = 0;
- (void) list_iter(iiburst->iib_td->td_labels, (int (*)())write_label,
+ (void) list_iter(iiburst->iib_td->td_labels, write_label,
buf);
pad_buffer(buf, 2);
@@ -616,7 +620,7 @@ ctf_gen(iiburst_t *iiburst, size_t *resszp, int do_compress)
pad_buffer(buf, 4);
h.cth_typeoff = ctf_buf_cur(buf);
- (void) list_iter(iiburst->iib_types, (int (*)())write_type, buf);
+ (void) list_iter(iiburst->iib_types, write_type, buf);
debug(2, "CTF wrote %d types\n", list_count(iiburst->iib_types));
@@ -637,7 +641,7 @@ ctf_gen(iiburst_t *iiburst, size_t *resszp, int do_compress)
return (outbuf);
}
-void
+static void
get_ctt_size(ctf_type_t *ctt, size_t *sizep, size_t *incrementp)
{
if (ctt->ctt_size == CTF_LSIZE_SENT) {
@@ -657,8 +661,8 @@ count_types(ctf_header_t *h, caddr_t data)
dptr = data + h->cth_typeoff;
while (dptr < data + h->cth_stroff) {
- /* LINTED - pointer alignment */
- ctf_type_t *ctt = (ctf_type_t *)dptr;
+ void *v = (void *) dptr;
+ ctf_type_t *ctt = v;
size_t vlen = CTF_INFO_VLEN(ctt->ctt_info);
size_t size, increment;
@@ -727,11 +731,11 @@ resurrect_labels(ctf_header_t *h, tdata_t *td, caddr_t ctfdata, char *matchlbl)
caddr_t sbuf = ctfdata + h->cth_stroff;
size_t bufsz = h->cth_objtoff - h->cth_lbloff;
int lastidx = 0, baseidx = -1;
- char *baselabel;
+ char *baselabel = NULL;
ctf_lblent_t *ctl;
+ void *v = (void *) buf;
- /* LINTED - pointer alignment */
- for (ctl = (ctf_lblent_t *)buf; (caddr_t)ctl < buf + bufsz; ctl++) {
+ for (ctl = v; (caddr_t)ctl < buf + bufsz; ctl++) {
char *label = sbuf + ctl->ctl_label;
lastidx = ctl->ctl_typeidx;
@@ -775,8 +779,8 @@ resurrect_objects(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
symit_reset(si);
for (dptr = buf; dptr < buf + bufsz; dptr += 2) {
- /* LINTED - pointer alignment */
- ushort_t id = *((ushort_t *)dptr);
+ void *v = (void *) dptr;
+ ushort_t id = *((ushort_t *)v);
iidesc_t *ii;
GElf_Sym *sym;
@@ -823,8 +827,8 @@ resurrect_functions(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
symit_reset(si);
while (dptr < buf + bufsz) {
- /* LINTED - pointer alignment */
- info = *((ushort_t *)dptr);
+ void *v = (void *) dptr;
+ info = *((ushort_t *)v);
dptr += 2;
if (!(sym = symit_next(si, STT_FUNC)) && info != 0)
@@ -836,8 +840,8 @@ resurrect_functions(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
continue;
}
- /* LINTED - pointer alignment */
- retid = *((ushort_t *)dptr);
+ v = (void *) dptr;
+ retid = *((ushort_t *)v);
dptr += 2;
if (retid >= tdsize)
@@ -856,8 +860,8 @@ resurrect_functions(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
xmalloc(sizeof (tdesc_t *) * ii->ii_nargs);
for (i = 0; i < ii->ii_nargs; i++, dptr += 2) {
- /* LINTED - pointer alignment */
- ushort_t id = *((ushort_t *)dptr);
+ v = (void *) dptr;
+ ushort_t id = *((ushort_t *)v);
if (id >= tdsize)
parseterminate("Reference to invalid type %d",
id);
@@ -917,8 +921,8 @@ resurrect_types(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
if (tid >= tdsize)
parseterminate("Reference to invalid type %d", tid);
- /* LINTED - pointer alignment */
- ctt = (ctf_type_t *)dptr;
+ void *v = (void *) dptr;
+ ctt = v;
get_ctt_size(ctt, &size, &increment);
dptr += increment;
@@ -942,8 +946,8 @@ resurrect_types(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
tdp->t_type = INTRINSIC;
tdp->t_size = size;
- /* LINTED - pointer alignment */
- data = *((uint_t *)dptr);
+ v = (void *) dptr;
+ data = *((uint_t *)v);
dptr += sizeof (uint_t);
encoding = CTF_INT_ENCODING(data);
@@ -969,8 +973,8 @@ resurrect_types(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
tdp->t_type = INTRINSIC;
tdp->t_size = size;
- /* LINTED - pointer alignment */
- data = *((uint_t *)dptr);
+ v = (void *) dptr;
+ data = *((uint_t *)v);
dptr += sizeof (uint_t);
ip = xcalloc(sizeof (intr_t));
@@ -990,8 +994,8 @@ resurrect_types(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
tdp->t_type = ARRAY;
tdp->t_size = size;
- /* LINTED - pointer alignment */
- cta = (ctf_array_t *)dptr;
+ v = (void *) dptr;
+ cta = v;
dptr += sizeof (ctf_array_t);
tdp->t_ardef = xmalloc(sizeof (ardef_t));
@@ -1008,9 +1012,8 @@ resurrect_types(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
if (size < CTF_LSTRUCT_THRESH) {
for (i = 0, mpp = &tdp->t_members; i < vlen;
i++, mpp = &((*mpp)->ml_next)) {
- /* LINTED - pointer alignment */
- ctf_member_t *ctm = (ctf_member_t *)
- dptr;
+ v = (void *) dptr;
+ ctf_member_t *ctm = v;
dptr += sizeof (ctf_member_t);
*mpp = xmalloc(sizeof (mlist_t));
@@ -1023,9 +1026,8 @@ resurrect_types(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
} else {
for (i = 0, mpp = &tdp->t_members; i < vlen;
i++, mpp = &((*mpp)->ml_next)) {
- /* LINTED - pointer alignment */
- ctf_lmember_t *ctlm = (ctf_lmember_t *)
- dptr;
+ v = (void *) dptr;
+ ctf_lmember_t *ctlm = v;
dptr += sizeof (ctf_lmember_t);
*mpp = xmalloc(sizeof (mlist_t));
@@ -1048,8 +1050,8 @@ resurrect_types(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
for (i = 0, epp = &tdp->t_emem; i < vlen;
i++, epp = &((*epp)->el_next)) {
- /* LINTED - pointer alignment */
- cte = (ctf_enum_t *)dptr;
+ v = (void *) dptr;
+ cte = v;
dptr += sizeof (ctf_enum_t);
*epp = xmalloc(sizeof (elist_t));
@@ -1084,9 +1086,8 @@ resurrect_types(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
tdp->t_fndef = xcalloc(sizeof (fndef_t));
tdp->t_fndef->fn_ret = tdarr[ctt->ctt_type];
- /* LINTED - pointer alignment */
- if (vlen > 0 && *(ushort_t *)(dptr +
- (sizeof (ushort_t) * (vlen - 1))) == 0)
+ v = (void *) (dptr + (sizeof (ushort_t) * (vlen - 1)));
+ if (vlen > 0 && *(ushort_t *)v == 0)
tdp->t_fndef->fn_vargs = 1;
tdp->t_fndef->fn_nargs = vlen - tdp->t_fndef->fn_vargs;
@@ -1094,8 +1095,8 @@ resurrect_types(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
vlen - tdp->t_fndef->fn_vargs);
for (i = 0; i < vlen; i++) {
- /* LINTED - pointer alignment */
- argid = *(ushort_t *)dptr;
+ v = (void *) dptr;
+ argid = *(ushort_t *)v;
dptr += sizeof (ushort_t);
if (argid != 0)
@@ -1196,7 +1197,7 @@ decompress_ctf(caddr_t cbuf, size_t cbufsz, caddr_t dbuf, size_t dbufsz)
(rc = inflate(&zstr, Z_NO_FLUSH)) != Z_STREAM_END ||
(rc = inflateEnd(&zstr)) != Z_OK) {
warning("CTF decompress zlib error %s\n", zError(rc));
- return (NULL);
+ return (0);
}
debug(3, "reflated %lu bytes to %lu, pointer at %d\n",
@@ -1225,8 +1226,8 @@ ctf_load(char *file, caddr_t buf, size_t bufsz, symit_data_t *si, char *label)
if (bufsz < sizeof (ctf_header_t))
parseterminate("Corrupt CTF - short header");
- /* LINTED - pointer alignment */
- h = (ctf_header_t *)buf;
+ void *v = (void *) buf;
+ h = v;
buf += sizeof (ctf_header_t);
bufsz -= sizeof (ctf_header_t);
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/ctfconvert.c b/cddl/contrib/opensolaris/tools/ctf/cvt/ctfconvert.c
index 756549e..efe6c27 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/ctfconvert.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/ctfconvert.c
@@ -46,7 +46,7 @@
const char *progname;
int debug_level = DEBUG_LEVEL;
-static const char *infile = NULL;
+static char *infile = NULL;
static const char *outfile = NULL;
static int dynsym;
@@ -64,10 +64,12 @@ usage(void)
static void
terminate_cleanup(void)
{
+#if !defined(__FreeBSD__)
if (!outfile) {
fprintf(stderr, "Removing %s\n", infile);
unlink(infile);
}
+#endif
}
static void
@@ -77,10 +79,10 @@ handle_sig(int sig)
}
static int
-file_read(tdata_t *td, const char *filename, int ignore_non_c)
+file_read(tdata_t *td, char *filename, int ignore_non_c)
{
- typedef int (*reader_f)(tdata_t *, Elf *, const char *);
- static const reader_f readers[] = {
+ typedef int (*reader_f)(tdata_t *, Elf *, char *);
+ static reader_f readers[] = {
stabs_read,
dw_read,
NULL
@@ -147,15 +149,17 @@ int
main(int argc, char **argv)
{
tdata_t *filetd, *mstrtd;
- char *label = NULL;
+ const char *label = NULL;
int verbose = 0;
int ignore_non_c = 0;
int keep_stabs = 0;
int c;
+#if defined(sun)
sighold(SIGINT);
sighold(SIGQUIT);
sighold(SIGTERM);
+#endif
progname = basename(argv[0]);
@@ -217,9 +221,15 @@ main(int argc, char **argv)
*/
set_terminate_cleanup(terminate_cleanup);
+#if defined(sun)
sigset(SIGINT, handle_sig);
sigset(SIGQUIT, handle_sig);
sigset(SIGTERM, handle_sig);
+#else
+ signal(SIGINT, handle_sig);
+ signal(SIGQUIT, handle_sig);
+ signal(SIGTERM, handle_sig);
+#endif
filetd = tdata_new();
@@ -243,7 +253,6 @@ main(int argc, char **argv)
write_ctf(mstrtd, infile, outfile, dynsym | keep_stabs);
} else {
char *tmpname = mktmpname(infile, ".ctf");
-
write_ctf(mstrtd, infile, tmpname, dynsym | keep_stabs);
if (rename(tmpname, infile) != 0)
terminate("Couldn't rename temp file %s", tmpname);
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c b/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c
index 2def4904..546dcdf 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c
@@ -176,16 +176,22 @@
#include <unistd.h>
#include <pthread.h>
#include <assert.h>
+#if defined(sun)
#include <synch.h>
+#endif
#include <signal.h>
#include <libgen.h>
#include <string.h>
#include <errno.h>
+#if defined(sun)
#include <alloca.h>
+#endif
#include <sys/param.h>
#include <sys/types.h>
#include <sys/mman.h>
+#if defined(sun)
#include <sys/sysconf.h>
+#endif
#include "ctf_headers.h"
#include "ctftools.h"
@@ -226,6 +232,7 @@ usage(void)
progname, progname);
}
+#if defined(sun)
static void
bigheap(void)
{
@@ -273,6 +280,7 @@ bigheap(void)
(void) memcntl(NULL, 0, MC_HAT_ADVISE, (caddr_t)&mha, 0, 0);
}
+#endif
static void
finalize_phase_one(workqueue_t *wq)
@@ -595,10 +603,12 @@ terminate_cleanup(void)
if (outfile == NULL)
return;
+#if !defined(__FreeBSD__)
if (dounlink) {
fprintf(stderr, "Removing %s\n", outfile);
unlink(outfile);
}
+#endif
}
static void
@@ -697,9 +707,15 @@ start_threads(workqueue_t *wq)
wq);
}
+#if defined(sun)
sigset(SIGINT, handle_sig);
sigset(SIGQUIT, handle_sig);
sigset(SIGTERM, handle_sig);
+#else
+ signal(SIGINT, handle_sig);
+ signal(SIGQUIT, handle_sig);
+ signal(SIGTERM, handle_sig);
+#endif
pthread_sigmask(SIG_UNBLOCK, &sets, NULL);
}
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h b/cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h
index 991f3bc..52bbf44 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h
@@ -91,7 +91,7 @@ extern "C" {
extern const char *progname;
extern int debug_level;
extern int debug_parse;
-extern const char *curhdr;
+extern char *curhdr;
/*
* This is a partial copy of the stab.h that DevPro includes with their
@@ -354,11 +354,11 @@ tdata_t *ctf_load(char *, caddr_t, size_t, symit_data_t *, char *);
iidesc_t *iidesc_new(char *);
int iidesc_hash(int, void *);
void iter_iidescs_by_name(tdata_t *, const char *,
- int (*)(iidesc_t *, void *), void *);
+ int (*)(void *, void *), void *);
iidesc_t *iidesc_dup(iidesc_t *);
iidesc_t *iidesc_dup_rename(iidesc_t *, char const *, char const *);
void iidesc_add(hash_t *, iidesc_t *);
-void iidesc_free(iidesc_t *, void *);
+void iidesc_free(void *, void *);
int iidesc_count_type(void *, void *);
void iidesc_stats(hash_t *);
int iidesc_dump(iidesc_t *);
@@ -404,10 +404,10 @@ void check_hash(void);
void resolve_typed_bitfields(void);
/* stabs.c */
-int stabs_read(tdata_t *, Elf *, const char *);
+int stabs_read(tdata_t *, Elf *, char *);
/* dwarf.c */
-int dw_read(tdata_t *, Elf *, const char *);
+int dw_read(tdata_t *, Elf *, char *);
const char *dw_tag2str(uint_t);
/* tdata.c */
@@ -422,7 +422,7 @@ int tdesc_namecmp(void *, void *);
int tdesc_layouthash(int, void *);
int tdesc_layoutcmp(void *, void *);
void tdesc_free(tdesc_t *);
-void tdata_label_add(tdata_t *, char *, int);
+void tdata_label_add(tdata_t *, const char *, int);
labelent_t *tdata_label_top(tdata_t *);
int tdata_label_find(tdata_t *, char *);
void tdata_label_free(tdata_t *);
@@ -434,13 +434,17 @@ int streq(const char *, const char *);
int findelfsecidx(Elf *, const char *, const char *);
size_t elf_ptrsz(Elf *);
char *mktmpname(const char *, const char *);
-void terminate(char *, ...);
-void aborterr(char *, ...);
-void set_terminate_cleanup(void (*)());
+void terminate(const char *, ...);
+void aborterr(const char *, ...);
+void set_terminate_cleanup(void (*)(void));
void elfterminate(const char *, const char *, ...);
-void warning(char *, ...);
-void vadebug(int, char *, va_list);
-void debug(int, char *, ...);
+void warning(const char *, ...);
+void vadebug(int, const char *, va_list);
+void debug(int, const char *, ...);
+
+
+void watch_dump(int);
+void watch_set(void *, int);
#ifdef __cplusplus
}
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/fixup_tdescs.c b/cddl/contrib/opensolaris/tools/ctf/cvt/fixup_tdescs.c
index 8524693..b239a62 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/fixup_tdescs.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/fixup_tdescs.c
@@ -52,17 +52,17 @@
static void
fix_ptrptr_to_struct(tdata_t *td)
{
- char *strs[2] = { "as", "fdbuffer" };
- char *mems[2] = { "a_objectdir", "fd_shadow" };
- char *acts[2] = { "vnode", "page" };
- char *tgts[2] = { "vnode_t", "page_t" };
+ const char *strs[2] = { "as", "fdbuffer" };
+ const char *mems[2] = { "a_objectdir", "fd_shadow" };
+ const char *acts[2] = { "vnode", "page" };
+ const char *tgts[2] = { "vnode_t", "page_t" };
tdesc_t *str;
tdesc_t *act, *tgt;
tdesc_t *p1, *p2;
mlist_t *ml;
int i;
- for (i = 0; i < sizeof (strs) / sizeof (strs[0]); i++) {
+ for (i = 0; i < (int) (sizeof (strs) / sizeof (strs[0])); i++) {
if (!(str = lookupname(strs[i])) || str->t_type != STRUCT)
continue;
@@ -106,8 +106,8 @@ fix_ptrptr_to_struct(tdata_t *td)
static void
fix_ptr_to_struct(tdata_t *td)
{
- char *strs[2] = { "vmem", "id_space" };
- char *mems[2] = { NULL, "is_vmem" };
+ const char *strs[2] = { "vmem", "id_space" };
+ const char *mems[2] = { NULL, "is_vmem" };
tdesc_t *ptr = NULL;
tdesc_t *str, *vmt;
mlist_t *ml;
@@ -116,7 +116,7 @@ fix_ptr_to_struct(tdata_t *td)
if ((vmt = lookupname("vmem_t")) == NULL || vmt->t_type != TYPEDEF)
return;
- for (i = 0; i < sizeof (strs) / sizeof (strs[0]); i++) {
+ for (i = 0; i < (int) (sizeof (strs) / sizeof (strs[0])); i++) {
if (!(str = lookupname(strs[i])) || str->t_type != STRUCT)
continue;
@@ -163,8 +163,10 @@ struct match {
};
static int
-matching_iidesc(iidesc_t *iidesc, struct match *match)
+matching_iidesc(void *arg1, void *arg2)
{
+ iidesc_t *iidesc = arg1;
+ struct match *match = arg2;
if (!streq(iidesc->ii_name, match->m_name))
return (0);
@@ -176,10 +178,10 @@ matching_iidesc(iidesc_t *iidesc, struct match *match)
}
static tdesc_t *
-lookup_tdesc(tdata_t *td, const char *name)
+lookup_tdesc(tdata_t *td, char const *name)
{
struct match match = { NULL, name };
- iter_iidescs_by_name(td, name, (int (*)())matching_iidesc, &match);
+ iter_iidescs_by_name(td, name, matching_iidesc, &match);
return (match.m_ret);
}
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/hash.c b/cddl/contrib/opensolaris/tools/ctf/cvt/hash.c
index e3c2978..36ed45a 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/hash.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/hash.c
@@ -50,7 +50,7 @@ struct hash {
struct hash_data {
hash_t *hd_hash;
- int (*hd_fun)();
+ int (*hd_fun)(void *, void *);
void *hd_key;
void *hd_private;
@@ -58,13 +58,14 @@ struct hash_data {
};
static int
-hash_def_hash(int nbuckets, uintptr_t data)
+hash_def_hash(int nbuckets, void *arg)
{
+ uintptr_t data = (uintptr_t) arg;
return (data % nbuckets);
}
static int
-hash_def_cmp(uintptr_t d1, uintptr_t d2)
+hash_def_cmp(void *d1, void *d2)
{
return (d1 != d2);
}
@@ -96,8 +97,8 @@ hash_new(int nbuckets, int (*hashfn)(int, void *), int (*cmp)(void *, void *))
hash = xmalloc(sizeof (hash_t));
hash->h_buckets = xcalloc(sizeof (list_t *) * nbuckets);
hash->h_nbuckets = nbuckets;
- hash->h_hashfn = hashfn ? hashfn : (int (*)())hash_def_hash;
- hash->h_cmp = cmp ? cmp : (int (*)())hash_def_cmp;
+ hash->h_hashfn = hashfn ? hashfn : hash_def_hash;
+ hash->h_cmp = cmp ? cmp : hash_def_cmp;
return (hash);
}
@@ -124,8 +125,9 @@ hash_merge(hash_t *to, hash_t *from)
}
static int
-hash_remove_cb(void *key1, void *key2, hash_t *hash)
+hash_remove_cb(void *key1, void *key2, void *arg)
{
+ hash_t *hash = arg;
return (hash->h_cmp(key1, key2));
}
@@ -135,7 +137,7 @@ hash_remove(hash_t *hash, void *key)
int bucket = hash->h_hashfn(hash->h_nbuckets, key);
(void) list_remove(&hash->h_buckets[bucket], key,
- (int (*)())hash_remove_cb, hash);
+ hash_remove_cb, hash);
}
int
@@ -148,8 +150,9 @@ hash_match(hash_t *hash, void *key, int (*fun)(void *, void *),
}
static int
-hash_find_list_cb(void *node, struct hash_data *hd)
+hash_find_list_cb(void *node, void *arg)
{
+ struct hash_data *hd = arg;
int cbrc;
int rc = 0;
@@ -174,14 +177,15 @@ hash_find_iter(hash_t *hash, void *key, int (*fun)(void *, void *),
hd.hd_key = key;
hd.hd_private = private;
- return (list_iter(hash->h_buckets[bucket], (int (*)())hash_find_list_cb,
+ return (list_iter(hash->h_buckets[bucket], hash_find_list_cb,
&hd));
}
/* stop on first match */
static int
-hash_find_first_cb(void *node, struct hash_data *hd)
+hash_find_first_cb(void *node, void *arg)
{
+ struct hash_data *hd = arg;
if (hd->hd_hash->h_cmp(hd->hd_key, node) == 0) {
hd->hd_ret = node;
return (-1);
@@ -200,7 +204,7 @@ hash_find(hash_t *hash, void *key, void **value)
hd.hd_fun = hash_find_first_cb;
hd.hd_key = key;
- ret = hash_match(hash, key, (int (*)())hash_find_first_cb, &hd);
+ ret = hash_match(hash, key, hash_find_first_cb, &hd);
if (ret && value)
*value = hd.hd_ret;
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/iidesc.c b/cddl/contrib/opensolaris/tools/ctf/cvt/iidesc.c
index b6b9a0c..fc1cefc 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/iidesc.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/iidesc.c
@@ -68,8 +68,10 @@ iidesc_hash(int nbuckets, void *arg)
}
static int
-iidesc_cmp(iidesc_t *src, iidesc_find_t *find)
+iidesc_cmp(void *arg1, void *arg2)
{
+ iidesc_t *src = arg1;
+ iidesc_find_t *find = arg2;
iidesc_t *tgt = find->iif_tgt;
if (src->ii_type != tgt->ii_type ||
@@ -89,7 +91,7 @@ iidesc_add(hash_t *hash, iidesc_t *new)
find.iif_tgt = new;
find.iif_ret = NULL;
- (void) hash_match(hash, new, (int (*)())iidesc_cmp, &find);
+ (void) hash_match(hash, new, iidesc_cmp, &find);
if (find.iif_ret != NULL) {
iidesc_t *old = find.iif_ret;
@@ -107,13 +109,14 @@ iidesc_add(hash_t *hash, iidesc_t *new)
}
void
-iter_iidescs_by_name(tdata_t *td, const char *name,
- int (*func)(iidesc_t *, void *), void *data)
+iter_iidescs_by_name(tdata_t *td, char const *name,
+ int (*func)(void *, void *), void *data)
{
iidesc_t tmpdesc;
- bzero(&tmpdesc, sizeof (iidesc_t));
- tmpdesc.ii_name = (char *)name;
- (void) hash_match(td->td_iihash, &tmpdesc, (int (*)())func, data);
+ bzero(&tmpdesc, sizeof(tmpdesc));
+ tmpdesc.ii_name = xstrdup(name);
+ (void) hash_match(td->td_iihash, &tmpdesc, func, data);
+ free(tmpdesc.ii_name);
}
iidesc_t *
@@ -151,8 +154,9 @@ iidesc_dup_rename(iidesc_t *src, char const *name, char const *owner)
/*ARGSUSED*/
void
-iidesc_free(iidesc_t *idp, void *private)
+iidesc_free(void *arg, void *private __unused)
{
+ iidesc_t *idp = arg;
if (idp->ii_name)
free(idp->ii_name);
if (idp->ii_nargs)
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/input.c b/cddl/contrib/opensolaris/tools/ctf/cvt/input.c
index d901e53..67ebde7 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/input.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/input.c
@@ -71,6 +71,7 @@ built_source_types(Elf *elf, char const *file)
/* ignore */
break;
case 's':
+ case 'S':
types |= SOURCE_S;
break;
default:
@@ -87,7 +88,7 @@ read_file(Elf *elf, char *file, char *label, read_cb_f *func, void *arg,
int require_ctf)
{
Elf_Scn *ctfscn;
- Elf_Data *ctfdata;
+ Elf_Data *ctfdata = NULL;
symit_data_t *si = NULL;
int ctfscnidx;
tdata_t *td;
@@ -220,7 +221,7 @@ read_ctf_common(char *file, char *label, read_cb_f *func, void *arg,
/*ARGSUSED*/
int
-read_ctf_save_cb(tdata_t *td, char *name, void *retp)
+read_ctf_save_cb(tdata_t *td, char *name __unused, void *retp)
{
tdata_t **tdp = retp;
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/merge.c b/cddl/contrib/opensolaris/tools/ctf/cvt/merge.c
index 2af28b6..2ef37d4 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/merge.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/merge.c
@@ -132,7 +132,7 @@ typedef struct merge_cb_data merge_cb_data_t;
* own traversal mechanism and ops vector here for those two cases.
*/
typedef struct tdesc_ops {
- char *name;
+ const char *name;
int (*equiv)(tdesc_t *, tdesc_t *, equiv_data_t *);
tdesc_t *(*conjure)(tdesc_t *, int, merge_cb_data_t *);
} tdesc_ops_t;
@@ -179,21 +179,21 @@ struct merge_cb_data {
static void
add_mapping(alist_t *ta, tid_t srcid, tid_t tgtid)
{
- debug(3, "Adding mapping %u => %u\n", srcid, tgtid);
+ debug(3, "Adding mapping %u <%x> => %u <%x>\n", srcid, srcid, tgtid, tgtid);
- assert(!alist_find(ta, (void *)srcid, NULL));
+ assert(!alist_find(ta, (void *)(uintptr_t)srcid, NULL));
assert(srcid != 0 && tgtid != 0);
- alist_add(ta, (void *)srcid, (void *)tgtid);
+ alist_add(ta, (void *)(uintptr_t)srcid, (void *)(uintptr_t)tgtid);
}
static tid_t
get_mapping(alist_t *ta, int srcid)
{
- long ltgtid;
+ void *ltgtid;
- if (alist_find(ta, (void *)srcid, (void **)&ltgtid))
- return ((int)ltgtid);
+ if (alist_find(ta, (void *)(uintptr_t)srcid, (void **)&ltgtid))
+ return ((uintptr_t)ltgtid);
else
return (0);
}
@@ -216,7 +216,7 @@ static int equiv_node(tdesc_t *, tdesc_t *, equiv_data_t *);
/*ARGSUSED2*/
static int
-equiv_intrinsic(tdesc_t *stdp, tdesc_t *ttdp, equiv_data_t *ed)
+equiv_intrinsic(tdesc_t *stdp, tdesc_t *ttdp, equiv_data_t *ed __unused)
{
intr_t *si = stdp->t_intr;
intr_t *ti = ttdp->t_intr;
@@ -256,7 +256,7 @@ equiv_function(tdesc_t *stdp, tdesc_t *ttdp, equiv_data_t *ed)
if (!equiv_node(fn1->fn_ret, fn2->fn_ret, ed))
return (0);
- for (i = 0; i < fn1->fn_nargs; i++) {
+ for (i = 0; i < (int) fn1->fn_nargs; i++) {
if (!equiv_node(fn1->fn_args[i], fn2->fn_args[i], ed))
return (0);
}
@@ -313,7 +313,7 @@ equiv_su(tdesc_t *stdp, tdesc_t *ttdp, equiv_data_t *ed)
/*ARGSUSED2*/
static int
-equiv_enum(tdesc_t *stdp, tdesc_t *ttdp, equiv_data_t *ed)
+equiv_enum(tdesc_t *stdp, tdesc_t *ttdp, equiv_data_t *ed __unused)
{
elist_t *el1 = stdp->t_emem;
elist_t *el2 = ttdp->t_emem;
@@ -335,7 +335,7 @@ equiv_enum(tdesc_t *stdp, tdesc_t *ttdp, equiv_data_t *ed)
/*ARGSUSED*/
static int
-equiv_assert(tdesc_t *stdp, tdesc_t *ttdp, equiv_data_t *ed)
+equiv_assert(tdesc_t *stdp __unused, tdesc_t *ttdp __unused, equiv_data_t *ed __unused)
{
/* foul, evil, and very bad - this is a "shouldn't happen" */
assert(1 == 0);
@@ -354,7 +354,7 @@ fwd_equiv(tdesc_t *ctdp, tdesc_t *mtdp)
static int
equiv_node(tdesc_t *ctdp, tdesc_t *mtdp, equiv_data_t *ed)
{
- int (*equiv)();
+ int (*equiv)(tdesc_t *, tdesc_t *, equiv_data_t *);
int mapping;
if (ctdp->t_emark > ed->ed_clear_mark ||
@@ -418,7 +418,8 @@ equiv_cb(void *bucket, void *arg)
ed->ed_cur_mark = ed->ed_clear_mark + 1;
if (equiv_node(ctdp, mtdp, ed)) {
- debug(3, "equiv_node matched %d %d\n", ctdp->t_id, mtdp->t_id);
+ debug(3, "equiv_node matched %d <%x> %d <%x>\n",
+ ctdp->t_id, ctdp->t_id, mtdp->t_id, mtdp->t_id);
ed->ed_tgt = mtdp;
/* matched. stop looking */
return (-1);
@@ -429,7 +430,7 @@ equiv_cb(void *bucket, void *arg)
/*ARGSUSED1*/
static int
-map_td_tree_pre(tdesc_t *ctdp, tdesc_t **ctdpp, void *private)
+map_td_tree_pre(tdesc_t *ctdp, tdesc_t **ctdpp __unused, void *private)
{
merge_cb_data_t *mcd = private;
@@ -441,7 +442,7 @@ map_td_tree_pre(tdesc_t *ctdp, tdesc_t **ctdpp, void *private)
/*ARGSUSED1*/
static int
-map_td_tree_post(tdesc_t *ctdp, tdesc_t **ctdpp, void *private)
+map_td_tree_post(tdesc_t *ctdp, tdesc_t **ctdpp __unused, void *private)
{
merge_cb_data_t *mcd = private;
equiv_data_t ed;
@@ -452,7 +453,7 @@ map_td_tree_post(tdesc_t *ctdp, tdesc_t **ctdpp, void *private)
ed.ed_node = ctdp;
ed.ed_selfuniquify = 0;
- debug(3, "map_td_tree_post on %d %s\n", ctdp->t_id, tdesc_name(ctdp));
+ debug(3, "map_td_tree_post on %d <%x> %s\n", ctdp->t_id, ctdp->t_id,tdesc_name(ctdp));
if (hash_find_iter(mcd->md_parent->td_layouthash, ctdp,
equiv_cb, &ed) < 0) {
@@ -460,7 +461,7 @@ map_td_tree_post(tdesc_t *ctdp, tdesc_t **ctdpp, void *private)
if (ed.ed_tgt->t_type == FORWARD && ctdp->t_type != FORWARD) {
int id = mcd->md_tgt->td_nextid++;
- debug(3, "Creating new defn type %d\n", id);
+ debug(3, "Creating new defn type %d <%x>\n", id, id);
add_mapping(mcd->md_ta, ctdp->t_id, id);
alist_add(mcd->md_fdida, (void *)(ulong_t)ed.ed_tgt,
(void *)(ulong_t)id);
@@ -481,7 +482,7 @@ map_td_tree_post(tdesc_t *ctdp, tdesc_t **ctdpp, void *private)
} else {
int id = mcd->md_tgt->td_nextid++;
- debug(3, "Creating new type %d\n", id);
+ debug(3, "Creating new type %d <%x>\n", id, id);
add_mapping(mcd->md_ta, ctdp->t_id, id);
hash_add(mcd->md_tdtba, ctdp);
}
@@ -493,7 +494,7 @@ map_td_tree_post(tdesc_t *ctdp, tdesc_t **ctdpp, void *private)
/*ARGSUSED1*/
static int
-map_td_tree_self_post(tdesc_t *ctdp, tdesc_t **ctdpp, void *private)
+map_td_tree_self_post(tdesc_t *ctdp, tdesc_t **ctdpp __unused, void *private)
{
merge_cb_data_t *mcd = private;
equiv_data_t ed;
@@ -506,8 +507,8 @@ map_td_tree_self_post(tdesc_t *ctdp, tdesc_t **ctdpp, void *private)
ed.ed_tgt = NULL;
if (hash_find_iter(mcd->md_tdtba, ctdp, equiv_cb, &ed) < 0) {
- debug(3, "Self check found %d in %d\n", ctdp->t_id,
- ed.ed_tgt->t_id);
+ debug(3, "Self check found %d <%x> in %d <%x>\n", ctdp->t_id,
+ ctdp->t_id, ed.ed_tgt->t_id, ed.ed_tgt->t_id);
add_mapping(mcd->md_ta, ctdp->t_id,
get_mapping(mcd->md_ta, ed.ed_tgt->t_id));
} else if (debug_level > 1 && hash_iter(mcd->md_tdtba,
@@ -518,12 +519,13 @@ map_td_tree_self_post(tdesc_t *ctdp, tdesc_t **ctdpp, void *private)
* through the entire hash. This usually means that the hash
* function is broken.
*/
- aborterr("Self-unique second pass for %d (%s) == %d\n",
- ctdp->t_id, tdesc_name(ctdp), ed.ed_tgt->t_id);
+ aborterr("Self-unique second pass for %d <%x> (%s) == %d <%x>\n",
+ ctdp->t_id, ctdp->t_id, tdesc_name(ctdp), ed.ed_tgt->t_id,
+ ed.ed_tgt->t_id);
} else {
int id = mcd->md_tgt->td_nextid++;
- debug(3, "Creating new type %d\n", id);
+ debug(3, "Creating new type %d <%x>\n", id, id);
add_mapping(mcd->md_ta, ctdp->t_id, id);
hash_add(mcd->md_tdtba, ctdp);
}
@@ -696,14 +698,14 @@ remap_node(tdesc_t **tgtp, tdesc_t *oldtgt, int selftid, tdesc_t *newself,
}
if ((template.t_id = get_mapping(mcd->md_ta, oldid)) == 0)
- aborterr("failed to get mapping for tid %d\n", oldid);
+ aborterr("failed to get mapping for tid %d <%x>\n", oldid, oldid);
if (!hash_find(mcd->md_parent->td_idhash, (void *)&template,
(void *)&tgt) && (!(mcd->md_flags & MCD_F_REFMERGE) ||
!hash_find(mcd->md_tgt->td_idhash, (void *)&template,
(void *)&tgt))) {
- debug(3, "Remap couldn't find %d (from %d)\n", template.t_id,
- oldid);
+ debug(3, "Remap couldn't find %d <%x> (from %d <%x>)\n", template.t_id,
+ template.t_id, oldid, oldid);
*tgtp = oldtgt;
list_add(mcd->md_tdtbr, tgtp);
return (0);
@@ -729,7 +731,7 @@ conjure_template(tdesc_t *old, int newselfid)
/*ARGSUSED2*/
static tdesc_t *
-conjure_intrinsic(tdesc_t *old, int newselfid, merge_cb_data_t *mcd)
+conjure_intrinsic(tdesc_t *old, int newselfid, merge_cb_data_t *mcd __unused)
{
tdesc_t *new = conjure_template(old, newselfid);
@@ -765,7 +767,7 @@ conjure_function(tdesc_t *old, int newselfid, merge_cb_data_t *mcd)
if (nfn->fn_nargs > 0)
nfn->fn_args = xcalloc(sizeof (tdesc_t *) * ofn->fn_nargs);
- for (i = 0; i < ofn->fn_nargs; i++) {
+ for (i = 0; i < (int) ofn->fn_nargs; i++) {
(void) remap_node(&nfn->fn_args[i], ofn->fn_args[i], old->t_id,
new, mcd);
}
@@ -805,7 +807,7 @@ conjure_su(tdesc_t *old, int newselfid, merge_cb_data_t *mcd)
*nmemp = xmalloc(sizeof (mlist_t));
(*nmemp)->ml_offset = omem->ml_offset;
(*nmemp)->ml_size = omem->ml_size;
- (*nmemp)->ml_name = xstrdup(omem->ml_name);
+ (*nmemp)->ml_name = xstrdup(omem->ml_name ? omem->ml_name : "empty omem->ml_name");
(void) remap_node(&((*nmemp)->ml_type), omem->ml_type,
old->t_id, new, mcd);
}
@@ -816,7 +818,7 @@ conjure_su(tdesc_t *old, int newselfid, merge_cb_data_t *mcd)
/*ARGSUSED2*/
static tdesc_t *
-conjure_enum(tdesc_t *old, int newselfid, merge_cb_data_t *mcd)
+conjure_enum(tdesc_t *old, int newselfid, merge_cb_data_t *mcd __unused)
{
tdesc_t *new = conjure_template(old, newselfid);
elist_t *oel, **nelp;
@@ -845,7 +847,7 @@ conjure_forward(tdesc_t *old, int newselfid, merge_cb_data_t *mcd)
/*ARGSUSED*/
static tdesc_t *
-conjure_assert(tdesc_t *old, int newselfid, merge_cb_data_t *mcd)
+conjure_assert(tdesc_t *old __unused, int newselfid __unused, merge_cb_data_t *mcd __unused)
{
assert(1 == 0);
return (NULL);
@@ -870,7 +872,7 @@ static int
fwd_redir(tdesc_t *fwd, tdesc_t **fwdp, void *private)
{
alist_t *map = private;
- tdesc_t *defn;
+ void *defn;
if (!alist_find(map, (void *)fwd, (void **)&defn))
return (0);
@@ -908,7 +910,7 @@ static int
redir_mstr_fwd_cb(void *name, void *value, void *arg)
{
tdesc_t *fwd = name;
- int defnid = (int)value;
+ int defnid = (uintptr_t)value;
redir_mstr_data_t *rmd = arg;
tdesc_t template;
tdesc_t *defn;
@@ -987,8 +989,9 @@ add_tdesc(tdesc_t *oldtdp, int newid, merge_cb_data_t *mcd)
assert(hash_find(mcd->md_parent->td_idhash,
(void *)&template, NULL) == 0);
- debug(3, "trying to conjure %d %s (%d) as %d\n",
- oldtdp->t_type, tdesc_name(oldtdp), oldtdp->t_id, newid);
+ debug(3, "trying to conjure %d %s (%d, <%x>) as %d, <%x>\n",
+ oldtdp->t_type, tdesc_name(oldtdp), oldtdp->t_id,
+ oldtdp->t_id, newid, newid);
if ((newtdp = tdesc_ops[oldtdp->t_type].conjure(oldtdp, newid,
mcd)) == NULL)
@@ -1049,16 +1052,16 @@ merge_types(hash_t *src, merge_cb_data_t *mcd)
(void) hash_iter(src, merge_type_cb, mcd);
- tdrc = hash_iter(mcd->md_tdtba, add_tdtba_cb, (void *)mcd);
+ tdrc = hash_iter(mcd->md_tdtba, add_tdtba_cb, mcd);
debug(3, "add_tdtba_cb added %d items\n", tdrc);
- iirc = list_iter(*mcd->md_iitba, add_iitba_cb, (void *)mcd);
+ iirc = list_iter(*mcd->md_iitba, add_iitba_cb, mcd);
debug(3, "add_iitba_cb added %d items\n", iirc);
assert(list_count(*mcd->md_iitba) == 0 &&
hash_count(mcd->md_tdtba) == 0);
- tdrc = list_iter(*mcd->md_tdtbr, add_tdtbr_cb, (void *)mcd);
+ tdrc = list_iter(*mcd->md_tdtbr, add_tdtbr_cb, mcd);
debug(3, "add_tdtbr_cb added %d items\n", tdrc);
if (list_count(*mcd->md_tdtbr) != 0)
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/output.c b/cddl/contrib/opensolaris/tools/ctf/cvt/output.c
index f699fbf..ae8c594 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/output.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/output.c
@@ -79,7 +79,7 @@ burst_iitypes(void *data, void *arg)
/*ARGSUSED1*/
static int
-save_type_by_id(tdesc_t *tdp, tdesc_t **tdpp, void *private)
+save_type_by_id(tdesc_t *tdp, tdesc_t **tdpp __unused, void *private)
{
iiburst_t *iiburst = private;
@@ -159,8 +159,10 @@ iiburst_free(iiburst_t *iiburst)
* a global type description.
*/
static int
-matching_iidesc(iidesc_t *iidesc, iidesc_match_t *match)
+matching_iidesc(void *arg1, void *arg2)
{
+ iidesc_t *iidesc = arg1;
+ iidesc_match_t *match = arg2;
if (streq(iidesc->ii_name, match->iim_name) == 0)
return (0);
@@ -185,6 +187,8 @@ matching_iidesc(iidesc_t *iidesc, iidesc_match_t *match)
return (-1);
}
break;
+ default:
+ break;
}
return (0);
}
@@ -194,7 +198,7 @@ find_iidesc(tdata_t *td, iidesc_match_t *match)
{
match->iim_ret = NULL;
iter_iidescs_by_name(td, match->iim_name,
- (int (*)())matching_iidesc, match);
+ matching_iidesc, match);
return (match->iim_ret);
}
@@ -239,10 +243,12 @@ check_for_weak(GElf_Sym *weak, char const *weakfile,
GElf_Sym *retsym, char **curfilep)
{
char *curfile = NULL;
- char *tmpfile;
+ char *tmpfile1 = NULL;
GElf_Sym tmpsym;
int candidate = 0;
int i;
+ tmpsym.st_info = 0;
+ tmpsym.st_name = 0;
if (GELF_ST_BIND(weak->st_info) != STB_WEAK)
return (0);
@@ -276,7 +282,7 @@ check_for_weak(GElf_Sym *weak, char const *weakfile,
(curfile == NULL || weakfile == NULL ||
strcmp(curfile, weakfile) != 0)) {
candidate = 1;
- tmpfile = curfile;
+ tmpfile1 = curfile;
tmpsym = sym;
continue;
}
@@ -287,7 +293,7 @@ check_for_weak(GElf_Sym *weak, char const *weakfile,
}
if (candidate) {
- *curfilep = tmpfile;
+ *curfilep = tmpfile1;
*retsym = tmpsym;
return (1);
}
@@ -496,14 +502,14 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname,
secxlate = xmalloc(sizeof (int) * sehdr.e_shnum);
for (srcidx = dstidx = 0; srcidx < sehdr.e_shnum; srcidx++) {
Elf_Scn *scn = elf_getscn(src, srcidx);
- GElf_Shdr shdr;
+ GElf_Shdr shdr1;
char *sname;
- gelf_getshdr(scn, &shdr);
- sname = elf_strptr(src, sehdr.e_shstrndx, shdr.sh_name);
+ gelf_getshdr(scn, &shdr1);
+ sname = elf_strptr(src, sehdr.e_shstrndx, shdr1.sh_name);
if (sname == NULL) {
elfterminate(srcname, "Can't find string at %u",
- shdr.sh_name);
+ shdr1.sh_name);
}
if (strcmp(sname, CTF_ELF_SCN_NAME) == 0) {
@@ -514,7 +520,7 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname,
strncmp(sname, ".rel.debug", 10) == 0 ||
strncmp(sname, ".rela.debug", 11) == 0)) {
secxlate[srcidx] = -1;
- } else if (dynsym && shdr.sh_type == SHT_SYMTAB) {
+ } else if (dynsym && shdr1.sh_type == SHT_SYMTAB) {
/*
* If we're building CTF against the dynsym,
* we'll rip out the symtab so debuggers aren't
@@ -567,11 +573,31 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname,
elfterminate(srcname, "Can't find string at %u",
shdr.sh_name);
}
+
+#if !defined(sun)
+ if (gelf_update_shdr(dscn, &shdr) == 0)
+ elfterminate(dstname, "Cannot update sect %s", sname);
+#endif
+
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)
bcopy(sdata, ddata, sizeof (Elf_Data));
+#else
+ /*
+ * FreeBSD's Elf_Data has private fields which the
+ * elf_* routines manage. Simply copying the
+ * entire structure corrupts the data. So we need
+ * to copy the public fields explictly.
+ */
+ ddata->d_align = sdata->d_align;
+ ddata->d_off = sdata->d_off;
+ ddata->d_size = sdata->d_size;
+ ddata->d_type = sdata->d_type;
+ ddata->d_version = sdata->d_version;
+#endif
if (srcidx == sehdr.e_shstrndx) {
char seclen = strlen(CTF_ELF_SCN_NAME);
@@ -601,7 +627,8 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname,
GElf_Sym sym;
short newscn;
- (void) gelf_getsym(ddata, i, &sym);
+ if (gelf_getsym(ddata, i, &sym) == NULL)
+ printf("Could not get symbol %d\n",i);
if (sym.st_shndx >= SHN_LORESERVE)
continue;
@@ -616,7 +643,14 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname,
}
}
- if (gelf_update_shdr(dscn, &shdr) == NULL)
+#if !defined(sun)
+ if (ddata->d_buf == NULL) {
+ ddata->d_buf = xmalloc(shdr.sh_size);
+ bcopy(sdata->d_buf, ddata->d_buf, shdr.sh_size);
+ }
+#endif
+
+ if (gelf_update_shdr(dscn, &shdr) == 0)
elfterminate(dstname, "Cannot update sect %s", sname);
new_offset = (off_t)shdr.sh_offset;
@@ -651,6 +685,7 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname,
ddata->d_buf = ctfdata;
ddata->d_size = ctfsize;
ddata->d_align = shdr.sh_addralign;
+ ddata->d_off = 0;
gelf_update_shdr(dscn, &shdr);
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c b/cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c
index d4d4921..5364320 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/st_parse.c
@@ -76,12 +76,11 @@ static char *tdefdecl(char *cp, int h, tdesc_t **rtdp);
static char *intrinsic(char *cp, tdesc_t **rtdp);
static char *arraydef(char *cp, tdesc_t **rtdp);
-extern int debug_level;
int debug_parse = DEBUG_PARSE;
/*PRINTFLIKE3*/
static void
-parse_debug(int level, char *cp, char *fmt, ...)
+parse_debug(int level, char *cp, const char *fmt, ...)
{
va_list ap;
char buf[1024];
@@ -113,9 +112,9 @@ parse_debug(int level, char *cp, char *fmt, ...)
/* Report unexpected syntax in stabs. */
static void
_expected(
- char *who, /* what function, or part thereof, is reporting */
- char *what, /* what was expected */
- char *where, /* where we were in the line of input */
+ const char *who, /* what function, or part thereof, is reporting */
+ const char *what, /* what was expected */
+ const char *where, /* where we were in the line of input */
int line)
{
fprintf(stderr, "%s, expecting \"%s\" at \"%s\"\n", who, what, where);
@@ -126,7 +125,7 @@ _expected(
/*ARGSUSED*/
void
-parse_init(tdata_t *td)
+parse_init(tdata_t *td __unused)
{
int i;
@@ -159,7 +158,7 @@ unres_new(int tid)
return (tdp);
}
-char *
+static char *
read_tid(char *cp, tdesc_t **tdpp)
{
tdesc_t *tdp;
@@ -190,7 +189,7 @@ read_tid(char *cp, tdesc_t **tdpp)
static iitype_t
parse_fun(char *cp, iidesc_t *ii)
{
- iitype_t iitype;
+ iitype_t iitype = 0;
tdesc_t *tdp;
tdesc_t **args = NULL;
int nargs = 0;
@@ -250,7 +249,7 @@ static iitype_t
parse_sym(char *cp, iidesc_t *ii)
{
tdesc_t *tdp;
- iitype_t iitype;
+ iitype_t iitype = 0;
/*
* name:G global variable
@@ -1038,14 +1037,14 @@ enumdef(char *cp, tdesc_t **rtdp)
}
}
-tdesc_t *
-lookup_name(tdesc_t **hash, const char *name)
+static tdesc_t *
+lookup_name(tdesc_t **hash, const char *name1)
{
- int bucket = compute_sum(name);
+ int bucket = compute_sum(name1);
tdesc_t *tdp, *ttdp = NULL;
for (tdp = hash[bucket]; tdp != NULL; tdp = tdp->t_next) {
- if (tdp->t_name != NULL && strcmp(tdp->t_name, name) == 0) {
+ if (tdp->t_name != NULL && strcmp(tdp->t_name, name1) == 0) {
if (tdp->t_type == STRUCT || tdp->t_type == UNION ||
tdp->t_type == ENUM || tdp->t_type == INTRINSIC)
return (tdp);
@@ -1057,9 +1056,9 @@ lookup_name(tdesc_t **hash, const char *name)
}
tdesc_t *
-lookupname(const char *name)
+lookupname(const char *name1)
{
- return (lookup_name(name_table, name));
+ return (lookup_name(name_table, name1));
}
/*
@@ -1151,8 +1150,9 @@ check_hash(void)
/*ARGSUSED1*/
static int
-resolve_typed_bitfields_cb(mlist_t *ml, void *private)
+resolve_typed_bitfields_cb(void *arg, void *private __unused)
{
+ mlist_t *ml = arg;
tdesc_t *tdp = ml->ml_type;
debug(3, "Resolving typed bitfields (member %s)\n",
@@ -1194,5 +1194,5 @@ void
resolve_typed_bitfields(void)
{
(void) list_iter(typedbitfldmems,
- (int (*)())resolve_typed_bitfields_cb, NULL);
+ resolve_typed_bitfields_cb, NULL);
}
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/stabs.c b/cddl/contrib/opensolaris/tools/ctf/cvt/stabs.c
index f7b3034..c0c68b5 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/stabs.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/stabs.c
@@ -47,7 +47,7 @@
#include "memory.h"
#include "traverse.h"
-const char *curhdr;
+char *curhdr;
/*
* The stabs generator will sometimes reference types before they've been
@@ -59,7 +59,7 @@ const char *curhdr;
*/
/*ARGSUSED2*/
static int
-resolve_tou_node(tdesc_t *node, tdesc_t **nodep, void *private)
+resolve_tou_node(tdesc_t *node, tdesc_t **nodep, void *private __unused)
{
tdesc_t *new;
@@ -79,7 +79,7 @@ resolve_tou_node(tdesc_t *node, tdesc_t **nodep, void *private)
/*ARGSUSED*/
static int
-resolve_fwd_node(tdesc_t *node, tdesc_t **nodep, void *private)
+resolve_fwd_node(tdesc_t *node, tdesc_t **nodep, void *private __unused)
{
tdesc_t *new = lookupname(node->t_name);
@@ -174,7 +174,7 @@ fnarg_free(iidesc_t *ii)
* assembled under an iidesc list.
*/
int
-stabs_read(tdata_t *td, Elf *elf, const char *file)
+stabs_read(tdata_t *td, Elf *elf, char *file)
{
Elf_Scn *scn;
Elf_Data *data;
@@ -200,7 +200,7 @@ stabs_read(tdata_t *td, Elf *elf, const char *file)
file_stack = stack_new(free);
- stack_push(file_stack, (void *)file);
+ stack_push(file_stack, file);
curhdr = file;
debug(3, "Found stabs in %d, strings in %d\n", stabidx, stabstridx);
@@ -255,7 +255,7 @@ stabs_read(tdata_t *td, Elf *elf, const char *file)
if (stab->n_type == N_BINCL) {
curhdr = xstrdup(str);
- stack_push(file_stack, (void *)curhdr);
+ stack_push(file_stack, curhdr);
continue;
} else if (stab->n_type == N_SO) {
if (str[strlen(str) - 1] != '/') {
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/strtab.c b/cddl/contrib/opensolaris/tools/ctf/cvt/strtab.c
index ba6b7d8..d8b2bf0 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/strtab.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/strtab.c
@@ -205,7 +205,7 @@ strtab_size(const strtab_t *sp)
ssize_t
strtab_write(const strtab_t *sp,
- ssize_t (*func)(const void *, size_t, void *), void *priv)
+ ssize_t (*func)(void *, size_t, void *), void *priv)
{
ssize_t res, total = 0;
ulong_t i;
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/strtab.h b/cddl/contrib/opensolaris/tools/ctf/cvt/strtab.h
index 7176e07..13c1e59 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/strtab.h
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/strtab.h
@@ -59,7 +59,7 @@ extern void strtab_destroy(strtab_t *);
extern size_t strtab_insert(strtab_t *, const char *);
extern size_t strtab_size(const strtab_t *);
extern ssize_t strtab_write(const strtab_t *,
- ssize_t (*)(const void *, size_t, void *), void *);
+ ssize_t (*)(void *, size_t, void *), void *);
extern void strtab_print(const strtab_t *);
#ifdef __cplusplus
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/tdata.c b/cddl/contrib/opensolaris/tools/ctf/cvt/tdata.c
index 32d8482..4a0cc79 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/tdata.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/tdata.c
@@ -174,9 +174,10 @@ tdesc_namecmp(void *arg1, void *arg2)
return (!streq(tdp1->t_name, tdp2->t_name));
}
+#if defined(sun)
/*ARGSUSED1*/
-int
-tdesc_print(void *data, void *private)
+static int
+tdesc_print(void *data, void *private __unused)
{
tdesc_t *tdp = data;
@@ -184,6 +185,7 @@ tdesc_print(void *data, void *private)
return (1);
}
+#endif
static void
free_intr(tdesc_t *tdp)
@@ -247,39 +249,42 @@ static void (*free_cbs[])(tdesc_t *) = {
};
/*ARGSUSED1*/
-static int
-tdesc_free_cb(tdesc_t *tdp, void *private)
+static void
+tdesc_free_cb(void *arg, void *private __unused)
{
+ tdesc_t *tdp = arg;
if (tdp->t_name)
free(tdp->t_name);
if (free_cbs[tdp->t_type])
free_cbs[tdp->t_type](tdp);
free(tdp);
- return (1);
+ return;
}
void
tdesc_free(tdesc_t *tdp)
{
- (void) tdesc_free_cb(tdp, NULL);
+ tdesc_free_cb(tdp, NULL);
}
static int
-tdata_label_cmp(labelent_t *le1, labelent_t *le2)
+tdata_label_cmp(void *arg1, void *arg2)
{
+ labelent_t *le1 = arg1;
+ labelent_t *le2 = arg2;
return (le1->le_idx - le2->le_idx);
}
void
-tdata_label_add(tdata_t *td, char *label, int idx)
+tdata_label_add(tdata_t *td, const char *label, int idx)
{
labelent_t *le = xmalloc(sizeof (*le));
le->le_name = xstrdup(label);
le->le_idx = (idx == -1 ? td->td_nextid - 1 : idx);
- slist_add(&td->td_labels, le, (int (*)())tdata_label_cmp);
+ slist_add(&td->td_labels, le, tdata_label_cmp);
}
static int
@@ -304,8 +309,10 @@ tdata_label_top(tdata_t *td)
}
static int
-tdata_label_find_cb(labelent_t *le, labelent_t *tmpl)
+tdata_label_find_cb(void *arg1, void *arg2)
{
+ labelent_t *le = arg1;
+ labelent_t *tmpl = arg2;
return (streq(le->le_name, tmpl->le_name));
}
@@ -323,7 +330,7 @@ tdata_label_find(tdata_t *td, char *label)
let.le_name = label;
if (!(ret = (labelent_t *)list_find(td->td_labels, &let,
- (int (*)())tdata_label_find_cb)))
+ tdata_label_find_cb)))
return (-1);
return (ret->le_idx);
@@ -351,8 +358,9 @@ tdata_label_newmax(tdata_t *td, int newmax)
/*ARGSUSED1*/
static void
-tdata_label_free_cb(labelent_t *le, void *private)
+tdata_label_free_cb(void *arg, void *private __unused)
{
+ labelent_t *le = arg;
if (le->le_name)
free(le->le_name);
free(le);
@@ -361,7 +369,7 @@ tdata_label_free_cb(labelent_t *le, void *private)
void
tdata_label_free(tdata_t *td)
{
- list_free(td->td_labels, (void (*)())tdata_label_free_cb, NULL);
+ list_free(td->td_labels, tdata_label_free_cb, NULL);
td->td_labels = NULL;
}
@@ -391,8 +399,8 @@ tdata_new(void)
void
tdata_free(tdata_t *td)
{
- hash_free(td->td_iihash, (void (*)())iidesc_free, NULL);
- hash_free(td->td_layouthash, (void (*)())tdesc_free_cb, NULL);
+ hash_free(td->td_iihash, iidesc_free, NULL);
+ hash_free(td->td_layouthash, tdesc_free_cb, NULL);
hash_free(td->td_idhash, NULL, NULL);
list_free(td->td_fwdlist, NULL, NULL);
@@ -408,7 +416,7 @@ tdata_free(tdata_t *td)
/*ARGSUSED1*/
static int
-build_hashes(tdesc_t *ctdp, tdesc_t **ctdpp, void *private)
+build_hashes(tdesc_t *ctdp, tdesc_t **ctdpp __unused, void *private)
{
tdata_t *td = private;
@@ -465,7 +473,7 @@ tdata_merge(tdata_t *td1, tdata_t *td2)
td2->td_fwdlist = NULL;
slist_merge(&td1->td_labels, td2->td_labels,
- (int (*)())tdata_label_cmp);
+ tdata_label_cmp);
td2->td_labels = NULL;
/* free the td2 hashes (data is now part of td1) */
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.c b/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.c
index b415b35..feb9908 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.c
@@ -37,10 +37,8 @@
#include "traverse.h"
#include "memory.h"
-int (*tddescenders[])();
-int (*tdnops[])();
-
-int tdtraverse(tdesc_t *, tdesc_t **, tdtrav_data_t *);
+int (*tddescenders[])(tdesc_t *, tdtrav_data_t *);
+tdtrav_cb_f tdnops[];
void
tdtrav_init(tdtrav_data_t *tdtd, int *vgenp, tdtrav_cb_f *firstops,
@@ -68,7 +66,7 @@ tdtrav_func(tdesc_t *this, tdtrav_data_t *tdtd)
if ((rc = tdtraverse(fn->fn_ret, &fn->fn_ret, tdtd)) < 0)
return (rc);
- for (i = 0; i < fn->fn_nargs; i++) {
+ for (i = 0; i < (int) fn->fn_nargs; i++) {
if ((rc = tdtraverse(fn->fn_args[i], &fn->fn_args[i],
tdtd)) < 0)
return (rc);
@@ -106,7 +104,7 @@ tdtrav_su(tdesc_t *this, tdtrav_data_t *tdtd)
/*ARGSUSED*/
int
-tdtrav_assert(tdesc_t *node, tdesc_t **nodep, void *private)
+tdtrav_assert(tdesc_t *node __unused, tdesc_t **nodep __unused, void *private __unused)
{
assert(1 == 0);
@@ -151,7 +149,7 @@ int
tdtraverse(tdesc_t *this, tdesc_t **thisp, tdtrav_data_t *tdtd)
{
tdtrav_cb_f travcb;
- int (*descender)();
+ int (*descender)(tdesc_t *, tdtrav_data_t *);
int descend = 1;
int rc;
@@ -187,8 +185,10 @@ tdtraverse(tdesc_t *this, tdesc_t **thisp, tdtrav_data_t *tdtd)
}
int
-iitraverse_td(iidesc_t *ii, tdtrav_data_t *tdtd)
+iitraverse_td(void *arg1, void *arg2)
{
+ iidesc_t *ii = arg1;
+ tdtrav_data_t *tdtd = arg2;
int i, rc;
if ((rc = tdtraverse(ii->ii_dtype, &ii->ii_dtype, tdtd)) < 0)
@@ -222,5 +222,5 @@ iitraverse_hash(hash_t *iihash, int *vgenp, tdtrav_cb_f *firstops,
tdtrav_init(&tdtd, vgenp, firstops, preops, postops, private);
- return (hash_iter(iihash, (int (*)())iitraverse_td, &tdtd));
+ return (hash_iter(iihash, iitraverse_td, &tdtd));
}
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.h b/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.h
index 0f8396f..6a56370 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.h
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/traverse.h
@@ -60,7 +60,7 @@ int iitraverse(iidesc_t *, int *, tdtrav_cb_f *, tdtrav_cb_f *, tdtrav_cb_f *,
void *);
int iitraverse_hash(hash_t *, int *, tdtrav_cb_f *, tdtrav_cb_f *,
tdtrav_cb_f *, void *);
-int iitraverse_td(iidesc_t *ii, tdtrav_data_t *);
+int iitraverse_td(void *, void *);
int tdtrav_assert(tdesc_t *, tdesc_t **, void *);
OpenPOWER on IntegriCloud