--- rpl/src/instructions_v1.c 2012/12/19 09:58:27 1.47 +++ rpl/src/instructions_v1.c 2017/08/03 17:17:49 1.73 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.1.12 - Copyright (C) 1989-2012 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.28 + Copyright (C) 1989-2017 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; @@ -132,8 +132,8 @@ instruction_var(struct_processus *s_etat return; } - if (((*s_objet_resultat).objet = variance_statistique((struct_matrice *) - (*s_objet_statistique).objet, 'E')) == NULL) + if (((*s_objet_resultat).objet = variance_statistique(s_etat_processus, + (struct_matrice *) (*s_objet_statistique).objet, 'E')) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; @@ -500,7 +500,8 @@ instruction_version(struct_processus *s_ return; } - if (((*(*l_element_courant).donnee).objet = date_compilation()) == NULL) + if (((*(*l_element_courant).donnee).objet = + date_compilation(s_etat_processus)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; @@ -933,8 +934,8 @@ instruction_version(struct_processus *s_ return; } - if (((*(*l_element_courant).donnee).objet = conversion_majuscule(HOST)) - == NULL) + if (((*(*l_element_courant).donnee).objet = conversion_majuscule( + s_etat_processus, HOST)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; @@ -969,8 +970,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 +1026,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 +1035,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 +1094,6 @@ instruction_vars(struct_processus *s_eta tableau[i].origine) == NULL) { // La variable partagée n'existe plus. - continue; } @@ -1122,6 +1122,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 +1151,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 +1183,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 +1207,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 +1239,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 +1266,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 +1280,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 +1300,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 +1320,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 +1334,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 +1353,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 +1385,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 +1411,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 +1426,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 +1443,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 +1466,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 +1484,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 +1492,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 +1507,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 +1524,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 +1570,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 +1596,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 +1636,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;