--- rpl/src/optimisation.c 2013/03/21 11:30:31 1.49 +++ rpl/src/optimisation.c 2017/07/10 14:47:59 1.75 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.1.13 - Copyright (C) 1989-2013 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.27 + Copyright (C) 1989-2017 Dr. BERTRAND Joël This file is part of RPL/2. @@ -36,15 +36,20 @@ */ logical1 -sequenceur_optimise(struct_processus *s_etat_processus) +sequenceur_optimise(struct_processus *s_etat_processus, struct_liste_chainee + *l_bibliotheques) { integer8 adresse_point_entree; integer8 i; + integer8 j; integer8 nb_variables; integer8 point_entree; logical1 erreur; + struct_liste_chainee *l_bibliotheque_courante; + struct_liste_chainee *l_nouvelle_bibliotheque; + struct_objet *programme_principal; struct_tableau_variables *tableau; @@ -97,7 +102,7 @@ sequenceur_optimise(struct_processus *s_ return(d_erreur); } - liste_variables(s_etat_processus, tableau); + nb_variables = liste_variables(s_etat_processus, tableau); for(i = 0; i < nb_variables; i++) { @@ -136,6 +141,14 @@ sequenceur_optimise(struct_processus *s_ printf("+++Fatal : Compilation failed\n"); } + for(j = 0; j < nb_variables; j++) + { + if (tableau[j].mutex != NULL) + { + pthread_mutex_unlock(tableau[j].mutex); + } + } + free(tableau); return(d_erreur); } @@ -147,6 +160,7 @@ sequenceur_optimise(struct_processus *s_ registre = (*s_etat_processus).autorisation_nom_implicite; (*s_etat_processus).autorisation_nom_implicite = 'Y'; + (*s_etat_processus).type_en_cours = NON; recherche_type(s_etat_processus); (*s_etat_processus).autorisation_nom_implicite = registre; @@ -194,6 +208,14 @@ sequenceur_optimise(struct_processus *s_ printf("+++Fatal : Compilation failed\n"); } + for(j = 0; j < nb_variables; j++) + { + if (tableau[j].mutex != NULL) + { + pthread_mutex_unlock(tableau[j].mutex); + } + } + free(tableau); return(d_erreur); } @@ -213,6 +235,14 @@ sequenceur_optimise(struct_processus *s_ printf("+++Fatal : Compilation failed\n"); } + for(j = 0; j < nb_variables; j++) + { + if (tableau[j].mutex != NULL) + { + pthread_mutex_unlock(tableau[j].mutex); + } + } + free(tableau); return(d_erreur); } @@ -232,6 +262,14 @@ sequenceur_optimise(struct_processus *s_ printf("+++Fatal : Compilation failed\n"); } + for(j = 0; j < nb_variables; j++) + { + if (tableau[j].mutex != NULL) + { + pthread_mutex_unlock(tableau[j].mutex); + } + } + free(tableau); return(d_erreur); } @@ -258,6 +296,14 @@ sequenceur_optimise(struct_processus *s_ printf("+++Fatal : Compilation failed\n"); } + for(j = 0; j < nb_variables; j++) + { + if (tableau[j].mutex != NULL) + { + pthread_mutex_unlock(tableau[j].mutex); + } + } + free(tableau); return(d_erreur); } @@ -299,6 +345,14 @@ sequenceur_optimise(struct_processus *s_ printf("+++Fatal : Compilation failed\n"); } + for(j = 0; j < nb_variables; j++) + { + if (tableau[j].mutex != NULL) + { + pthread_mutex_unlock(tableau[j].mutex); + } + } + free(tableau); return(d_erreur); } @@ -323,12 +377,61 @@ sequenceur_optimise(struct_processus *s_ printf("+++System : Not enough memory\n"); } + for(j = 0; j < nb_variables; j++) + { + if (tableau[j].mutex != NULL) + { + pthread_mutex_unlock(tableau[j].mutex); + } + } + free(tableau); return(d_erreur); } + for(j = 0; j < nb_variables; j++) + { + if (tableau[j].mutex != NULL) + { + pthread_mutex_unlock(tableau[j].mutex); + } + } + free(tableau); + + // Libération des bibliothèques + + l_bibliotheque_courante = l_bibliotheques; + + while(l_bibliotheque_courante != NULL) + { + if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile), + (*l_bibliotheque_courante).donnee) == d_erreur) + { + if ((*s_etat_processus).langue == 'F') + { + printf("+++Système : Mémoire insuffisante\n"); + } + else + { + printf("+++System : Not enough memory\n"); + } + + return(d_erreur); + } + + affichage_rplso = d_faux; + instruction_remove(s_etat_processus); + affichage_rplso = d_vrai; + + l_nouvelle_bibliotheque = + (*l_bibliotheque_courante).suivant; + free(l_bibliotheque_courante); + l_bibliotheque_courante = + l_nouvelle_bibliotheque; + } + erreur = evaluation(s_etat_processus, programme_principal, 'E'); if ((*s_etat_processus).profilage == d_vrai)