andre@3: /*- andre@3: * Copyright (c) 1990, 1993, 1994 andre@3: * The Regents of the University of California. All rights reserved. andre@3: * andre@3: * This code is derived from software contributed to Berkeley by andre@3: * Margo Seltzer. andre@3: * andre@3: * Redistribution and use in source and binary forms, with or without andre@3: * modification, are permitted provided that the following conditions andre@3: * are met: andre@3: * 1. Redistributions of source code must retain the above copyright andre@3: * notice, this list of conditions and the following disclaimer. andre@3: * 2. Redistributions in binary form must reproduce the above copyright andre@3: * notice, this list of conditions and the following disclaimer in the andre@3: * documentation and/or other materials provided with the distribution. andre@3: * 3. ***REMOVED*** - see andre@3: * ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change andre@3: * 4. Neither the name of the University nor the names of its contributors andre@3: * may be used to endorse or promote products derived from this software andre@3: * without specific prior written permission. andre@3: * andre@3: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND andre@3: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE andre@3: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE andre@3: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE andre@3: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL andre@3: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS andre@3: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) andre@3: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT andre@3: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY andre@3: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF andre@3: * SUCH DAMAGE. andre@3: * andre@3: * @(#)page.h 8.2 (Berkeley) 5/31/94 andre@3: */ andre@3: andre@3: /* andre@3: * Definitions for hashing page file format. andre@3: */ andre@3: andre@3: /* andre@3: * routines dealing with a data page andre@3: * andre@3: * page format: andre@3: * +------------------------------+ andre@3: * p | n | keyoff | datoff | keyoff | andre@3: * +------------+--------+--------+ andre@3: * | datoff | free | ptr | --> | andre@3: * +--------+---------------------+ andre@3: * | F R E E A R E A | andre@3: * +--------------+---------------+ andre@3: * | <---- - - - | data | andre@3: * +--------+-----+----+----------+ andre@3: * | key | data | key | andre@3: * +--------+----------+----------+ andre@3: * andre@3: * Pointer to the free space is always: p[p[0] + 2] andre@3: * Amount of free space on the page is: p[p[0] + 1] andre@3: */ andre@3: andre@3: /* andre@3: * How many bytes required for this pair? andre@3: * 2 shorts in the table at the top of the page + room for the andre@3: * key and room for the data andre@3: * andre@3: * We prohibit entering a pair on a page unless there is also room to append andre@3: * an overflow page. The reason for this it that you can get in a situation andre@3: * where a single key/data pair fits on a page, but you can't append an andre@3: * overflow page and later you'd have to split the key/data and handle like andre@3: * a big pair. andre@3: * You might as well do this up front. andre@3: */ andre@3: #ifndef PAGE_H andre@3: #define PAGE_H andre@3: andre@3: #define PAIRSIZE(K,D) (2*sizeof(uint16) + (K)->size + (D)->size) andre@3: #define BIGOVERHEAD (4*sizeof(uint16)) andre@3: #define KEYSIZE(K) (4*sizeof(uint16) + (K)->size); andre@3: #define OVFLSIZE (2*sizeof(uint16)) andre@3: #define FREESPACE(P) ((P)[(P)[0]+1]) andre@3: #define OFFSET(P) ((P)[(P)[0]+2]) andre@3: #define PAIRFITS(P,K,D) \ andre@3: (((P)[2] >= REAL_KEY) && \ andre@3: (PAIRSIZE((K),(D)) + OVFLSIZE) <= FREESPACE((P))) andre@3: #define PAGE_META(N) (((N)+3) * sizeof(uint16)) andre@3: andre@3: typedef struct { andre@3: BUFHEAD *newp; andre@3: BUFHEAD *oldp; andre@3: BUFHEAD *nextp; andre@3: uint16 next_addr; andre@3: } SPLIT_RETURN; andre@3: #endif andre@3: