diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1998-06-29 00:19:07 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1998-06-29 00:19:07 +0000 |
commit | b0594c55ee89492c0a1d4b8ef6425955998d168c (patch) | |
tree | d7231f13dae2de4fa0af9a9aba0f81d3632777f5 /gnu/usr.bin/bc/dc/dc-regdef.h | |
parent | e038c1555f2e165a35c68bb94f24b03bf9ecc49c (diff) |
GNU bc 1.05a
Diffstat (limited to 'gnu/usr.bin/bc/dc/dc-regdef.h')
-rw-r--r-- | gnu/usr.bin/bc/dc/dc-regdef.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/gnu/usr.bin/bc/dc/dc-regdef.h b/gnu/usr.bin/bc/dc/dc-regdef.h new file mode 100644 index 00000000000..129d0ae6596 --- /dev/null +++ b/gnu/usr.bin/bc/dc/dc-regdef.h @@ -0,0 +1,40 @@ +/* + * definitions for dc's "register" declarations + * + * Copyright (C) 1994 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you can either send email to this + * program's author (see below) or write to: The Free Software Foundation, + * Inc.; 675 Mass Ave. Cambridge, MA 02139, USA. + */ + +#ifdef HAVE_LIMITS_H +# include <limits.h> /* UCHAR_MAX */ +#endif + +/* determine how many register stacks there are */ +#ifndef DC_REGCOUNT +# ifndef UCHAR_MAX +# define DC_REGCOUNT 256 +# else +# define DC_REGCOUNT (UCHAR_MAX+1) +# endif +#endif /* not DC_REGCOUNT */ + +/* efficiency hack for masking arbritrary integers to 0..(DC_REGCOUNT-1) */ +#if (DC_REGCOUNT & (DC_REGCOUNT-1)) == 0 /* DC_REGCOUNT is power of 2 */ +# define regmap(r) ((r) & (DC_REGCOUNT-1)) +#else +# define regmap(r) ((r) % DC_REGCOUNT) +#endif |