4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
30 #pragma ident "%Z%%M% %I% %E% SMI"
40 #define B (BYTE * sizeof (unsigned))
41 #define L (BYTE * sizeof (long)-1)
42 #define MASK (~((unsigned long)1L<<L))
44 #ifdef pdp11 /* sizeof (unsigned)==sizeof(long)/2 */
45 #define fetch(wp, bp)\
46 (((((long)wp[0]<<B)|wp[1])<<(B-bp))|(wp[2]>>bp))
47 #else /* sizeof (unsigned)==sizeof(long) */
48 #define fetch(wp, bp) ((wp[0] << (B - bp)) | (wp[1] >> bp))
62 t
= h
>>(HASHWIDTH
-INDEXWIDTH
);
63 wp
= &table
[hindex
[t
]];
64 tp
= &table
[hindex
[t
+1]];
66 sum
= (long)t
<<(HASHWIDTH
-INDEXWIDTH
);
70 * this block is equivalent to:
71 * bp -= decode((fetch(wp, bp) >> 1) & MASK, &t);
77 * shift 32 on those machines leaves destination
83 y
= wp
[0] << (B
- bp
);
88 t
= y
>> (long) (L
+1-w
);
91 for (bp
-= w
, v
= v0
; y
>= qcs
;
92 y
= (y
<< 1) & MASK
, v
+= n
)
94 t
= v
+ (y
>> (long)(L
-w
));
101 if (wp
>= tp
&& (wp
> tp
||bp
< B
))
116 #ifdef pdp11 /* because of insufficient address space for buffers */
119 if (open(file
, 0) != 0)
122 if (rhuff(f
) == 0 || read(fileno(f
), (char *)hindex
,
123 NI
* sizeof (*hindex
)) != NI
* sizeof (*hindex
) ||
124 (table
= (unsigned *)malloc(hindex
[NI
-1] * sizeof (*table
))) == 0 ||
125 read(fileno(f
), (char *)table
, sizeof (*table
) * hindex
[NI
-1]) !=
126 hindex
[NI
-1] * sizeof (*table
))
133 if ((f
= fopen(file
, "r")) == NULL
)
136 fread((char *)hindex
, sizeof (*hindex
), NI
, f
) != NI
||
137 (table
= (unsigned *)malloc(hindex
[NI
-1] * sizeof (*table
))) == 0 ||
138 fread((char *)table
, sizeof (*table
), hindex
[NI
-1], f
) !=