home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / bc-1.03-base.tgz / bc-1.03-base.tar / fsf / bc / dc-regdef.h < prev    next >
C/C++ Source or Header  |  1994-08-08  |  1KB  |  41 lines

  1. /* 
  2.  * definitions for dc's "register" declarations
  3.  *
  4.  * Copyright (C) 1994 Free Software Foundation, Inc.
  5.  *
  6.  * This program is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; either version 2, or (at your option)
  9.  * any later version.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program; if not, you can either send email to this
  18.  * program's author (see below) or write to: The Free Software Foundation,
  19.  * Inc.; 675 Mass Ave. Cambridge, MA 02139, USA.
  20.  */
  21.  
  22. #ifdef HAVE_LIMITS_H
  23. # include <limits.h>    /* UCHAR_MAX */
  24. #endif
  25.  
  26. /* determine how many register stacks there are */
  27. #ifndef DC_REGCOUNT
  28. # ifndef UCHAR_MAX
  29. #  define DC_REGCOUNT 256
  30. # else
  31. #  define DC_REGCOUNT (UCHAR_MAX+1)
  32. # endif
  33. #endif /* not DC_REGCOUNT */
  34.  
  35. /* efficiency hack for masking arbritrary integers to 0..(DC_REGCOUNT-1) */
  36. #if (DC_REGCOUNT & (DC_REGCOUNT-1)) == 0    /* DC_REGCOUNT is power of 2 */
  37. # define regmap(r)    ((r) & (DC_REGCOUNT-1))
  38. #else
  39. # define regmap(r)    ((r) % DC_REGCOUNT)
  40. #endif
  41.