/*
 *  Configuration parameters that depend on computer architecture.
 *  Some depend on values defined in config.h, which is always
 *  included before this file.
 */

#ifndef CStateSize
#define CStateSize 15			/* size of C state for co-expressions */
#endif					/* CStateSize */

/*
 * The following definitions depend on the sizes of ints and pointers.
 */

/*
 * Most of the present implementations use 32-bit "words".  The section
 *  for 64-bit words is tentative and untested.  16-bit words are no
 *  longer supported.  Note that WordBits is the number of bits in an Icon
 *  integer, not necessarily the number of bits in an int (given by IntBits).
 *  For example, in MS-DOS an Icon integer is a long, not an int.
 *
 *  MaxStrLen must not be so large as to overlap flags.
 */

/*
 * 64-bit words.  NOTE:  This section is under construction!
 */

#if WordBits == 64

#ifndef MinLong
#define MinLong  ((long int)0x8000000000000000) /* smallest long integer */
#endif

#ifndef MaxLong
#define MaxLong  ((long int)0x7fffffffffffffff) /* largest long integer */
#endif

#define MaxDigits 40		/* maximum number of digits in images */
#define MaxStrLen 017777777777L /* maximum string length */

#ifndef MaxNegInt
#define MaxNegInt "-9223372036854775808"
#endif

#ifndef F_Nqual
#define F_Nqual 0x8000000000000000	/* set if NOT string qualifier */
#endif
#ifndef F_Var
#define F_Var	0x4000000000000000	/* set if variable */
#endif
#ifndef F_Tvar
#define F_Tvar	0x2000000000000000	/* set if trapped variable */
#endif
#ifndef F_Ptr
#define F_Ptr	0x1000000000000000	/* set if value field is pointer */
#endif

#endif					/* WordBits == 64 */

/*
 * 32-bit words.
 */

#if WordBits == 32

#define MaxLong  ((long int)017777777777L)   /* largest long integer */
#define MinLong  ((long int)020000000000L)   /* smallest long integer */
#define MaxDigits 20		/* maximum number of digits in images */

#define MaxNegInt "-2147483648"

#define MaxStrLen	     0777777777	/* maximum string length */

#define F_Nqual 0x80000000		/* set if NOT string qualifier */
#define F_Var	0x40000000		/* set if variable */
#define F_Tvar	0x20000000		/* set if trapped variable */
#define F_Ptr	0x10000000		/* set if value field is pointer */
#endif					/* WordBits == 32 */

/* Values that depend on the number of bits in an int (not necessarily
 * the same as the number of bits in a word).
 */

#if IntBits == 64
#define LogIntBits		    6	/* log of IntBits */
#define MaxUnsigned 01777777777777777777777L /* largest unsigned integer */
#define MaxInt	     0777777777777777777777L /* largest int */
/*
 * Cset initialization macros.
 */
#define fwd(w0, w1, w2, w3) \
 ((w0)&0xffff | ((w1)&0xffff)<<16 | ((w2)&0xffff)<<32 | ((w3)&0xffff)<<48)
#define cset_display(w0,w1,w2,w3,w4,w5,w6,w7,w8,w9,wa,wb,wc,wd,we,wf) \
 {fwd(w0,w1,w2,w3),fwd(w4,w5,w6,w7),fwd(w8,w9,wa,wb),fwd(wc,wd,we,wf)}
#endif					/* IntBits == 64 */

#if IntBits == 32
#define LogIntBits		    5	/* log of IntBits */
#define MaxUnsigned 	 037777777777	/* largest unsigned integer */
#define MaxInt	 	  07777777777	/* largest int */
/*
 * Cset initialization macros.
 */
#define twd(w0,w1)	((w0)&0xffff | (w1)<<16)
#define cset_display(w0,w1,w2,w3,w4,w5,w6,w7,w8,w9,wa,wb,wc,wd,we,wf) \
	{twd(w0,w1),twd(w2,w3),twd(w4,w5),twd(w6,w7), \
	 twd(w8,w9),twd(wa,wb),twd(wc,wd),twd(we,wf)}
#endif					/* IntBits == 32 */

#if IntBits == 16
#define LogIntBits	            4	/* log of IntBits */
#define MaxUnsigned ((unsigned int)0177777)	/* largest unsigned integer */
#define MaxInt		      077777	/* largest int */
/*
 * Cset initialization macro.
 */
#define cset_display(w0,w1,w2,w3,w4,w5,w6,w7,w8,w9,wa,wb,wc,wd,we,wf) \
	{w0,w1,w2,w3,w4,w5,w6,w7,w8,w9,wa,wb,wc,wd,we,wf}
#endif					/* IntBits == 16 */

#ifndef LogHuge
#define LogHuge 309			/* maximum base-10 exp+1 of real */
#endif					/* LogHuge */

#ifndef Big
#define Big 9007199254740992.		/* larger than 2^53 lose precision */
#endif					/* Big */

#ifndef Precision
#define Precision 10			/* digits in string from real */
#endif					/* Precision */

/*
 * Parameters that configure tables and sets:
 *
 *  HSlots	Initial number of hash buckets; must be a power of 2.
 *  LogHSlots	Log to the base 2 of HSlots.
 *
 *  HSegs	Maximum number of hash bin segments; the maximum number of
 *		hash bins is HSlots * 2 ^ (HSegs - 1).
 *
 *		If Hsegs is increased above 12, the arrays log2[] and segsize[]
 *		in iconx will need modification.
 *
 *  MaxHLoad	Maximum loading factor; more hash bins are allocated when
 *		the average bin exceeds this many entries.
 *
 *  MinHLoad	Minimum loading factor; if a newly created table (e.g. via
 *		copy()) is more lightly loaded than this, bins are combined.
 *
 *  Because splitting doubles the number of hash bins, and combining halves it,
 *  MaxHLoad should be at least twice MinHLoad.
 */

#ifndef HSlots
#if IntBits == 16
#define HSlots     4
#define LogHSlots  2
#else
#define HSlots     8
#define LogHSlots  3
#endif					/* IntBits */
#endif					/* HSlots */

#if ((1 << LogHSlots) != HSlots)
Deliberate Syntax Error -- HSlots and LogHSlots are inconsistent
#endif					/* HSlots / LogHSlots consistency */

#ifndef HSegs
#if IntBits == 16
#define HSegs	  6
#else
#define HSegs	 10
#endif					/* IntBits */
#endif					/* HSegs */

#ifndef MinHLoad
#define MinHLoad  1
#endif					/* MinHLoad */

#ifndef MaxHLoad
#define MaxHLoad  5
#endif					/* MaxHLoad */

/*
 * The number of bits in each base-B digit; the type DIGIT (unsigned int)
 *  in rt.h must be large enough to hold this many bits.
 *  It must be at least 2 and at most WordBits / 2.
 */

#define NB           (WordBits / 2)

