Detect FPU by checking CPUID features.
[dragonfly.git] / contrib / bind-9.5.2 / lib / dns / rdata / generic / hinfo_13.c
blob53213574027cce7dd239845c7c6d3a62705a3a17
1 /*
2 * Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1998-2002 Internet Software Consortium.
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
18 /* $Id: hinfo_13.c,v 1.44 2007/06/19 23:47:17 tbox Exp $ */
21 * Reviewed: Wed Mar 15 16:47:10 PST 2000 by halley.
24 #ifndef RDATA_GENERIC_HINFO_13_C
25 #define RDATA_GENERIC_HINFO_13_C
27 #define RRTYPE_HINFO_ATTRIBUTES (0)
29 static inline isc_result_t
30 fromtext_hinfo(ARGS_FROMTEXT) {
31 isc_token_t token;
32 int i;
34 UNUSED(type);
35 UNUSED(rdclass);
36 UNUSED(origin);
37 UNUSED(options);
38 UNUSED(callbacks);
40 REQUIRE(type == 13);
42 for (i = 0; i < 2; i++) {
43 RETERR(isc_lex_getmastertoken(lexer, &token,
44 isc_tokentype_qstring,
45 ISC_FALSE));
46 RETTOK(txt_fromtext(&token.value.as_textregion, target));
48 return (ISC_R_SUCCESS);
51 static inline isc_result_t
52 totext_hinfo(ARGS_TOTEXT) {
53 isc_region_t region;
55 UNUSED(tctx);
57 REQUIRE(rdata->type == 13);
58 REQUIRE(rdata->length != 0);
60 dns_rdata_toregion(rdata, &region);
61 RETERR(txt_totext(&region, target));
62 RETERR(str_totext(" ", target));
63 return (txt_totext(&region, target));
66 static inline isc_result_t
67 fromwire_hinfo(ARGS_FROMWIRE) {
69 REQUIRE(type == 13);
71 UNUSED(type);
72 UNUSED(dctx);
73 UNUSED(rdclass);
74 UNUSED(options);
76 RETERR(txt_fromwire(source, target));
77 return (txt_fromwire(source, target));
80 static inline isc_result_t
81 towire_hinfo(ARGS_TOWIRE) {
83 UNUSED(cctx);
85 REQUIRE(rdata->type == 13);
86 REQUIRE(rdata->length != 0);
88 return (mem_tobuffer(target, rdata->data, rdata->length));
91 static inline int
92 compare_hinfo(ARGS_COMPARE) {
93 isc_region_t r1;
94 isc_region_t r2;
96 REQUIRE(rdata1->type == rdata2->type);
97 REQUIRE(rdata1->rdclass == rdata2->rdclass);
98 REQUIRE(rdata1->type == 13);
99 REQUIRE(rdata1->length != 0);
100 REQUIRE(rdata2->length != 0);
102 dns_rdata_toregion(rdata1, &r1);
103 dns_rdata_toregion(rdata2, &r2);
104 return (isc_region_compare(&r1, &r2));
107 static inline isc_result_t
108 fromstruct_hinfo(ARGS_FROMSTRUCT) {
109 dns_rdata_hinfo_t *hinfo = source;
111 REQUIRE(type == 13);
112 REQUIRE(source != NULL);
113 REQUIRE(hinfo->common.rdtype == type);
114 REQUIRE(hinfo->common.rdclass == rdclass);
116 UNUSED(type);
117 UNUSED(rdclass);
119 RETERR(uint8_tobuffer(hinfo->cpu_len, target));
120 RETERR(mem_tobuffer(target, hinfo->cpu, hinfo->cpu_len));
121 RETERR(uint8_tobuffer(hinfo->os_len, target));
122 return (mem_tobuffer(target, hinfo->os, hinfo->os_len));
125 static inline isc_result_t
126 tostruct_hinfo(ARGS_TOSTRUCT) {
127 dns_rdata_hinfo_t *hinfo = target;
128 isc_region_t region;
130 REQUIRE(rdata->type == 13);
131 REQUIRE(target != NULL);
132 REQUIRE(rdata->length != 0);
134 hinfo->common.rdclass = rdata->rdclass;
135 hinfo->common.rdtype = rdata->type;
136 ISC_LINK_INIT(&hinfo->common, link);
138 dns_rdata_toregion(rdata, &region);
139 hinfo->cpu_len = uint8_fromregion(&region);
140 isc_region_consume(&region, 1);
141 hinfo->cpu = mem_maybedup(mctx, region.base, hinfo->cpu_len);
142 if (hinfo->cpu == NULL)
143 return (ISC_R_NOMEMORY);
144 isc_region_consume(&region, hinfo->cpu_len);
146 hinfo->os_len = uint8_fromregion(&region);
147 isc_region_consume(&region, 1);
148 hinfo->os = mem_maybedup(mctx, region.base, hinfo->os_len);
149 if (hinfo->os == NULL)
150 goto cleanup;
152 hinfo->mctx = mctx;
153 return (ISC_R_SUCCESS);
155 cleanup:
156 if (mctx != NULL && hinfo->cpu != NULL)
157 isc_mem_free(mctx, hinfo->cpu);
158 return (ISC_R_NOMEMORY);
161 static inline void
162 freestruct_hinfo(ARGS_FREESTRUCT) {
163 dns_rdata_hinfo_t *hinfo = source;
165 REQUIRE(source != NULL);
167 if (hinfo->mctx == NULL)
168 return;
170 if (hinfo->cpu != NULL)
171 isc_mem_free(hinfo->mctx, hinfo->cpu);
172 if (hinfo->os != NULL)
173 isc_mem_free(hinfo->mctx, hinfo->os);
174 hinfo->mctx = NULL;
177 static inline isc_result_t
178 additionaldata_hinfo(ARGS_ADDLDATA) {
179 REQUIRE(rdata->type == 13);
181 UNUSED(add);
182 UNUSED(arg);
183 UNUSED(rdata);
185 return (ISC_R_SUCCESS);
188 static inline isc_result_t
189 digest_hinfo(ARGS_DIGEST) {
190 isc_region_t r;
192 REQUIRE(rdata->type == 13);
194 dns_rdata_toregion(rdata, &r);
196 return ((digest)(arg, &r));
199 static inline isc_boolean_t
200 checkowner_hinfo(ARGS_CHECKOWNER) {
202 REQUIRE(type == 13);
204 UNUSED(name);
205 UNUSED(type);
206 UNUSED(rdclass);
207 UNUSED(wildcard);
209 return (ISC_TRUE);
212 static inline isc_boolean_t
213 checknames_hinfo(ARGS_CHECKNAMES) {
215 REQUIRE(rdata->type == 13);
217 UNUSED(rdata);
218 UNUSED(owner);
219 UNUSED(bad);
221 return (ISC_TRUE);
224 #endif /* RDATA_GENERIC_HINFO_13_C */