8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / sgs / libconv / common / segments.c
blob4c893012881c865d6b91f181b2a6026b229b417d
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
28 * String conversion routine for segment flags.
30 #include <string.h>
31 #include <libld.h>
32 #include "_conv.h"
33 #include "segments_msg.h"
35 #define SEGSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
36 MSG_FLG_SG_P_VADDR_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
37 MSG_FLG_SG_P_PADDR_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
38 MSG_FLG_SG_LENGTH_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
39 MSG_FLG_SG_P_ALIGN_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
40 MSG_FLG_SG_ROUND_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
41 MSG_FLG_SG_P_FLAGS_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
42 MSG_FLG_SG_P_TYPE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
43 MSG_FLG_SG_IS_ORDER_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
44 MSG_FLG_SG_NOHDR_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
45 MSG_FLG_SG_EMPTY_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
46 MSG_FLG_SG_KEY_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
47 MSG_FLG_SG_NODISABLE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
48 MSG_FLG_SG_DISABLED_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
49 MSG_FLG_SG_PHREQ_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
50 MSG_FLG_SG_ORDERED_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
51 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
54 * Ensure that Conv_seg_flags_buf_t is large enough:
56 * SEGSZ is the real minimum size of the buffer required by conv_seg_flags().
57 * However, Conv_seg_flags_buf_t uses CONV_SEG_FLAGS_BUFSIZE to set the
58 * buffer size. We do things this way because the definition of SEGSZ uses
59 * information that is not available in the environment of other programs
60 * that include the conv.h header file.
62 #if (CONV_SEG_FLAGS_BUFSIZE != SEGSZ) && !defined(__lint)
63 #define REPORT_BUFSIZE SEGSZ
64 #include "report_bufsize.h"
65 #error "CONV_SEG_FLAGS_BUFSIZE does not match SEGSZ"
66 #endif
68 const char *
69 conv_seg_flags(sg_flags_t flags, Conv_seg_flags_buf_t *seg_flags_buf)
71 static Val_desc vda[] = {
72 { FLG_SG_P_VADDR, MSG_FLG_SG_P_VADDR },
73 { FLG_SG_P_PADDR, MSG_FLG_SG_P_PADDR },
74 { FLG_SG_LENGTH, MSG_FLG_SG_LENGTH },
75 { FLG_SG_P_ALIGN, MSG_FLG_SG_P_ALIGN },
76 { FLG_SG_ROUND, MSG_FLG_SG_ROUND },
77 { FLG_SG_P_FLAGS, MSG_FLG_SG_P_FLAGS },
78 { FLG_SG_P_TYPE, MSG_FLG_SG_P_TYPE },
79 { FLG_SG_IS_ORDER, MSG_FLG_SG_IS_ORDER },
80 { FLG_SG_NOHDR, MSG_FLG_SG_NOHDR },
81 { FLG_SG_EMPTY, MSG_FLG_SG_EMPTY },
82 { FLG_SG_KEY, MSG_FLG_SG_KEY },
83 { FLG_SG_NODISABLE, MSG_FLG_SG_NODISABLE },
84 { FLG_SG_DISABLED, MSG_FLG_SG_DISABLED },
85 { FLG_SG_PHREQ, MSG_FLG_SG_PHREQ },
86 { FLG_SG_ORDERED, MSG_FLG_SG_ORDERED },
87 { 0, 0 }
89 static CONV_EXPN_FIELD_ARG conv_arg = {
90 NULL, sizeof (seg_flags_buf->buf) };
92 if (flags == 0)
93 return (MSG_ORIG(MSG_GBL_ZERO));
95 conv_arg.buf = seg_flags_buf->buf;
96 conv_arg.oflags = conv_arg.rflags = flags;
97 (void) conv_expn_field(&conv_arg, vda, 0);
99 return ((const char *)seg_flags_buf->buf);