00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "db_config.h"
00011
00012 #ifndef NO_SYSTEM_INCLUDES
00013 #include <sys/types.h>
00014 #endif
00015
00016 #include "db_int.h"
00017 #include "dbinc/db_page.h"
00018 #include "dbinc/db_swap.h"
00019 #include "dbinc/hash.h"
00020
00021
00022
00023
00024
00025
00026
00027
00028 int
00029 __ham_pgin(dbenv, dummydbp, pg, pp, cookie)
00030 DB_ENV *dbenv;
00031 DB *dummydbp;
00032 db_pgno_t pg;
00033 void *pp;
00034 DBT *cookie;
00035 {
00036 DB_PGINFO *pginfo;
00037 PAGE *h;
00038
00039 h = pp;
00040 pginfo = (DB_PGINFO *)cookie->data;
00041
00042
00043
00044
00045
00046
00047 if (h->type != P_HASHMETA && h->pgno == PGNO_INVALID) {
00048 P_INIT(pp, (db_indx_t)pginfo->db_pagesize,
00049 pg, PGNO_INVALID, PGNO_INVALID, 0, P_HASH);
00050 return (0);
00051 }
00052
00053 if (!F_ISSET(pginfo, DB_AM_SWAP))
00054 return (0);
00055
00056 return (h->type == P_HASHMETA ? __ham_mswap(pp) :
00057 __db_byteswap(dbenv, dummydbp, pg, pp, pginfo->db_pagesize, 1));
00058 }
00059
00060
00061
00062
00063
00064
00065
00066
00067 int
00068 __ham_pgout(dbenv, dummydbp, pg, pp, cookie)
00069 DB_ENV *dbenv;
00070 DB *dummydbp;
00071 db_pgno_t pg;
00072 void *pp;
00073 DBT *cookie;
00074 {
00075 DB_PGINFO *pginfo;
00076 PAGE *h;
00077
00078 pginfo = (DB_PGINFO *)cookie->data;
00079 if (!F_ISSET(pginfo, DB_AM_SWAP))
00080 return (0);
00081
00082 h = pp;
00083 return (h->type == P_HASHMETA ? __ham_mswap(pp) :
00084 __db_byteswap(dbenv, dummydbp, pg, pp, pginfo->db_pagesize, 0));
00085 }
00086
00087
00088
00089
00090
00091
00092
00093 int
00094 __ham_mswap(pg)
00095 void *pg;
00096 {
00097 u_int8_t *p;
00098 int i;
00099
00100 __db_metaswap(pg);
00101
00102 p = (u_int8_t *)pg + sizeof(DBMETA);
00103
00104 SWAP32(p);
00105 SWAP32(p);
00106 SWAP32(p);
00107 SWAP32(p);
00108 SWAP32(p);
00109 SWAP32(p);
00110 for (i = 0; i < NCACHED; ++i)
00111 SWAP32(p);
00112 p += 59 * sizeof(u_int32_t);
00113 SWAP32(p);
00114 return (0);
00115 }