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
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 1999 by Sun Microsystems, Inc.
24 * All rights reserved.
31 #pragma ident "%Z%%M% %I% %E% SMI"
41 #define ITMC_STATUS_SUCCESS (0)
42 #define ITMC_STATUS_CMD (1)
43 #define ITMC_STATUS_CMD2 (2)
44 #define ITMC_STATUS_BT (3)
45 #define ITMC_STATUS_BT2 (4)
46 #define ITMC_STATUS_SYS (5)
47 #define ITMC_STATUS_SYS2 (6)
54 * ITMC_STATUS_CMD specified options are wrong
55 * ITMC_STATUS_CMD2 cannot access specified file
56 * ITMC_STATUS_BT Binary Table format error
57 * ITMC_STATUS_BT2 Binary Table against limitation
58 * ITMC_STATUS_SYS resource shortage (e.g.: malloc )
59 * ITMC_STATUS_SYS2 internal error: never happen
76 ITMC_MAP_SIMPLE_INDEX
,
78 ITMC_MAP_BINARY_SEARCH
,
79 ITMC_MAP_DENSE_ENCODING
84 typedef struct _itmc_map_name_type
{
88 struct _itmc_map_name_type
*next
;
89 } itmc_map_name_type_t
;
100 int cpp_opt_reserved
;
101 char *preprocess_default
;
102 char *preprocess_specified
;
106 itmc_map_name_type_t
*
126 typedef struct _itmc_obj
{
130 struct _itmc_ref
*ref
[3];
131 struct _itmc_obj
*next
;
132 struct _itmc_obj
*last
;
137 * data pair: used for map and range
140 typedef itm_data_t itmc_map_range_t
;
144 itmc_map_range_t range
;
151 typedef struct _itmc_map
{
152 itmc_data_pair_t data_pair
;
153 struct _itmc_map
*next
;
154 struct _itmc_map
*last
;
159 * cross reference: used for relocation
162 typedef struct _itmc_ref_link
{
163 struct _itmc_ref
*ref
;
164 struct _itmc_ref_link
*next
;
167 typedef struct _itmc_name
{
172 struct _itmc_ref
*object
;
174 itmc_ref_link_t
*ref_first
;
175 itmc_ref_link_t
*ref_last
;
176 struct _itmc_name
*next
;
179 typedef struct _itmc_ref
{
184 itm_place_t
*referencer
;
185 struct _itmc_ref
*next
;
195 itm_tbl_hdr_t
*tbl_hdr
;
202 itm_size_t resultlen
;
209 * operation hierarchy
211 typedef struct itm_opt_outer
{
212 struct itm_opt_outer
*link
;
213 struct itm_opt_inner
*in
;
214 itm_tbl_hdr_t
*optbl
; /* operation object address */
215 itmc_ref_t
*ref
; /* corresponding object's ref */
217 typedef struct itm_opt_inner
{
218 struct itm_opt_inner
*in
;
219 itmc_ref_t
*ref
; /* corresponding object's ref */
224 * itm compiler object type
227 #define ITMC_OBJ_NONE (0)
228 #define ITMC_OBJ_FIRST (1)
229 #define ITMC_OBJ_ITM (1)
230 #define ITMC_OBJ_STRING (2)
231 #define ITMC_OBJ_DIREC (3)
232 #define ITMC_OBJ_COND (4)
233 #define ITMC_OBJ_MAP (5)
234 #define ITMC_OBJ_OP (6)
235 #define ITMC_OBJ_EXPR (7)
236 #define ITMC_OBJ_DATA (8)
237 #define ITMC_OBJ_ACTION (9)
238 #define ITMC_OBJ_RANGE (10)
239 #define ITMC_OBJ_REGISTER (11)
240 #define ITMC_OBJ_ESCAPESEQ (12)
241 #define ITMC_OBJ_LAST (12)
248 extern itmc_ref_t
*ref_first
[ITMC_OBJ_LAST
+ 1];
249 extern itmc_ref_t
*ref_last
[ITMC_OBJ_LAST
+ 1];
251 extern itmc_name_t
*name_first
;
252 extern itmc_name_t
*name_last
;
254 extern itm_num_t name_id
;
255 extern itm_num_t reg_id
;
257 extern itmc_name_t name_lookup_error
;
258 extern int error_deferred
;
260 extern cmd_opt_t cmd_opt
;
261 extern char *itm_input_file
;
262 extern char *itm_output_file
;
264 extern struct itm_opt_outer
*itm_op_outer
;
269 #define NSPTR(n) (((n)->size <= (sizeof ((n)->place))) ? \
270 ((void *)(&((n)->place.itm_64d))) : \
271 ((void *)((n)->place.itm_ptr)))
272 #if !defined(ROUNDUP)
273 #define ROUNDUP(a, n) (((a) + ((n) - 1)) & ~((n) - 1))
275 #define ITMROUNDUP(i) ROUNDUP(i, sizeof (uint64_t))
282 #if defined(ENABLE_TRACE)
283 #define TRACE(c) ((cmd_opt.trace != 0) && \
284 (0 != *(cmd_opt.trace + (c & 0x007f))))
285 #define TRACE_MESSAGE(c, args) ((TRACE(c))? trace_message args: (void)0)
288 #define TRACE_MESSAGE(c, args)
294 #define PERROR(s) if (cmd_opt.quiet == 0) perror(s)
300 extern int assemble(itm_hdr_t
*);
301 extern void disassemble(char *);
303 extern void *malloc_vital(size_t);
305 extern char *name_to_str(itm_data_t
*);
306 extern char *data_to_hexadecimal(itm_data_t
*);
307 extern itm_data_t
*str_to_data(int, char *);
309 #if defined(ENABLE_TRACE)
310 extern void dump_itm_header(itm_hdr_t
*, itm_info_hdr_t
*);
312 extern void trace_message(char *, ...);
315 extern char *itm_name_type_name
[];
316 extern void itm_error(char *format
, ...);
321 #endif /* !_ITMCOMP_H */