* splay-tree.h: Wrap function pointer parameter declarations in
[official-gcc.git] / libchill / inbitstr.c
blobc83c13411eb27859f810e1c680fed79863e8e6c5
1 /* Implement POWERSET runtime actions for CHILL.
2 Copyright (C) 1992,1993 Free Software Foundation, Inc.
3 Author: Wilfried Moser, et al
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
21 /* As a special exception, if you link this library with other files,
22 some of which are compiled with GCC, to produce an executable,
23 this library does not by itself cause the resulting executable
24 to be covered by the GNU General Public License.
25 This exception does not however invalidate any other reasons why
26 the executable file might be covered by the GNU General Public License. */
28 #define __CHILL_LIB__
30 #include <stdio.h>
31 #include "powerset.h"
33 extern void __cause_ex1 (char *exname, char *file, int lineno);
36 * function __inbitstring
38 * parameters:
39 * bitno bit number within set
40 * powerset the powerset
41 * bitlength length of powerset in bits
42 * minval number of lowest bit stored
43 * fname filename of caller
44 * lineno linenumber of caller
46 * returns:
47 * int 1 .. found
48 * 0 .. not found
50 * exceptions:
51 * rangefail
53 * abstract:
54 * checks if a given value is included in a bitstring
57 int
58 __inbitstring (bitno, powerset, bitlength, minval, fname, lineno)
59 unsigned long bitno;
60 SET_WORD *powerset;
61 unsigned long bitlength;
62 long minval;
63 char *fname;
64 int lineno;
67 if (powerset == NULL
68 || bitno < minval
69 || (bitno - minval) >= bitlength)
70 __cause_ex1 ("rangefail", fname, lineno);
72 bitno -= minval;
73 if (bitlength <= SET_CHAR_SIZE)
74 return GET_BIT_IN_CHAR (*((SET_CHAR *)powerset), bitno);
75 else if (bitlength <= SET_SHORT_SIZE)
76 return GET_BIT_IN_SHORT (*((SET_SHORT *)powerset), bitno);
77 else
78 return GET_BIT_IN_WORD (powerset[bitno / SET_WORD_SIZE],
79 bitno % SET_WORD_SIZE);