--- rpl/src/bibliotheques_externes.c 2010/04/07 13:45:00 1.6 +++ rpl/src/bibliotheques_externes.c 2011/09/20 09:51:42 1.36 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.0.14 - Copyright (C) 1989-2010 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.3 + Copyright (C) 1989-2011 Dr. BERTRAND Joël This file is part of RPL/2. @@ -20,7 +20,7 @@ */ -#include "rpl.conv.h" +#include "rpl-conv.h" static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; @@ -41,9 +41,12 @@ void * chargement_bibliotheque(struct_processus *s_etat_processus, unsigned char *bibliotheque) { - char **(*fonction)(unsigned long *); + char **(*fonction)(unsigned long *, const char *); char *message; + long i; + long nombre_symboles; + struct_rpl_arguments rpl_arguments; struct_liste_chainee *l_element_courant; @@ -52,9 +55,6 @@ chargement_bibliotheque(struct_processus unsigned char **tableau; unsigned char *tampon; - unsigned long nombre_symboles; - unsigned long i; - void *descripteur_bibliotheque; void (*onloading)(struct_rpl_arguments *); @@ -169,7 +169,7 @@ chargement_bibliotheque(struct_processus (*onloading)(&rpl_arguments); - while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) + while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) { if (errno != EINTR) { @@ -315,6 +315,8 @@ chargement_bibliotheque(struct_processus } } + dlerror(); + if (pthread_mutex_unlock(&mutex) != 0) { (*s_etat_processus).erreur_systeme = d_es_processus; @@ -325,12 +327,24 @@ chargement_bibliotheque(struct_processus * Ajout des symboles externes */ - if ((tableau = (unsigned char **) (*fonction)(&nombre_symboles)) == NULL) + if ((tableau = (unsigned char **) (*fonction)((&nombre_symboles), + d_version_rpl)) == NULL) { + /* + * Nombre symboles : + * 0 : aucun symbole exporté + * >0 : nombre de symboles exportés + * -1 : version de bibliothèque incompatible + */ + if (nombre_symboles == 0) { (*s_etat_processus).erreur_execution = d_ex_aucun_symbole; } + else if (nombre_symboles == -1) + { + (*s_etat_processus).erreur_execution = d_ex_version_bibliotheque; + } else { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -380,6 +394,7 @@ chargement_bibliotheque(struct_processus strcpy((*s_etat_processus).s_instructions_externes[(*s_etat_processus) .nombre_instructions_externes].nom_bibliotheque, tableau[i]); (*s_etat_processus).nombre_instructions_externes++; + free(tableau[i]); } @@ -565,7 +580,7 @@ retrait_bibliotheque(struct_processus *s (*onclosing)(&rpl_arguments); - while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) + while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) { if (errno != EINTR) { @@ -1067,6 +1082,8 @@ execution_fonction_de_bibliotheque(struc } } + dlerror(); + if (pthread_mutex_unlock(&mutex) != 0) { (*s_etat_processus).erreur_systeme = d_es_processus; @@ -1130,7 +1147,7 @@ execution_fonction_de_bibliotheque(struc (*fonction)(&rpl_arguments); - while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) + while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) { if (errno != EINTR) { @@ -1593,7 +1610,6 @@ tri_base_symboles_externes(struct_proces do { indice_i = indice_j; - terminaison_boucle_3 = d_faux; do @@ -1687,7 +1703,7 @@ tri_base_symboles_externes(struct_proces indice_i++; } while((unsigned long) (indice_i + 1) < - (*s_etat_processus).nombre_variables); + (*s_etat_processus).nombre_instructions_externes); return; }