1*ed857e95Sphil /* $NetBSD: const.h,v 1.1 2017/04/10 02:28:23 phil Exp $ */ 2*ed857e95Sphil 3*ed857e95Sphil /* 4*ed857e95Sphil * Copyright (C) 1991-1994, 1997, 2006, 2008, 2012-2017 Free Software Foundation, Inc. 5*ed857e95Sphil * Copyright (C) 2016-2017 Philip A. Nelson. 6*ed857e95Sphil * All rights reserved. 7*ed857e95Sphil * 8*ed857e95Sphil * Redistribution and use in source and binary forms, with or without 9*ed857e95Sphil * modification, are permitted provided that the following conditions 10*ed857e95Sphil * are met: 11*ed857e95Sphil * 12*ed857e95Sphil * 1. Redistributions of source code must retain the above copyright 13*ed857e95Sphil * notice, this list of conditions and the following disclaimer. 14*ed857e95Sphil * 2. Redistributions in binary form must reproduce the above copyright 15*ed857e95Sphil * notice, this list of conditions and the following disclaimer in the 16*ed857e95Sphil * documentation and/or other materials provided with the distribution. 17*ed857e95Sphil * 3. The names Philip A. Nelson and Free Software Foundation may not be 18*ed857e95Sphil * used to endorse or promote products derived from this software 19*ed857e95Sphil * without specific prior written permission. 20*ed857e95Sphil * 21*ed857e95Sphil * THIS SOFTWARE IS PROVIDED BY PHILIP A. NELSON ``AS IS'' AND ANY EXPRESS OR 22*ed857e95Sphil * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23*ed857e95Sphil * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24*ed857e95Sphil * IN NO EVENT SHALL PHILIP A. NELSON OR THE FREE SOFTWARE FOUNDATION BE 25*ed857e95Sphil * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26*ed857e95Sphil * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27*ed857e95Sphil * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28*ed857e95Sphil * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29*ed857e95Sphil * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30*ed857e95Sphil * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 31*ed857e95Sphil * THE POSSIBILITY OF SUCH DAMAGE. 32*ed857e95Sphil */ 33*ed857e95Sphil 34*ed857e95Sphil /* const.h: Constants for bc. */ 35*ed857e95Sphil 36*ed857e95Sphil /* Define INT_MAX and LONG_MAX if not defined. Assuming 32 bits... */ 37*ed857e95Sphil 38*ed857e95Sphil #ifndef INT_MAX 39*ed857e95Sphil #define INT_MAX 0x7FFFFFFF 40*ed857e95Sphil #endif 41*ed857e95Sphil #ifndef LONG_MAX 42*ed857e95Sphil #define LONG_MAX 0x7FFFFFFF 43*ed857e95Sphil #endif 44*ed857e95Sphil 45*ed857e95Sphil 46*ed857e95Sphil /* Define constants in some reasonable size. The next 4 constants are 47*ed857e95Sphil POSIX constants. */ 48*ed857e95Sphil 49*ed857e95Sphil #ifdef BC_BASE_MAX 50*ed857e95Sphil /* <limits.h> on a POSIX.2 system may have defined these. Override. */ 51*ed857e95Sphil # undef BC_BASE_MAX 52*ed857e95Sphil # undef BC_SCALE_MAX 53*ed857e95Sphil # undef BC_STRING_MAX 54*ed857e95Sphil # undef BC_DIM_MAX 55*ed857e95Sphil #endif 56*ed857e95Sphil 57*ed857e95Sphil #define BC_BASE_MAX INT_MAX 58*ed857e95Sphil #define BC_SCALE_MAX INT_MAX 59*ed857e95Sphil #define BC_STRING_MAX INT_MAX 60*ed857e95Sphil 61*ed857e95Sphil 62*ed857e95Sphil /* Definitions for arrays. */ 63*ed857e95Sphil 64*ed857e95Sphil #define BC_DIM_MAX 16777215 /* this should be NODE_SIZE^NODE_DEPTH-1 */ 65*ed857e95Sphil 66*ed857e95Sphil #define NODE_SIZE 64 /* Must be a power of 2. */ 67*ed857e95Sphil #define NODE_MASK 0x3f /* Must be NODE_SIZE-1. */ 68*ed857e95Sphil #define NODE_SHIFT 6 /* Number of 1 bits in NODE_MASK. */ 69*ed857e95Sphil #define NODE_DEPTH 4 70*ed857e95Sphil 71*ed857e95Sphil 72*ed857e95Sphil /* Other BC limits defined but not part of POSIX. */ 73*ed857e95Sphil 74*ed857e95Sphil #define BC_LABEL_GROUP 64 75*ed857e95Sphil #define BC_LABEL_LOG 6 76*ed857e95Sphil #define BC_START_SIZE 1024 /* Initial code body size. */ 77*ed857e95Sphil 78*ed857e95Sphil /* Maximum number of variables, arrays and functions and the 79*ed857e95Sphil allocation increment for the dynamic arrays. */ 80*ed857e95Sphil 81*ed857e95Sphil #define MAX_STORE 32767 82*ed857e95Sphil #define STORE_INCR 32 83*ed857e95Sphil 84*ed857e95Sphil /* Other interesting constants. */ 85*ed857e95Sphil 86*ed857e95Sphil #define FALSE 0 87*ed857e95Sphil #define TRUE 1 88*ed857e95Sphil 89*ed857e95Sphil /* for use with lookup (). */ 90*ed857e95Sphil #define SIMPLE 0 91*ed857e95Sphil #define ARRAY 1 92*ed857e95Sphil #define FUNCT 2 93*ed857e95Sphil #define FUNCTDEF 3 94*ed857e95Sphil 95*ed857e95Sphil #ifdef __STDC__ 96*ed857e95Sphil #define CONST const 97*ed857e95Sphil #define VOID void 98*ed857e95Sphil #else 99*ed857e95Sphil #define CONST 100*ed857e95Sphil #define VOID 101*ed857e95Sphil #endif 102