summaryrefslogtreecommitdiffstats
path: root/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c
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/tools/ctf/cvt/ctf.c
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/tools/ctf/cvt/ctf.c')
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c109
1 files changed, 55 insertions, 54 deletions
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);
OpenPOWER on IntegriCloud