summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2023-10-09 22:49:59 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2023-10-09 22:49:59 (GMT)
commit7c6fe94c90d320813d0d78a9dbef707696f31505 (patch)
tree912b5c51469c02e6ef680c0c60739787ccff4891 /src/arch
parentcb05b99a8c451ff80d88f988e2654c794b0f3750 (diff)
Support some last missing features from Kaitai: bit fields, instance search order and stream EOF.
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/vmpa.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/arch/vmpa.h b/src/arch/vmpa.h
index f353ebd..4f35ebe 100644
--- a/src/arch/vmpa.h
+++ b/src/arch/vmpa.h
@@ -156,6 +156,62 @@ bool store_vmpa(const vmpa2t *, const char *, bound_value **, size_t *);
+/* ------------------------ DEFINITION DE POSITION AVEC BITS ------------------------ */
+
+
+/* Adresse mémoire ou position physique */
+typedef struct _ext_vmpa_t
+{
+ vmpa2t base; /* Vision macroscopique */
+
+ uint8_t consumed_extra_bits; /* Avancée supplémentaire */
+
+} ext_vmpa_t;
+
+
+#define init_evmpa_from_vmpa(d, s) \
+ do \
+ { \
+ copy_vmpa(&(d)->base, (s)); \
+ (d)->consumed_extra_bits = 0; \
+ } \
+ while (0)
+
+#define copy_evmpa(d, s) \
+ do \
+ { \
+ copy_vmpa(&(d)->base, &(s)->base); \
+ (d)->consumed_extra_bits = (s)->consumed_extra_bits; \
+ } \
+ while (0)
+
+#define advance_evmpa_bits(a, q) \
+ do \
+ { \
+ uint8_t __sum; \
+ __sum = (a)->consumed_extra_bits + q; \
+ if (__sum > 8) \
+ { \
+ advance_vmpa(&(a)->base, __sum / 8); \
+ (a)->consumed_extra_bits = __sum % 8; \
+ } \
+ else \
+ (a)->consumed_extra_bits = __sum; \
+ } \
+ while (0)
+
+#define align_evmpa_on_byte(a) \
+ do \
+ { \
+ if ((a)->consumed_extra_bits > 0) \
+ { \
+ advance_vmpa(&(a)->base, 1); \
+ (a)->consumed_extra_bits = 0; \
+ } \
+ } \
+ while (0);
+
+
/* ------------------------ AIDES FONCTIONNELLES AUXILIAIRES ------------------------ */