ctf_types.c (256281) | ctf_types.c (268578) |
---|---|
1/* 2 * CDDL HEADER START 3 * 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. 8 * --- 11 unchanged lines hidden (view full) --- 20 * CDDL HEADER END 21 */ 22 23/* 24 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 25 * Use is subject to license terms. 26 */ 27 | 1/* 2 * CDDL HEADER START 3 * 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. 8 * --- 11 unchanged lines hidden (view full) --- 20 * CDDL HEADER END 21 */ 22 23/* 24 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 25 * Use is subject to license terms. 26 */ 27 |
28#pragma ident "%Z%%M% %I% %E% SMI" 29 | |
30#include <ctf_impl.h> 31 32ssize_t 33ctf_get_ctt_size(const ctf_file_t *fp, const ctf_type_t *tp, ssize_t *sizep, 34 ssize_t *incrementp) 35{ 36 ssize_t size, increment; 37 --- 156 unchanged lines hidden (view full) --- 194 195 return (CTF_ERR); /* errno is set for us */ 196} 197 198/* 199 * Lookup the given type ID and print a string name for it into buf. Return 200 * the actual number of bytes (not including \0) needed to format the name. 201 */ | 28#include <ctf_impl.h> 29 30ssize_t 31ctf_get_ctt_size(const ctf_file_t *fp, const ctf_type_t *tp, ssize_t *sizep, 32 ssize_t *incrementp) 33{ 34 ssize_t size, increment; 35 --- 156 unchanged lines hidden (view full) --- 192 193 return (CTF_ERR); /* errno is set for us */ 194} 195 196/* 197 * Lookup the given type ID and print a string name for it into buf. Return 198 * the actual number of bytes (not including \0) needed to format the name. 199 */ |
202ssize_t 203ctf_type_lname(ctf_file_t *fp, ctf_id_t type, char *buf, size_t len) | 200static ssize_t 201ctf_type_qlname(ctf_file_t *fp, ctf_id_t type, char *buf, size_t len, 202 const char *qname) |
204{ 205 ctf_decl_t cd; 206 ctf_decl_node_t *cdp; 207 ctf_decl_prec_t prec, lp, rp; 208 int ptr, arr; 209 uint_t k; 210 211 if (fp == NULL && type == CTF_ERR) --- 38 unchanged lines hidden (view full) --- 250 ctf_decl_sprintf(&cd, "("); 251 lp = -1; 252 } 253 254 switch (cdp->cd_kind) { 255 case CTF_K_INTEGER: 256 case CTF_K_FLOAT: 257 case CTF_K_TYPEDEF: | 203{ 204 ctf_decl_t cd; 205 ctf_decl_node_t *cdp; 206 ctf_decl_prec_t prec, lp, rp; 207 int ptr, arr; 208 uint_t k; 209 210 if (fp == NULL && type == CTF_ERR) --- 38 unchanged lines hidden (view full) --- 249 ctf_decl_sprintf(&cd, "("); 250 lp = -1; 251 } 252 253 switch (cdp->cd_kind) { 254 case CTF_K_INTEGER: 255 case CTF_K_FLOAT: 256 case CTF_K_TYPEDEF: |
257 if (qname != NULL) 258 ctf_decl_sprintf(&cd, "%s`", qname); |
|
258 ctf_decl_sprintf(&cd, "%s", name); 259 break; 260 case CTF_K_POINTER: 261 ctf_decl_sprintf(&cd, "*"); 262 break; 263 case CTF_K_ARRAY: 264 ctf_decl_sprintf(&cd, "[%u]", cdp->cd_n); 265 break; 266 case CTF_K_FUNCTION: 267 ctf_decl_sprintf(&cd, "()"); 268 break; 269 case CTF_K_STRUCT: 270 case CTF_K_FORWARD: | 259 ctf_decl_sprintf(&cd, "%s", name); 260 break; 261 case CTF_K_POINTER: 262 ctf_decl_sprintf(&cd, "*"); 263 break; 264 case CTF_K_ARRAY: 265 ctf_decl_sprintf(&cd, "[%u]", cdp->cd_n); 266 break; 267 case CTF_K_FUNCTION: 268 ctf_decl_sprintf(&cd, "()"); 269 break; 270 case CTF_K_STRUCT: 271 case CTF_K_FORWARD: |
271 ctf_decl_sprintf(&cd, "struct %s", name); | 272 ctf_decl_sprintf(&cd, "struct "); 273 if (qname != NULL) 274 ctf_decl_sprintf(&cd, "%s`", qname); 275 ctf_decl_sprintf(&cd, "%s", name); |
272 break; 273 case CTF_K_UNION: | 276 break; 277 case CTF_K_UNION: |
274 ctf_decl_sprintf(&cd, "union %s", name); | 278 ctf_decl_sprintf(&cd, "union "); 279 if (qname != NULL) 280 ctf_decl_sprintf(&cd, "%s`", qname); 281 ctf_decl_sprintf(&cd, "%s", name); |
275 break; 276 case CTF_K_ENUM: | 282 break; 283 case CTF_K_ENUM: |
277 ctf_decl_sprintf(&cd, "enum %s", name); | 284 ctf_decl_sprintf(&cd, "enum "); 285 if (qname != NULL) 286 ctf_decl_sprintf(&cd, "%s`", qname); 287 ctf_decl_sprintf(&cd, "%s", name); |
278 break; 279 case CTF_K_VOLATILE: 280 ctf_decl_sprintf(&cd, "volatile"); 281 break; 282 case CTF_K_CONST: 283 ctf_decl_sprintf(&cd, "const"); 284 break; 285 case CTF_K_RESTRICT: --- 10 unchanged lines hidden (view full) --- 296 297 if (cd.cd_len >= len) 298 (void) ctf_set_errno(fp, ECTF_NAMELEN); 299 300 ctf_decl_fini(&cd); 301 return (cd.cd_len); 302} 303 | 288 break; 289 case CTF_K_VOLATILE: 290 ctf_decl_sprintf(&cd, "volatile"); 291 break; 292 case CTF_K_CONST: 293 ctf_decl_sprintf(&cd, "const"); 294 break; 295 case CTF_K_RESTRICT: --- 10 unchanged lines hidden (view full) --- 306 307 if (cd.cd_len >= len) 308 (void) ctf_set_errno(fp, ECTF_NAMELEN); 309 310 ctf_decl_fini(&cd); 311 return (cd.cd_len); 312} 313 |
314ssize_t 315ctf_type_lname(ctf_file_t *fp, ctf_id_t type, char *buf, size_t len) 316{ 317 return (ctf_type_qlname(fp, type, buf, len, NULL)); 318} 319 |
|
304/* 305 * Lookup the given type ID and print a string name for it into buf. If buf 306 * is too small, return NULL: the ECTF_NAMELEN error is set on 'fp' for us. 307 */ 308char * 309ctf_type_name(ctf_file_t *fp, ctf_id_t type, char *buf, size_t len) 310{ | 320/* 321 * Lookup the given type ID and print a string name for it into buf. If buf 322 * is too small, return NULL: the ECTF_NAMELEN error is set on 'fp' for us. 323 */ 324char * 325ctf_type_name(ctf_file_t *fp, ctf_id_t type, char *buf, size_t len) 326{ |
311 ssize_t rv = ctf_type_lname(fp, type, buf, len); | 327 ssize_t rv = ctf_type_qlname(fp, type, buf, len, NULL); |
312 return (rv >= 0 && rv < len ? buf : NULL); 313} 314 | 328 return (rv >= 0 && rv < len ? buf : NULL); 329} 330 |
331char * 332ctf_type_qname(ctf_file_t *fp, ctf_id_t type, char *buf, size_t len, 333 const char *qname) 334{ 335 ssize_t rv = ctf_type_qlname(fp, type, buf, len, qname); 336 return (rv >= 0 && rv < len ? buf : NULL); 337} 338 339 |
|
315/* 316 * Resolve the type down to a base type node, and then return the size 317 * of the type storage in bytes. 318 */ 319ssize_t 320ctf_type_size(ctf_file_t *fp, ctf_id_t type) 321{ 322 const ctf_type_t *tp; --- 523 unchanged lines hidden --- | 340/* 341 * Resolve the type down to a base type node, and then return the size 342 * of the type storage in bytes. 343 */ 344ssize_t 345ctf_type_size(ctf_file_t *fp, ctf_id_t type) 346{ 347 const ctf_type_t *tp; --- 523 unchanged lines hidden --- |