diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/arch/vmpa.c | 52 | ||||
-rw-r--r-- | src/arch/vmpa.h | 3 |
2 files changed, 39 insertions, 16 deletions
diff --git a/src/arch/vmpa.c b/src/arch/vmpa.c index 6db62cc..f90ab22 100644 --- a/src/arch/vmpa.c +++ b/src/arch/vmpa.c @@ -193,8 +193,8 @@ int cmp_vmpa_by_phy(const vmpa2t *a, const vmpa2t *b) else { if (a->physical == VMPA_NO_PHYSICAL && b->physical == VMPA_NO_PHYSICAL) result = 0; - else if (a->physical == VMPA_NO_PHYSICAL) result = -1; - else result = 1; + else if (a->physical == VMPA_NO_PHYSICAL) result = 1; + else result = -1; } return result; @@ -228,8 +228,8 @@ int cmp_vmpa_by_virt(const vmpa2t *a, const vmpa2t *b) else { if (a->virtual == VMPA_NO_VIRTUAL && b->virtual == VMPA_NO_VIRTUAL) result = 0; - else if (a->virtual == VMPA_NO_VIRTUAL) result = -1; - else result = 1; + else if (a->virtual == VMPA_NO_VIRTUAL) result = 1; + else result = -1; } return result; @@ -253,22 +253,48 @@ int cmp_vmpa_by_virt(const vmpa2t *a, const vmpa2t *b) int cmp_vmpa(const vmpa2t *a, const vmpa2t *b) { int result; /* Bilan à retourner */ - bool half; /* Comparaison débutée */ + bool compared; /* Comparaison effectuée */ - result = -1; + if (a->physical == VMPA_NO_PHYSICAL && a->virtual == VMPA_NO_VIRTUAL + && b->physical == VMPA_NO_PHYSICAL && b->virtual == VMPA_NO_VIRTUAL) + { + result = 0; - half = false; + } - if (a->physical != VMPA_NO_PHYSICAL && b->physical != VMPA_NO_PHYSICAL) + else if (a->physical == VMPA_NO_PHYSICAL && a->virtual == VMPA_NO_VIRTUAL) { - result = cmp_vmpa_by_phy(a, b); - half = true; + result = 1; + } - if (a->virtual != VMPA_NO_VIRTUAL && b->virtual != VMPA_NO_VIRTUAL - && (!half || (half && result == 0))) + else if (b->physical == VMPA_NO_PHYSICAL && b->virtual == VMPA_NO_VIRTUAL) + { + result = -1; + + } + + else { - result = cmp_vmpa_by_virt(a, b); + compared = false; + + if (a->physical != VMPA_NO_PHYSICAL && b->physical != VMPA_NO_PHYSICAL) + { + result = cmp_vmpa_by_phy(a, b); + compared = true; + } + + if (a->virtual != VMPA_NO_VIRTUAL && b->virtual != VMPA_NO_VIRTUAL + && (!compared || (compared && result == 0))) + { + result = cmp_vmpa_by_virt(a, b); + compared = true; + } + + /* Cas particulier : les deux éléments n'ont aucun champ défini en commun ! */ + if (!compared) + result = cmp_vmpa_by_phy(a, b); + } return result; diff --git a/src/arch/vmpa.h b/src/arch/vmpa.h index 871e282..6ed7605 100644 --- a/src/arch/vmpa.h +++ b/src/arch/vmpa.h @@ -99,9 +99,6 @@ int cmp_vmpa_by_virt(const vmpa2t *, const vmpa2t *); /* Compare deux localisations selon leurs parties définies. */ int cmp_vmpa(const vmpa2t *, const vmpa2t *); -#define are_equal(a, b) \ - (cmp_vmpa_by_phy(a, b) == 0 && cmp_vmpa_by_virt(a, b) == 0) - #define get_phy_addr(a) (a)->physical #define get_virt_addr(a) (a)->virtual |