6811333 Remove prom_printf() message in emlxs driver
[opensolaris.git] / usr / src / lib / libtnf / type.c
blobbd18e265597d3c6104e96517afbeb608b712d91a
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright (c) 1994, by Sun Microsytems, Inc.
26 #pragma ident "%Z%%M% %I% %E% SMI"
28 #include "libtnf.h"
31 * All types are struct records
34 void
35 _tnf_check_type(tnf_datum_t datum)
37 CHECK_RECORD(datum);
38 CHECK_SLOTS(datum);
40 if (!INFO_TYPE(DATUM_INFO(datum)))
41 _tnf_error(DATUM_TNF(datum), TNF_ERR_TYPEMISMATCH);
45 * Get data kind of a type record
48 tnf_kind_t
49 tnf_type_get_kind(tnf_datum_t datum)
51 struct taginfo *info;
53 CHECK_TYPE(datum);
55 /* Note: DATUM_RECORD(), not DATUM_TAG() */
56 /* LINTED pointer cast may result in improper alignment */
57 info = _tnf_get_info(DATUM_TNF(datum), DATUM_RECORD(datum));
58 return (info->kind);
62 * Retrieve type name for datum type record
65 char *
66 tnf_type_get_name(tnf_datum_t datum)
68 CHECK_TYPE(datum);
69 /* XXX Dispatch to ABI routine; faster than taginfo lookup? */
70 /* LINTED pointer cast may result in improper alignment */
71 return (_tnf_get_name(DATUM_TNF(datum), DATUM_RECORD(datum)));
75 * Fetch size member of info for datum type record
78 size_t
79 tnf_type_get_size(tnf_datum_t datum)
81 struct taginfo *info;
83 CHECK_TYPE(datum);
85 /* Note: DATUM_RECORD(), not DATUM_TAG() */
86 /* LINTED pointer cast may result in improper alignment */
87 info = _tnf_get_info(DATUM_TNF(datum), DATUM_RECORD(datum));
89 if (INFO_ARRAY(info))
90 /* XXX All arrays are self-sized */
91 return ((size_t)-1);
92 else
93 return (info->size);
97 * Get the base type of a type
100 tnf_datum_t
101 tnf_type_get_base(tnf_datum_t datum)
103 struct taginfo *info;
105 CHECK_TYPE(datum);
107 /* Note: DATUM_RECORD(), not DATUM_TAG() */
108 /* LINTED pointer cast may result in improper alignment */
109 info = _tnf_get_info(DATUM_TNF(datum), DATUM_RECORD(datum));
111 if (INFO_DERIVED(info))
112 return (DATUM(info->base->meta, (caddr_t)info->base->tag));
113 else
114 return (datum);
118 * If type record has named property, return a datum for it
121 tnf_datum_t
122 tnf_type_get_property(tnf_datum_t datum, char *name)
124 tnf_ref32_t *property;
126 CHECK_TYPE(datum);
128 /* Note: DATUM_RECORD(), not DATUM_TAG() */
129 property = _tnf_get_property(DATUM_TNF(datum),
130 /* LINTED pointer cast may result in improper alignment */
131 DATUM_RECORD(datum), name);
133 if (property == TNF_NULL)
134 return (TNF_DATUM_NULL);
135 else
136 return (RECORD_DATUM(DATUM_TNF(datum), property));