--- rpl/src/instructions_v1.c 2013/02/27 17:11:44 1.49 +++ rpl/src/instructions_v1.c 2015/01/05 13:12:40 1.61 @@ -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.19 + Copyright (C) 1989-2015 Dr. BERTRAND Joël This file is part of RPL/2. @@ -42,7 +42,7 @@ instruction_var(struct_processus *s_etat struct_objet *s_objet_resultat; struct_objet *s_objet_temporaire; - unsigned long nombre_colonnes; + integer8 nombre_colonnes; (*s_etat_processus).erreur_execution = d_ex; @@ -969,8 +969,8 @@ instruction_version(struct_processus *s_ void instruction_vars(struct_processus *s_etat_processus) { - int i; - int nb_variables; + integer8 i; + integer8 nb_variables; logical1 variable_partagee; @@ -1025,8 +1025,8 @@ instruction_vars(struct_processus *s_eta nb_variables = nombre_variables(s_etat_processus); - if ((tableau = malloc(nb_variables * sizeof(struct_tableau_variables))) - == NULL) + if ((tableau = malloc(((size_t) nb_variables) * + sizeof(struct_tableau_variables))) == NULL) { liberation_mutexes_arbre_variables_partagees(s_etat_processus, (*(*s_etat_processus).s_arbre_variables_partagees)); @@ -1034,7 +1034,7 @@ instruction_vars(struct_processus *s_eta return; } - liste_variables(s_etat_processus, tableau); + nb_variables = liste_variables(s_etat_processus, tableau); for(i = 0; i < nb_variables; i++) { @@ -1093,7 +1093,6 @@ instruction_vars(struct_processus *s_eta tableau[i].origine) == NULL) { // La variable partagée n'existe plus. - continue; } @@ -1122,6 +1121,12 @@ instruction_vars(struct_processus *s_eta } } + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1145,6 +1150,12 @@ instruction_vars(struct_processus *s_eta } } + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1171,6 +1182,12 @@ instruction_vars(struct_processus *s_eta } } + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1189,6 +1206,12 @@ instruction_vars(struct_processus *s_eta } } + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1215,6 +1238,12 @@ instruction_vars(struct_processus *s_eta } } + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1236,6 +1265,13 @@ instruction_vars(struct_processus *s_eta return; } + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère + // le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1243,6 +1279,13 @@ instruction_vars(struct_processus *s_eta if (pthread_mutex_unlock(&((*(*s_etat_processus) .pointeur_variable_partagee_courante).mutex)) != 0) { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère + // le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_processus; return; } @@ -1256,6 +1299,13 @@ instruction_vars(struct_processus *s_eta .donnee = copie_objet(s_etat_processus, tableau[i].objet, 'P')) == NULL) { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère + // le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1269,6 +1319,12 @@ instruction_vars(struct_processus *s_eta (*l_element_courant).donnee)).objet)).suivant).suivant) .suivant = allocation_maillon(s_etat_processus)) == NULL) { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1277,6 +1333,12 @@ instruction_vars(struct_processus *s_eta (*l_element_courant).donnee)).objet)).suivant).suivant).suivant) .donnee = allocation(s_etat_processus, CHN)) == NULL) { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1290,6 +1352,13 @@ instruction_vars(struct_processus *s_eta .suivant).donnee).objet = malloc(7 * sizeof(unsigned char))) == NULL) { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère + // le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1315,7 +1384,14 @@ instruction_vars(struct_processus *s_eta (*l_element_courant).donnee)).objet)).suivant).suivant) .suivant).donnee).objet = malloc(9 * sizeof(unsigned char))) == NULL) - { + { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère + // le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1334,6 +1410,12 @@ instruction_vars(struct_processus *s_eta .suivant).suivant = allocation_maillon(s_etat_processus)) == NULL) { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1343,6 +1425,12 @@ instruction_vars(struct_processus *s_eta .suivant).donnee = allocation(s_etat_processus, CHN)) == NULL) { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1354,6 +1442,13 @@ instruction_vars(struct_processus *s_eta .suivant).suivant).donnee).objet = malloc(7 * sizeof(unsigned char))) == NULL) { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère + // le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1370,6 +1465,13 @@ instruction_vars(struct_processus *s_eta .suivant).suivant).donnee).objet = malloc(9 * sizeof(unsigned char))) == NULL) { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère + // le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1381,7 +1483,7 @@ instruction_vars(struct_processus *s_eta } /* - * Préparation du drapeau PRIVATE/SHARED + * Préparation du drapeau PRIVATE/SHARED/MAPPED */ if (((*(*(*(*(*((struct_liste_chainee *) (*((struct_objet *) @@ -1389,6 +1491,12 @@ instruction_vars(struct_processus *s_eta .suivant).suivant).suivant = allocation_maillon(s_etat_processus)) == NULL) { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1398,6 +1506,12 @@ instruction_vars(struct_processus *s_eta .suivant).suivant).donnee = allocation(s_etat_processus, CHN)) == NULL) { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1409,6 +1523,36 @@ instruction_vars(struct_processus *s_eta .suivant).suivant).suivant).donnee).objet = malloc(7 * sizeof(unsigned char))) == NULL) { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère + // le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } + + strcpy((unsigned char *) (*(*(*(*(*(*(*((struct_liste_chainee *) + (*((struct_objet *) (*l_element_courant).donnee)).objet)) + .suivant).suivant).suivant).suivant).suivant).donnee).objet, + "MAPPED"); + } + else if (tableau[i].mutex != NULL) + { + if (((*(*(*(*(*(*(*((struct_liste_chainee *) (*((struct_objet *) + (*l_element_courant).donnee)).objet)).suivant).suivant) + .suivant).suivant).suivant).donnee).objet = malloc(7 * + sizeof(unsigned char))) == NULL) + { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère + // le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1425,6 +1569,13 @@ instruction_vars(struct_processus *s_eta .suivant).suivant).suivant).donnee).objet = malloc(8 * sizeof(unsigned char))) == NULL) { + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère + // le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } @@ -1444,6 +1595,13 @@ instruction_vars(struct_processus *s_eta .suivant).suivant).suivant).suivant = NULL; l_element_precedent = l_element_courant; + + if (tableau[i].mutex != NULL) + { + // La variable est une variable partagée. On libère + // le mutex. + pthread_mutex_unlock(tableau[i].mutex); + } } free(tableau); @@ -1477,7 +1635,7 @@ instruction_visit(struct_processus *s_et struct_objet *s_objet; - unsigned long profondeur_initiale; + integer8 profondeur_initiale; (*s_etat_processus).erreur_execution = d_ex;