#include "config.h"
#ifndef lint
static const char sccsid[] = "@(#)hash_conv.c 10.4 (Sleepycat) 9/15/97";
static const char sccsi2[] = "%W% (Sun) %G%";
#endif
#ifndef NO_SYSTEM_INCLUDES
#include <sys/types.h>
#endif
#include "db_int.h"
#include "db_page.h"
#include "db_swap.h"
#include "hash.h"
int
__ham_pgin(pg, pp, cookie)
db_pgno_t pg;
void *pp;
DBT *cookie;
{
DB_PGINFO *pginfo;
u_int32_t tpgno;
pginfo = (DB_PGINFO *)cookie->data;
tpgno = PGNO((PAGE *)pp);
if (pginfo->needswap)
M_32_SWAP(tpgno);
if (pg != PGNO_METADATA && pg != tpgno) {
P_INIT(pp, pginfo->db_pagesize,
pg, PGNO_INVALID, PGNO_INVALID, 0, P_HASH);
return (0);
}
if (!pginfo->needswap)
return (0);
return (pg == PGNO_METADATA ?
__ham_mswap(pp) : __db_pgin(pg, pginfo->db_pagesize, pp));
}
int
__ham_pgout(pg, pp, cookie)
db_pgno_t pg;
void *pp;
DBT *cookie;
{
DB_PGINFO *pginfo;
pginfo = (DB_PGINFO *)cookie->data;
if (!pginfo->needswap)
return (0);
return (pg == PGNO_METADATA ?
__ham_mswap(pp) : __db_pgout(pg, pginfo->db_pagesize, pp));
}
int
__ham_mswap(pg)
void *pg;
{
u_int8_t *p;
int i;
p = (u_int8_t *)pg;
SWAP32(p);
SWAP32(p);
SWAP32(p);
SWAP32(p);
SWAP32(p);
SWAP32(p);
SWAP32(p);
SWAP32(p);
SWAP32(p);
SWAP32(p);
SWAP32(p);
SWAP32(p);
SWAP32(p);
SWAP32(p);
SWAP32(p);
for (i = 0; i < NCACHED; ++i)
SWAP32(p);
return (0);
}