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