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