Imported Upstream version 0.7.2
[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 extern int solver_is_namespace_dep_slow(Solver *solv, Reldep *rd);
25
26 extern void solver_createcleandepsmap(Solver *solv, Map *cleandepsmap, int unneeded);
27 extern int solver_check_cleandeps_mistakes(Solver *solv);
28
29
30 #define ISSIMPLEDEP(pool, dep) (!ISRELDEP(dep) || GETRELDEP(pool, dep)->flags < 8)
31
32 static inline int
33 solver_dep_possible(Solver *solv, Id dep, Map *m)
34 {
35   Pool *pool = solv->pool;
36   Id p, pp;
37
38   if (!ISSIMPLEDEP(pool, dep))
39     return solver_dep_possible_slow(solv, dep, m);
40   FOR_PROVIDES(p, pp, dep)
41     {  
42       if (MAPTST(m, p))
43         return 1;
44     }
45   return 0;
46 }
47
48 static inline int
49 solver_dep_fulfilled(Solver *solv, Id dep)
50 {
51   Pool *pool = solv->pool;
52   Id p, pp;
53
54   if (ISRELDEP(dep))
55     {
56       Reldep *rd = GETRELDEP(pool, dep);
57       if (rd->flags == REL_COND || rd->flags == REL_UNLESS || rd->flags == REL_AND || rd->flags == REL_OR)
58         return solver_dep_fulfilled_cplx(solv, rd);
59       if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_SPLITPROVIDES)
60         return solver_splitprovides(solv, rd->evr, 0);
61     }
62   FOR_PROVIDES(p, pp, dep)
63     {
64       if (solv->decisionmap[p] > 0)
65         return 1;
66     }
67   return 0;
68 }
69
70 static inline int
71 solver_is_supplementing(Solver *solv, Solvable *s)
72 {
73   Id sup, *supp;
74   if (!s->supplements)
75     return 0;
76   supp = s->repo->idarraydata + s->supplements;
77   while ((sup = *supp++) != 0)
78     if (solver_dep_fulfilled(solv, sup))
79       return 1;
80   return 0;
81 }
82
83 static inline int
84 solver_is_enhancing(Solver *solv, Solvable *s)
85 {
86   Id enh, *enhp;
87   if (!s->enhances)
88     return 0;
89   enhp = s->repo->idarraydata + s->enhances;
90   while ((enh = *enhp++) != 0)
91     if (solver_dep_fulfilled(solv, enh))
92       return 1;
93   return 0;
94 }
95
96 static inline int
97 solver_is_namespace_dep(Solver *solv, Id dep)
98 {
99   Pool *pool = solv->pool;
100   Reldep *rd;
101   if (!ISRELDEP(dep))
102     return 0;
103   rd = GETRELDEP(pool, dep);
104   if (rd->flags == REL_NAMESPACE)
105     return 1;
106   if (ISRELDEP(rd->name))
107     return solver_is_namespace_dep_slow(solv, rd);
108   if (ISRELDEP(rd->evr))
109     return solver_is_namespace_dep_slow(solv, GETRELDEP(pool, rd->evr));
110   return 0;
111 }
112
113 #endif /* LIBSOLV_SOLVER_PRIVATE_H */