allgmem.c: Do not include config.h anymore.
[gcc.git] / libchill / ltps.c
1 /* Implement POWERSET runtime actions for CHILL.
2 Copyright (C) 1992,1993 Free Software Foundation, Inc.
3 Author: Wilfried Moser, et al
4
5 This file is part of GNU CC.
6
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.
11
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.
16
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. */
20
21 #define __CHILL_LIB__
22
23 #include <stdio.h>
24 #include "powerset.h"
25
26 /*
27 * function __ltpowerset
28 *
29 * parameters:
30 * left powerset
31 * right powerset
32 * bitlength length of powerset
33 *
34 * returns:
35 * int 1 .. left is proper subset of right
36 * (excludes case where left == right)
37 * 0 .. not
38 *
39 * abstract:
40 * check if one powerset is included in another
41 *
42 */
43 int
44 __ltpowerset (left, right, bitlength)
45 SET_WORD *left;
46 SET_WORD *right;
47 unsigned long bitlength;
48 {
49 if (bitlength <= SET_CHAR_SIZE)
50 {
51 if ((*((SET_CHAR *)left) & *((SET_CHAR *)right))
52 != *((SET_CHAR *)left))
53 return 0;
54 if (*((SET_CHAR *)left) != *((SET_CHAR *)right))
55 return 1;
56 return 0;
57 }
58 else if (bitlength <= SET_SHORT_SIZE)
59 {
60 if ((*((SET_SHORT *)left) & *((SET_SHORT *)right))
61 != *((SET_SHORT *)left))
62 return 0;
63 if (*((SET_SHORT *)left) != *((SET_SHORT *)right))
64 return 1;
65 return 0;
66 }
67 else
68 {
69 SET_WORD *endp = left + BITS_TO_WORDS(bitlength);
70 int all_equal = 1; /* assume all bits are equal */
71
72 while (left < endp)
73 {
74 if ((*right & *left) != *left)
75 return 0;
76 if (*left != *right)
77 all_equal = 0;
78 left++;
79 right++;
80 }
81 if (left == endp && all_equal) /* exclude TRUE return for == case */
82 return 0;
83 return 1;
84 }
85 }