2 * Copyright (c) 1983 Regents of the University of California.
5 * Redistribution and use in source and binary forms are permitted
6 * provided that: (1) source distributions retain this entire copyright
7 * notice and comment, and (2) distributions including binaries display
8 * the following acknowledgement: ``This product includes software
9 * developed by the University of California, Berkeley and its contributors''
10 * in the documentation or other materials provided with the distribution
11 * and in all advertising materials mentioning features or use of this
12 * software. Neither the name of the University nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 static char sccsid[] = "@(#)lookup.c 5.4 (Berkeley) 6/1/90";
27 * look up an address in a sorted-by-address namelist
28 * this deals with misses by mapping them to the next lower
32 nltype *dbg_nllookup();
37 unsigned long address;
47 for ( low = 0 , high = nname - 1 ; low != high ; ) {
51 middle = ( high + low ) >> 1;
52 if ( nl[ middle ].value <= address && nl[ middle+1 ].value > address ) {
54 if ( debug & LOOKUPDEBUG ) {
55 printf( "[nllookup] %d (%d) probes\n" , probes , nname-1 );
60 if ( nl[ middle ].value > address ) {
66 if(nl[middle+1].value <= address) {
68 if (debug & LOOKUPDEBUG ) {
69 printf("[nllookup] %d (%d) probes, fall off\n", probes, nname-1);
74 fprintf( stderr , "[nllookup] binary search fails???\n" );
76 dbg_nllookup(address);
83 dbg_nllookup( address )
84 unsigned long address;
89 fprintf(stderr,"[nllookup] address 0x%x\n",address);
91 for ( low = 0 , high = nname - 1 ; low != high ; ) {
93 middle = ( high + low ) >> 1;
94 fprintf(stderr, "[nllookup] low 0x%x middle 0x%x high 0x%x nl[m] 0x%x nl[m+1] 0x%x\n",
95 low,middle,high,nl[middle].value,nl[middle+1].value);
96 if ( nl[ middle ].value <= address && nl[ middle+1 ].value > address) {
99 if ( nl[ middle ].value > address ) {
105 fprintf( stderr , "[nllookup] binary search fails???\n" );
111 arclookup( parentp , childp )
117 if ( parentp == 0 || childp == 0 ) {
118 printf( "[arclookup] parentp == 0 || childp == 0\n" );
122 if ( debug & LOOKUPDEBUG ) {
123 printf( "[arclookup] parent %s child %s\n" ,
124 parentp -> name , childp -> name );
127 for ( arcp = parentp -> children ; arcp ; arcp = arcp -> arc_childlist ) {
129 if ( debug & LOOKUPDEBUG ) {
130 printf( "[arclookup]\t arc_parent %s arc_child %s\n" ,
131 arcp -> arc_parentp -> name ,
132 arcp -> arc_childp -> name );
135 if ( arcp -> arc_childp == childp ) {