summaryrefslogtreecommitdiff
path: root/src/common/bits.h
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-10-06 18:47:10 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-10-06 18:47:10 (GMT)
commit0588195aedf09d4dfcee16dfd1cb3856961b1e4e (patch)
treef95352aff5938a7b37d7a639329cbedfcb9e056f /src/common/bits.h
parentbc9c991e4aba495e2cb7c1962ce790f91ca62d9e (diff)
Optimized loop detections using bit fields.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@586 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/common/bits.h')
-rw-r--r--src/common/bits.h86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/common/bits.h b/src/common/bits.h
new file mode 100644
index 0000000..6eeb19c
--- /dev/null
+++ b/src/common/bits.h
@@ -0,0 +1,86 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * bits.h - prototypes pour la manipulation d'un champ de bits quelconque
+ *
+ * Copyright (C) 2015 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _COMMON_BITS_H
+#define _COMMON_BITS_H
+
+
+#include "../arch/vmpa.h"
+
+
+
+/* ----------------------------- CHAMPS DE BITS SIMPLES ----------------------------- */
+
+
+/* Champ de bits simple */
+typedef struct _bitfield_t bitfield_t;
+
+
+/* Crée un champ de bits initialisé à zéro. */
+bitfield_t *create_bit_field(size_t);
+
+/* Crée une copie de champ de bits initialisé à zéro. */
+bitfield_t *create_bit_field_from(const bitfield_t *);
+
+/* Supprime de la mémoire un champ de bits donné. */
+void delete_bit_field(bitfield_t *);
+
+/* Crée une copie d'un champ de bits classique. */
+bitfield_t *dup_bit_field(const bitfield_t *);
+
+/* Bascule à 1 une partie d'un champ de bits. */
+void set_in_bit_field(bitfield_t *, size_t, size_t);
+
+/* Détermine si un bit est à 1 dans un champ de bits. */
+bool test_in_bit_field(bitfield_t *, size_t, size_t);
+
+
+
+/* ------------------------- CHAMPS LIES À UNE ZONE MEMOIRE ------------------------- */
+
+
+/* Champ de bits couvrant une mémoire */
+typedef struct _bitfield_t memfield_t;
+
+
+/* Crée un champ de bits couvrant une zone mémoire. */
+memfield_t *create_mem_field(const mrange_t *);
+
+/* Crée une copie de champ de bits couvrant une zone mémoire. */
+memfield_t *create_mem_field_from(const memfield_t *);
+
+/* Supprime de la mémoire un champ de bits donné. */
+void delete_mem_field(memfield_t *);
+
+/* Crée une copie d'un champ de bits couvrant une zone mémoire. */
+memfield_t *dup_mem_field(const memfield_t *);
+
+/* Bascule à 1 un bit d'un champ de bits. */
+void set_in_mem_field(memfield_t *, const vmpa2t *);
+
+/* Détermine si un bit est à 1 dans un champ de bits. */
+bool test_in_mem_field(memfield_t *, const vmpa2t *);
+
+
+
+#endif /* _COMMON_BITS_H */