From b24aca86f0a096730fa8df440f7493556b39ae46 Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Fri, 11 May 2018 15:44:46 +0200
Subject: Reorganized processor registrations.

---
 plugins/arm/core.c    |  6 ++----
 plugins/arm/v7/core.c |  6 +++++-
 plugins/dalvik/core.c |  3 +--
 src/core/processors.c | 13 +------------
 src/core/processors.h |  9 +--------
 5 files changed, 10 insertions(+), 27 deletions(-)

diff --git a/plugins/arm/core.c b/plugins/arm/core.c
index a23a96e..43e82e4 100644
--- a/plugins/arm/core.c
+++ b/plugins/arm/core.c
@@ -24,13 +24,11 @@
 #include "core.h"
 
 
-#include <core/processors.h>
 #include <plugins/plugin-def.h>
 
 
 #include "python/module.h"
 #include "v7/core.h"
-#include "v7/processor.h"
 
 
 
@@ -55,8 +53,7 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin)
 {
     bool result;                            /* Bilan à retourner           */
 
-    result = register_processor_type("armv7", "ARM v7", G_TYPE_ARMV7_PROCESSOR,
-                                     init_armv7_core, exit_armv7_core);
+    result = init_armv7_core();
 
     if (result)
         result = add_arch_arm_module_to_python_module();
@@ -79,5 +76,6 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin)
 
 G_MODULE_EXPORT void chrysalide_plugin_exit(GPluginModule *plugin)
 {
+    exit_armv7_core();
 
 }
diff --git a/plugins/arm/v7/core.c b/plugins/arm/v7/core.c
index 06b8d23..a2ed090 100644
--- a/plugins/arm/v7/core.c
+++ b/plugins/arm/v7/core.c
@@ -24,6 +24,10 @@
 #include "core.h"
 
 
+#include <core/processors.h>
+#include "processor.h"
+
+
 
 /******************************************************************************
 *                                                                             *
@@ -41,7 +45,7 @@ bool init_armv7_core(void)
 {
     bool result;                            /* Bilan à renvoyer            */
 
-    result = true;
+    result = register_processor_type("armv7", "ARM v7", G_TYPE_ARMV7_PROCESSOR);
 
     return result;
 
diff --git a/plugins/dalvik/core.c b/plugins/dalvik/core.c
index 7a32112..f945c18 100644
--- a/plugins/dalvik/core.c
+++ b/plugins/dalvik/core.c
@@ -54,8 +54,7 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin)
 {
     bool result;                            /* Bilan à retourner           */
 
-    result = register_processor_type("dalvik35", "Dalvik Virtual Machine v35", G_TYPE_DALVIK35_PROCESSOR,
-                                     NULL, NULL);
+    result = register_processor_type("dalvik35", "Dalvik Virtual Machine v35", G_TYPE_DALVIK35_PROCESSOR);
 
     return result;
 
diff --git a/src/core/processors.c b/src/core/processors.c
index 4678d7a..0251f6f 100644
--- a/src/core/processors.c
+++ b/src/core/processors.c
@@ -40,9 +40,6 @@ typedef struct _proc_t
     char *name;                             /* Désignation humaine         */
     GType instance;                         /* Type à manipuler en interne */
 
-    init_arch_fc init;                      /* Phase d'intialisation       */
-    exit_arch_fc exit;                      /* Phase de relâchement        */
-
 } proc_t;
 
 
@@ -64,8 +61,6 @@ static proc_t *find_processor_by_key(const char *);
 *  Paramètres  : key      = désignation rapide et interne d'un processeur.    *
 *                name     = désignation humaine de l'architecture.            *
 *                instance = type GLib représentant le type à instancier.      *
-*                init     = procédure d'initialisation de mécanismes internes.*
-*                exit     = procédure de suppression de mécanismes internes.  *
 *                                                                             *
 *  Description : Enregistre un processeur pour une architecture donnée.       *
 *                                                                             *
@@ -75,7 +70,7 @@ static proc_t *find_processor_by_key(const char *);
 *                                                                             *
 ******************************************************************************/
 
-bool register_processor_type(const char *key, const char *name, GType instance, init_arch_fc init, exit_arch_fc exit)
+bool register_processor_type(const char *key, const char *name, GType instance)
 {
     bool result;                            /* Bilan à retourner           */
     proc_t *new;                            /* Nouvel élément à définir    */
@@ -86,9 +81,6 @@ bool register_processor_type(const char *key, const char *name, GType instance,
 
     result = (new == NULL);
 
-    if (init != NULL)
-        result &= init();
-
     if (result)
     {
         _processors_definitions = (proc_t *)realloc(_processors_definitions,
@@ -100,9 +92,6 @@ bool register_processor_type(const char *key, const char *name, GType instance,
         new->name = strdup(name);
         new->instance = instance;
 
-        new->init = init;
-        new->exit = exit;
-
     }
 
     G_UNLOCK(_pdef_access);
diff --git a/src/core/processors.h b/src/core/processors.h
index cd87b68..10bbcf3 100644
--- a/src/core/processors.h
+++ b/src/core/processors.h
@@ -33,15 +33,8 @@
 
 
 
-/* Mise en place de mécanismes internes */
-typedef bool (* init_arch_fc) (void);
-
-/* Suppression de mécanismes internes */
-typedef void (* exit_arch_fc) (void);
-
-
 /* Enregistre un processeur pour une architecture donnée. */
-bool register_processor_type(const char *, const char *, GType, init_arch_fc, exit_arch_fc);
+bool register_processor_type(const char *, const char *, GType);
 
 /* Charge les définitions de processeurs "natifs". */
 bool load_hard_coded_processors_definitions(void);
-- 
cgit v0.11.2-87-g4458