summaryrefslogtreecommitdiff
path: root/src/solver.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2012-02-16 21:46:09 +0200
committerTimo Teräs <timo.teras@iki.fi>2012-02-16 21:46:09 +0200
commit4bc8add78dea29769c9ee774d821fe0232d64d75 (patch)
tree3232b2e0cf1dadef536f77482066b9b332261835 /src/solver.c
parent706664c178a7af3acc54a818eb916daaea48d5da (diff)
downloadapk-tools-4bc8add78dea29769c9ee774d821fe0232d64d75.tar.gz
apk-tools-4bc8add78dea29769c9ee774d821fe0232d64d75.tar.bz2
apk-tools-4bc8add78dea29769c9ee774d821fe0232d64d75.tar.xz
apk-tools-4bc8add78dea29769c9ee774d821fe0232d64d75.zip
solver: convert some package state flags to bitfields
Diffstat (limited to 'src/solver.c')
-rw-r--r--src/solver.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/solver.c b/src/solver.c
index 5f65f3b..fbe50e8 100644
--- a/src/solver.c
+++ b/src/solver.c
@@ -26,8 +26,6 @@
#define APK_PKGSTF_NOINSTALL 0
#define APK_PKGSTF_INSTALL 1
#define APK_PKGSTF_ALT_BRANCH 2
-#define APK_PKGSTF_INSTALLIF 4
-#define APK_PKGSTF_DECIDED 8
struct apk_score {
unsigned short unsatisfiable;
@@ -42,7 +40,9 @@ struct apk_package_state {
unsigned availability_checked : 1;
unsigned unavailable : 1;
unsigned install_applied : 1;
- unsigned flags : 4;
+ unsigned handle_install_if : 1;
+ unsigned locked : 1;
+ unsigned flags : 2;
};
struct apk_name_state {
@@ -411,7 +411,7 @@ static int get_preference(struct apk_solver_state *ss,
if (installable_only &&
(ss->topology_position < pkg0->topology_hard ||
- (ps0->flags & APK_PKGSTF_DECIDED)))
+ ps0->locked))
continue;
r = compare_package_preference(name_flags,
@@ -498,7 +498,7 @@ static int update_name_state(struct apk_solver_state *ss, struct apk_name *name)
if (ps0 == NULL ||
ss->topology_position < pkg0->topology_hard ||
- (ps0->flags & APK_PKGSTF_DECIDED) ||
+ ps0->locked ||
check_if_package_unavailable(ss, pkg0))
continue;
@@ -673,7 +673,7 @@ static void undo_decision(struct apk_solver_state *ss,
dbg_printf("-->undo_decision: " PKG_VER_FMT " %s\n", PKG_VER_PRINTF(pkg),
(ps->flags & APK_PKGSTF_INSTALL) ? "INSTALL" : "NO_INSTALL");
- if (ps->flags & APK_PKGSTF_INSTALLIF)
+ if (ps->handle_install_if)
ss->topology_position = ps->topology_soft;
else
ss->topology_position = pkg->topology_hard;
@@ -705,15 +705,16 @@ static solver_result_t push_decision(struct apk_solver_state *ss, struct apk_pac
struct apk_package_state *ps = pkg_to_ps(pkg);
ps->backtrack = ss->latest_decision;
- ps->flags = flags | APK_PKGSTF_DECIDED;
+ ps->locked = 1;
+ ps->flags = flags;
ps->saved_score = ss->score;
if (ps->topology_soft < ss->topology_position) {
if (flags & APK_PKGSTF_INSTALL)
- ps->flags |= APK_PKGSTF_INSTALLIF;
+ ps->handle_install_if = 1;
ss->topology_position = ps->topology_soft;
} else {
- ps->flags &= ~APK_PKGSTF_INSTALLIF;
+ ps->handle_install_if = 0;
ss->topology_position = pkg->topology_hard;
}
ss->latest_decision = pkg;
@@ -723,7 +724,7 @@ static solver_result_t push_decision(struct apk_solver_state *ss, struct apk_pac
ss->score.unsatisfiable,
ss->score.preference);
- if (ps->flags & APK_PKGSTF_INSTALLIF)
+ if (ps->handle_install_if)
dbg_printf("triggers due to " PKG_VER_FMT "\n",
PKG_VER_PRINTF(pkg));
@@ -742,7 +743,8 @@ static int next_branch(struct apk_solver_state *ss)
if (ps->flags & APK_PKGSTF_ALT_BRANCH) {
dbg_printf("-->next_branch: undo decision at topology_position %d\n",
ss->topology_position);
- ps->flags &= ~(APK_PKGSTF_ALT_BRANCH | APK_PKGSTF_DECIDED);
+ ps->flags &= ~APK_PKGSTF_ALT_BRANCH;
+ ps->locked = 0;
undo_decision(ss, pkg, ps);
ss->latest_decision = ps->backtrack;