blob: 0097d06a3a5b9c55e54bda84f043f3f4577a4e35 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
/* ISC license. */
#include <string.h>
#include <skalibs/bitarray.h>
#include <s6-rc/s6rc-db.h>
int s6rc_db_check_revdeps (s6rc_db_t const *db)
{
size_t n = db->nshort + db->nlong ;
size_t m = bitarray_div8(n) ;
unsigned char matrix[n * m] ;
unsigned int i = n ;
unsigned char const *p = matrix ;
memset(matrix, 0, n * m) ;
while (i--)
{
unsigned int j = db->services[i].ndeps[1] ;
while (j--) bitarray_not(matrix + m * i, db->deps[db->ndeps + db->services[i].deps[1] + j], 1) ;
}
i = n ;
while (i--)
{
unsigned int j = db->services[i].ndeps[0] ;
while (j--) bitarray_not(matrix + m * db->deps[db->services[i].deps[0] + j], i, 1) ;
}
n *= m ;
while (n--) if (*p++) return 1 ;
return 0 ;
}
|