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.3 (Sleepycat) 6/21/97";
13 #ifndef NO_SYSTEM_INCLUDES
14 #include <sys/types.h>
23 * __h_pgin, __ham_pgout --
24 * Convert host-specific page layout to/from the host-independent
25 * format stored on disk.
27 * PUBLIC: int __ham_pgin __P((db_pgno_t, void *, DBT *));
28 * PUBLIC: int __ham_pgout __P((db_pgno_t, void *, DBT *));
31 __ham_pgin(pg, pp, cookie)
39 pginfo = (DB_PGINFO *)cookie->data;
40 tpgno = PGNO((PAGE *)pp);
44 if (pg != PGNO_METADATA && pg != tpgno) {
45 P_INIT(pp, pginfo->db_pagesize,
46 pg, PGNO_INVALID, PGNO_INVALID, 0, P_HASH);
50 if (!pginfo->needswap)
52 return (pg == PGNO_METADATA ? __ham_mswap(pp) : __db_pgin(pg, pp));
56 __ham_pgout(pg, pp, cookie)
63 pginfo = (DB_PGINFO *)cookie->data;
64 if (!pginfo->needswap)
66 return (pg == PGNO_METADATA ? __ham_mswap(pp) : __db_pgout(pg, pp));
71 * Swap the bytes on the hash metadata page.
73 * PUBLIC: int __ham_mswap __P((void *));
83 SWAP32(p); /* lsn part 1 */
84 SWAP32(p); /* lsn part 2 */
86 SWAP32(p); /* magic */
87 SWAP32(p); /* version */
88 SWAP32(p); /* pagesize */
89 SWAP32(p); /* ovfl_point */
90 SWAP32(p); /* last_freed */
91 SWAP32(p); /* max_bucket */
92 SWAP32(p); /* high_mask */
93 SWAP32(p); /* low_mask */
94 SWAP32(p); /* ffactor */
95 SWAP32(p); /* nelem */
96 SWAP32(p); /* h_charkey */
97 SWAP32(p); /* flags */
98 for (i = 0; i < NCACHED; ++i)
99 SWAP32(p); /* spares */