summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2020-02-04 13:25:08 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2020-02-04 13:25:08 (GMT)
commitfa68ba09820676563ba11f63213168e8e7bfd1d8 (patch)
treeed3bbb0e794a5f241e2961a75ffa61ed29fac914
parentec0f07c0b9468d6798befd887b02d9668faf806b (diff)
Moved the definition of a lock bit.
-rw-r--r--src/arch/instruction-int.h18
-rw-r--r--src/arch/instruction.c32
-rw-r--r--src/glibext/objhole.h23
3 files changed, 39 insertions, 34 deletions
diff --git a/src/arch/instruction-int.h b/src/arch/instruction-int.h
index fcb5453..f53f2f6 100644
--- a/src/arch/instruction-int.h
+++ b/src/arch/instruction-int.h
@@ -74,24 +74,6 @@ typedef union _instr_obj_extra
} instr_obj_extra;
-/**
- * Choix du bit de verrou pour le champ "lock".
- */
-
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-
-# define INSTR_EXTRA_LOCK_BIT 31
-
-#elif __BYTE_ORDER == __BIG_ENDIAN
-
-# define INSTR_EXTRA_LOCK_BIT 0
-
-#else
-
-# error "Unknown byte order"
-
-#endif
-
/* Définition générique d'une instruction d'architecture (instance) */
struct _GArchInstruction
{
diff --git a/src/arch/instruction.c b/src/arch/instruction.c
index 1090138..b9f9e29 100644
--- a/src/arch/instruction.c
+++ b/src/arch/instruction.c
@@ -287,13 +287,13 @@ bool g_arch_instruction_set_flag(GArchInstruction *instr, ArchInstrFlag flag)
extra = GET_ARCH_INSTR_EXTRA(instr);
- g_bit_lock(&extra->lock, INSTR_EXTRA_LOCK_BIT);
+ g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
extra->flags |= flag;
result = true;
- g_bit_unlock(&extra->lock, INSTR_EXTRA_LOCK_BIT);
+ g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
return result;
@@ -322,13 +322,13 @@ bool g_arch_instruction_unset_flag(GArchInstruction *instr, ArchInstrFlag flag)
extra = GET_ARCH_INSTR_EXTRA(instr);
- g_bit_lock(&extra->lock, INSTR_EXTRA_LOCK_BIT);
+ g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
extra->flags &= ~flag;
result = true;
- g_bit_unlock(&extra->lock, INSTR_EXTRA_LOCK_BIT);
+ g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
return result;
@@ -357,11 +357,11 @@ bool g_arch_instruction_has_flag(const GArchInstruction *instr, ArchInstrFlag fl
extra = GET_ARCH_INSTR_EXTRA(instr);
- g_bit_lock(&extra->lock, INSTR_EXTRA_LOCK_BIT);
+ g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
result = (extra->flags & flag);
- g_bit_unlock(&extra->lock, INSTR_EXTRA_LOCK_BIT);
+ g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
return result;
@@ -387,11 +387,11 @@ ArchInstrFlag g_arch_instruction_get_flags(const GArchInstruction *instr)
extra = GET_ARCH_INSTR_EXTRA(instr);
- g_bit_lock(&extra->lock, INSTR_EXTRA_LOCK_BIT);
+ g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
result = extra->flags;
- g_bit_unlock(&extra->lock, INSTR_EXTRA_LOCK_BIT);
+ g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
return result;
@@ -417,11 +417,11 @@ void g_arch_instruction_set_unique_id(GArchInstruction *instr, itid_t uid)
extra = GET_ARCH_INSTR_EXTRA(instr);
- g_bit_lock(&extra->lock, INSTR_EXTRA_LOCK_BIT);
+ g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
extra->uid = uid;
- g_bit_unlock(&extra->lock, INSTR_EXTRA_LOCK_BIT);
+ g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
}
@@ -445,11 +445,11 @@ itid_t g_arch_instruction_get_unique_id(const GArchInstruction *instr)
extra = GET_ARCH_INSTR_EXTRA(instr);
- g_bit_lock(&extra->lock, INSTR_EXTRA_LOCK_BIT);
+ g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
result = extra->uid;
- g_bit_unlock(&extra->lock, INSTR_EXTRA_LOCK_BIT);
+ g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
return result;
@@ -1598,14 +1598,14 @@ static bool g_arch_instruction_unserialize(GArchInstruction *instr, GAsmStorage
{
extra = GET_ARCH_INSTR_EXTRA(instr);
- g_bit_lock(&extra->lock, INSTR_EXTRA_LOCK_BIT);
+ g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
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, INSTR_EXTRA_LOCK_BIT);
+ g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
}
@@ -1780,14 +1780,14 @@ static bool g_arch_instruction_serialize(GArchInstruction *instr, GAsmStorage *s
{
extra = GET_ARCH_INSTR_EXTRA(instr);
- g_bit_lock(&extra->lock, INSTR_EXTRA_LOCK_BIT);
+ g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
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, INSTR_EXTRA_LOCK_BIT);
+ g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
}
diff --git a/src/glibext/objhole.h b/src/glibext/objhole.h
index 184e599..ad28c63 100644
--- a/src/glibext/objhole.h
+++ b/src/glibext/objhole.h
@@ -68,4 +68,27 @@
+/**
+ * Choix du bit de verrou pour le champ "lock".
+ *
+ * Dans la structure exploitant le mot utilisé ici, ce verrou est généralement
+ * placé dans le bit de poids fort pour les objets qui l'utilisent.
+ */
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+
+# define HOLE_LOCK_BIT 31
+
+#elif __BYTE_ORDER == __BIG_ENDIAN
+
+# define HOLE_LOCK_BIT 0
+
+#else
+
+# error "Unknown byte order"
+
+#endif
+
+
+
#endif /* _GLIBEXT_OBJHOLE_H */