_conv.h revision 9273:9a0603d78ad3
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 (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24 * Use is subject to license terms.
25 */
26
27#ifndef	__CONV_DOT_H
28#define	__CONV_DOT_H
29
30/*
31 * Local include file for conversion library.
32 */
33#include <conv.h>
34
35#ifdef	__cplusplus
36extern "C" {
37#endif
38
39/*
40 * Some format strings differ depending on whether they are used for 32-bit
41 * or 64-bit values.
42 */
43#if	defined(_ELF64)
44#define	MSG_GBL_FMT_DEC		MSG_GBL_FMT_DEC_64
45#define	MSG_GBL_FMT_DECS	MSG_GBL_FMT_DECS_64
46#define	MSG_GBL_FMT_HEX		MSG_GBL_FMT_HEX_64
47#define	MSG_GBL_FMT_HEXS	MSG_GBL_FMT_HEXS_64
48
49#define	MSG_SYM_FMT_VAL		MSG_SYM_FMT_VAL_64
50#else
51#define	MSG_GBL_FMT_DEC		MSG_GBL_FMT_DEC_32
52#define	MSG_GBL_FMT_DECS	MSG_GBL_FMT_DECS_32
53#define	MSG_GBL_FMT_HEX		MSG_GBL_FMT_HEX_32
54#define	MSG_GBL_FMT_HEXS	MSG_GBL_FMT_HEXS_32
55
56#define	MSG_SYM_FMT_VAL		MSG_SYM_FMT_VAL_32
57#endif
58
59
60/*
61 * There are routines in libconv that are built once for each ELFCLASS
62 * because they are formatting Xword values. However, all ELF constants
63 * lie in 32-bit ranges, due to the need be usable for ELFCLASS32. Hence,
64 * the value of the ELFCLASS64 support here is purely to detect unexpected
65 * garbage values above the 32-bit range.
66 *
67 * The CONV_XWORD_64TEST() macro tests the upper half of an ELFCLASS64 Xword,
68 * and formats the value in hex if non-zero bits are seen. For ELFCLASS32,
69 * it is a no-op.
70 */
71#ifdef _ELF64
72#define	CONV_XWORD_64TEST(_value, _fmt_flags, _inv_buf) \
73	if (_value & 0xffffffff00000000) \
74	    return (conv_invalid_val(_inv_buf, _value, _fmt_flags))
75#else
76#define	CONV_XWORD_64TEST(_value, _fmt_flags, _inv_buf)
77#endif
78
79
80/* # of elements in an array */
81#define	ARRAY_NELTS(arr) (sizeof (arr) / sizeof (*arr))
82
83/*
84 * Functions intended for use inter-file, within libconv only
85 */
86extern	const conv_ds_t	**conv_cap_tag_strings(Conv_fmt_flags_t);
87extern	const Val_desc	*conv_dyn_feature1_strings(Conv_fmt_flags_t);
88extern	const Val_desc	*conv_dyn_flag_strings(Conv_fmt_flags_t);
89extern	const Val_desc	*conv_dyn_flag1_strings(Conv_fmt_flags_t);
90extern	const Val_desc	*conv_dyn_posflag1_strings(Conv_fmt_flags_t);
91extern	const conv_ds_t	**conv_dyn_tag_strings(conv_iter_osabi_t, Half,
92			    Conv_fmt_flags_t);
93extern	const Val_desc2	*conv_sec_flags_strings(Conv_fmt_flags_t);
94
95
96#ifdef	__cplusplus
97}
98#endif
99
100#endif	/* __CONV_DOT_H */
101