tools/llvm: Do not build with symbols
[minix3.git] / external / bsd / byacc / dist / warshall.c
blobae50c9e86aa37d585a3546c460d4d0184f0eee7f
1 /* $NetBSD: warshall.c,v 1.7 2013/04/06 14:52:24 christos Exp $ */
3 /* Id: warshall.c,v 1.7 2010/06/06 22:48:51 tom Exp */
5 #include "defs.h"
7 #include <sys/cdefs.h>
8 __RCSID("$NetBSD: warshall.c,v 1.7 2013/04/06 14:52:24 christos Exp $");
10 static void
11 transitive_closure(unsigned *R, int n)
13 int rowsize;
14 unsigned i;
15 unsigned *rowj;
16 unsigned *rp;
17 unsigned *rend;
18 unsigned *ccol;
19 unsigned *relend;
20 unsigned *cword;
21 unsigned *rowi;
23 rowsize = WORDSIZE(n);
24 relend = R + n * rowsize;
26 cword = R;
27 i = 0;
28 rowi = R;
29 while (rowi < relend)
31 ccol = cword;
32 rowj = R;
34 while (rowj < relend)
36 if (*ccol & (unsigned)(1 << i))
38 rp = rowi;
39 rend = rowj + rowsize;
40 while (rowj < rend)
41 *rowj++ |= *rp++;
43 else
45 rowj += rowsize;
48 ccol += rowsize;
51 if (++i >= BITS_PER_WORD)
53 i = 0;
54 cword++;
57 rowi += rowsize;
61 void
62 reflexive_transitive_closure(unsigned *R, int n)
64 int rowsize;
65 unsigned i;
66 unsigned *rp;
67 unsigned *relend;
69 transitive_closure(R, n);
71 rowsize = WORDSIZE(n);
72 relend = R + n * rowsize;
74 i = 0;
75 rp = R;
76 while (rp < relend)
78 *rp |= (unsigned)(1 << i);
79 if (++i >= BITS_PER_WORD)
81 i = 0;
82 rp++;
85 rp += rowsize;