Ejemplo n.º 1
0
static struct taginfo *
/* ARGSUSED */
init_abstract_info(TNF *tnf, tnf_ref32_t *tag, struct taginfo *info)
{
	if (INFO_SCALAR(info) || INFO_DERIVED(info) ||
	    INFO_STRUCT(info) || INFO_ARRAY(info))
		_tnf_error(tnf, TNF_ERR_INTERNAL);
	if (info->size == (size_t)-1)
		_tnf_error(tnf, TNF_ERR_BADTNF);
	return (info);
}
Ejemplo n.º 2
0
void
_tnf_check_slots(tnf_datum_t datum)
{
	struct taginfo	*info;

	CHECK_DATUM(datum);

	info = DATUM_INFO(datum);

	/* Must be an aggregate */
	if (!(INFO_STRUCT(info) || INFO_ARRAY(info)))
		_tnf_error(DATUM_TNF(datum), TNF_ERR_TYPEMISMATCH);
}
Ejemplo n.º 3
0
static struct taginfo *
init_struct_info(TNF *tnf, tnf_ref32_t *tag, struct taginfo *info)
{
	if ((!INFO_STRUCT(info)) ||
	    (INFO_DERIVED(info) || INFO_ARRAY(info) || INFO_SCALAR(info)))
		_tnf_error(tnf, TNF_ERR_INTERNAL);
	if (info->size == (size_t)-1)
		_tnf_error(tnf, TNF_ERR_BADTNF);

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

	return (info);
}
Ejemplo n.º 4
0
static struct taginfo *
/* ARGSUSED */
init_scalar_info(TNF *tnf, tnf_ref32_t *tag, struct taginfo *info)
{
	if ((!INFO_SCALAR(info)) ||
	    (INFO_DERIVED(info) || INFO_ARRAY(info) || INFO_STRUCT(info)))
		_tnf_error(tnf, TNF_ERR_INTERNAL);
	if (info->size == (size_t)-1)
		_tnf_error(tnf, TNF_ERR_BADTNF);

	/* XXX alignment already done */

	return (info);
}
Ejemplo n.º 5
0
static struct taginfo *
add_info(TNF *tnf, tnf_ref32_t *tag)
{
	struct taginfo 	*info, *bucket;
	unsigned	hash;
	tnf_ref32_t	*meta;

	info = (struct taginfo *)calloc(1, sizeof (struct taginfo));

	/* Initialize members */
	info->tnf 	= tnf;
	info->tag 	= tag;
	info->name	= _tnf_get_name(tnf, tag);
	info->props	= _tnf_get_props(tnf, tag);
	info->kind	= _tnf_get_kind(tnf, tag);
	info->size	= _tnf_get_storage_size(tnf, tag);
	info->align	= _tnf_get_align(tnf, tag);

	/* Add it to table */
	hash 		= TAGHASH(tnf, tag);
	bucket 		= tnf->tag_table[hash];
	info->link 	= bucket;
	tnf->tag_table[hash] = info;

	/* Ensure meta info is available */
	meta		= _tnf_get_tag(tnf, tag);
	info->meta	= _tnf_get_info(tnf, meta);

	/*
	 * Initialize info
	 * Derived must be first clause due to property inheritance
	 */

	if (INFO_DERIVED(info))
		return (init_derived_info(tnf, tag, info));
	else if (INFO_STRUCT(info))
		return (init_struct_info(tnf, tag, info));
	else if (INFO_ARRAY(info))
		return (init_array_info(tnf, tag, info));
	else if (INFO_SCALAR(info))
		return (init_scalar_info(tnf, tag, info));
	else			/* XXX assume abstract type */
		return (init_abstract_info(tnf, tag, info));
}
Ejemplo n.º 6
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);
}