xref: /titanic_51/usr/src/cmd/sgs/libconv/common/_conv.h (revision 4f680cc668fa6cf678c531083400ade9a9c7934c)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
55aefb655Srie  * Common Development and Distribution License (the "License").
65aefb655Srie  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
215aefb655Srie 
227c478bd9Sstevel@tonic-gate /*
23*4f680cc6SAli Bahrami  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef	__CONV_DOT_H
287c478bd9Sstevel@tonic-gate #define	__CONV_DOT_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate /*
317c478bd9Sstevel@tonic-gate  * Local include file for conversion library.
327c478bd9Sstevel@tonic-gate  */
337c478bd9Sstevel@tonic-gate #include <conv.h>
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
367c478bd9Sstevel@tonic-gate extern "C" {
377c478bd9Sstevel@tonic-gate #endif
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate /*
405aefb655Srie  * Some format strings differ depending on whether they are used for 32-bit
415aefb655Srie  * or 64-bit values.
427c478bd9Sstevel@tonic-gate  */
435aefb655Srie #if	defined(_ELF64)
445aefb655Srie #define	MSG_GBL_FMT_DEC		MSG_GBL_FMT_DEC_64
455aefb655Srie #define	MSG_GBL_FMT_DECS	MSG_GBL_FMT_DECS_64
465aefb655Srie #define	MSG_GBL_FMT_HEX		MSG_GBL_FMT_HEX_64
475aefb655Srie #define	MSG_GBL_FMT_HEXS	MSG_GBL_FMT_HEXS_64
485aefb655Srie 
495aefb655Srie #define	MSG_SYM_FMT_VAL		MSG_SYM_FMT_VAL_64
505aefb655Srie #else
515aefb655Srie #define	MSG_GBL_FMT_DEC		MSG_GBL_FMT_DEC_32
525aefb655Srie #define	MSG_GBL_FMT_DECS	MSG_GBL_FMT_DECS_32
535aefb655Srie #define	MSG_GBL_FMT_HEX		MSG_GBL_FMT_HEX_32
545aefb655Srie #define	MSG_GBL_FMT_HEXS	MSG_GBL_FMT_HEXS_32
555aefb655Srie 
565aefb655Srie #define	MSG_SYM_FMT_VAL		MSG_SYM_FMT_VAL_32
575aefb655Srie #endif
587c478bd9Sstevel@tonic-gate 
59c13de8f6Sab196087 
60c13de8f6Sab196087 /*
61*4f680cc6SAli Bahrami  * There are routines in libconv that are built once for each ELFCLASS
62*4f680cc6SAli Bahrami  * because they are formatting Xword values. However, all ELF constants
63*4f680cc6SAli Bahrami  * lie in 32-bit ranges, due to the need be usable for ELFCLASS32. Hence,
64*4f680cc6SAli Bahrami  * the value of the ELFCLASS64 support here is purely to detect unexpected
65*4f680cc6SAli Bahrami  * garbage values above the 32-bit range.
66c13de8f6Sab196087  *
67*4f680cc6SAli Bahrami  * The CONV_XWORD_64TEST() macro tests the upper half of an ELFCLASS64 Xword,
68*4f680cc6SAli Bahrami  * and formats the value in hex if non-zero bits are seen. For ELFCLASS32,
69*4f680cc6SAli Bahrami  * it is a no-op.
70c13de8f6Sab196087  */
71*4f680cc6SAli Bahrami #ifdef _ELF64
72*4f680cc6SAli Bahrami #define	CONV_XWORD_64TEST(_value, _fmt_flags, _inv_buf) \
73*4f680cc6SAli Bahrami 	if (_value & 0xffffffff00000000) \
74*4f680cc6SAli Bahrami 	    return (conv_invalid_val(_inv_buf, _value, _fmt_flags))
75*4f680cc6SAli Bahrami #else
76*4f680cc6SAli Bahrami #define	CONV_XWORD_64TEST(_value, _fmt_flags, _inv_buf)
77*4f680cc6SAli Bahrami #endif
78*4f680cc6SAli Bahrami 
79c13de8f6Sab196087 
80c13de8f6Sab196087 /* # of elements in an array */
81c13de8f6Sab196087 #define	ARRAY_NELTS(arr) (sizeof (arr) / sizeof (*arr))
82c13de8f6Sab196087 
83*4f680cc6SAli Bahrami /*
84*4f680cc6SAli Bahrami  * Functions intended for use inter-file, within libconv only
85*4f680cc6SAli Bahrami  */
86*4f680cc6SAli Bahrami extern	const conv_ds_t	**conv_cap_tag_strings(Conv_fmt_flags_t);
87*4f680cc6SAli Bahrami extern	const Val_desc	*conv_dyn_feature1_strings(Conv_fmt_flags_t);
88*4f680cc6SAli Bahrami extern	const Val_desc	*conv_dyn_flag_strings(Conv_fmt_flags_t);
89*4f680cc6SAli Bahrami extern	const Val_desc	*conv_dyn_flag1_strings(Conv_fmt_flags_t);
90*4f680cc6SAli Bahrami extern	const Val_desc	*conv_dyn_posflag1_strings(Conv_fmt_flags_t);
91*4f680cc6SAli Bahrami extern	const conv_ds_t	**conv_dyn_tag_strings(conv_iter_osabi_t, Half,
92*4f680cc6SAli Bahrami 			    Conv_fmt_flags_t);
93*4f680cc6SAli Bahrami extern	const Val_desc2	*conv_sec_flags_strings(Conv_fmt_flags_t);
94c13de8f6Sab196087 
95c13de8f6Sab196087 
967c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
977c478bd9Sstevel@tonic-gate }
987c478bd9Sstevel@tonic-gate #endif
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate #endif	/* __CONV_DOT_H */
101