summaryrefslogtreecommitdiff
path: root/src/libs6rc
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2015-08-12 20:00:17 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2015-08-12 20:00:17 +0000
commit9473830ad612dcb674f6048a9a17e372ff9d9ec3 (patch)
tree6cf045657b34be4b6fd685c68993b13bf7e55f26 /src/libs6rc
parentabfd58b78188c3408599b98fcce611349bfa8b9c (diff)
downloads6-rc-9473830ad612dcb674f6048a9a17e372ff9d9ec3.tar.xz
Intermediary commit; working on source dir format change. Should work, but untested as for now.
Diffstat (limited to 'src/libs6rc')
-rw-r--r--src/libs6rc/deps-lib/s6rc4
-rw-r--r--src/libs6rc/s6rc_db_check_depcycles.c26
-rw-r--r--src/libs6rc/s6rc_db_check_revdeps.c5
-rw-r--r--src/libs6rc/s6rc_db_read.c5
4 files changed, 23 insertions, 17 deletions
diff --git a/src/libs6rc/deps-lib/s6rc b/src/libs6rc/deps-lib/s6rc
index 65b562e..194ea43 100644
--- a/src/libs6rc/deps-lib/s6rc
+++ b/src/libs6rc/deps-lib/s6rc
@@ -1,6 +1,8 @@
s6rc_db_check_depcycles.o
+s6rc_db_check_pipelines.o
+s6rc_db_check_revdeps.o
s6rc_db_read.o
s6rc_db_read_sizes.o
s6rc_db_read_uint32.o
-s6rc_db_check_revdeps.o
s6rc_graph_closure.o
+-lskarnet
diff --git a/src/libs6rc/s6rc_db_check_depcycles.c b/src/libs6rc/s6rc_db_check_depcycles.c
index 13dcf7b..db6ed6e 100644
--- a/src/libs6rc/s6rc_db_check_depcycles.c
+++ b/src/libs6rc/s6rc_db_check_depcycles.c
@@ -1,6 +1,7 @@
/* ISC license. */
#include <skalibs/uint32.h>
+#include <skalibs/diuint32.h>
#include <skalibs/bitarray.h>
#include <skalibs/bytestr.h>
#include <s6-rc/s6rc-db.h>
@@ -9,22 +10,22 @@ typedef struct recinfo_s recinfo_t, *recinfo_t_ref ;
struct recinfo_s
{
s6rc_db_t const *db ;
- unsigned int n ;
+ uint32 n ;
unsigned char *gray ;
unsigned char *black ;
unsigned char h : 1 ;
} ;
-static unsigned int s6rc_db_checknocycle_rec (recinfo_t *recinfo, unsigned int i)
+static uint32 s6rc_db_checknocycle_rec (recinfo_t *recinfo, uint32 i)
{
if (!bitarray_peek(recinfo->black, i))
{
- unsigned int j = recinfo->db->services[i].ndeps[recinfo->h] ;
+ uint32 j = recinfo->db->services[i].ndeps[recinfo->h] ;
if (bitarray_peek(recinfo->gray, i)) return i ;
bitarray_set(recinfo->gray, i) ;
while (j--)
{
- register unsigned int r = s6rc_db_checknocycle_rec(recinfo, recinfo->db->deps[recinfo->h * recinfo->db->ndeps + recinfo->db->services[i].deps[recinfo->h] + j]) ;
+ register uint32 r = s6rc_db_checknocycle_rec(recinfo, recinfo->db->deps[recinfo->h * recinfo->db->ndeps + recinfo->db->services[i].deps[recinfo->h] + j]) ;
if (r < recinfo->n) return r ;
}
bitarray_set(recinfo->black, i) ;
@@ -32,19 +33,24 @@ static unsigned int s6rc_db_checknocycle_rec (recinfo_t *recinfo, unsigned int i
return recinfo->n ;
}
-unsigned int s6rc_db_check_depcycles (s6rc_db_t const *db, int h, unsigned int *problem)
+int s6rc_db_check_depcycles (s6rc_db_t const *db, int h, diuint32 *problem)
{
- unsigned int n = db->nshort + db->nlong ;
+ uint32 n = db->nshort + db->nlong ;
+ uint32 i = n ;
unsigned char gray[bitarray_div8(n)] ;
unsigned char black[bitarray_div8(n)] ;
recinfo_t info = { .db = db, .n = n, .gray = gray, .black = black, .h = !!h } ;
- unsigned int i = n ;
byte_zero(gray, bitarray_div8(n)) ;
byte_zero(black, bitarray_div8(n)) ;
while (i--)
{
- register unsigned int r = s6rc_db_checknocycle_rec(&info, i) ;
- if (r < n) return (*problem = r, i) ;
+ register uint32 r = s6rc_db_checknocycle_rec(&info, i) ;
+ if (r < n)
+ {
+ problem->left = i ;
+ problem->right = r ;
+ return 1 ;
+ }
}
- return n ;
+ return 0 ;
}
diff --git a/src/libs6rc/s6rc_db_check_revdeps.c b/src/libs6rc/s6rc_db_check_revdeps.c
index 0cb2845..a4342b1 100644
--- a/src/libs6rc/s6rc_db_check_revdeps.c
+++ b/src/libs6rc/s6rc_db_check_revdeps.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include <skalibs/uint32.h>
#include <skalibs/bytestr.h>
#include <skalibs/bitarray.h>
#include <s6-rc/s6rc-db.h>
@@ -25,6 +24,6 @@ int s6rc_db_check_revdeps (s6rc_db_t const *db)
while (j--) bitarray_not(matrix + m * db->deps[db->services[i].deps[0] + j], i, 1) ;
}
i = n * m ;
- while (i--) if (*p++) return 0 ;
- return 1 ;
+ while (i--) if (*p++) return 1 ;
+ return 0 ;
}
diff --git a/src/libs6rc/s6rc_db_read.c b/src/libs6rc/s6rc_db_read.c
index 7a38797..50e1f78 100644
--- a/src/libs6rc/s6rc_db_read.c
+++ b/src/libs6rc/s6rc_db_read.c
@@ -90,9 +90,8 @@ static inline int s6rc_db_read_services (buffer *b, s6rc_db_t *db)
#endif
if (i < db->nlong)
{
- if (!s6rc_db_read_uint32(b, &sv->x.longrun.servicedir)) return -1 ;
- DBG(" longrun - servicedir is %u: %s", sv->x.longrun.servicedir, db->string + sv->x.longrun.servicedir) ;
- if (!s6rc_db_check_valid_string(db->string, db->stringlen, sv->x.longrun.servicedir)) return 0 ;
+ if (!s6rc_db_read_uint32(b, &sv->x.longrun.pipeline[0])) return -1 ;
+ if (!s6rc_db_read_uint32(b, &sv->x.longrun.pipeline[1])) return -1 ;
}
else
{