File: find_rtn_hdr.c

package info (click to toggle)
fis-gtm 6.3-014-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 36,680 kB
  • sloc: ansic: 333,039; asm: 5,180; csh: 4,956; sh: 1,924; awk: 291; makefile: 66; sed: 13
file content (85 lines) | stat: -rw-r--r-- 2,212 bytes parent folder | download | duplicates (2)
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
/****************************************************************
 *								*
 * Copyright (c) 2001-2019 Fidelity National Information	*
 * Services, Inc. and/or its subsidiaries. All rights reserved.	*
 *								*
 *	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.	*
 *								*
 ****************************************************************/

#include "mdef.h"

#include "gtm_string.h"
#include <rtnhdr.h>
#include "min_max.h"
#include "stack_frame.h"
#include "compiler.h"	/* for WANT_CURRENT_RTN_MSTR macro */

GBLREF rtn_tabent	*rtn_names, *rtn_names_end;
GBLREF stack_frame	*frame_pointer;

rhdtyp	*find_rtn_hdr(mstr *name)
{
	rtn_tabent	*rtabent;

	if (WANT_CURRENT_RTN_MSTR(name))	/* want the *current* version on the stack, not the *newest* ZLINK'd version */
		return CURRENT_RHEAD_ADR(frame_pointer->rvector);
	if (find_rtn_tabent(&rtabent, name))
		return rtabent->rt_adr;
	else
		return NULL;
}

/*
 * Returns TRUE if a rtn_tabent exists for routine <name>, i.e. if
 * 	<name> is currently ZLINK'd.
 * Returns FALSE otherwise.
 * In either case, also "returns" (via <res>) the rtn_tabent
 * 	corresponding to the first routine name greater than or equal to
 * 	<name>. This is useful for looking up trigger routines that
 * 	include runtime disambiguators in their names.
 */

boolean_t find_rtn_tabent(rtn_tabent **res, mstr *name)
{
	rtn_tabent	*bot, *top, *mid;
	int4		comp;
	mident		rtn_name;
	mident_fixed	rtn_name_buff;
	boolean_t	ret;
	int		len;

	len = name->len;
	rtn_name.len = MIN(MAX_MIDENT_LEN, len);
	rtn_name.addr = name->addr;
	bot = rtn_names + 1;	/* Exclude the first NULL entry */
	top = rtn_names_end + 1;/* Include the last entry */
	for ( ; ; )
	{
		if (bot == top)
			break;
		assert(bot < top);
		mid = bot + (top - bot) / 2;
		assert(mid >= bot);
		MIDENT_CMP(&mid->rt_name, &rtn_name, comp);
		if (0 == comp)
		{
			*res = mid;
			return TRUE;
		} else if (0 > comp)
		{
			bot = mid + 1;
			continue;
		} else
		{
			assert(mid < top);
			top = mid;
			continue;
		}
	}
	*res = bot;
	return FALSE;
}