16ff6d951SJohn Birrell /* 26ff6d951SJohn Birrell * CDDL HEADER START 36ff6d951SJohn Birrell * 46ff6d951SJohn Birrell * The contents of this file are subject to the terms of the 56ff6d951SJohn Birrell * Common Development and Distribution License, Version 1.0 only 66ff6d951SJohn Birrell * (the "License"). You may not use this file except in compliance 76ff6d951SJohn Birrell * with the License. 86ff6d951SJohn Birrell * 96ff6d951SJohn Birrell * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 106ff6d951SJohn Birrell * or http://www.opensolaris.org/os/licensing. 116ff6d951SJohn Birrell * See the License for the specific language governing permissions 126ff6d951SJohn Birrell * and limitations under the License. 136ff6d951SJohn Birrell * 146ff6d951SJohn Birrell * When distributing Covered Code, include this CDDL HEADER in each 156ff6d951SJohn Birrell * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 166ff6d951SJohn Birrell * If applicable, add the following below this CDDL HEADER, with the 176ff6d951SJohn Birrell * fields enclosed by brackets "[]" replaced with your own identifying 186ff6d951SJohn Birrell * information: Portions Copyright [yyyy] [name of copyright owner] 196ff6d951SJohn Birrell * 206ff6d951SJohn Birrell * CDDL HEADER END 216ff6d951SJohn Birrell */ 226ff6d951SJohn Birrell /* 236ff6d951SJohn Birrell * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 246ff6d951SJohn Birrell * Use is subject to license terms. 256ff6d951SJohn Birrell */ 26*8e648814SRui Paulo /* 27*8e648814SRui Paulo * Copyright (c) 2013 by Delphix. All rights reserved. 28*8e648814SRui Paulo * Copyright (c) 2013 Joyent, Inc. All rights reserved. 29*8e648814SRui Paulo */ 306ff6d951SJohn Birrell 316ff6d951SJohn Birrell #ifndef _DT_DECL_H 326ff6d951SJohn Birrell #define _DT_DECL_H 336ff6d951SJohn Birrell 346ff6d951SJohn Birrell #include <sys/types.h> 356ff6d951SJohn Birrell #include <libctf.h> 366ff6d951SJohn Birrell #include <dtrace.h> 376ff6d951SJohn Birrell #include <stdio.h> 386ff6d951SJohn Birrell 396ff6d951SJohn Birrell #ifdef __cplusplus 406ff6d951SJohn Birrell extern "C" { 416ff6d951SJohn Birrell #endif 426ff6d951SJohn Birrell 436ff6d951SJohn Birrell struct dt_node; /* forward declaration of dt_node_t */ 446ff6d951SJohn Birrell 456ff6d951SJohn Birrell typedef struct dt_decl { 466ff6d951SJohn Birrell ushort_t dd_kind; /* declaration kind (CTF_K_* kind) */ 476ff6d951SJohn Birrell ushort_t dd_attr; /* attributes (DT_DA_* flags) */ 486ff6d951SJohn Birrell ctf_file_t *dd_ctfp; /* CTF container for decl's type */ 496ff6d951SJohn Birrell ctf_id_t dd_type; /* CTF identifier for decl's type */ 506ff6d951SJohn Birrell char *dd_name; /* string name of this decl (or NULL) */ 516ff6d951SJohn Birrell struct dt_node *dd_node; /* node for array size or parm list */ 526ff6d951SJohn Birrell struct dt_decl *dd_next; /* next declaration in list */ 536ff6d951SJohn Birrell } dt_decl_t; 546ff6d951SJohn Birrell 556ff6d951SJohn Birrell #define DT_DA_SIGNED 0x0001 /* signed integer value */ 566ff6d951SJohn Birrell #define DT_DA_UNSIGNED 0x0002 /* unsigned integer value */ 576ff6d951SJohn Birrell #define DT_DA_SHORT 0x0004 /* short integer value */ 586ff6d951SJohn Birrell #define DT_DA_LONG 0x0008 /* long integer or double */ 596ff6d951SJohn Birrell #define DT_DA_LONGLONG 0x0010 /* long long integer value */ 606ff6d951SJohn Birrell #define DT_DA_CONST 0x0020 /* qualify type as const */ 616ff6d951SJohn Birrell #define DT_DA_RESTRICT 0x0040 /* qualify type as restrict */ 626ff6d951SJohn Birrell #define DT_DA_VOLATILE 0x0080 /* qualify type as volatile */ 636ff6d951SJohn Birrell #define DT_DA_PAREN 0x0100 /* parenthesis tag */ 64*8e648814SRui Paulo #define DT_DA_USER 0x0200 /* user-land type specifier */ 656ff6d951SJohn Birrell 666ff6d951SJohn Birrell typedef enum dt_dclass { 676ff6d951SJohn Birrell DT_DC_DEFAULT, /* no storage class specified */ 686ff6d951SJohn Birrell DT_DC_AUTO, /* automatic storage */ 696ff6d951SJohn Birrell DT_DC_REGISTER, /* register storage */ 706ff6d951SJohn Birrell DT_DC_STATIC, /* static storage */ 716ff6d951SJohn Birrell DT_DC_EXTERN, /* extern storage */ 726ff6d951SJohn Birrell DT_DC_TYPEDEF, /* type definition */ 736ff6d951SJohn Birrell DT_DC_SELF, /* thread-local storage */ 746ff6d951SJohn Birrell DT_DC_THIS /* clause-local storage */ 756ff6d951SJohn Birrell } dt_dclass_t; 766ff6d951SJohn Birrell 776ff6d951SJohn Birrell typedef struct dt_scope { 786ff6d951SJohn Birrell dt_decl_t *ds_decl; /* pointer to top of decl stack */ 796ff6d951SJohn Birrell struct dt_scope *ds_next; /* pointer to next scope */ 806ff6d951SJohn Birrell char *ds_ident; /* identifier for this scope (if any) */ 816ff6d951SJohn Birrell ctf_file_t *ds_ctfp; /* CTF container for this scope */ 826ff6d951SJohn Birrell ctf_id_t ds_type; /* CTF id of enclosing type */ 836ff6d951SJohn Birrell dt_dclass_t ds_class; /* declaration class for this scope */ 846ff6d951SJohn Birrell int ds_enumval; /* most recent enumerator value */ 856ff6d951SJohn Birrell } dt_scope_t; 866ff6d951SJohn Birrell 876ff6d951SJohn Birrell extern dt_decl_t *dt_decl_alloc(ushort_t, char *); 886ff6d951SJohn Birrell extern void dt_decl_free(dt_decl_t *); 896ff6d951SJohn Birrell extern void dt_decl_reset(void); 906ff6d951SJohn Birrell extern dt_decl_t *dt_decl_push(dt_decl_t *); 916ff6d951SJohn Birrell extern dt_decl_t *dt_decl_pop(void); 926ff6d951SJohn Birrell extern dt_decl_t *dt_decl_pop_param(char **); 936ff6d951SJohn Birrell extern dt_decl_t *dt_decl_top(void); 946ff6d951SJohn Birrell 956ff6d951SJohn Birrell extern dt_decl_t *dt_decl_ident(char *); 966ff6d951SJohn Birrell extern void dt_decl_class(dt_dclass_t); 976ff6d951SJohn Birrell 986ff6d951SJohn Birrell #define DT_DP_VARARGS 0x1 /* permit varargs in prototype */ 996ff6d951SJohn Birrell #define DT_DP_DYNAMIC 0x2 /* permit dynamic type in prototype */ 1006ff6d951SJohn Birrell #define DT_DP_VOID 0x4 /* permit void type in prototype */ 1016ff6d951SJohn Birrell #define DT_DP_ANON 0x8 /* permit anonymous parameters */ 1026ff6d951SJohn Birrell 1036ff6d951SJohn Birrell extern int dt_decl_prototype(struct dt_node *, struct dt_node *, 1046ff6d951SJohn Birrell const char *, uint_t); 1056ff6d951SJohn Birrell 1066ff6d951SJohn Birrell extern dt_decl_t *dt_decl_spec(ushort_t, char *); 1076ff6d951SJohn Birrell extern dt_decl_t *dt_decl_attr(ushort_t); 1086ff6d951SJohn Birrell extern dt_decl_t *dt_decl_array(struct dt_node *); 1096ff6d951SJohn Birrell extern dt_decl_t *dt_decl_func(dt_decl_t *, struct dt_node *); 1106ff6d951SJohn Birrell extern dt_decl_t *dt_decl_ptr(void); 1116ff6d951SJohn Birrell 1126ff6d951SJohn Birrell extern dt_decl_t *dt_decl_sou(uint_t, char *); 1136ff6d951SJohn Birrell extern void dt_decl_member(struct dt_node *); 1146ff6d951SJohn Birrell 1156ff6d951SJohn Birrell extern dt_decl_t *dt_decl_enum(char *); 1166ff6d951SJohn Birrell extern void dt_decl_enumerator(char *, struct dt_node *); 1176ff6d951SJohn Birrell 1186ff6d951SJohn Birrell extern int dt_decl_type(dt_decl_t *, dtrace_typeinfo_t *); 1196ff6d951SJohn Birrell 1206ff6d951SJohn Birrell extern void dt_scope_create(dt_scope_t *); 1216ff6d951SJohn Birrell extern void dt_scope_destroy(dt_scope_t *); 1226ff6d951SJohn Birrell extern void dt_scope_push(ctf_file_t *, ctf_id_t); 1236ff6d951SJohn Birrell extern dt_decl_t *dt_scope_pop(void); 1246ff6d951SJohn Birrell 1256ff6d951SJohn Birrell #ifdef __cplusplus 1266ff6d951SJohn Birrell } 1276ff6d951SJohn Birrell #endif 1286ff6d951SJohn Birrell 1296ff6d951SJohn Birrell #endif /* _DT_DECL_H */ 130