Changeset View
Changeset View
Standalone View
Standalone View
head/cddl/contrib/opensolaris/common/ctf/ctf_create.c
Show First 20 Lines • Show All 1,252 Lines • ▼ Show 20 Lines | ctf_add_type(ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type) | ||||
ctf_id_t dst_type = CTF_ERR; | ctf_id_t dst_type = CTF_ERR; | ||||
uint_t dst_kind = CTF_K_UNKNOWN; | uint_t dst_kind = CTF_K_UNKNOWN; | ||||
const ctf_type_t *tp; | const ctf_type_t *tp; | ||||
const char *name; | const char *name; | ||||
uint_t kind, flag, vlen; | uint_t kind, flag, vlen; | ||||
ctf_bundle_t src, dst; | ctf_bundle_t src, dst; | ||||
ctf_encoding_t src_en, dst_en; | ctf_encoding_t src_en, main_en, dst_en; | ||||
ctf_arinfo_t src_ar, dst_ar; | ctf_arinfo_t src_ar, dst_ar; | ||||
ctf_dtdef_t *dtd; | ctf_dtdef_t *dtd; | ||||
ctf_funcinfo_t ctc; | ctf_funcinfo_t ctc; | ||||
ssize_t size; | ssize_t size; | ||||
ctf_hash_t *hp; | ctf_hash_t *hp; | ||||
ctf_helem_t *hep; | ctf_helem_t *hep; | ||||
▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | ctf_add_type(ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type) | ||||
* If dst_type is not CTF_ERR, then we verify that dst_type has the | * If dst_type is not CTF_ERR, then we verify that dst_type has the | ||||
* same attributes as src_type. We recurse for embedded references. | * same attributes as src_type. We recurse for embedded references. | ||||
*/ | */ | ||||
switch (kind) { | switch (kind) { | ||||
case CTF_K_INTEGER: | case CTF_K_INTEGER: | ||||
case CTF_K_FLOAT: | case CTF_K_FLOAT: | ||||
if (ctf_type_encoding(src_fp, src_type, &src_en) != 0) | if (ctf_type_encoding(src_fp, src_type, &src_en) != 0) | ||||
return (ctf_set_errno(dst_fp, ctf_errno(src_fp))); | return (ctf_set_errno(dst_fp, ctf_errno(src_fp))); | ||||
/* | |||||
* This could be a bitfield, and the CTF library assumes | |||||
* intrinsics will appear before bitfields. Therefore, | |||||
* try to copy over the intrinsic prior to copying the | |||||
* bitfield. | |||||
*/ | |||||
if (dst_type == CTF_ERR && name[0] != '\0' && | |||||
(hep = ctf_hash_lookup(&src_fp->ctf_names, src_fp, name, | |||||
strlen(name))) != NULL && | |||||
src_type != (ctf_id_t)hep->h_type) { | |||||
if (ctf_type_encoding(src_fp, (ctf_id_t)hep->h_type, | |||||
&main_en) != 0) { | |||||
return (ctf_set_errno(dst_fp, | |||||
ctf_errno(src_fp))); | |||||
} | |||||
if (bcmp(&src_en, &main_en, sizeof (ctf_encoding_t)) && | |||||
ctf_add_type(dst_fp, src_fp, | |||||
(ctf_id_t)hep->h_type) == CTF_ERR) | |||||
return (CTF_ERR); /* errno is set for us */ | |||||
} | |||||
if (dst_type != CTF_ERR) { | if (dst_type != CTF_ERR) { | ||||
if (ctf_type_encoding(dst_fp, dst_type, &dst_en) != 0) | if (ctf_type_encoding(dst_fp, dst_type, &dst_en) != 0) | ||||
return (CTF_ERR); /* errno is set for us */ | return (CTF_ERR); /* errno is set for us */ | ||||
if (bcmp(&src_en, &dst_en, sizeof (ctf_encoding_t))) | if (bcmp(&src_en, &dst_en, sizeof (ctf_encoding_t))) | ||||
return (ctf_set_errno(dst_fp, ECTF_CONFLICT)); | return (ctf_set_errno(dst_fp, ECTF_CONFLICT)); | ||||
▲ Show 20 Lines • Show All 176 Lines • Show Last 20 Lines |