e92617dd55a1575d03682c199fa81a46749b1c73
[platform/upstream/libsolv.git] / src / solver_private.h
1 /*
2  * Copyright (c) 2011, Novell Inc.
3  *
4  * This program is licensed under the BSD license, read LICENSE.BSD
5  * for further information
6  */
7
8 /*
9  * solver_private.h - private functions
10  *
11  */
12
13 #ifndef LIBSOLV_SOLVER_PRIVATE_H
14 #define LIBSOLV_SOLVER_PRIVATE_H
15
16 extern void solver_run_sat(Solver *solv, int disablerules, int doweak);
17 extern void solver_reset(Solver *solv);
18
19 extern int solver_splitprovides(Solver *solv, Id dep, Map *m);
20 extern int solver_dep_possible_slow(Solver *solv, Id dep, Map *m);
21 extern int solver_dep_fulfilled_cplx(Solver *solv, Reldep *rd);
22 extern int solver_is_supplementing_alreadyinstalled(Solver *solv, Solvable *s);
23 extern void solver_intersect_obsoleted(Solver *solv, Id p, Queue *q, int qstart, Map *m);
24
25 extern void solver_createcleandepsmap(Solver *solv, Map *cleandepsmap, int unneeded);
26 extern int solver_check_cleandeps_mistakes(Solver *solv);
27
28
29 #define ISSIMPLEDEP(pool, dep) (!ISRELDEP(dep) || GETRELDEP(pool, dep)->flags < 8)
30
31 static inline int
32 solver_dep_possible(Solver *solv, Id dep, Map *m)
33 {
34   Pool *pool = solv->pool;
35   Id p, pp;
36
37   if (!ISSIMPLEDEP(pool, dep))
38     return solver_dep_possible_slow(solv, dep, m);
39   FOR_PROVIDES(p, pp, dep)
40     {  
41       if (MAPTST(m, p))
42         return 1;
43     }
44   return 0;
45 }
46
47 static inline int
48 solver_dep_fulfilled(Solver *solv, Id dep)
49 {
50   Pool *pool = solv->pool;
51   Id p, pp;
52
53   if (ISRELDEP(dep))
54     {
55       Reldep *rd = GETRELDEP(pool, dep);
56       if (rd->flags == REL_COND || rd->flags == REL_UNLESS || rd->flags == REL_AND || rd->flags == REL_OR)
57         return solver_dep_fulfilled_cplx(solv, rd);
58       if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_SPLITPROVIDES)
59         return solver_splitprovides(solv, rd->evr, 0);
60     }
61   FOR_PROVIDES(p, pp, dep)
62     {
63       if (solv->decisionmap[p] > 0)
64         return 1;
65     }
66   return 0;
67 }
68
69 static inline int
70 solver_is_supplementing(Solver *solv, Solvable *s)
71 {
72   Id sup, *supp;
73   if (!s->supplements)
74     return 0;
75   supp = s->repo->idarraydata + s->supplements;
76   while ((sup = *supp++) != 0)
77     if (solver_dep_fulfilled(solv, sup))
78       return 1;
79   return 0;
80 }
81
82 static inline int
83 solver_is_enhancing(Solver *solv, Solvable *s)
84 {
85   Id enh, *enhp;
86   if (!s->enhances)
87     return 0;
88   enhp = s->repo->idarraydata + s->enhances;
89   while ((enh = *enhp++) != 0)
90     if (solver_dep_fulfilled(solv, enh))
91       return 1;
92   return 0;
93 }
94
95 #endif /* LIBSOLV_SOLVER_PRIVATE_H */