File: gtm_threadgbl_deftypes.c

package info (click to toggle)
fis-gtm 6.2-000-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 30,784 kB
  • ctags: 42,554
  • sloc: ansic: 358,483; asm: 4,847; csh: 4,574; sh: 2,261; awk: 200; makefile: 86; sed: 13
file content (223 lines) | stat: -rw-r--r-- 7,193 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
/****************************************************************
 *								*
 *	Copyright 2010, 2014 Fidelity Information Services, Inc	*
 *								*
 *	This source code contains the intellectual property	*
 *	of its copyright holder(s), and is made available	*
 *	under a license.  If you do not know the terms of	*
 *	the license, please stop and do not read further.	*
 *								*
 ****************************************************************/

/* Since we are about to create gtm_threadgbl_deftypes.h, signal gtm_threadgbl.h to avoid including it */
#define NO_THREADGBL_DEFTYPES
#include "mdef.h"

#include <stddef.h>
#include "gtm_inet.h"
#include "gtm_iconv.h"
#include "gtm_socket.h"
#include "gtm_unistd.h"
#include "gtm_limits.h"

#include <signal.h>
#include <sys/time.h>
#ifdef UNIX
# include <sys/un.h>
#endif
#ifdef VMS
# include <descrip.h>		/* Required for gtmsource.h */
# include <ssdef.h>
# include <fab.h>
# include "desblk.h"
#endif
#include "cache.h"
#include "hashtab_addr.h"
#include "hashtab_int4.h"
#include "hashtab_int8.h"
#include "hashtab_mname.h"
#include "hashtab_str.h"
#include "hashtab_objcode.h"
#include "error.h"
#include <rtnhdr.h>
#include "gdsroot.h"
#include "gdskill.h"
#include "ccp.h"
#include "gtm_facility.h"
#include "fileinfo.h"
#include "gdsbt.h"
#include "gdsfhead.h"
#include "filestruct.h"
#include "gdscc.h"
#include "comline.h"
#include "compiler.h"
#include "cmd_qlf.h"
#include "io.h"
#include "iosp.h"
#include "jnl.h"
#include "lv_val.h"
#include "collseq.h"
#include "mdq.h"
#include "mprof.h"
#include "mv_stent.h"
#include "find_mvstent.h"	/* needed for zintcmd_active */
#include "stack_frame.h"
#include "stp_parms.h"
#include "stringpool.h"
#include "buddy_list.h"		/* needed for tp.h */
#include "tp.h"
#include "tp_frame.h"
#include "mlkdef.h"
#include "zshow.h"
#include "zwrite.h"
#include "zbreak.h"
#include "fnpc.h"
#include "mmseg.h"
#ifndef VMS
# include "gtmsiginfo.h"
#endif
#include "gtmimagename.h"
#include "gt_timer.h"
#include "iosocketdef.h"	/* needed for socket_pool and MAX_N_SOCKETS*/
#include "ctrlc_handler_dummy.h"
#include "unw_prof_frame_dummy.h"
#include "op.h"
#include "gtmsecshr.h"
#include "error_trap.h"
#include "patcode.h"	/* for pat_everything and sizeof_pat_everything */
#include "source_file.h"	/* for REV_TIME_BUFF_LEN */
#include "mupipbckup.h"
#include "dpgbldir.h"
#include "mmemory.h"
#include "have_crit.h"
#include "alias.h"
#include "zroutines.h"
#include "trace_table.h"
#include "parm_pool.h"
#include "util.h"		/* for util_outbuff manipulations */
#include "nametabtyp.h"

/* FOR REPLICATION RELATED GLOBALS */
#include "repl_msg.h"
#include "gtmsource.h"
#include "gtmrecv.h"
#include "replgbl.h"

/* FOR MERGE RELATED GLOBALS */
#include "gvname_info.h"
#include "op_merge.h"

#ifdef UNIX
# include "cli.h"
# include "invocation_mode.h"
# include "fgncal.h"
# include "parse_file.h"	/* for MAX_FBUFF */
# include "repl_sem.h"
# include "gtm_zlib.h"
# include "zro_shlibs.h"
#endif

#include "jnl_typedef.h"

#ifdef VMS
# include "gtm_logicals.h"	/* for GTM_MEMORY_NOACCESS_COUNT */
#endif

#include "gds_blk_upgrade.h"	/* for UPGRADE_IF_NEEDED flag */
#include "cws_insert.h"		/* for CWS_REORG_ARRAYSIZE */

#ifdef UNICODE_SUPPORTED
# include "gtm_icu_api.h"
# include "gtm_utf8.h"
#endif

#ifdef GTM_CRYPT
# include "gtmcrypt.h"
# include "gdsblk.h"
# include "muextr.h"
#endif

#ifdef GTM_TRIGGER
# include "gv_trigger.h"
# include "gtm_trigger.h"
#endif

#ifdef USHBIN_SUPPORTED
# include "relinkctl.h"
# include "zhist.h"
#endif

/* This module's purpose is to generate gtm_threadgbl_deftypes.h for a given platform. This header file
 * contains all the type and offset informatin needed for the TREF macro in gtm_threadgbl.h to access
 * any field in the global structure without having to have all the types known in every module. Only the
 * types used need be known.
 *
 * This is acomplished by creating the structure in this module with all types and offsets known and outputting
 * those values in the form of #define statements that can be used by subsequent compiles.
 */

/* First step, create the structure */
#define THREADGBLDEF(name, type)		type name;
#define THREADGBLFPTR(name, type, args)		type (*name)args;
#define THREADGBLAR1DEF(name, type, dim1)	type name[dim1];
#define THREADGBLAR2DEF(name, type, dim1, dim2)	type name[dim1][dim2];
typedef struct
{
#include "gtm_threadgbl_defs.h"
} gtm_threadgbl_def_t;
#undef THREADGBLDEF
#undef THREADGBLFPTR
#undef THREADGBLAR1DEF
#undef THREADGBLAR2DEF

/* Note this module uses regular (lower case) printf because using PRINTF calls gtm_printf which is inappropriate
 * since this module is not part of the GTM runtime but a standalone text generator.
 */

/* Define macros that will generate the type and offset #defines */
#define PRINT_TYPE_OFFSET(name, type)								\
	printf("# define ggo_%s %d\n", #name, (int)OFFSETOF(gtm_threadgbl_def_t, name));	\
	printf("# define ggt_%s %s\n", #name, #type);

/* For function pointers, we need the offset and type (which is a return type in this case since the actual type of
 * the item is "function pointer") but also need the argument declarations for the function declaration to be complete
 * Lastly, we need a function pointer typedef to make invocations work correctly.
 */
#define PRINT_TYPE_OFFSET_FPTR(name, type, args) 						\
	printf("# define ggo_%s %d\n", #name, (int)OFFSETOF(gtm_threadgbl_def_t, name));	\
	printf("# define ggt_%s %s\n", #name, #type);	/* In this case, return type */		\
	printf("# define gga_%s %s\n", #name, #args);						\
	printf("typedef %s (*ggf_%s)%s;\n", #type, #name, #args);

/* For single dimension arrays, include the length of the entire array as it is likely needed, especially
 * for character types.
 */
#define PRINT_TYPE_OFFSET_ARY1(name, type, dim1)						\
	printf("# define ggo_%s %d\n", #name, (int)OFFSETOF(gtm_threadgbl_def_t, name));	\
	printf("# define ggt_%s %s\n", #name, #type);						\
	printf("# define ggl_%s %d\n", #name, (int)SIZEOF(gtd.name));

/* For two dimensional arrays, we need to record the 2nd dimension as it is needed in the address computations */
#define PRINT_TYPE_OFFSET_ARY2(name, type, dim1, dim2)						\
	printf("# define ggo_%s %d\n", #name, (int)OFFSETOF(gtm_threadgbl_def_t, name));	\
	printf("# define ggt_%s %s\n", #name, #type);						\
	printf("# define ggl_%s %d\n", #name, (int)SIZEOF(gtm_threadgbl_def_t.name));		\
	printf("# define ggd_%s %d\n", #name, (int)dim2);

int main()
{
	gtm_threadgbl_def_t gtd;

	/* Now run through each var in the structure generating defines for the type and offset within the structure */
#	define THREADGBLDEF(name, type)			PRINT_TYPE_OFFSET(name, type)
#	define THREADGBLFPTR(name, type, args)		PRINT_TYPE_OFFSET_FPTR(name, type, args)
#	define THREADGBLAR1DEF(name, type, dim1)	PRINT_TYPE_OFFSET_ARY1(name, type, dim1)
#	define THREADGBLAR2DEF(name, type, dim1, dim2)	PRINT_TYPE_OFFSET_ARY1(name, type, dim1, dim2)
#	include "gtm_threadgbl_defs.h"
#	undef THREADGBLDEF
#	undef THREADGBLFPTR
#	undef THREADGBLAR1DEF
#	undef THREADGBLAR2DEF
	printf("# define size_gtm_threadgbl_struct %d\n", (int)SIZEOF(gtm_threadgbl_def_t));
	return 0;
}