Lines Matching refs:fp

60 	ctf_file_t *fp;
73 if ((fp = ctf_bufopen(&cts, NULL, NULL, errp)) == NULL) {
78 fp->ctf_flags |= LCTF_RDWR;
79 fp->ctf_dthashlen = hashlen;
81 fp->ctf_dthash = hash;
82 fp->ctf_dtstrlen = sizeof (_CTF_STRTAB_TEMPLATE);
83 fp->ctf_dtnextid = 1;
84 fp->ctf_dtoldid = 0;
86 return (fp);
184 ctf_ref_inc(ctf_file_t *fp, ctf_id_t tid)
186 ctf_dtdef_t *dtd = ctf_dtd_lookup(fp, tid);
191 if (!(fp->ctf_flags & LCTF_RDWR))
202 ctf_ref_dec(ctf_file_t *fp, ctf_id_t tid)
204 ctf_dtdef_t *dtd = ctf_dtd_lookup(fp, tid);
209 if (!(fp->ctf_flags & LCTF_RDWR))
227 * ctf_bufopen() will return a new ctf_file_t, but we want to keep the fp
236 ctf_update(ctf_file_t *fp)
248 if (!(fp->ctf_flags & LCTF_RDWR))
249 return (ctf_set_errno(fp, ECTF_RDONLY));
251 if (!(fp->ctf_flags & LCTF_DIRTY))
264 if (fp->ctf_flags & LCTF_CHILD)
271 for (size = 0, dtd = ctf_list_next(&fp->ctf_dtdefs);
312 hdr.cth_strlen = fp->ctf_dtstrlen;
316 return (ctf_set_errno(fp, EAGAIN));
329 for (dtd = ctf_list_next(&fp->ctf_dtdefs);
415 * is successful, we then switch nfp and fp and free the old container.
428 return (ctf_set_errno(fp, err));
431 (void) ctf_setmodel(nfp, ctf_getmodel(fp));
432 (void) ctf_import(nfp, fp->ctf_parent);
434 nfp->ctf_refcnt = fp->ctf_refcnt;
435 nfp->ctf_flags |= fp->ctf_flags & ~LCTF_DIRTY;
437 nfp->ctf_dthash = fp->ctf_dthash;
438 nfp->ctf_dthashlen = fp->ctf_dthashlen;
439 nfp->ctf_dtdefs = fp->ctf_dtdefs;
440 nfp->ctf_dtstrlen = fp->ctf_dtstrlen;
441 nfp->ctf_dtnextid = fp->ctf_dtnextid;
442 nfp->ctf_dtoldid = fp->ctf_dtnextid - 1;
443 nfp->ctf_specific = fp->ctf_specific;
445 fp->ctf_dthash = NULL;
446 fp->ctf_dthashlen = 0;
447 bzero(&fp->ctf_dtdefs, sizeof (ctf_list_t));
449 bcopy(fp, &ofp, sizeof (ctf_file_t));
450 bcopy(nfp, fp, sizeof (ctf_file_t));
458 fp->ctf_lookups[0].ctl_hash = &fp->ctf_structs;
459 fp->ctf_lookups[1].ctl_hash = &fp->ctf_unions;
460 fp->ctf_lookups[2].ctl_hash = &fp->ctf_enums;
461 fp->ctf_lookups[3].ctl_hash = &fp->ctf_names;
470 ctf_dtd_insert(ctf_file_t *fp, ctf_dtdef_t *dtd)
472 ulong_t h = dtd->dtd_type & (fp->ctf_dthashlen - 1);
474 dtd->dtd_hash = fp->ctf_dthash[h];
475 fp->ctf_dthash[h] = dtd;
476 ctf_list_append(&fp->ctf_dtdefs, dtd);
480 ctf_dtd_delete(ctf_file_t *fp, ctf_dtdef_t *dtd)
482 ulong_t h = dtd->dtd_type & (fp->ctf_dthashlen - 1);
483 ctf_dtdef_t *p, **q = &fp->ctf_dthash[h];
508 fp->ctf_dtstrlen -= len;
511 ctf_ref_dec(fp, dmd->dmd_type);
517 ctf_ref_dec(fp, dtd->dtd_data.ctt_type);
520 ctf_ref_dec(fp, dtd->dtd_u.dtu_argv[i]);
525 ctf_ref_dec(fp, dtd->dtd_u.dtu_arr.ctr_contents);
526 ctf_ref_dec(fp, dtd->dtd_u.dtu_arr.ctr_index);
529 ctf_ref_dec(fp, dtd->dtd_data.ctt_type);
535 ctf_ref_dec(fp, dtd->dtd_data.ctt_type);
542 fp->ctf_dtstrlen -= len;
545 ctf_list_delete(&fp->ctf_dtdefs, dtd);
550 ctf_dtd_lookup(ctf_file_t *fp, ctf_id_t type)
552 ulong_t h = type & (fp->ctf_dthashlen - 1);
555 if (fp->ctf_dthash == NULL)
558 for (dtd = fp->ctf_dthash[h]; dtd != NULL; dtd = dtd->dtd_hash) {
575 ctf_discard(ctf_file_t *fp)
579 if (!(fp->ctf_flags & LCTF_RDWR))
580 return (ctf_set_errno(fp, ECTF_RDONLY));
582 if (!(fp->ctf_flags & LCTF_DIRTY))
585 for (dtd = ctf_list_prev(&fp->ctf_dtdefs); dtd != NULL; dtd = ntd) {
586 if (dtd->dtd_type <= fp->ctf_dtoldid)
590 ctf_dtd_delete(fp, dtd);
593 fp->ctf_dtnextid = fp->ctf_dtoldid + 1;
594 fp->ctf_flags &= ~LCTF_DIRTY;
600 ctf_add_generic(ctf_file_t *fp, uint_t flag, const char *name, ctf_dtdef_t **rp)
607 return (ctf_set_errno(fp, EINVAL));
609 if (!(fp->ctf_flags & LCTF_RDWR))
610 return (ctf_set_errno(fp, ECTF_RDONLY));
612 if (CTF_INDEX_TO_TYPE(fp->ctf_dtnextid, 1) > CTF_MAX_TYPE)
613 return (ctf_set_errno(fp, ECTF_FULL));
616 return (ctf_set_errno(fp, EAGAIN));
620 return (ctf_set_errno(fp, EAGAIN));
623 type = fp->ctf_dtnextid++;
624 type = CTF_INDEX_TO_TYPE(type, (fp->ctf_flags & LCTF_CHILD));
631 fp->ctf_dtstrlen += strlen(s) + 1;
633 ctf_dtd_insert(fp, dtd);
634 fp->ctf_flags |= LCTF_DIRTY;
660 ctf_add_encoded(ctf_file_t *fp, uint_t flag,
667 return (ctf_set_errno(fp, EINVAL));
669 if ((type = ctf_add_generic(fp, flag, name, &dtd)) == CTF_ERR)
680 ctf_add_reftype(ctf_file_t *fp, uint_t flag, ctf_id_t ref, uint_t kind)
686 return (ctf_set_errno(fp, EINVAL));
688 if ((type = ctf_add_generic(fp, flag, NULL, &dtd)) == CTF_ERR)
691 ctf_ref_inc(fp, ref);
700 ctf_add_integer(ctf_file_t *fp, uint_t flag,
703 return (ctf_add_encoded(fp, flag, name, ep, CTF_K_INTEGER));
707 ctf_add_float(ctf_file_t *fp, uint_t flag,
710 return (ctf_add_encoded(fp, flag, name, ep, CTF_K_FLOAT));
714 ctf_add_pointer(ctf_file_t *fp, uint_t flag, ctf_id_t ref)
716 return (ctf_add_reftype(fp, flag, ref, CTF_K_POINTER));
720 ctf_add_array(ctf_file_t *fp, uint_t flag, const ctf_arinfo_t *arp)
727 return (ctf_set_errno(fp, EINVAL));
729 fpd = fp;
731 ctf_dtd_lookup(fp, arp->ctr_contents) == NULL)
732 return (ctf_set_errno(fp, ECTF_BADID));
734 fpd = fp;
736 ctf_dtd_lookup(fp, arp->ctr_index) == NULL)
737 return (ctf_set_errno(fp, ECTF_BADID));
739 if ((type = ctf_add_generic(fp, flag, NULL, &dtd)) == CTF_ERR)
745 ctf_ref_inc(fp, arp->ctr_contents);
746 ctf_ref_inc(fp, arp->ctr_index);
752 ctf_set_array(ctf_file_t *fp, ctf_id_t type, const ctf_arinfo_t *arp)
755 ctf_dtdef_t *dtd = ctf_dtd_lookup(fp, type);
757 if (!(fp->ctf_flags & LCTF_RDWR))
758 return (ctf_set_errno(fp, ECTF_RDONLY));
761 return (ctf_set_errno(fp, ECTF_BADID));
763 fpd = fp;
765 ctf_dtd_lookup(fp, arp->ctr_contents) == NULL)
766 return (ctf_set_errno(fp, ECTF_BADID));
768 fpd = fp;
770 ctf_dtd_lookup(fp, arp->ctr_index) == NULL)
771 return (ctf_set_errno(fp, ECTF_BADID));
773 ctf_ref_dec(fp, dtd->dtd_u.dtu_arr.ctr_contents);
774 ctf_ref_dec(fp, dtd->dtd_u.dtu_arr.ctr_index);
775 fp->ctf_flags |= LCTF_DIRTY;
777 ctf_ref_inc(fp, arp->ctr_contents);
778 ctf_ref_inc(fp, arp->ctr_index);
784 ctf_add_function(ctf_file_t *fp, uint_t flag,
796 return (ctf_set_errno(fp, EINVAL));
803 return (ctf_set_errno(fp, EOVERFLOW));
805 fpd = fp;
807 ctf_dtd_lookup(fp, ctc->ctc_return) == NULL)
808 return (ctf_set_errno(fp, ECTF_BADID));
811 fpd = fp;
813 ctf_dtd_lookup(fp, argv[i]) == NULL)
814 return (ctf_set_errno(fp, ECTF_BADID));
818 return (ctf_set_errno(fp, EAGAIN));
820 if ((type = ctf_add_generic(fp, flag, NULL, &dtd)) == CTF_ERR) {
828 ctf_ref_inc(fp, ctc->ctc_return);
830 ctf_ref_inc(fp, argv[i]);
841 ctf_add_struct(ctf_file_t *fp, uint_t flag, const char *name)
843 ctf_hash_t *hp = &fp->ctf_structs;
849 hep = ctf_hash_lookup(hp, fp, name, strlen(name));
851 if (hep != NULL && ctf_type_kind(fp, hep->h_type) == CTF_K_FORWARD)
852 dtd = ctf_dtd_lookup(fp, type = hep->h_type);
853 else if ((type = ctf_add_generic(fp, flag, name, &dtd)) == CTF_ERR)
863 ctf_add_union(ctf_file_t *fp, uint_t flag, const char *name)
865 ctf_hash_t *hp = &fp->ctf_unions;
871 hep = ctf_hash_lookup(hp, fp, name, strlen(name));
873 if (hep != NULL && ctf_type_kind(fp, hep->h_type) == CTF_K_FORWARD)
874 dtd = ctf_dtd_lookup(fp, type = hep->h_type);
875 else if ((type = ctf_add_generic(fp, flag, name, &dtd)) == CTF_ERR)
885 ctf_add_enum(ctf_file_t *fp, uint_t flag, const char *name)
887 ctf_hash_t *hp = &fp->ctf_enums;
893 hep = ctf_hash_lookup(hp, fp, name, strlen(name));
895 if (hep != NULL && ctf_type_kind(fp, hep->h_type) == CTF_K_FORWARD)
896 dtd = ctf_dtd_lookup(fp, type = hep->h_type);
897 else if ((type = ctf_add_generic(fp, flag, name, &dtd)) == CTF_ERR)
901 dtd->dtd_data.ctt_size = fp->ctf_dmodel->ctd_int;
907 ctf_add_forward(ctf_file_t *fp, uint_t flag, const char *name, uint_t kind)
916 hp = &fp->ctf_structs;
919 hp = &fp->ctf_unions;
922 hp = &fp->ctf_enums;
925 return (ctf_set_errno(fp, ECTF_NOTSUE));
933 fp, name, strlen(name))) != NULL)
936 if ((type = ctf_add_generic(fp, flag, name, &dtd)) == CTF_ERR)
946 ctf_add_typedef(ctf_file_t *fp, uint_t flag, const char *name, ctf_id_t ref)
952 fpd = fp;
954 ctf_dtd_lookup(fp, ref) == NULL))
955 return (ctf_set_errno(fp, EINVAL));
957 if ((type = ctf_add_generic(fp, flag, name, &dtd)) == CTF_ERR)
962 ctf_ref_inc(fp, ref);
968 ctf_add_volatile(ctf_file_t *fp, uint_t flag, ctf_id_t ref)
970 return (ctf_add_reftype(fp, flag, ref, CTF_K_VOLATILE));
974 ctf_add_const(ctf_file_t *fp, uint_t flag, ctf_id_t ref)
976 return (ctf_add_reftype(fp, flag, ref, CTF_K_CONST));
980 ctf_add_restrict(ctf_file_t *fp, uint_t flag, ctf_id_t ref)
982 return (ctf_add_reftype(fp, flag, ref, CTF_K_RESTRICT));
986 ctf_add_enumerator(ctf_file_t *fp, ctf_id_t enid, const char *name, int value)
988 ctf_dtdef_t *dtd = ctf_dtd_lookup(fp, enid);
995 return (ctf_set_errno(fp, EINVAL));
997 if (!(fp->ctf_flags & LCTF_RDWR))
998 return (ctf_set_errno(fp, ECTF_RDONLY));
1001 return (ctf_set_errno(fp, ECTF_BADID));
1008 return (ctf_set_errno(fp, ECTF_NOTENUM));
1011 return (ctf_set_errno(fp, ECTF_DTFULL));
1016 return (ctf_set_errno(fp, ECTF_DUPMEMBER));
1020 return (ctf_set_errno(fp, EAGAIN));
1024 return (ctf_set_errno(fp, EAGAIN));
1035 fp->ctf_dtstrlen += strlen(s) + 1;
1036 fp->ctf_flags |= LCTF_DIRTY;
1042 ctf_add_member(ctf_file_t *fp, ctf_id_t souid, const char *name, ctf_id_t type)
1044 ctf_dtdef_t *dtd = ctf_dtd_lookup(fp, souid);
1051 if (!(fp->ctf_flags & LCTF_RDWR))
1052 return (ctf_set_errno(fp, ECTF_RDONLY));
1055 return (ctf_set_errno(fp, ECTF_BADID));
1062 return (ctf_set_errno(fp, ECTF_NOTSOU));
1065 return (ctf_set_errno(fp, ECTF_DTFULL));
1072 return (ctf_set_errno(fp, ECTF_DUPMEMBER));
1076 if ((msize = ctf_type_size(fp, type)) == CTF_ERR ||
1077 (malign = ctf_type_align(fp, type)) == CTF_ERR)
1081 return (ctf_set_errno(fp, EAGAIN));
1085 return (ctf_set_errno(fp, EAGAIN));
1094 ctf_id_t ltype = ctf_type_resolve(fp, lmd->dmd_type);
1100 if (ctf_type_encoding(fp, ltype, &linfo) != CTF_ERR)
1102 else if ((lsize = ctf_type_size(fp, ltype)) != CTF_ERR)
1120 ssize = ctf_get_ctt_size(fp, &dtd->dtd_data, NULL, NULL);
1135 fp->ctf_dtstrlen += strlen(s) + 1;
1137 ctf_ref_inc(fp, type);
1138 fp->ctf_flags |= LCTF_DIRTY;
1151 ctf_delete_type(ctf_file_t *fp, ctf_id_t type)
1154 ctf_dtdef_t *dtd = ctf_dtd_lookup(fp, type);
1156 if (!(fp->ctf_flags & LCTF_RDWR))
1157 return (ctf_set_errno(fp, ECTF_RDONLY));
1164 fpd = fp;
1166 ctf_dtd_lookup(fp, type) == NULL)
1170 return (ctf_set_errno(fp, ECTF_NOTDYN));
1172 if (dtd->dtd_ref != 0 || fp->ctf_refcnt > 1)
1173 return (ctf_set_errno(fp, ECTF_REFERENCED));
1175 ctf_dtd_delete(fp, dtd);
1176 fp->ctf_flags |= LCTF_DIRTY;