2 * See the file LICENSE for redistribution information.
4 * Copyright (c) 1996, 1997
5 * Sleepycat Software. All rights reserved.
10 static const char sccsid[] = "@(#)hash_conv.c 10.4 (Sleepycat) 9/15/97";
13 #ifndef NO_SYSTEM_INCLUDES
14 #include <sys/types.h>
24 * Convert host-specific page layout from the host-independent format
27 * PUBLIC: int __ham_pgin __P((db_pgno_t, void *, DBT *));
30 __ham_pgin(pg, pp, cookie)
38 pginfo = (DB_PGINFO *)cookie->data;
39 tpgno = PGNO((PAGE *)pp);
43 if (pg != PGNO_METADATA && pg != tpgno) {
44 P_INIT(pp, pginfo->db_pagesize,
45 pg, PGNO_INVALID, PGNO_INVALID, 0, P_HASH);
49 if (!pginfo->needswap)
51 return (pg == PGNO_METADATA ?
52 __ham_mswap(pp) : __db_pgin(pg, pginfo->db_pagesize, pp));
57 * Convert host-specific page layout to the host-independent format
60 * PUBLIC: int __ham_pgout __P((db_pgno_t, void *, DBT *));
63 __ham_pgout(pg, pp, cookie)
70 pginfo = (DB_PGINFO *)cookie->data;
71 if (!pginfo->needswap)
73 return (pg == PGNO_METADATA ?
74 __ham_mswap(pp) : __db_pgout(pg, pginfo->db_pagesize, pp));
79 * Swap the bytes on the hash metadata page.
81 * PUBLIC: int __ham_mswap __P((void *));
91 SWAP32(p); /* lsn part 1 */
92 SWAP32(p); /* lsn part 2 */
94 SWAP32(p); /* magic */
95 SWAP32(p); /* version */
96 SWAP32(p); /* pagesize */
97 SWAP32(p); /* ovfl_point */
98 SWAP32(p); /* last_freed */
99 SWAP32(p); /* max_bucket */
100 SWAP32(p); /* high_mask */
101 SWAP32(p); /* low_mask */
102 SWAP32(p); /* ffactor */
103 SWAP32(p); /* nelem */
104 SWAP32(p); /* h_charkey */
105 SWAP32(p); /* flags */
106 for (i = 0; i < NCACHED; ++i)
107 SWAP32(p); /* spares */