]> gcc.gnu.org Git - gcc.git/blob - libchill/eqps.c
* Chill runtime moved into toplevel libchill.
[gcc.git] / libchill / eqps.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 "config.h"
24 #include <stdio.h>
25 #include "powerset.h"
26
27 /*
28 * function __eqpowerset
29 *
30 * parameters:
31 * left left powerset
32 * right right powerset
33 * bitlength length of powerset in bits
34 *
35 * returns:
36 * 1 if powersets are equal, bit for bit
37 *
38 * exceptions:
39 * none
40 *
41 * abstract:
42 * compares two powersets for equality
43 *
44 */
45 int
46 __eqpowerset (left, right, bitlength)
47 SET_WORD *left;
48 SET_WORD *right;
49 unsigned long bitlength;
50 {
51 #ifndef USE_CHARS
52 if (bitlength <= SET_CHAR_SIZE)
53 {
54 SET_CHAR c = *(SET_CHAR *)left ^ *(SET_CHAR *)right;
55 MASK_UNUSED_CHAR_BITS (&c, bitlength);
56 return (c == 0) ? 1 : 0;
57 }
58 else if (bitlength <= SET_SHORT_SIZE)
59 {
60 SET_SHORT c = *(SET_SHORT *)left ^ *(SET_SHORT *)right;
61 MASK_UNUSED_SHORT_BITS (&c, bitlength);
62 return (c == 0) ? 1 : 0;
63 }
64 else if (bitlength <= SET_WORD_SIZE)
65 {
66 SET_WORD c = *(SET_WORD *)left ^ *(SET_WORD *)right;
67 MASK_UNUSED_WORD_BITS (&c, bitlength % SET_WORD_SIZE);
68 return (c == 0) ? 1 : 0;
69 }
70 else
71 #endif
72 {
73 SET_WORD c;
74 register unsigned long i;
75 unsigned long len = bitlength / SET_WORD_SIZE;
76
77 for (i = 0; i < len; i++) /* a word-oriented memcmp */
78 if (left[i] != right[i])
79 return 0;
80 /* do the last (possibly partial) word */
81 bitlength %= SET_WORD_SIZE;
82 if (bitlength == 0)
83 return 1;
84 c = left[i] ^ right[i];
85 MASK_UNUSED_WORD_BITS (&c, bitlength);
86 return (c == 0) ? 1 : 0;
87 }
88 }
This page took 0.050237 seconds and 6 git commands to generate.