xref: /titanic_44/usr/src/lib/libast/common/cdt/dthdr.h (revision 3e14f97f673e8a630f076077de35afdd43dc1587)
1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *          Copyright (c) 1985-2010 AT&T Intellectual Property          *
5 *                      and is licensed under the                       *
6 *                  Common Public License, Version 1.0                  *
7 *                    by AT&T Intellectual Property                     *
8 *                                                                      *
9 *                A copy of the License is available at                 *
10 *            http://www.opensource.org/licenses/cpl1.0.txt             *
11 *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
12 *                                                                      *
13 *              Information and Software Systems Research               *
14 *                            AT&T Research                             *
15 *                           Florham Park NJ                            *
16 *                                                                      *
17 *                 Glenn Fowler <gsf@research.att.com>                  *
18 *                  David Korn <dgk@research.att.com>                   *
19 *                   Phong Vo <kpv@research.att.com>                    *
20 *                                                                      *
21 ***********************************************************************/
22 #ifndef _DTHDR_H
23 #define _DTHDR_H	1
24 #ifndef _BLD_cdt
25 #define _BLD_cdt	1
26 #endif
27 
28 /*	Internal definitions for libcdt.
29 **	Written by Kiem-Phong Vo (5/25/96)
30 */
31 
32 #if _PACKAGE_ast
33 #include	<ast.h>
34 #endif
35 
36 #include	<cdt.h>
37 
38 /* short-hand notations */
39 #define NIL(t)	((t)0)
40 #define reg	register
41 #define uint	unsigned int
42 #define left	hl._left
43 #define hash	hl._hash
44 #define htab	hh._htab
45 #define head	hh._head
46 
47 /* this must be disjoint from DT_METHODS */
48 #define DT_FLATTEN	010000	/* dictionary already flattened	*/
49 #define DT_WALK		020000	/* hash table being walked	*/
50 
51 /* how the Dt_t handle was allocated */
52 #define DT_MALLOC	0
53 #define DT_MEMORYF	1
54 
55 /* max search length before splaying */
56 #define DT_MINP		(sizeof(size_t)*8 - 2)
57 
58 /* hash start size and load factor */
59 #define HSLOT		(256)
60 #define HRESIZE(n)	((n) << 1)
61 #define HLOAD(s)	((s) << 1)
62 #define HINDEX(n,h)	((h)&((n)-1))
63 
64 #define UNFLATTEN(dt) \
65 		((dt->data->type&DT_FLATTEN) ? dtrestore(dt,NIL(Dtlink_t*)) : 0)
66 
67 /* tree rotation/linking functions */
68 #define rrotate(x,y)	((x)->left  = (y)->right, (y)->right = (x))
69 #define lrotate(x,y)	((x)->right = (y)->left,  (y)->left  = (x))
70 #define rlink(r,x)	((r) = (r)->left   = (x) )
71 #define llink(l,x)	((l) = (l)->right  = (x) )
72 
73 #define RROTATE(x,y)	(rrotate(x,y), (x) = (y))
74 #define LROTATE(x,y)	(lrotate(x,y), (x) = (y))
75 
76 #if !_PACKAGE_ast
77 _BEGIN_EXTERNS_
78 extern Void_t*	malloc _ARG_((size_t));
79 extern Void_t*	realloc _ARG_((Void_t*, size_t));
80 extern void	free _ARG_((Void_t*));
81 _END_EXTERNS_
82 #endif
83 
84 #endif /* _DTHDR_H */
85