diff options
Diffstat (limited to 'src/arch/instruction.c')
-rw-r--r-- | src/arch/instruction.c | 74 |
1 files changed, 33 insertions, 41 deletions
diff --git a/src/arch/instruction.c b/src/arch/instruction.c index cd9ccff..e0d1091 100644 --- a/src/arch/instruction.c +++ b/src/arch/instruction.c @@ -144,7 +144,11 @@ static void g_arch_instruction_class_init(GArchInstructionClass *klass) static void g_arch_instruction_init(GArchInstruction *instr) { - INIT_ARCH_INSTR_EXTRA(instr); + instr_extra_data_t *extra; /* Données insérées à modifier */ + + extra = GET_ARCH_INSTR_EXTRA(instr); + + INIT_GOBJECT_EXTRA_LOCK(extra); instr->operands = NULL; @@ -286,19 +290,19 @@ const char *g_arch_instruction_get_encoding(const GArchInstruction *instr) bool g_arch_instruction_set_flag(GArchInstruction *instr, ArchInstrFlag flag) { bool result; /* Bilan à retourner */ - instr_obj_extra *extra; /* Données insérées à modifier */ + instr_extra_data_t *extra; /* Données insérées à modifier */ assert(flag <= AIF_HIGH_USER); extra = GET_ARCH_INSTR_EXTRA(instr); - g_bit_lock(&extra->lock, HOLE_LOCK_BIT); + LOCK_GOBJECT_EXTRA(extra); - extra->flags |= flag; + result = !(extra->flags & flag); - result = true; + extra->flags |= flag; - g_bit_unlock(&extra->lock, HOLE_LOCK_BIT); + UNLOCK_GOBJECT_EXTRA(extra); return result; @@ -321,19 +325,19 @@ bool g_arch_instruction_set_flag(GArchInstruction *instr, ArchInstrFlag flag) bool g_arch_instruction_unset_flag(GArchInstruction *instr, ArchInstrFlag flag) { bool result; /* Bilan à retourner */ - instr_obj_extra *extra; /* Données insérées à modifier */ + instr_extra_data_t *extra; /* Données insérées à modifier */ assert(flag <= AIF_HIGH_USER); extra = GET_ARCH_INSTR_EXTRA(instr); - g_bit_lock(&extra->lock, HOLE_LOCK_BIT); + LOCK_GOBJECT_EXTRA(extra); - extra->flags &= ~flag; + result = (extra->flags & flag); - result = true; + extra->flags &= ~flag; - g_bit_unlock(&extra->lock, HOLE_LOCK_BIT); + UNLOCK_GOBJECT_EXTRA(extra); return result; @@ -356,17 +360,17 @@ bool g_arch_instruction_unset_flag(GArchInstruction *instr, ArchInstrFlag flag) bool g_arch_instruction_has_flag(const GArchInstruction *instr, ArchInstrFlag flag) { bool result; /* Bilan à retourner */ - instr_obj_extra *extra; /* Données insérées à consulter*/ + instr_extra_data_t *extra; /* Données insérées à modifier */ assert(flag <= AIF_HIGH_USER); extra = GET_ARCH_INSTR_EXTRA(instr); - g_bit_lock(&extra->lock, HOLE_LOCK_BIT); + LOCK_GOBJECT_EXTRA(extra); result = (extra->flags & flag); - g_bit_unlock(&extra->lock, HOLE_LOCK_BIT); + UNLOCK_GOBJECT_EXTRA(extra); return result; @@ -388,27 +392,15 @@ bool g_arch_instruction_has_flag(const GArchInstruction *instr, ArchInstrFlag fl ArchInstrFlag g_arch_instruction_get_flags(const GArchInstruction *instr) { ArchInstrFlag result; /* Fanions à retourner */ - instr_obj_extra *extra; /* Données insérées à consulter*/ + instr_extra_data_t *extra; /* Données insérées à modifier */ extra = GET_ARCH_INSTR_EXTRA(instr); - g_bit_lock(&extra->lock, HOLE_LOCK_BIT); + LOCK_GOBJECT_EXTRA(extra); result = extra->flags; - g_bit_unlock(&extra->lock, HOLE_LOCK_BIT); - - /** - * La pose du verrou a entraîné la mise à 1 du bit de poids fort de la zone - * couverte par le champ "extra". - * - * Même si les fanions ne couvrent pas cet emplacement, leur stockage s'étend - * sur 16 bits, et contient donc le fameux bit de verrouillage. - * - * On efface ce marqueur après-coup ici. - */ - - result &= ((AIF_HIGH_USER << 1) - 1); + UNLOCK_GOBJECT_EXTRA(extra); return result; @@ -430,15 +422,15 @@ ArchInstrFlag g_arch_instruction_get_flags(const GArchInstruction *instr) void g_arch_instruction_set_unique_id(GArchInstruction *instr, itid_t uid) { - instr_obj_extra *extra; /* Données insérées à modifier */ + instr_extra_data_t *extra; /* Données insérées à modifier */ extra = GET_ARCH_INSTR_EXTRA(instr); - g_bit_lock(&extra->lock, HOLE_LOCK_BIT); + LOCK_GOBJECT_EXTRA(extra); extra->uid = uid; - g_bit_unlock(&extra->lock, HOLE_LOCK_BIT); + UNLOCK_GOBJECT_EXTRA(extra); } @@ -458,15 +450,15 @@ void g_arch_instruction_set_unique_id(GArchInstruction *instr, itid_t uid) itid_t g_arch_instruction_get_unique_id(const GArchInstruction *instr) { itid_t result; /* Numéro à retourner */ - instr_obj_extra *extra; /* Données insérées à consulter*/ + instr_extra_data_t *extra; /* Données insérées à consulter*/ extra = GET_ARCH_INSTR_EXTRA(instr); - g_bit_lock(&extra->lock, HOLE_LOCK_BIT); + LOCK_GOBJECT_EXTRA(extra); result = extra->uid; - g_bit_unlock(&extra->lock, HOLE_LOCK_BIT); + UNLOCK_GOBJECT_EXTRA(extra); return result; @@ -1681,7 +1673,7 @@ static bool g_arch_instruction_unserialize(GArchInstruction *instr, GAsmStorage GArchOperand *op; /* Opérande à traiter */ instr_link_t link; /* Lien vers une instruction */ packed_buffer_t ins_pbuf; /* Tampon des données à écrire */ - instr_obj_extra *extra; /* Données insérées à consulter*/ + instr_extra_data_t *extra; /* Données insérées à consulter*/ result = unpack_mrange(&instr->range, pbuf); @@ -1765,14 +1757,14 @@ static bool g_arch_instruction_unserialize(GArchInstruction *instr, GAsmStorage { extra = GET_ARCH_INSTR_EXTRA(instr); - g_bit_lock(&extra->lock, HOLE_LOCK_BIT); + LOCK_GOBJECT_EXTRA(extra); result = extract_packed_buffer(pbuf, &extra->uid, sizeof(itid_t), true); if (result) result = extract_packed_buffer(pbuf, &extra->flags, sizeof(ArchInstrFlag), true); - g_bit_unlock(&extra->lock, HOLE_LOCK_BIT); + UNLOCK_GOBJECT_EXTRA(extra); } @@ -1843,7 +1835,7 @@ static bool g_arch_instruction_serialize(GArchInstruction *instr, GAsmStorage *s off64_t pos; /* Position dans le flux */ size_t kept; /* Nombre de liens conservés */ const instr_link_t *link; /* Lien vers une instruction */ - instr_obj_extra *extra; /* Données insérées à consulter*/ + instr_extra_data_t *extra; /* Données insérées à consulter*/ result = pack_mrange(&instr->range, pbuf); @@ -1947,14 +1939,14 @@ static bool g_arch_instruction_serialize(GArchInstruction *instr, GAsmStorage *s { extra = GET_ARCH_INSTR_EXTRA(instr); - g_bit_lock(&extra->lock, HOLE_LOCK_BIT); + LOCK_GOBJECT_EXTRA(extra); result = extend_packed_buffer(pbuf, &extra->uid, sizeof(itid_t), true); if (result) result = extend_packed_buffer(pbuf, &extra->flags, sizeof(ArchInstrFlag), true); - g_bit_unlock(&extra->lock, HOLE_LOCK_BIT); + UNLOCK_GOBJECT_EXTRA(extra); } |