Merge lp:~jeff-apple/openvista-gtm-integration/bug327480 into lp:openvista-gtm-integration

Proposed by jeff.apple
Status: Merged
Merged at revision: not available
Proposed branch: lp:~jeff-apple/openvista-gtm-integration/bug327480
Merge into: lp:openvista-gtm-integration
Diff against target: None lines
To merge this branch: bzr merge lp:~jeff-apple/openvista-gtm-integration/bug327480
Reviewer Review Type Date Requested Status
Jon Tai Disapprove
Review via email: mp+5269@code.launchpad.net
To post a comment you must log in.
Revision history for this message
jeff.apple (jeff-apple) wrote :

This set of changes doesn't break the compile.

Revision history for this message
Jon Tai (jontai) wrote :

Jeff, your new approach seems to work, but instead of merging directly with mainline, I'd like to merge it with my gtm-packaging branch, then merge that branch into mainline. My branch has the infrastructure necessary to build GT.M RPMs that include your work.

I've already merged your branch into my gtm-packaging branch and re-created the diff for the RPMs and tested lightly. Everything seems to jive - great work! I'm going to Disapprove this merge request and put up one of my own in a few minutes.

review: Disapprove

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'src'
=== added directory 'src/gtm'
=== added directory 'src/gtm/sr_port'
=== added file 'src/gtm/sr_port/gbldefs.c'
--- src/gtm/sr_port/gbldefs.c 1970-01-01 00:00:00 +0000
+++ src/gtm/sr_port/gbldefs.c 2009-04-07 01:13:36 +0000
@@ -0,0 +1,1012 @@
1/****************************************************************
2 * *
3 * Copyright 2001, 2008 Fidelity Information Services, Inc *
4 * *
5 * This source code contains the intellectual property *
6 * of its copyright holder(s), and is made available *
7 * under a license. If you do not know the terms of *
8 * the license, please stop and do not read further. *
9 * *
10 ****************************************************************/
11
12 /* General repository for global variable definitions. This keeps us from
13 pulling in modules and all their references when all we wanted was the
14 global data def.. */
15
16#include "mdef.h"
17
18#include "gtm_inet.h"
19#include "gtm_iconv.h"
20#include "gtm_socket.h"
21#include "gtm_unistd.h"
22#include "gtm_limits.h"
23
24#include <signal.h>
25#ifdef __MVS__
26#include "gtm_time.h" /* required for fd_set */
27#endif
28#include <sys/time.h>
29#ifdef UNIX
30# include <sys/un.h>
31#endif
32#ifdef VMS
33# include <descrip.h> /* Required for gtmsource.h */
34# include <ssdef.h>
35# include <fab.h>
36# include "desblk.h"
37#endif
38#include "cache.h"
39#include "hashtab_int4.h"
40#include "hashtab_int8.h"
41#include "hashtab_mname.h"
42#include "hashtab_objcode.h"
43#include "rtnhdr.h"
44#include "gdsroot.h"
45#include "gdskill.h"
46#include "ccp.h"
47#include "gtm_facility.h"
48#include "fileinfo.h"
49#include "gdsbt.h"
50#include "gdsfhead.h"
51#include "filestruct.h"
52#include "gdscc.h"
53#include "comline.h"
54#include "compiler.h"
55#include "cmd_qlf.h"
56#include "io.h"
57#include "iosp.h"
58#include "jnl.h"
59#include "lv_val.h"
60#include "sbs_blk.h"
61#include "mdq.h"
62#include "mprof.h"
63#include "mv_stent.h"
64#include "stack_frame.h"
65#include "stp_parms.h"
66#include "stringpool.h"
67#include "buddy_list.h" /* needed for tp.h */
68#include "tp.h"
69#include "tp_frame.h"
70#include "mlkdef.h"
71#include "zshow.h"
72#include "zwrite.h"
73#include "zbreak.h"
74#include "fnpc.h"
75#include "mmseg.h"
76#ifndef VMS
77# include "gtmsiginfo.h"
78#endif
79#include "gtmimagename.h"
80#include "iotcpdef.h"
81#include "gt_timer.h"
82#include "iosocketdef.h" /* needed for socket_pool and MAX_N_SOCKETS*/
83#include "ctrlc_handler_dummy.h"
84#include "unw_prof_frame_dummy.h"
85#include "op.h"
86#include "gtmsecshr.h"
87#include "error_trap.h"
88#include "patcode.h" /* for pat_everything and sizeof_pat_everything */
89#include "source_file.h" /* for REV_TIME_BUFF_LEN */
90#include "mupipbckup.h"
91#include "dpgbldir.h"
92#include "mmemory.h"
93#include "have_crit.h"
94
95/* FOR REPLICATION RELATED GLOBALS */
96#include "repl_msg.h"
97#include "gtmsource.h"
98#include "gtmrecv.h"
99
100/* FOR MERGE RELATED GLOBALS */
101#include "subscript.h"
102#include "lvname_info.h"
103#include "gvname_info.h"
104#include "op_merge.h"
105
106#ifdef UNIX
107/* The define of CHEXPAND below causes error.h to create GBLDEFs */
108#define CHEXPAND
109#include "error.h"
110
111#include "cli.h"
112#include "invocation_mode.h"
113#include "fgncal.h"
114#include "parse_file.h" /* for MAX_FBUFF */
115#include "repl_sem.h"
116#include "gtm_zlib.h"
117#endif
118
119#include "jnl_typedef.h"
120
121#ifdef VMS
122#include "gtm_logicals.h" /* for GTM_MEMORY_NOACCESS_COUNT */
123#endif
124
125#include "gds_blk_upgrade.h" /* for UPGRADE_IF_NEEDED flag */
126#include "cws_insert.h" /* for CWS_REORG_ARRAYSIZE */
127
128#ifdef UNICODE_SUPPORTED
129#include "gtm_icu_api.h"
130#include "gtm_utf8.h"
131#endif
132
133#define DEFAULT_ZERROR_STR "Unprocessed $ZERROR, see $ZSTATUS"
134#define DEFAULT_ZERROR_LEN (sizeof(DEFAULT_ZERROR_STR) - 1)
135
136GBLDEF gd_region *db_init_region;
137GBLDEF sgmnt_data_ptr_t cs_data;
138GBLDEF sgmnt_addrs *cs_addrs;
139
140GBLDEF unsigned short proc_act_type;
141GBLDEF volatile bool ctrlc_pending;
142GBLDEF volatile int4 ctrap_action_is;
143GBLDEF bool out_of_time;
144GBLDEF io_pair io_curr_device; /* current device */
145GBLDEF io_pair io_std_device; /* standard device */
146GBLDEF io_log_name *dollar_principal; /* pointer to log name GTM$PRINCIPAL if defined */
147GBLDEF bool prin_in_dev_failure = FALSE;
148GBLDEF bool prin_out_dev_failure = FALSE;
149GBLDEF io_desc *active_device;
150
151GBLDEF bool error_mupip = FALSE,
152 compile_time = FALSE,
153 file_backed_up = FALSE,
154 gv_replopen_error = FALSE,
155 gv_replication_error = FALSE,
156 incremental = FALSE,
157 jobpid = FALSE,
158 online = FALSE,
159 record = FALSE,
160 is_standalone = FALSE,
161 std_dev_outbnd = FALSE,
162 in_mupip_freeze = FALSE,
163 in_backup = FALSE,
164 view_debug1 = FALSE,
165 view_debug2 = FALSE,
166 view_debug3 = FALSE,
167 view_debug4 = FALSE,
168 dec_nofac;
169
170GBLDEF boolean_t is_updproc = FALSE,
171 is_updhelper = FALSE,
172 mupip_jnl_recover = FALSE,
173 repl_allowed = FALSE,
174 run_time = FALSE,
175 unhandled_stale_timer_pop = FALSE,
176 gtcm_connection = FALSE,
177 is_replicator = FALSE, /* TRUE => this process can write jnl records to the jnlpool for replicated db */
178 tp_in_use = FALSE, /* TRUE => TP has been used by this process and is thus initialized */
179 dollar_truth = TRUE;
180
181GBLDEF VSIG_ATOMIC_T forced_exit = FALSE; /* Asynchronous signal/interrupt handler sets this variable to TRUE,
182 * hence the VSIG_ATOMIC_T type in the definition.
183 */
184GBLDEF intrpt_state_t intrpt_ok_state = INTRPT_OK_TO_INTERRUPT; /* any other value implies it is not ok to interrupt */
185
186GBLDEF unsigned char *msp,
187 *mubbuf,
188 *restart_ctxt,
189 *stackbase,
190 *stacktop,
191 *stackwarn,
192 *restart_pc;
193GBLDEF int4 backup_close_errno,
194 backup_write_errno,
195 mubmaxblk,
196 forced_exit_err,
197 exit_state,
198 restore_read_errno;
199GBLDEF volatile int4 outofband, crit_count = 0;
200GBLDEF int mumps_status = SS_NORMAL,
201 stp_array_size = 0;
202GBLDEF gvzwrite_struct gvzwrite_block;
203GBLDEF io_log_name *io_root_log_name;
204GBLDEF lvzwrite_struct lvzwrite_block;
205GBLDEF mliteral literal_chain;
206GBLDEF mstr *comline_base,
207 dollar_zsource,
208 *err_act,
209 **stp_array,
210 extnam_str,
211 env_gtm_env_xlate;
212GBLDEF MSTR_CONST(default_sysid, "gtm_sysid");
213GBLDEF int (*gtm_env_xlate_entry)() = NULL;
214GBLDEF void (*gtm_sigusr1_handler)() = NULL;
215GBLDEF mval dollar_zgbldir,
216 dollar_zstatus,
217 dollar_zstep = DEFINE_MVAL_LITERAL(MV_STR | MV_NM | MV_INT | MV_NUM_APPROX, 0, 0, 1, "B", 0, 0),
218 dollar_ztrap,
219 ztrap_pop2level = DEFINE_MVAL_LITERAL(MV_NM | MV_INT, 0, 0, 0, 0, 0, 0),
220 zstep_action,
221 dollar_system,
222 dollar_estack_delta = DEFINE_MVAL_LITERAL(MV_STR, 0, 0, 0, NULL, 0, 0),
223 dollar_etrap,
224 dollar_zerror = DEFINE_MVAL_LITERAL(MV_STR, 0, 0, DEFAULT_ZERROR_LEN, DEFAULT_ZERROR_STR, 0, 0),
225 dollar_zyerror,
226 dollar_ztexit = DEFINE_MVAL_LITERAL(MV_STR, 0, 0, 0, NULL, 0, 0);
227GBLDEF uint4 dollar_zjob;
228GBLDEF mval dollar_zinterrupt;
229GBLDEF boolean_t dollar_zininterrupt;
230GBLDEF boolean_t dollar_ztexit_bool; /* Truth value of dollar_ztexit when coerced to boolean */
231GBLDEF boolean_t dollar_zquit_anyway;
232
233#define DEFAULT_PROMPT "GTM>"
234/* The prompt buffer size (31) below would allow at least 8 Unicode characters, but since most
235 * commonly used Unicode characters only occupy upto 3 bytes, the buffer would at least accommodate
236 * 10 Unicode characters in a prompt */
237GBLDEF char prombuf[MAX_MIDENT_LEN] = DEFAULT_PROMPT;
238GBLDEF MSTR_DEF(gtmprompt, STR_LIT_LEN(DEFAULT_PROMPT), &prombuf[0]);
239
240GBLDEF mv_stent *mv_chain;
241GBLDEF sgm_info *first_sgm_info; /* List of participating regions in the TP transaction with NO ftok ordering */
242GBLDEF sgm_info *first_tp_si_by_ftok; /* List of participating regions in the TP transaction sorted on ftok order */
243GBLDEF spdesc indr_stringpool,
244 rts_stringpool,
245 stringpool;
246GBLDEF stack_frame *frame_pointer;
247GBLDEF stack_frame *zyerr_frame = NULL;
248GBLDEF symval *curr_symval;
249GBLDEF tp_frame *tp_pointer;
250GBLDEF tp_region *halt_ptr,
251 *grlist;
252GBLDEF trans_num local_tn; /* transaction number for THIS PROCESS (starts at 0 each time) */
253GBLDEF gv_namehead *gv_target;
254GBLDEF gv_namehead *gv_target_list;
255GBLDEF gvt_container *gvt_pending_list; /* list of gvts that need to be re-examined/re-allocated when region is opened */
256GBLDEF buddy_list *gvt_pending_buddy_list;/* buddy_list for maintaining memory for gv_targets to be re-examined/allocated */
257
258GBLDEF int4 exi_condition;
259GBLDEF uint4 gtmDebugLevel;
260GBLDEF caddr_t smCallerId; /* Caller of top level malloc/free */
261GBLDEF int process_exiting;
262GBLDEF int4 dollar_zsystem;
263GBLDEF int4 dollar_zeditor;
264GBLDEF boolean_t sem_incremented = FALSE;
265GBLDEF boolean_t new_dbinit_ipc = FALSE;
266GBLDEF mval **ind_result_array, **ind_result_sp, **ind_result_top;
267GBLDEF mval **ind_source_array, **ind_source_sp, **ind_source_top;
268GBLDEF rtn_tabent *rtn_fst_table, *rtn_names, *rtn_names_top, *rtn_names_end;
269GBLDEF int4 break_message_mask;
270GBLDEF bool rc_locked = FALSE;
271GBLDEF boolean_t certify_all_blocks = FALSE; /* If flag is set all blocks are checked after they are
272 * written to the database. Upon error we stay critical
273 * and report. This flag can be set via the MUMPS command
274 * VIEW "GDSCERT":1. */
275GBLDEF mval curr_gbl_root;
276GBLDEF gd_addr *original_header;
277GBLDEF hash_table_mname *gd_tab_ptr = NULL;
278GBLDEF mem_list *mem_list_head;
279GBLDEF boolean_t debug_mupip;
280GBLDEF unsigned char t_fail_hist[CDB_MAX_TRIES];
281GBLDEF cache_rec_ptr_t cr_array[((MAX_BT_DEPTH * 2) - 1) * 2]; /* Maximum number of blocks that can be in transaction */
282GBLDEF unsigned int cr_array_index;
283GBLDEF boolean_t need_core; /* Core file should be created */
284GBLDEF boolean_t created_core; /* core file was created */
285GBLDEF boolean_t core_in_progress; /* creating core NOW */
286GBLDEF boolean_t dont_want_core; /* Higher level flag overrides need_core set by lower level rtns */
287GBLDEF boolean_t exit_handler_active; /* recursion prevention */
288GBLDEF boolean_t block_saved;
289#if defined(KEEP_zOS_EBCDIC) || defined(VMS)
290GBLDEF iconv_t dse_over_cvtcd = (iconv_t)0;
291#endif
292GBLDEF gtm_chset_t dse_over_chset = CHSET_M;
293GBLDEF short int last_source_column;
294GBLDEF char window_token;
295GBLDEF mval window_mval;
296GBLDEF char director_token;
297GBLDEF mval director_mval;
298LITDEF MIDENT_DEF(zero_ident, 0, NULL); /* the null mident */
299static char ident_buff1[sizeof(mident_fixed)];
300static char ident_buff2[sizeof(mident_fixed)];
301GBLDEF MIDENT_DEF(window_ident, 0, &ident_buff1[0]); /* the current identifier */
302GBLDEF MIDENT_DEF(director_ident, 0, &ident_buff2[0]); /* the look-ahead identifier */
303GBLDEF char *lexical_ptr;
304GBLDEF int4 aligned_source_buffer[MAX_SRCLINE / sizeof(int4) + 1];
305GBLDEF unsigned char *source_buffer = (unsigned char *)aligned_source_buffer;
306GBLDEF int4 source_error_found;
307GBLDEF src_line_struct src_head;
308GBLDEF bool code_generated;
309GBLDEF short int source_column, source_line;
310GBLDEF bool devctlexp;
311GBLDEF char cg_phase; /* code generation phase */
312/* Previous code generation phase: Only used by emit_code.c to initialize the push list at the
313 * beginning of each phase (bug fix: C9D12-002478) */
314GBLDEF char cg_phase_last;
315
316GBLDEF int cmd_cnt;
317
318GBLDEF command_qualifier glb_cmd_qlf = { CQ_DEFAULT },
319 cmd_qlf = { CQ_DEFAULT };
320#ifdef __osf__
321#pragma pointer_size (save)
322#pragma pointer_size (long)
323#endif
324GBLDEF char **cmd_arg;
325#ifdef __osf__
326#pragma pointer_size (restore)
327#endif
328
329#ifndef __vax
330GBLDEF fnpc_area fnpca; /* $piece cache structure area */
331#endif
332
333#ifdef UNIX
334GBLDEF volatile uint4 heartbeat_counter = 0;
335#endif
336
337/* DEFERRED EVENTS */
338GBLDEF int dollar_zmaxtptime = 0;
339GBLDEF bool licensed = TRUE;
340
341#if defined(UNIX)
342GBLDEF volatile int4 num_deferred;
343#elif defined(VMS)
344GBLDEF volatile short num_deferred;
345GBLDEF int4 lkid, lid;
346GBLDEF desblk exi_blk;
347GBLDEF struct chf$signal_array *tp_restart_fail_sig;
348GBLDEF boolean_t tp_restart_fail_sig_used;
349#else
350# error "Unsupported Platform"
351#endif
352
353GBLDEF volatile int4 fast_lock_count = 0; /* Used in wcs_stale */
354
355/* REPLICATION RELATED GLOBALS */
356GBLDEF gtmsource_options_t gtmsource_options;
357GBLDEF gtmrecv_options_t gtmrecv_options;
358
359GBLDEF unsigned char *profstack_base, *profstack_top, *prof_msp, *profstack_warn;
360GBLDEF unsigned char *prof_stackptr;
361GBLDEF boolean_t is_tracing_on;
362GBLDEF stack_frame_prof *prof_fp;
363GBLDEF void (*tp_timeout_start_timer_ptr)(int4 tmout_sec) = tp_start_timer_dummy;
364GBLDEF void (*tp_timeout_clear_ptr)(void) = tp_clear_timeout_dummy;
365GBLDEF void (*tp_timeout_action_ptr)(void) = tp_timeout_action_dummy;
366GBLDEF void (*ctrlc_handler_ptr)() = ctrlc_handler_dummy;
367GBLDEF int (*op_open_ptr)(mval *v, mval *p, int t, mval *mspace) = op_open_dummy;
368GBLDEF void (*unw_prof_frame_ptr)(void) = unw_prof_frame_dummy;
369GBLDEF boolean_t mu_reorg_process = FALSE; /* set to TRUE by MUPIP REORG */
370GBLDEF boolean_t mu_reorg_in_swap_blk = FALSE; /* set to TRUE for the duration of the call to "mu_swap_blk" */
371GBLDEF boolean_t mu_rndwn_process = FALSE;
372GBLDEF gv_key *gv_currkey_next_reorg;
373GBLDEF gv_namehead *reorg_gv_target;
374
375#ifdef UNIX
376GBLDEF struct sockaddr_un gtmsecshr_sock_name;
377GBLDEF struct sockaddr_un gtmsecshr_cli_sock_name;
378GBLDEF key_t gtmsecshr_key;
379#endif
380GBLDEF int gtmsecshr_sockpath_len;
381GBLDEF int gtmsecshr_cli_sockpath_len;
382GBLDEF mstr gtmsecshr_pathname;
383GBLDEF int server_start_tries;
384GBLDEF int gtmsecshr_log_file;
385GBLDEF int gtmsecshr_sockfd = -1;
386GBLDEF boolean_t gtmsecshr_sock_init_done = FALSE;
387GBLDEF char muext_code[MUEXT_MAX_TYPES][2] =
388 { {'0', '0'},
389 {'0', '1'},
390 {'0', '2'},
391 {'0', '3'},
392 {'0', '4'},
393 {'0', '5'},
394 {'0', '6'},
395 {'0', '7'},
396 {'0', '8'},
397 {'0', '9'},
398 {'1', '0'}
399 };
400GBLDEF int patch_is_fdmp;
401GBLDEF int patch_fdmp_recs;
402GBLDEF boolean_t horiz_growth = FALSE;
403GBLDEF int4 prev_first_off, prev_next_off;
404 /* these two globals store the values of first_off and next_off in cse,
405 * when there is a blk split at index level. This is to permit rollback
406 * to intermediate states */
407GBLDEF sm_uc_ptr_t min_mmseg;
408GBLDEF sm_uc_ptr_t max_mmseg;
409GBLDEF mmseg *mmseg_head;
410GBLDEF ua_list *first_ua, *curr_ua;
411GBLDEF char *update_array, *update_array_ptr;
412GBLDEF int gv_fillfactor = 100,
413 rc_set_fragment; /* Contains offset within data at which data fragment starts */
414GBLDEF uint4 update_array_size = 0,
415 cumul_update_array_size = 0; /* the current total size of the update array */
416GBLDEF kill_set *kill_set_tail;
417GBLDEF boolean_t pool_init = FALSE;
418GBLDEF boolean_t is_src_server = FALSE;
419GBLDEF boolean_t is_rcvr_server = FALSE;
420GBLDEF jnl_format_buffer *non_tp_jfb_ptr = NULL;
421GBLDEF unsigned char *non_tp_jfb_buff_ptr;
422GBLDEF boolean_t dse_running = FALSE;
423GBLDEF jnlpool_addrs jnlpool;
424GBLDEF jnlpool_ctl_ptr_t jnlpool_ctl;
425GBLDEF jnlpool_ctl_struct temp_jnlpool_ctl_struct;
426GBLDEF jnlpool_ctl_ptr_t temp_jnlpool_ctl = &temp_jnlpool_ctl_struct;
427GBLDEF sm_uc_ptr_t jnldata_base;
428GBLDEF int4 jnlpool_shmid = INVALID_SHMID;
429GBLDEF recvpool_addrs recvpool;
430GBLDEF int recvpool_shmid = INVALID_SHMID;
431GBLDEF int gtmsource_srv_count = 0;
432GBLDEF int gtmrecv_srv_count = 0;
433
434/* The following _in_prog counters are needed to prevent deadlocks while doing jnl-qio (timer & non-timer). */
435GBLDEF volatile int4 db_fsync_in_prog;
436GBLDEF volatile int4 jnl_qio_in_prog;
437#ifdef UNIX
438GBLDEF gtmsiginfo_t signal_info;
439#ifndef MUTEX_MSEM_WAKE
440GBLDEF int mutex_sock_fd = -1;
441GBLDEF struct sockaddr_un mutex_sock_address;
442GBLDEF struct sockaddr_un mutex_wake_this_proc;
443GBLDEF int mutex_wake_this_proc_len;
444GBLDEF int mutex_wake_this_proc_prefix_len;
445GBLDEF fd_set mutex_wait_on_descs;
446#endif
447#endif
448GBLDEF void (*call_on_signal)();
449GBLDEF gtmImageName gtmImageNames[n_image_types] =
450{
451#define IMAGE_TABLE_ENTRY(A,B) {LIT_AND_LEN(B)},
452#include "gtmimagetable.h"
453#undef IMAGE_TABLE_ENTRY
454};
455GBLDEF enum gtmImageTypes image_type; /* initialized at startup i.e. in dse.c, lke.c, gtm.c, mupip.c, gtmsecshr.c etc. */
456GBLDEF volatile boolean_t semwt2long;
457
458#ifdef UNIX
459GBLDEF parmblk_struct *param_list; /* call-in parameters block (defined in unix/fgncalsp.h)*/
460GBLDEF unsigned int invocation_mode = MUMPS_COMPILE; /* how mumps has been invoked */
461GBLDEF char cli_err_str[MAX_CLI_ERR_STR] = ""; /* Parse Error message buffer */
462GBLDEF char *cli_err_str_ptr = NULL;
463#endif
464
465/* this array is indexed by file descriptor */
466GBLDEF boolean_t *lseekIoInProgress_flags = (boolean_t *)0;
467
468#if defined(UNIX)
469/* Latch variable for Unix implementations. Used in SUN and HP */
470GBLDEF global_latch_t defer_latch;
471#endif
472
473GBLDEF int num_additional_processors;
474GBLDEF int gtm_errno = -1; /* holds the errno (unix) in case of an rts_error */
475GBLDEF int4 error_condition = 0;
476GBLDEF global_tlvl_info *global_tlvl_info_head;
477GBLDEF buddy_list *global_tlvl_info_list;
478GBLDEF boolean_t job_try_again;
479GBLDEF volatile int4 gtmMallocDepth; /* Recursion indicator */
480GBLDEF d_socket_struct *socket_pool;
481GBLDEF boolean_t disable_sigcont = FALSE;
482GBLDEF boolean_t mu_star_specified;
483GBLDEF backup_reg_list *mu_repl_inst_reg_list;
484
485#ifndef VMS
486GBLDEF volatile int suspend_status = NO_SUSPEND;
487#endif
488
489GBLDEF gv_namehead *reset_gv_target = INVALID_GV_TARGET;
490GBLDEF VSIG_ATOMIC_T util_interrupt = 0;
491GBLDEF boolean_t kip_incremented;
492GBLDEF boolean_t need_kip_incr;
493GBLDEF int merge_args = 0;
494GBLDEF merge_glvn_ptr mglvnp = NULL;
495GBLDEF int ztrap_form;
496GBLDEF boolean_t ztrap_new;
497GBLDEF int4 wtfini_in_prog;
498/* items for $piece stats */
499#ifdef DEBUG
500GBLDEF int c_miss; /* cache misses (debug) */
501GBLDEF int c_hit; /* cache hits (debug) */
502GBLDEF int c_small; /* scanned small string brute force */
503GBLDEF int c_small_pcs; /* chars scanned by small scan */
504GBLDEF int c_pskip; /* number of pieces "skipped" */
505GBLDEF int c_pscan; /* number of pieces "scanned" */
506GBLDEF int c_parscan; /* number of partial scans (partial cache hits) */
507GBLDEF int cs_miss; /* cache misses (debug) */
508GBLDEF int cs_hit; /* cache hits (debug) */
509GBLDEF int cs_small; /* scanned small string brute force */
510GBLDEF int cs_small_pcs; /* chars scanned by small scan */
511GBLDEF int cs_pskip; /* number of pieces "skipped" */
512GBLDEF int cs_pscan; /* number of pieces "scanned" */
513GBLDEF int cs_parscan; /* number of partial scans (partial cache hits) */
514GBLDEF int c_clear; /* cleared due to (possible) value change */
515GBLDEF boolean_t setp_work;
516#endif
517GBLDEF z_records zbrk_recs = {NULL, NULL, NULL};
518
519#ifdef UNIX
520GBLDEF ipcs_mesg db_ipcs; /* For requesting gtmsecshr to update ipc fields */
521GBLDEF gd_region *ftok_sem_reg = NULL; /* Last region for which ftok semaphore is grabbed */
522GBLDEF gd_region *standalone_reg = NULL; /* We have standalone access for this region */
523GBLDEF int gtm_non_blocked_write_retries; /* number of retries for non-blocked write to pipe */
524#endif
525
526#ifdef VMS
527/* Following global variables store the state of an erroring sys$qio just before a GTMASSERT in the CHECK_CHANNEL_STATUS macro */
528GBLDEF uint4 check_channel_status = 0; /* stores the qio return status */
529GBLDEF uint4 check_channel_id = 0; /* stores the qio channel id */
530#endif
531
532GBLDEF boolean_t write_after_image = FALSE; /* true for after-image jnlrecord writing by recover/rollback */
533GBLDEF int iott_write_error;
534GBLDEF boolean_t recovery_success = FALSE; /* To Indicate successful recovery */
535GBLDEF int4 write_filter;
536GBLDEF int4 zdate_form = 0;
537GBLDEF boolean_t need_no_standalone = FALSE;
538
539GBLDEF int4 zdir_form = ZDIR_FORM_FULLPATH; /* $ZDIR shows full path including DEVICE and DIRECTORY */
540GBLDEF mval dollar_zdir = DEFINE_MVAL_LITERAL(MV_STR, 0, 0, 0, NULL, 0, 0);
541
542GBLDEF int * volatile var_on_cstack_ptr = NULL; /* volatile pointer to int; volatile so that nothing gets optimized out */
543GBLDEF boolean_t gtm_environment_init = FALSE;
544GBLDEF hash_table_int4 cw_stagnate;
545GBLDEF boolean_t cw_stagnate_reinitialized = FALSE;
546
547GBLDEF uint4 pat_everything[] = { 0, 2, PATM_E, 1, 0, PAT_MAX_REPEAT, 0, PAT_MAX_REPEAT, 1 }; /* pattern = ".e" */
548GBLDEF mstr_len_t sizeof_pat_everything = SIZEOF(pat_everything);
549
550GBLDEF uint4 *pattern_typemask;
551GBLDEF pattern *pattern_list;
552GBLDEF pattern *curr_pattern;
553
554/* Unicode related data */
555GBLDEF boolean_t gtm_utf8_mode; /* Is GT.M running with Unicode Character Set; Set only after ICU initialization */
556GBLDEF boolean_t is_gtm_chset_utf8; /* Is gtm_chset environment variable set to UTF8 */
557GBLDEF boolean_t utf8_patnumeric; /* Should patcode N match non-ASCII numbers in pattern match ? */
558GBLDEF boolean_t badchar_inhibit = FALSE;/* Suppress malformed UTF-8 characters by default */
559GBLDEF MSTR_DEF(dollar_zchset, 1, "M");
560GBLDEF MSTR_DEF(dollar_zpatnumeric, 1, "M");
561
562/* Standard MUMPS pattern-match table.
563 * This table holds the current pattern-matching attributes of each ASCII character.
564 * Bits 0..23 of each entry correspond with the pattern-match characters, A..X.
565 */
566GBLDEF pattern mumps_pattern = {
567 (void *) 0, /* flink */
568 (void *) 0, /* typemask */
569 (void *) 0, /* pat YZ name array */
570 (void *) 0, /* pat YZ name-length array */
571 -1, /* number of YZ patcodes */
572 1, /* namlen */
573 {'M', '\0'} /* name */
574};
575
576/* mapbit is used by pattab.c and patstr.c. Note that patstr.c uses only entries until PATM_X */
577GBLDEF readonly uint4 mapbit[] =
578{
579 PATM_A, PATM_B, PATM_C, PATM_D, PATM_E, PATM_F, PATM_G, PATM_H,
580 PATM_I, PATM_J, PATM_K, PATM_L, PATM_M, PATM_N, PATM_O, PATM_P,
581 PATM_Q, PATM_R, PATM_S, PATM_T, PATM_U, PATM_V, PATM_W, PATM_X,
582 PATM_YZ1, PATM_YZ2, PATM_YZ3, PATM_YZ4
583};
584
585LITDEF uint4 typemask[PATENTS] =
586{
587 PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, /* hex 00-07 : ASCII characters */
588 PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, /* hex 08-0F : ASCII characters */
589 PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, /* hex 10-17 : ASCII characters */
590 PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, /* hex 18-1F : ASCII characters */
591 PATM_P, PATM_P, PATM_P, PATM_P, PATM_P, PATM_P, PATM_P, PATM_P, /* hex 20-27 : ASCII characters */
592 PATM_P, PATM_P, PATM_P, PATM_P, PATM_P, PATM_P, PATM_P, PATM_P, /* hex 28-2F : ASCII characters */
593 PATM_N, PATM_N, PATM_N, PATM_N, PATM_N, PATM_N, PATM_N, PATM_N, /* hex 30-37 : ASCII characters */
594 PATM_N, PATM_N, PATM_P, PATM_P, PATM_P, PATM_P, PATM_P, PATM_P, /* hex 38-3F : ASCII characters */
595 PATM_P, PATM_U, PATM_U, PATM_U, PATM_U, PATM_U, PATM_U, PATM_U, /* hex 40-47 : ASCII characters */
596 PATM_U, PATM_U, PATM_U, PATM_U, PATM_U, PATM_U, PATM_U, PATM_U, /* hex 48-4F : ASCII characters */
597 PATM_U, PATM_U, PATM_U, PATM_U, PATM_U, PATM_U, PATM_U, PATM_U, /* hex 50-57 : ASCII characters */
598 PATM_U, PATM_U, PATM_U, PATM_P, PATM_P, PATM_P, PATM_P, PATM_P, /* hex 58-5F : ASCII characters */
599 PATM_P, PATM_L, PATM_L, PATM_L, PATM_L, PATM_L, PATM_L, PATM_L, /* hex 60-67 : ASCII characters */
600 PATM_L, PATM_L, PATM_L, PATM_L, PATM_L, PATM_L, PATM_L, PATM_L, /* hex 68-6F : ASCII characters */
601 PATM_L, PATM_L, PATM_L, PATM_L, PATM_L, PATM_L, PATM_L, PATM_L, /* hex 70-77 : ASCII characters */
602 PATM_L, PATM_L, PATM_L, PATM_P, PATM_P, PATM_P, PATM_P, PATM_C, /* hex 78-7F : ASCII characters */
603 PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, /* hex 80-87 : non-ASCII characters */
604 PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, /* hex 88-8F : non-ASCII characters */
605 PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, /* hex 90-97 : non-ASCII characters */
606 PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, PATM_C, /* hex 98-9F : non-ASCII characters */
607 PATM_P, PATM_P, PATM_P, PATM_P, PATM_P, PATM_P, PATM_P, PATM_P, /* hex A0-A7 : non-ASCII characters */
608 PATM_P, PATM_P, PATM_L, PATM_P, PATM_P, PATM_P, PATM_P, PATM_P, /* hex A8-AF : non-ASCII characters */
609 PATM_P, PATM_P, PATM_P, PATM_P, PATM_P, PATM_P, PATM_P, PATM_P, /* hex B0-B7 : non-ASCII characters */
610 PATM_P, PATM_P, PATM_L, PATM_P, PATM_P, PATM_P, PATM_P, PATM_P, /* hex B8-BF : non-ASCII characters */
611 PATM_U, PATM_U, PATM_U, PATM_U, PATM_U, PATM_U, PATM_U, PATM_U, /* hex C0-C7 : non-ASCII characters */
612 PATM_U, PATM_U, PATM_U, PATM_U, PATM_U, PATM_U, PATM_U, PATM_U, /* hex C8-CF : non-ASCII characters */
613 PATM_P, PATM_U, PATM_U, PATM_U, PATM_U, PATM_U, PATM_U, PATM_U, /* hex D0-D7 : non-ASCII characters */
614 PATM_U, PATM_U, PATM_U, PATM_U, PATM_U, PATM_U, PATM_P, PATM_L, /* hex D8-DF : non-ASCII characters */
615 PATM_L, PATM_L, PATM_L, PATM_L, PATM_L, PATM_L, PATM_L, PATM_L, /* hex E0-E7 : non-ASCII characters */
616 PATM_L, PATM_L, PATM_L, PATM_L, PATM_L, PATM_L, PATM_L, PATM_L, /* hex E8-EF : non-ASCII characters */
617 PATM_P, PATM_L, PATM_L, PATM_L, PATM_L, PATM_L, PATM_L, PATM_L, /* hex F0-F7 : non-ASCII characters */
618 PATM_L, PATM_L, PATM_L, PATM_L, PATM_L, PATM_L, PATM_P, PATM_C /* hex F8-FF : non-ASCII characters */
619};
620
621GBLDEF uint4 pat_allmaskbits; /* universal set of valid pattern bit codes for currently active pattern table */
622
623/* globals related to caching of pattern evaluation match result.
624 * for a given <strptr, strlen, patptr, depth> tuple, we store the evaluation result.
625 * in the above,
626 * <strptr, strlen> uniquely identifies a substring of the input string.
627 * <patptr> identifies the pattern atom that we are matching with
628 * <depth> identifies the recursion depth of do_patalt() for this pattern atom ("repcnt" in code)
629 * note that <depth> is a necessity in the above because the same alternation pattern atom can have different
630 * match or not-match status for the same input string depending on the repetition count usage of the pattern atom
631 * after a series of thoughts on an efficient structure for storing pattern evaluation, finally arrived at a simple
632 * array of structures wherein for a given length (strlen) we have a fixed number of structures available.
633 * we allocate an array of structures, say, 1024 structures.
634 * this is a simple 1-1 mapping, wherein
635 * for length 0, the available structures are the first 32 structures of the array,
636 * for length 1, the available structures are the second 32 structures of the array.
637 * ...
638 * for length 47, the available structures are the 47th 32 structures of the array.
639 * for length 48 and above, the available structures are all the remaining structures of the array.
640 * whenever any new entry needs to be cached and there is no room among the available structures, we preempt the
641 * most unfrequently used cache entry (to do this we do keep a count of every entry's frequency of usage)
642 * the assumption is that substrings of length > 48 (an arbitrary reasonable small number) won't be used
643 * so frequently so that they have lesser entries to fight for among themselves than lower values of length.
644 * with the above caching in place, the program segment below took 15 seconds.
645 * it was found that if the array size is increased to 16384 (as opposed to 1024 as above) and the available
646 * structures for each length increased proportionally (i.e. 16 times = 16*32 structures instead of 32 as above)
647 * the performance improved to the extent of taking 3 seconds.
648 * but this raised an interesting question, that of "size" vs. "time" tradeoff.
649 * with increasing array size, we get better "time" performance due to better caching.
650 * but that has an overhead of increased "size" (memory) usage.
651 * to arrive at a compromise, a dynamic algorithm emerged. the process will allocate a small array
652 * beginning at 1024 entries and grow to a max of 16384 entries as and when it deems the hit ratio is not good.
653 * the array only grows, i.e. there is no downsizing algorithm at play.
654 * the dynamic algorithm addresses to an extent both the "size" and "time" issues and finishes the below in 1 second.
655 * #defines for the dynamic algorithm growth can be found in patcode.h
656 */
657GBLDEF int4 curalt_depth = -1; /* depth of alternation nesting */
658GBLDEF int4 do_patalt_calls[PTE_MAX_CURALT_DEPTH]; /* number of calls to do_patalt() */
659GBLDEF int4 do_patalt_hits[PTE_MAX_CURALT_DEPTH]; /* number of pte_csh hits in do_patalt() */
660GBLDEF int4 do_patalt_maxed_out[PTE_MAX_CURALT_DEPTH]; /* no. of pte_csh misses after maxing on allocation size */
661
662GBLDEF pte_csh *pte_csh_array[PTE_MAX_CURALT_DEPTH]; /* pte_csh array (per curalt_depth) */
663GBLDEF int4 pte_csh_cur_size[PTE_MAX_CURALT_DEPTH]; /* current pte_csh size (per curalt_depth) */
664GBLDEF int4 pte_csh_alloc_size[PTE_MAX_CURALT_DEPTH]; /* current allocated pte_csh size (per curalt_depth) */
665GBLDEF int4 pte_csh_entries_per_len[PTE_MAX_CURALT_DEPTH]; /* current number of entries per len */
666GBLDEF int4 pte_csh_tail_count[PTE_MAX_CURALT_DEPTH]; /* count of non 1-1 corresponding pte_csh_array members */
667
668GBLDEF pte_csh *cur_pte_csh_array; /* copy of pte_csh_array corresponding to curalt_depth */
669GBLDEF int4 cur_pte_csh_size; /* copy of pte_csh_cur_size corresponding to curalt_depth */
670GBLDEF int4 cur_pte_csh_entries_per_len; /* copy of pte_csh_entries_per_len corresponding to curalt_depth */
671GBLDEF int4 cur_pte_csh_tail_count; /* copy of pte_csh_tail_count corresponding to curalt_depth */
672
673GBLDEF readonly char *before_image_lit[] = {"NOBEFORE_IMAGES", "BEFORE_IMAGES"};
674GBLDEF readonly char *jnl_state_lit[] = {"DISABLED", "OFF", "ON"};
675GBLDEF readonly char *repl_state_lit[] = {"OFF", "ON", "WAS_ON"};
676
677GBLDEF boolean_t crit_sleep_expired; /* mutex.mar: signals that a timer waiting for crit has expired */
678GBLDEF uint4 crit_deadlock_check_cycle; /* compared to csa->crit_check_cycle to determine if a given region
679 in a transaction legitimately has crit or not */
680GBLDEF node_local_ptr_t locknl; /* if non-NULL, indicates node-local of interest to the LOCK_HIST macro */
681GBLDEF boolean_t in_mutex_deadlock_check; /* if TRUE, mutex_deadlock_check() is part of our current C-stack trace */
682/* $ECODE and $STACK related variables.
683 * error_frame and skip_error_ret should ideally be part of dollar_ecode structure. since sr_avms/opp_ret.m64 uses these
684 * global variables and it was felt risky changing it to access a member of a structure, they are kept as separate globals */
685GBLDEF stack_frame *error_frame; /* ptr to frame where last error occurred or was rethrown */
686GBLDEF boolean_t skip_error_ret; /* set to TRUE by golevel(), used and reset by op_unwind() */
687GBLDEF dollar_ecode_type dollar_ecode; /* structure containing $ECODE related information */
688GBLDEF dollar_stack_type dollar_stack; /* structure containing $STACK related information */
689GBLDEF boolean_t ztrap_explicit_null; /* whether $ZTRAP was explicitly set to NULL in the current frame */
690GBLDEF int4 gtm_object_size; /* Size of entire gtm object for compiler use */
691GBLDEF int4 linkage_size; /* Size of linkage section during compile */
692GBLDEF uint4 lnkrel_cnt; /* number of entries in linkage Psect to relocate */
693GBLDEF int4 sym_table_size; /* size of the symbol table during compilation */
694GBLDEF boolean_t disallow_forced_expansion, forced_expansion; /* Used in stringpool managment */
695GBLDEF jnl_fence_control jnl_fence_ctl;
696GBLDEF jnl_process_vector *prc_vec = NULL; /* for current process */
697GBLDEF jnl_process_vector *originator_prc_vec = NULL; /* for client/originator */
698LITDEF char *jrt_label[JRT_RECTYPES] =
699{
700#define JNL_TABLE_ENTRY(rectype, extract_rtn, label, update, fixed_size, is_replicated) label,
701#include "jnl_rec_table.h"
702#undef JNL_TABLE_ENTRY
703};
704LITDEF int jrt_update[JRT_RECTYPES] =
705{
706#define JNL_TABLE_ENTRY(rectype, extract_rtn, label, update, fixed_size, is_replicated) update,
707#include "jnl_rec_table.h"
708#undef JNL_TABLE_ENTRY
709};
710LITDEF boolean_t jrt_fixed_size[JRT_RECTYPES] =
711{
712#define JNL_TABLE_ENTRY(rectype, extract_rtn, label, update, fixed_size, is_replicated) fixed_size,
713#include "jnl_rec_table.h"
714#undef JNL_TABLE_ENTRY
715};
716LITDEF boolean_t jrt_is_replicated[JRT_RECTYPES] =
717{
718#define JNL_TABLE_ENTRY(rectype, extract_rtn, label, update, fixed_size, is_replicated) is_replicated,
719#include "jnl_rec_table.h"
720#undef JNL_TABLE_ENTRY
721};
722/* Change the initialization if struct_jrec_tcom in jnl.h changes */
723GBLDEF struct_jrec_tcom tcom_record = {{JRT_TCOM, TCOM_RECLEN, 0, 0, 0},
724 0, "", 0, {TCOM_RECLEN, JNL_REC_SUFFIX_CODE}};
725GBLDEF jnl_gbls_t jgbl;
726GBLDEF short crash_count;
727GBLDEF trans_num start_tn;
728GBLDEF cw_set_element cw_set[CDB_CW_SET_SIZE];
729GBLDEF unsigned char cw_set_depth, cw_map_depth;
730GBLDEF unsigned int t_tries;
731GBLDEF uint4 t_err;
732GBLDEF int4 update_trans; /* TRUE whenever a non-TP transaction needs to increment the database transaction number.
733 * usually TRUE if cw_set_depth/cw_map_depth of the current non-TP transaction is non-zero,
734 * but additionally TRUE in case of a redundant set in gvcst_put.c
735 * can take on a special value T_COMMIT_STARTED in t_end/tp_tend hence is not "boolean_t"
736 */
737GBLDEF boolean_t mu_rndwn_file_dbjnl_flush; /* to indicate standalone access is available to shared memory so
738 * wcs_recover() need not increment db curr_tn or write inctn record */
739
740GBLDEF boolean_t is_uchar_wcs_code[] = /* uppercase failure codes that imply database cache related problem */
741{ /* if any of the following failure codes are seen in the final retry, wc_blocked will be set to trigger cache recovery */
742#define CDB_SC_NUM_ENTRY(code, value)
743#define CDB_SC_UCHAR_ENTRY(code, is_wcs_code, value) is_wcs_code,
744#define CDB_SC_LCHAR_ENTRY(code, is_wcs_code, value)
745#include "cdb_sc_table.h"
746#undef CDB_SC_NUM_ENTRY
747#undef CDB_SC_UCHAR_ENTRY
748#undef CDB_SC_LCHAR_ENTRY
749};
750
751GBLDEF boolean_t is_lchar_wcs_code[] = /* lowercase failure codes that imply database cache related problem */
752{ /* if any of the following failure codes are seen in the final retry, wc_blocked will be set to trigger cache recovery */
753#define CDB_SC_NUM_ENTRY(code, value)
754#define CDB_SC_UCHAR_ENTRY(code, is_wcs_code, value)
755#define CDB_SC_LCHAR_ENTRY(code, is_wcs_code, value) is_wcs_code,
756#include "cdb_sc_table.h"
757#undef CDB_SC_NUM_ENTRY
758#undef CDB_SC_UCHAR_ENTRY
759#undef CDB_SC_LCHAR_ENTRY
760};
761
762GBLDEF mval last_fnquery_return_varname; /* Return value of last $QUERY (on stringpool) (varname) */
763GBLDEF mval last_fnquery_return_sub[MAX_LVSUBSCRIPTS]; /* .. (subscripts) */
764GBLDEF int last_fnquery_return_subcnt ; /* .. (count of subscripts) */
765
766GBLDEF boolean_t gvdupsetnoop = FALSE; /* if TRUE, duplicate SETs do not change GDS block (and therefore no PBLK journal
767 * records will be written) although the database transaction number will be
768 * incremented and logical SET journal records will be written.
769 */
770GBLDEF boolean_t gtm_fullblockwrites; /* Do full (not partial) database block writes T/F */
771UNIX_ONLY(GBLDEF int4 gtm_shmflags;) /* Extra flags for shmat */
772#ifdef VMS
773GBLDEF uint4 gtm_memory_noaccess_defined; /* count of the number of GTM_MEMORY_NOACCESS_ADDR logicals which are defined */
774GBLDEF uint4 gtm_memory_noaccess[GTM_MEMORY_NOACCESS_COUNT]; /* see VMS gtm_env_init_sp.c */
775#endif
776
777GBLDEF volatile boolean_t in_wcs_recover = FALSE; /* TRUE if in wcs_recover(), used by "bt_put" and "generic_exit_handler" */
778
779/* Following definitions are related to white_box testing */
780GBLDEF boolean_t gtm_white_box_test_case_enabled = FALSE;
781GBLDEF int gtm_white_box_test_case_number = 0;
782GBLDEF int gtm_white_box_test_case_count = 0;
783GBLDEF int gtm_wbox_input_test_case_count = 0; /* VMS allows maximum 31 characters for external identifer */
784
785GBLDEF boolean_t in_gvcst_incr = FALSE; /* set to TRUE by gvcst_incr, set to FALSE by gvcst_put
786 * distinguishes to gvcst_put, if the current db operation is a SET or $INCR */
787GBLDEF mval *post_incr_mval; /* mval pointing to the post-$INCR value */
788GBLDEF mval increment_delta_mval; /* mval holding the INTEGER increment value, set by gvcst_incr,
789 * used by gvcst_put/gvincr_recompute_upd_array which is invoked by t_end */
790GBLDEF boolean_t is_dollar_incr = FALSE; /* valid only if gvcst_put is in the call-stack (i.e. t_err == ERR_GVPUTFAIL);
791 * is a copy of "in_gvcst_incr" just before it got reset to FALSE */
792GBLDEF boolean_t pre_incr_update_trans; /* copy of "sgm_info_ptr->update_trans" before the $INCR */
793GBLDEF int indir_cache_mem_size; /* Amount of memory currently in use by indirect cache */
794GBLDEF hash_table_mname rt_name_tbl;
795GBLDEF hash_table_objcode cache_table;
796GBLDEF int cache_hits, cache_fails;
797
798/* The alignment feature is disabled due to some issues in stringpool garbage collection.
799 * TODO: When we sort out stringpool issues, change mstr_native_align to TRUE below */
800GBLDEF boolean_t mstr_native_align = FALSE;
801GBLDEF boolean_t save_mstr_native_align;
802
803GBLDEF mvar *mvartab;
804GBLDEF mvax *mvaxtab,*mvaxtab_end;
805GBLDEF mlabel *mlabtab;
806GBLDEF mline mline_root;
807GBLDEF mline *mline_tail;
808GBLDEF short int block_level;
809GBLDEF triple t_orig;
810GBLDEF int mvmax, mlmax, mlitmax;
811static char routine_name_buff[sizeof(mident_fixed)], module_name_buff[sizeof(mident_fixed)];
812GBLDEF MIDENT_DEF(routine_name, 0, &routine_name_buff[0]);
813GBLDEF MIDENT_DEF(module_name, 0, &module_name_buff[0]);
814GBLDEF char rev_time_buf[REV_TIME_BUFF_LEN];
815GBLDEF unsigned short source_name_len;
816GBLDEF short object_name_len;
817UNIX_ONLY(
818 GBLDEF unsigned char source_file_name[MAX_FBUFF + 1];
819 GBLDEF unsigned char object_file_name[MAX_FBUFF + 1];
820 GBLDEF int object_file_des;
821)
822VMS_ONLY(
823 GBLDEF char source_file_name[PATH_MAX];
824 GBLDEF char object_file_name[256];
825 GBLDEF struct FAB obj_fab; /* file access block for the object file */
826)
827
828GBLDEF int4 curr_addr, code_size;
829GBLDEF mident_fixed zlink_mname;
830GBLDEF boolean_t in_op_fnnext = FALSE; /* set to TRUE by op_fnnext, set to FALSE by op_fnorder */
831
832GBLDEF sm_uc_ptr_t reformat_buffer;
833GBLDEF int reformat_buffer_len;
834GBLDEF volatile int reformat_buffer_in_use; /* used only in DEBUG mode */
835
836GBLDEF boolean_t mu_reorg_upgrd_dwngrd_in_prog; /* TRUE if MUPIP REORG UPGRADE/DOWNGRADE is in progress */
837GBLDEF boolean_t mu_reorg_nosafejnl; /* TRUE if NOSAFEJNL explicitly specified */
838GBLDEF trans_num mu_reorg_upgrd_dwngrd_blktn; /* tn in blkhdr of current block processed by MUPIP REORG {UP,DOWN}GRADE */
839
840GBLDEF inctn_opcode_t inctn_opcode = inctn_invalid_op;
841GBLDEF inctn_detail_t inctn_detail; /* holds detail to fill in to inctn jnl record */
842GBLDEF uint4 region_open_count; /* Number of region "opens" we have executed */
843
844GBLDEF uint4 gtm_blkupgrade_flag = UPGRADE_IF_NEEDED; /* by default upgrade only if necessary */
845GBLDEF boolean_t disk_blk_read;
846
847GBLDEF boolean_t gtm_dbfilext_syslog_disable = FALSE; /* by default, log every file extension message */
848
849GBLDEF int4 cws_reorg_remove_index; /* see mu_swap_blk.c for comments on the need for these two */
850GBLDEF block_id cws_reorg_remove_array[CWS_REORG_REMOVE_ARRAYSIZE];
851
852GBLDEF uint4 log_interval;
853
854#ifdef UNIX
855GBLDEF uint4 gtm_principal_editing_defaults; /* ext_cap flags if tt */
856GBLDEF boolean_t in_repl_inst_edit = FALSE; /* used by an assert in repl_inst_read/repl_inst_write */
857GBLDEF boolean_t in_repl_inst_create; /* used by repl_inst_read/repl_inst_write */
858GBLDEF boolean_t holds_sem[NUM_SEM_SETS][NUM_SRC_SEMS]; /* whether a particular replication semaphore is being held
859 * by the current process or not. */
860GBLDEF boolean_t print_offset; /* Set to TRUE if -DETAIL is specified in MUPIP REPLIC -JNLPOOL or -EDITINST */
861GBLDEF boolean_t in_mupip_ftok; /* Used by an assert in repl_inst_read */
862GBLDEF uint4 section_offset; /* Used by PRINT_OFFSET_PREFIX macro in repl_inst_dump.c */
863
864GBLDEF uint4 mutex_per_process_init_pid; /* pid that invoked "mutex_per_process_init" */
865GBLDEF boolean_t gtm_quiet_halt; /* Suppress FORCEDHALT message */
866#endif
867
868#ifdef UNICODE_SUPPORTED
869/* Unicode line terminators. In addition to the following
870 * codepoints, the sequence CR LF is considered a single
871 * line terminator.
872 */
873LITDEF UChar32 u32_line_term[] =
874{
875 0x000A, /* Line Feed */
876 0x000D, /* Carraige Return */
877 0x0085, /* Next Line - EBCDIC mostly */
878 0x000C, /* Form Feed */
879 UTF_LINE_SEPARATOR, /* Line Separator */
880 UTF_PARA_SEPARATOR, /* Paragraph Separator */
881 0x0000
882};
883
884/* Given the first byte in a UTF-8 representation, the following array returns the total number of bytes in the encoding
885 * 00-7F : 1 byte
886 * C2-DF : 2 bytes
887 * E0-EF : 3 bytes
888 * F0-F4 : 4 bytes
889 * All others: 1 byte
890 * For details on the UTF-8 encoding see gtm_utf8.h
891 */
892LITDEF unsigned int utf8_bytelen[] =
893{
894 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 00-1F */
895 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 20-3F */
896 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 40-5F */
897 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 60-7F */
898 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 80-9F */
899 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* A0-BF */
900 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* C0-DF */
901 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* E0-FF */
902};
903
904/* Given the first byte in a UTF-8 representation, the following array returns the number of bytes to follow
905 * 00-7F : 0 byte
906 * C2-DF : 1 byte
907 * E0-EF : 2 bytes
908 * F0-F4 : 3 bytes
909 * All others: -1 bytes
910 * For details on the UTF-8 encoding see gtm_utf8.h
911 */
912LITDEF signed int utf8_followlen[] =
913{
914 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 00-1F */
915 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 20-3F */
916 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 40-5F */
917 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 60-7F */
918 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 80-9F */
919 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* A0-BF */
920 -1,-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* C0-DF */
921 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* E0-FF */
922};
923
924GBLDEF gtm_wcswidth_fnptr_t gtm_wcswidth_fnptr; /* see comment in gtm_utf8.h about this typedef */
925#endif
926
927GBLDEF uint4 gtm_max_sockets; /* Maximum sockets per socket device supported by this process */
928GBLDEF d_socket_struct *newdsocket; /* Commonly used temp socket area */
929
930GBLDEF boolean_t dse_all_dump; /* TRUE if DSE ALL -DUMP is specified */
931GBLDEF int socketus_interruptus; /* How many times socket reads have been interrutped */
932
933GBLDEF int4 pending_errtriplecode; /* if non-zero contains the error code to invoke ins_errtriple with */
934
935GBLDEF uint4 process_id;
936GBLDEF uint4 image_count; /* not used in UNIX but defined to preserve VMS compatibility */
937
938GBLDEF size_t totalRmalloc; /* Total storage currently (real) malloc'd (includes extent blocks) */
939GBLDEF size_t totalAlloc; /* Total allocated (includes allocation overhead but not free space */
940GBLDEF size_t totalUsed; /* Sum of user allocated portions (totalAlloc - overhead) */
941
942GBLDEF size_t totalRallocGta; /* Total storage currently (real) mmap alloc'd */
943GBLDEF size_t totalAllocGta; /* Total mmap allocated (includes allocation overhead but not free space */
944GBLDEF size_t totalUsedGta; /* Sum of "in-use" portions (totalAllocGta - overhead) */
945
946GBLDEF volatile char *outOfMemoryMitigation; /* Cache that we will freed to help cleanup if run out of memory */
947GBLDEF uint4 outOfMemoryMitigateSize;/* Size of above cache (in Kbytes) */
948
949GBLDEF int mcavail;
950GBLDEF mcalloc_hdr *mcavailptr, *mcavailbase;
951
952GBLDEF uint4 max_cache_memsize; /* Maximum bytes used for indirect cache object code */
953GBLDEF uint4 max_cache_entries; /* Maximum number of cached indirect compilations */
954
955GBLDEF void (*cache_table_relobjs)(void); /* Function pointer to call cache_table_rebuild() */
956UNIX_ONLY(GBLDEF ch_ret_type (*ht_rhash_ch)();) /* Function pointer to hashtab_rehash_ch */
957UNIX_ONLY(GBLDEF ch_ret_type (*jbxm_dump_ch)();) /* Function pointer to jobexam_dump_ch */
958
959#ifdef VMS
960GBLDEF boolean_t tp_has_kill_t_cse; /* cse->mode of kill_t_write or kill_t_create got created in this transaction */
961#endif
962
963#ifdef DEBUG
964/* Set to TRUE in a few selected places before wcs_recover is called. Any other place that calls wcs_recover in the final
965 * retry will fail an assert as we dont want to call cache recovery while in the middle of a transaction and confuse ourselves
966 * enough to cause further restarts (which is an out-of-design situation while in the final retry).
967 */
968GBLDEF boolean_t ok_to_call_wcs_recover;
969GBLDEF uint4 donot_commit; /* see gdsfhead.h for purpose of this debug-only global */
970#endif
971
972GBLDEF cache_rec_ptr_t pin_fail_cr; /* Pointer to the cache-record that we failed while pinning */
973GBLDEF cache_rec pin_fail_cr_contents; /* Contents of the cache-record that we failed while pinning */
974GBLDEF cache_rec_ptr_t pin_fail_twin_cr; /* Pointer to twin of the cache-record that we failed to pin */
975GBLDEF cache_rec pin_fail_twin_cr_contents; /* Contents of twin of the cache-record that we failed to pin */
976GBLDEF bt_rec_ptr_t pin_fail_bt; /* Pointer to bt of the cache-record that we failed to pin */
977GBLDEF bt_rec pin_fail_bt_contents; /* Contents of bt of the cache-record that we failed to pin */
978GBLDEF int4 pin_fail_in_crit; /* Holder of crit at the time we failed to pin */
979GBLDEF int4 pin_fail_wc_in_free; /* Number of write cache records in free queue when we failed to pin */
980GBLDEF int4 pin_fail_wcs_active_lvl; /* Number of entries in active queue when we failed to pin */
981GBLDEF int4 pin_fail_ref_cnt; /* Reference count when we failed to pin */
982GBLDEF int4 pin_fail_in_wtstart; /* Count of processes in wcs_wtstart when we failed to pin */
983GBLDEF int4 pin_fail_phase2_commit_pidcnt; /* Number of processes in phase2 commit when we failed to pin */
984
985#ifdef DEBUG
986GBLDEF boolean_t gtm_gvundef_fatal;
987GBLDEF boolean_t in_op_gvget; /* TRUE if op_gvget() is a call ancestor in the C-stack */
988GBLDEF boolean_t ready2signal_gvundef; /* TRUE if GET operation is about to signal a GVUNDEF */
989#endif
990
991GBLDEF boolean_t gtm_tp_allocation_clue; /* block# hint to start allocation for created blocks in TP */
992
993#ifdef UNIX
994GBLDEF int4 gtm_zlib_cmp_level; /* zlib compression level specified at process startup */
995GBLDEF int4 repl_zlib_cmp_level; /* zlib compression level currently in use in replication pipe.
996 * This is a source-server specific variable and is non-zero only
997 * if compression is enabled and works in the receiver server as well.
998 */
999GBLDEF zlib_cmp_func_t zlib_compress_fnptr;
1000GBLDEF zlib_uncmp_func_t zlib_uncompress_fnptr;
1001#endif
1002
1003GBLDEF mlk_stats_t mlk_stats; /* Process-private M-lock statistics */
1004
1005#ifdef UNIX
1006/* Initialized blockalrm and block_sigsent can be used by all */
1007GBLDEF boolean_t blocksig_initialized = FALSE; /* set to TRUE when blockalrm and block_sigsent are initialized */
1008GBLDEF sigset_t blockalrm;
1009GBLDEF sigset_t block_sigsent; /* block all signals that can be sent externally
1010 (SIGINT, SIGQUIT, SIGTERM, SIGTSTP, SIGCONT) */
1011#endif
1012
01013
=== added file 'src/gtm/sr_port/gtm_env_init.c'
--- src/gtm/sr_port/gtm_env_init.c 1970-01-01 00:00:00 +0000
+++ src/gtm/sr_port/gtm_env_init.c 2009-04-07 01:13:36 +0000
@@ -0,0 +1,216 @@
1/****************************************************************
2 * *
3 * Copyright 2004, 2008 Fidelity Information Services, Inc *
4 * *
5 * This source code contains the intellectual property *
6 * of its copyright holder(s), and is made available *
7 * under a license. If you do not know the terms of *
8 * the license, please stop and do not read further. *
9 * *
10 ****************************************************************/
11
12#include "mdef.h"
13
14#include "gtm_logicals.h"
15#include "gtm_stdlib.h"
16#include "gtm_string.h"
17#include "logical_truth_value.h"
18#include "trans_numeric.h"
19#include "gtmdbglvl.h"
20#include "iosp.h"
21#include "wbox_test_init.h"
22#include "gtm_env_init.h" /* for gtm_env_init() and gtm_env_init_sp() prototype */
23#include "gt_timer.h"
24#include "io.h"
25#include "iotcpdef.h"
26#include "iosocketdef.h"
27#include "gtm_malloc.h"
28#include "cache.h"
29#include "gdsroot.h" /* needed for gdsfhead.h */
30#include "gdskill.h" /* needed for gdsfhead.h */
31#include "gdsbt.h" /* needed for gdsfhead.h */
32#include "gdsfhead.h" /* needed for MAXTOTALBLKS_MAX macro */
33#include "trans_log_name.h"
34#include "op.h"
35#include "svnames.h"
36
37#ifdef DEBUG
38# define INITIAL_DEBUG_LEVEL GDL_Simple
39GBLDEF boolean_t gtmdbglvl_inited; /* gtmDebugLevel has been initialized */
40#else
41# define INITIAL_DEBUG_LEVEL GDL_None
42#endif
43
44#ifdef FULLBLOCKWRITES
45# define DEFAULT_FBW_FLAG TRUE
46#else
47# define DEFAULT_FBW_FLAG FALSE
48#endif
49
50GBLREF boolean_t dollar_zquit_anyway; /* if TRUE compile QUITs to not care whether or not they're from an extrinsic */
51GBLREF boolean_t gvdupsetnoop; /* if TRUE, duplicate SETs update journal but not database (except
52 for curr_tn++) */
53GBLREF uint4 gtmDebugLevel; /* Debug level (0 = using default sm module so with
54 a DEBUG build, even level 0 implies basic debugging) */
55GBLREF boolean_t gtm_fullblockwrites; /* Do full (not partial) database block writes T/F */
56GBLREF boolean_t certify_all_blocks;
57GBLREF boolean_t local_collseq_stdnull; /* If true, standard null subscript collation will be used for local variables */
58GBLREF uint4 gtm_blkupgrade_flag; /* controls whether dynamic block upgrade is attempted or not */
59GBLREF boolean_t gtm_dbfilext_syslog_disable; /* control whether db file extension message is logged or not */
60GBLREF uint4 gtm_max_sockets; /* Maximum sockets in a socket device that can be created by this process */
61GBLREF bool undef_inhibit;
62GBLREF uint4 outOfMemoryMitigateSize; /* Reserve that we will freed to help cleanup if run out of memory */
63GBLREF uint4 max_cache_memsize; /* Maximum bytes used for indirect cache object code */
64GBLREF uint4 max_cache_entries; /* Maximum number of cached indirect compilations */
65GBLREF boolean_t gtm_tp_allocation_clue; /* block# hint to start allocation for created blocks in TP */
66
67GBLREF char prombuf[MAX_MIDENT_LEN];
68GBLREF mstr gtmprompt;
69
70#ifdef DEBUG
71GBLREF boolean_t gtm_gvundef_fatal;
72#endif
73
74void gtm_env_init(void)
75{
76 static boolean_t gtm_env_init_done = FALSE;
77 mstr val;
78 boolean_t ret, is_defined;
79 uint4 tdbglvl, tmsock, reservesize, memsize, cachent;
80 char* prompt_env_val;
81
82 if (!gtm_env_init_done)
83 {
84 /* See if a debug level has been specified. Do this first since gtmDebugLevel needs
85 to be initialized before any mallocs are done in the system.
86 */
87 gtmDebugLevel = INITIAL_DEBUG_LEVEL;
88 val.addr = GTM_DEBUG_LEVEL_ENVLOG;
89 val.len = sizeof(GTM_DEBUG_LEVEL_ENVLOG) - 1;
90 if (tdbglvl = trans_numeric(&val, &is_defined, TRUE)) /* Note assignment!! */
91 { /* Some kind of debugging was asked for.. */
92 tdbglvl |= GDL_Simple; /* Make sure simple debugging turned on if any is */
93 if ((GDL_SmChkFreeBackfill | GDL_SmChkAllocBackfill) & tdbglvl)
94 tdbglvl |= GDL_SmBackfill; /* Can't check it unless it's filled in */
95 if (GDL_SmStorHog & tdbglvl)
96 tdbglvl |= GDL_SmBackfill | GDL_SmChkAllocBackfill;
97 gtmDebugLevel |= tdbglvl;
98 }
99 DEBUG_ONLY(gtmdbglvl_inited = TRUE);
100
101 /* Duplicate Set Noop environment/logical */
102 val.addr = GTM_GVDUPSETNOOP;
103 val.len = sizeof(GTM_GVDUPSETNOOP) - 1;
104 assert(FALSE == gvdupsetnoop); /* should have been set to FALSE in gbldefs.c */
105 ret = logical_truth_value(&val, FALSE, &is_defined);
106 if (is_defined)
107 gvdupsetnoop = ret; /* if the logical is not defined, we want gvdupsetnoop to take its default value */
108
109 /* NOUNDEF environment/logical */
110 val.addr = GTM_NOUNDEF;
111 val.len = sizeof(GTM_NOUNDEF) - 1;
112 assert(FALSE == undef_inhibit); /* should have been set to FALSE at global variable definition time */
113 ret = logical_truth_value(&val, FALSE, &is_defined);
114 if (is_defined)
115 undef_inhibit = ret; /* if the logical is not defined, we want undef_inhibit to take its default value */
116
117# ifdef DEBUG
118 /* GTM_GVUNDEF_FATAL environment/logical */
119 val.addr = GTM_GVUNDEF_FATAL;
120 val.len = sizeof(GTM_GVUNDEF_FATAL) - 1;
121 assert(FALSE == gtm_gvundef_fatal); /* should have been set to FALSE in gbldefs.c */
122 ret = logical_truth_value(&val, FALSE, &is_defined);
123 if (is_defined)
124 gtm_gvundef_fatal = ret; /* if logical is not defined, we want gtm_gvundef_fatal to take default value */
125# endif
126
127 /* Initialize variable that controls TP allocation clue (for created blocks) */
128 val.addr = GTM_TP_ALLOCATION_CLUE;
129 val.len = sizeof(GTM_TP_ALLOCATION_CLUE) - 1;
130 gtm_tp_allocation_clue = trans_numeric(&val, &is_defined, TRUE);
131 if (!is_defined)
132 gtm_tp_allocation_clue = MAXTOTALBLKS_MAX;
133
134 /* Full Database-block Write mode */
135 val.addr = GTM_FULLBLOCKWRITES;
136 val.len = sizeof(GTM_FULLBLOCKWRITES) - 1;
137 gtm_fullblockwrites = logical_truth_value(&val, FALSE, &is_defined);
138 if (!is_defined)
139 gtm_fullblockwrites = DEFAULT_FBW_FLAG;
140
141 /* GDS Block certification */
142 val.addr = GTM_GDSCERT;
143 val.len = sizeof(GTM_GDSCERT) - 1;
144 ret = logical_truth_value(&val, FALSE, &is_defined);
145 if (is_defined)
146 certify_all_blocks = ret; /* if the logical is not defined, we want to take default value */
147
148 /* Initialize null subscript's collation order */
149 val.addr = LCT_STDNULL;
150 val.len = sizeof(LCT_STDNULL) - 1;
151 ret = logical_truth_value(&val, FALSE, &is_defined);
152 if (is_defined)
153 local_collseq_stdnull = ret;
154
155 /* Initialize variables for white box testing. Even though these white-box test variables only control the
156 * flow of the DBG builds, the PRO builds check on these variables (for example, in tp_restart.c to decide
157 * whether to fork_n_core or not) so need to do this initialization for PRO builds as well.
158 */
159 wbox_test_init();
160
161 /* Initialize variable that controls dynamic GT.M block upgrade */
162 val.addr = GTM_BLKUPGRADE_FLAG;
163 val.len = sizeof(GTM_BLKUPGRADE_FLAG) - 1;
164 gtm_blkupgrade_flag = trans_numeric(&val, &is_defined, TRUE);
165
166 /* Initialize whether database file extensions need to be logged in the operator log */
167 val.addr = GTM_DBFILEXT_SYSLOG_DISABLE;
168 val.len = sizeof(GTM_DBFILEXT_SYSLOG_DISABLE) - 1;
169 ret = logical_truth_value(&val, FALSE, &is_defined);
170 if (is_defined)
171 gtm_dbfilext_syslog_disable = ret; /* if the logical is not defined, we want to take default value */
172
173 /* Initialize maximum sockets in a single socket device createable by this process */
174 gtm_max_sockets = MAX_N_SOCKET;
175 val.addr = GTM_MAX_SOCKETS;
176 val.len = sizeof(GTM_MAX_SOCKETS) - 1;
177 if ((tmsock = trans_numeric(&val, &is_defined, TRUE)) && MAX_MAX_N_SOCKET > tmsock) /* Note assignment!! */
178 gtm_max_sockets = tmsock;
179
180 /* Initialize storage to allocate and keep in our back pocket in case run out of memory */
181 outOfMemoryMitigateSize = GTM_MEMORY_RESERVE_DEFAULT;
182 val.addr = GTM_MEMORY_RESERVE;
183 val.len = sizeof(GTM_MEMORY_RESERVE) - 1;
184 if (reservesize = trans_numeric(&val, &is_defined, TRUE)) /* Note assignment!! */
185 outOfMemoryMitigateSize = reservesize;
186
187 /* Initialize indirect cache limits (max memory, max entries) */
188 max_cache_memsize = MAX_CACHE_MEMSIZE * 1024;
189 val.addr = GTM_MAX_INDRCACHE_MEMORY;
190 val.len = sizeof(GTM_MAX_INDRCACHE_MEMORY) - 1;
191 if (memsize = trans_numeric(&val, &is_defined, TRUE)) /* Note assignment!! */
192 max_cache_memsize = memsize * 1024;
193 max_cache_entries = MAX_CACHE_ENTRIES;
194 val.addr = GTM_MAX_INDRCACHE_COUNT;
195 val.len = sizeof(GTM_MAX_INDRCACHE_COUNT) - 1;
196 if (cachent = trans_numeric(&val, &is_defined, TRUE)) /* Note assignment!! */
197 max_cache_entries = cachent;
198
199 /* Initialize ZQUIT to control funky QUIT compilation */
200 val.addr = GTM_ZQUIT_ANYWAY;
201 val.len = sizeof(GTM_ZQUIT_ANYWAY) - 1;
202 ret = logical_truth_value(&val, FALSE, &is_defined);
203 if (is_defined)
204 dollar_zquit_anyway = ret;
205
206 if (NULL!=(prompt_env_val=GETENV(GTM_PROMPT+1)) && strlen(prompt_env_val)<sizeof(prombuf)) {
207 val.addr = GTM_PROMPT;
208 val.len = sizeof(GTM_PROMPT) - 1;
209 TRANS_LOG_NAME(&val, &gtmprompt, prombuf, sizeof(prombuf), do_sendmsg_on_log2long);
210 }
211
212 /* Platform specific initializations */
213 gtm_env_init_sp();
214 gtm_env_init_done = TRUE;
215 }
216}
0217
=== added file 'src/gtm/sr_port/op_svput.c'
--- src/gtm/sr_port/op_svput.c 1970-01-01 00:00:00 +0000
+++ src/gtm/sr_port/op_svput.c 2009-04-07 01:13:36 +0000
@@ -0,0 +1,314 @@
1/****************************************************************
2 * *
3 * Copyright 2001, 2008 Fidelity Information Services, Inc *
4 * *
5 * This source code contains the intellectual property *
6 * of its copyright holder(s), and is made available *
7 * under a license. If you do not know the terms of *
8 * the license, please stop and do not read further. *
9 * *
10 ****************************************************************/
11
12#include "mdef.h"
13
14#include "gtm_stdlib.h"
15#include "gtm_string.h"
16
17#include "svnames.h"
18#include "io.h"
19#include "gdsroot.h"
20#include "gtm_facility.h"
21#include "fileinfo.h"
22#include "gdsbt.h"
23#include "gdsfhead.h"
24#include "indir_enum.h"
25#include "error.h"
26#include "stringpool.h"
27#include "op.h"
28#include "mvalconv.h"
29#include "zroutines.h"
30#include "dpgbldir.h"
31#include "dpgbldir_sysops.h"
32#include "gtmmsg.h"
33#include "ztrap_save_ctxt.h"
34#include "dollar_zlevel.h"
35#include "error_trap.h"
36#include "gtm_ctype.h"
37#include "setzdir.h"
38#include "rtnhdr.h"
39#include "stack_frame.h"
40#include "getzdir.h"
41#include "gtm_newintrinsic.h"
42
43GBLREF char prombuf[MAX_MIDENT_LEN];
44GBLREF mstr gtmprompt;
45
46GBLREF gv_key *gv_currkey;
47GBLREF gv_namehead *gv_target;
48GBLREF gd_addr *gd_header;
49GBLREF gd_addr *gd_targ_addr;
50GBLREF gd_binding *gd_map;
51GBLREF gd_binding *gd_map_top;
52GBLREF io_pair io_curr_device;
53GBLREF mval dollar_ztrap;
54GBLREF mval dollar_zstatus;
55GBLREF mval dollar_zgbldir;
56GBLREF mval dollar_zstep;
57GBLREF mstr dollar_zcompile;
58GBLREF mstr dollar_zroutines;
59GBLREF mstr dollar_zsource;
60GBLREF int dollar_zmaxtptime;
61GBLREF int ztrap_form;
62GBLREF mval dollar_etrap;
63GBLREF mval dollar_zerror;
64GBLREF mval dollar_zyerror;
65GBLREF mval dollar_system;
66GBLREF mval dollar_zinterrupt;
67GBLREF boolean_t ztrap_new;
68GBLREF stack_frame *error_frame;
69GBLREF boolean_t ztrap_explicit_null; /* whether $ZTRAP was explicitly set to NULL in this frame */
70GBLREF int4 zdate_form;
71GBLREF mval dollar_ztexit;
72GBLREF boolean_t dollar_ztexit_bool;
73GBLREF boolean_t dollar_zquit_anyway;
74
75void op_svput(int varnum, mval *v)
76{
77 int i, ok, state;
78 char *vptr;
79 error_def(ERR_INVECODEVAL);
80 error_def(ERR_SETECODE);
81 error_def(ERR_SYSTEMVALUE);
82
83 switch (varnum)
84 {
85 case SV_X:
86 MV_FORCE_NUM(v);
87 io_curr_device.out->dollar.x = (short)MV_FORCE_INT(v);
88 if ((short)(io_curr_device.out->dollar.x) < 0)
89 io_curr_device.out->dollar.x = 0;
90 break;
91 case SV_Y:
92 MV_FORCE_NUM(v);
93 io_curr_device.out->dollar.y = (short)MV_FORCE_INT(v);
94 if ((short)(io_curr_device.out->dollar.y) < 0)
95 io_curr_device.out->dollar.y = 0;
96 break;
97 case SV_ZCOMPILE:
98 MV_FORCE_STR(v);
99 if (dollar_zcompile.addr)
100 free (dollar_zcompile.addr);
101 dollar_zcompile.addr = (char *)malloc(v->str.len);
102 memcpy (dollar_zcompile.addr, v->str.addr, v->str.len);
103 dollar_zcompile.len = v->str.len;
104 break;
105 case SV_ZSTEP:
106 MV_FORCE_STR(v);
107 op_commarg(v,indir_linetail);
108 op_unwind();
109 dollar_zstep = *v;
110 break;
111 case SV_ZGBLDIR:
112 MV_FORCE_STR(v);
113 if ((dollar_zgbldir.str.len != v->str.len) || memcmp(dollar_zgbldir.str.addr, v->str.addr, dollar_zgbldir.str.len))
114 {
115 if (0 == v->str.len)
116 {
117 /* set $zgbldir="" */
118 dpzgbini();
119 gd_header = NULL;
120 } else
121 {
122 gd_header = zgbldir(v);
123 /* update the gd_map */
124 SET_GD_MAP;
125 dollar_zgbldir.str.len = v->str.len;
126 dollar_zgbldir.str.addr = v->str.addr;
127 s2pool(&dollar_zgbldir.str);
128 }
129 if (NULL != gv_currkey)
130 {
131 gv_currkey->base[0] = '\0';
132 gv_currkey->prev = gv_currkey->end = 0;
133 } else if (NULL != gd_header)
134 gvinit();
135 if (NULL != gv_target)
136 gv_target->clue.end = 0;
137 }
138 break;
139 case SV_ZMAXTPTIME:
140 dollar_zmaxtptime = mval2i(v);
141 break;
142 case SV_ZROUTINES:
143 MV_FORCE_STR(v);
144 /* The string(v) should be parsed and loaded before setting $zroutines
145 * to retain the old value in case errors occur while loading */
146 zro_load(&v->str);
147 if (dollar_zroutines.addr)
148 free (dollar_zroutines.addr);
149 dollar_zroutines.addr = (char *)malloc(v->str.len);
150 memcpy (dollar_zroutines.addr, v->str.addr, v->str.len);
151 dollar_zroutines.len = v->str.len;
152 break;
153 case SV_ZSOURCE:
154 MV_FORCE_STR(v);
155 dollar_zsource = v->str;
156 break;
157 case SV_ZTRAP:
158 MV_FORCE_STR(v);
159 if (ztrap_new)
160 op_newintrinsic(SV_ZTRAP);
161 dollar_ztrap.mvtype = MV_STR;
162 dollar_ztrap.str = v->str;
163 /* Setting either $ZTRAP or $ETRAP to empty causes any current error trapping to be canceled */
164 if (!v->str.len)
165 {
166 dollar_etrap.mvtype = MV_STR;
167 dollar_etrap.str = v->str;
168 ztrap_explicit_null = TRUE;
169 } else /* Ensure that $ETRAP and $ZTRAP are not both active at the same time */
170 {
171 ztrap_explicit_null = FALSE;
172 if (dollar_etrap.str.len > 0)
173 gtm_newintrinsic(&dollar_etrap);
174 }
175 if (ztrap_form & ZTRAP_POP)
176 ztrap_save_ctxt();
177 break;
178 case SV_ZSTATUS:
179 MV_FORCE_STR(v);
180 dollar_zstatus.mvtype = MV_STR;
181 dollar_zstatus.str = v->str;
182 break;
183 case SV_PROMPT:
184 MV_FORCE_STR(v);
185 MV_FORCE_LEN_STRICT(v); /* Ensure that direct mode prompt will not have BADCHARs,
186 otherwise the BADCHAR error may fill up the filesystem */
187 if (v->str.len <= sizeof(prombuf))
188 gtmprompt.len = v->str.len;
189 else if (!gtm_utf8_mode)
190 gtmprompt.len = sizeof(prombuf);
191#ifdef UNICODE_SUPPORTED
192 else
193 {
194 UTF8_LEADING_BYTE(v->str.addr + sizeof(prombuf), v->str.addr, vptr);
195 gtmprompt.len = INTCAST(vptr - v->str.addr);
196 }
197#endif
198 memcpy(gtmprompt.addr, v->str.addr, gtmprompt.len);
199 break;
200 case SV_ECODE:
201 MV_FORCE_STR(v);
202 if (v->str.len)
203 {
204 /* Format must be like ,Mnnn,Mnnn,Zxxx,Uxxx,
205 * Mnnn are ANSI standard error codes
206 * Zxxx are implementation-specific codes
207 * Uxxx are end-user defined codes
208 * Note that there must be commas at the start and at the end
209 */
210 for (state = 2, i = 0; (i < v->str.len) && (state <= 2); i++)
211 {
212 switch(state)
213 {
214 case 2: state = (v->str.addr[i] == ',') ? 1 : 101;
215 break;
216 case 1: state = ((v->str.addr[i] == 'M') ||
217 (v->str.addr[i] == 'U') ||
218 (v->str.addr[i] == 'Z')) ? 0 : 101;
219 break;
220 case 0: state = (v->str.addr[i] == ',') ? 1 : 0;
221 break;
222 }
223 }
224 /* The above check would pass strings like ","
225 * so double-check that there are at least three characters
226 * (starting comma, ending comma, and something in between)
227 */
228 if ((state != 1) || (v->str.len < 3))
229 {
230 /* error, ecode = M101 */
231 rts_error(VARLSTCNT(4) ERR_INVECODEVAL, 2, v->str.len, v->str.addr);
232 }
233 }
234 if (v->str.len > 0)
235 {
236 ecode_add(&v->str);
237 rts_error(VARLSTCNT(2) ERR_SETECODE, 0);
238 } else
239 {
240 NULLIFY_DOLLAR_ECODE; /* reset $ECODE related variables to correspond to $ECODE = NULL state */
241 NULLIFY_ERROR_FRAME; /* we are no more in error-handling mode */
242 }
243 break;
244 case SV_ETRAP:
245 MV_FORCE_STR(v);
246 dollar_etrap.mvtype = MV_STR;
247 dollar_etrap.str = v->str;
248 /* Setting either $ZTRAP or $ETRAP to empty causes any current error trapping to be canceled */
249 if (!v->str.len)
250 {
251 dollar_ztrap.mvtype = MV_STR;
252 dollar_ztrap.str = v->str;
253 } else if (dollar_ztrap.str.len > 0)
254 { /* Ensure that $ETRAP and $ZTRAP are not both active at the same time */
255 assert(FALSE == ztrap_explicit_null);
256 gtm_newintrinsic(&dollar_ztrap);
257 }
258 ztrap_explicit_null = FALSE;
259 break;
260 case SV_ZERROR:
261 MV_FORCE_STR(v);
262 dollar_zerror.mvtype = MV_STR;
263 dollar_zerror.str = v->str;
264 break;
265 case SV_ZYERROR:
266 MV_FORCE_STR(v);
267 dollar_zyerror.mvtype = MV_STR;
268 dollar_zyerror.str = v->str;
269 break;
270 case SV_SYSTEM:
271 ok = 1;
272 if (!(v->mvtype & MV_STR))
273 ok = 0;
274 if (ok && v->str.addr[0] != '4')
275 ok = 0;
276 if (ok && v->str.addr[1] != '7')
277 ok = 0;
278 if ((' ' != v->str.addr[2]) && !ispunct(v->str.addr[2]))
279 ok = 0;
280 if (ok)
281 dollar_system.str = v->str;
282 else
283 rts_error(VARLSTCNT(4) ERR_SYSTEMVALUE, 2, v->str.len, v->str.addr);
284 break;
285 case SV_ZDIR:
286 setzdir(v, NULL); /* change directory to v */
287 getzdir(); /* update dollar_zdir with current working directory */
288 break;
289 case SV_ZINTERRUPT:
290 MV_FORCE_STR(v);
291 dollar_zinterrupt.mvtype = MV_STR;
292 dollar_zinterrupt.str = v->str;
293 break;
294 case SV_ZDATE_FORM:
295 MV_FORCE_NUM(v);
296 zdate_form = (short)MV_FORCE_INT(v);
297 break;
298 case SV_ZTEXIT:
299 MV_FORCE_STR(v);
300 dollar_ztexit.mvtype = MV_STR;
301 dollar_ztexit.str = v->str;
302 /* Coercing $ZTEXIT to boolean at SET command is more efficient than coercing before each
303 * rethrow at TR/TRO. Since we want to maintain dollar_ztexit as a string, coercion should
304 * not be performed on dollar_ztext, but on a temporary (i.e. parameter v) */
305 dollar_ztexit_bool = MV_FORCE_BOOL(v);
306 break;
307 case SV_ZQUIT:
308 dollar_zquit_anyway = MV_FORCE_BOOL(v);
309 break;
310 default:
311 GTMASSERT;
312 }
313 return;
314}
0315
=== added directory 'src/gtm/sr_unix'
=== added file 'src/gtm/sr_unix/gtm_logicals.h'
--- src/gtm/sr_unix/gtm_logicals.h 1970-01-01 00:00:00 +0000
+++ src/gtm/sr_unix/gtm_logicals.h 2009-02-13 06:21:27 +0000
@@ -0,0 +1,94 @@
1/****************************************************************
2 * *
3 * Copyright 2001, 2008 Fidelity Information Services, Inc *
4 * *
5 * This source code contains the intellectual property *
6 * of its copyright holder(s), and is made available *
7 * under a license. If you do not know the terms of *
8 * the license, please stop and do not read further. *
9 * *
10 ****************************************************************/
11
12/* gtm_logicals.h - Environment variables used by GT.M. */
13
14/* -------------------------- Common to Unix and VMS -------------------------- */
15
16#define GTM_DIST_LOG "$gtm_dist"
17
18/* Database */
19#define GTM_GBLDIR "$gtmgbldir"
20#define GTM_ENV_XLATE "$gtm_env_translate"
21#define GTM_GVDUPSETNOOP "$gtm_gvdupsetnoop"
22#define GTM_GVUNDEF_FATAL "$gtm_gvundef_fatal"
23#define GTM_GDSCERT "$gtm_gdscert"
24#define GTM_BLKUPGRADE_FLAG "$gtm_blkupgrade_flag"
25#define GTM_DBFILEXT_SYSLOG_DISABLE "$gtm_dbfilext_syslog_disable"
26#define GTM_TP_ALLOCATION_CLUE "$gtm_tp_allocation_clue"
27#define GTM_TPRESTART_LOG_DELTA "$gtm_tprestart_log_delta"
28#define GTM_TPRESTART_LOG_LIMIT "$gtm_tprestart_log_first"
29#define GTM_FULLBLOCKWRITES "$gtm_fullblockwrites"
30
31/* White-box testing */
32#define GTM_WHITE_BOX_TEST_CASE_ENABLE "$gtm_white_box_test_case_enable"
33#define GTM_WHITE_BOX_TEST_CASE_NUMBER "$gtm_white_box_test_case_number"
34#define GTM_WHITE_BOX_TEST_CASE_COUNT "$gtm_white_box_test_case_count"
35
36/* Indirection-cache */
37#define GTM_MAX_INDRCACHE_MEMORY "$gtm_max_indrcache_memory"
38#define GTM_MAX_INDRCACHE_COUNT "$gtm_max_indrcache_count"
39
40/* MUPIP BACKUP */
41# define GTM_BAK_TEMPDIR_LOG_NAME "$GTM_BAKTMPDIR"
42
43/* Pattern match operator */
44#define PAT_FILE "$gtm_pattern_file"
45#define PAT_TABLE "$gtm_pattern_table"
46
47/* Alternative Collation */
48#define CT_PREFIX "$gtm_collate_"
49#define LCT_PREFIX "$gtm_local_collate"
50#define LCT_STDNULL "$gtm_lct_stdnull"
51
52/* Miscellaneous */
53#define GTM_DEBUG_LEVEL_ENVLOG "$gtmdbglvl"
54#define GTM_PRINCIPAL "$gtm_principal"
55#define GTM_ZINTERRUPT "$gtm_zinterrupt"
56#define SYSID "$gtm_sysid"
57#define ZCOMPILE "$gtmcompile"
58#define GTM_ZROUTINES "$gtmroutines"
59#define ZYERROR "$gtm_zyerror"
60#define ZTRAP_FORM "$gtm_ztrap_form"
61#define ZTRAP_NEW "$gtm_ztrap_new"
62#define ZDATE_FORM "$gtm_zdate_form"
63#define DISABLE_ALIGN_STRINGS "$gtm_disable_alignstr"
64#define GTM_MAX_SOCKETS "$gtm_max_sockets"
65#define GTM_MEMORY_RESERVE "$gtm_memory_reserve"
66#define GTM_ZQUIT_ANYWAY "$gtm_zquit_anyway"
67#define GTM_NOUNDEF "$gtm_noundef"
68#define GTM_PROMPT "$gtm_prompt"
69
70/* -------------------------- Unix only -------------------------- */
71
72/* Database */
73#define GTM_TMP_ENV "$gtm_tmp"
74#define GTM_SHMFLAGS "$gtm_shmatflags"
75
76/* Replication */
77#define GTM_REPL_INSTANCE "$gtm_repl_instance"
78#define GTM_REPL_INSTNAME "$gtm_repl_instname"
79#define GTM_REPL_INSTSECONDARY "$gtm_repl_instsecondary"
80#define GTM_ZLIB_CMP_LEVEL "$gtm_zlib_cmp_level"
81#define GTM_EVENT_LOG_LIB_ENV "$gtm_event_log_libpath"
82#define GTM_EVENT_LOG_RTN_ENV "$gtm_event_log_rtn"
83
84/* Unicode */
85#define GTM_CHSET_ENV "$gtm_chset"
86#define GTM_PATNUMERIC_ENV "$gtm_patnumeric"
87#define GTM_BADCHAR_ENV "$gtm_badchar"
88#define GTM_ICU_MINOR_ENV "$gtm_icu_minorver"
89
90/* Miscellaneous */
91#define GTM_LOG_ENV "$gtm_log"
92#define GTM_PRINCIPAL_EDITING "$gtm_principal_editing"
93#define GTM_QUIET_HALT "$gtm_quiet_halt"
94#define GTM_NON_BLOCKED_WRITE_RETRIES "$gtm_non_blocked_write_retries"

Subscribers

People subscribed via source and target branches