/*
 * this sets up the definitions of various terms so we can say
 * PACKBITS=SHIFTANDMASK (which, while not crystal clear, is
 * more understandable than PACKBITS=0)
 */
/****************************************************************
 * Copyright notice.						*
 * This software is copyrighted (c) 1991 by Matt Bishop and the *
 * Trustees of Dartmouth College.  All rights reserved.		*
 *								*
 * Author:	Matt Bishop					*
 * Address:	Department of Mathematics and Computer Science	*
 *		Dartmouth College				*
 *		Hanover, NH  03755-1831				*
 *		USA						*
 * telephone:	+1 603 646 3267					*
 * fax:		+1 603 646 1312					*
 * internet:	Matt.Bishop@dartmouth.edu			*
 * usenet:	...!decvax!dartvax!Matt.Bishop			*
 ****************************************************************/
 
/* Version GAMMA 6/31/91 Matt.Bishop@dartmouth.edu */

/*
 * First, the bit accessing representation (PACKBYTES):
 * do we use shifting, extraction, or alignment to get the most speed?
 * -- masking is using logical and with shifts to access bit fields
 * -- extraction uses bitfield extraction instructions to get bit fields
 * -- alignment forces fields of interest to be aligned on byte boundaries
 *    so byte instructions can be used to get the field
 */
#define	SHIFTANDMASK	0	/* masking */
#define	BITFIELDS	1	/* extraction */
#define	BYTES		2	/* alignment */

/*
 * Next, the salting (COMPSALT):
 * do we precompute the SPE table to include the salting perturbation,
 * or do we use a normal SPE table and perturb it each iteration?
 */
#define ONFLY           0	/* do no precomputation whatsoever */
#define PRECOMPUTE      1	/* compute as needed, save the table */

/*
 * Then, the autoincrement mode (ADDRMODE):
 * do we put the array addresses into another array, and use indirection
 * or do we just put the array addresses directly into the instruction
 * stream?  If the computer has a postincrement addressing mode, the former
 * is probably better; otherwise, the latter probably is.
 */
#define AUTOINC		0	/* use autoincrement mode */
#define IMMED		1	/* use immediate (non-sutoincrement) mode */

/*
 * After that, the byte ordering (BYTEORDER):
 * Currently we support big endian (which is network order) and
 * little endian (reverse network).  There are other orders possible
 * (like pdp-11, which is just downright WEIRD).
 */
#define BIGENDIAN	0	/* MSB is first */
#define LITTLEENDIAN	1	/* LSB is first */

/*
 * Finally, the array indexing (ARRINDEX):
 * Some compilers are really STUPID and generate array indexing instructions
 * using MULTIPLIES instead of shifts.  For these brain-dead compilers, you
 * can set ARRINDEX to TYPEPUN to do the offset computation using some spiffy
 * type punning.  You need both LOFFSET and COFFSET to get away with this,
 * though
 */
#define TYPEPUN		0	/* *(type *)(((unsigned char *)a)+i)) */
#define USUAL		1	/* x = a[i] */
#ifdef ARRINDEX
#	ifndef COFFSET
#		undef	ARRINDEX
#		define	ARRINDEX	USUAL
#	endif
#	ifndef LOFFSET
#		undef	ARRINDEX
#		define	ARRINDEX	USUAL
#	endif
#endif

/*
 * what now follows are the sanity checks
 */
#ifdef PACKBYTES
#	if PACKBYTES != SHIFTANDMASK && PACKBYTES != BITFIELDS && \
							PACKBYTES != BYTES
		error "PACKBITS must be SHIFTANDMASK, BITFIELDS, or BYTES"
#	endif
#endif
#ifdef COMPSALT
#	if COMPSALT != ONFLY && COMPSALT != PRECOMPUTE
		error "COMPSALT must be ONFLY or PRECOMPUTE"
#	endif
#endif
#ifdef ADDRMODE
#	if ADDRMODE != AUTOINC && ADDRMODE != IMMED
		error "ADDRMODE must be AUTOINC or IMMED"
#	endif
#endif
#ifdef BYTEORDER
#	if BYTEORDER != BIGENDIAN && BYTEORDER != LITTLEENDIAN
		error "BYTEORDER must be BIGENDIAN or LITTLEENDIAN"
#	endif
#endif
#ifdef ARRINDEX
#	if ARRINDEX != TYPEPUN && ARRINDEX != USUAL
		error "ARRINDEX must be TYPEPUN or USUAL"
#	endif
#endif
