Exemple #1
0
void
_tnf_check_record(tnf_datum_t datum)
{
	CHECK_DATUM(datum);

	/* All records must be tagged */
	if (!INFO_TAGGED(DATUM_INFO(datum)))
		_tnf_error(DATUM_TNF(datum), TNF_ERR_TYPEMISMATCH);
}
Exemple #2
0
static tnf_datum_t
get_slot(tnf_datum_t datum, struct slot *slot)
{
	if (slot == NULL) {
		_tnf_error(DATUM_TNF(datum), TNF_ERR_BADSLOT); /* XXX */
		return (TNF_DATUM_NULL);

	} else if (INFO_TAGGED(slot->slot_type)) {
		TNF		*tnf;
		tnf_ref32_t	*rec;

		tnf = DATUM_TNF(datum);
		/* LINTED pointer cast may result in improper alignment */
		rec = _GET_REF32(tnf, (tnf_ref32_t *)
			(DATUM_VAL(datum) + slot->slot_offset));
		/* NULL slots are allowed */
		return ((rec == TNF_NULL)? TNF_DATUM_NULL :
			RECORD_DATUM(tnf, rec));

	} else			/* inline */
		return DATUM(slot->slot_type,
			DATUM_VAL(datum) + slot->slot_offset);
}
Exemple #3
0
static struct taginfo *
init_array_info(TNF *tnf, tnf_ref32_t *tag, struct taginfo *info)
{
	tnf_ref32_t	*elt_tag;
	int		defeat;

	if ((!INFO_ARRAY(info)) ||
	    (INFO_DERIVED(info) || INFO_STRUCT(info) || INFO_SCALAR(info)))
		_tnf_error(tnf, TNF_ERR_INTERNAL);

	/* XXX special-case abstract array tag */
	defeat = (strcmp(info->name, TNF_N_ARRAY) == 0);

	/* Require all arrays to be self-sized records */
	if (!(INFO_TAGGED(info) && (info->size == (size_t)-1)))
		if (!defeat)
			_tnf_error(tnf, TNF_ERR_BADTNF);

	/* Store array header size */
	info->hdrsize = _tnf_get_header_size(tnf, tag);
	/* XXX Temporary sanity check */
	if (info->hdrsize != sizeof (struct tnf_array_hdr))
		if (!defeat)
			_tnf_error(tnf, TNF_ERR_BADTNF);

	/* Get slot information */
	init_slots(tnf, tag, info);

	/* Get info for element type */
	elt_tag = (tnf_ref32_t *)_tnf_get_slot_typed(tnf, tag,
		/* LINTED pointer cast may result in improper alignment */
						    TNF_N_ELEMENT_TYPE);
	/* XXX tnf_array has element_type == NULL */
	info->base = elt_tag ? _tnf_get_info(tnf, elt_tag): NULL;

	return (info);
}