--- rpl/src/instructions_v1.c 2011/06/20 17:54:20 1.21 +++ rpl/src/instructions_v1.c 2013/02/26 19:56:16 1.48 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.1.0.prerelease.1 - Copyright (C) 1989-2011 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.12 + Copyright (C) 1989-2013 Dr. BERTRAND Joël This file is part of RPL/2. @@ -237,6 +237,7 @@ instruction_version(struct_processus *s_ struct_objet *s_objet_resultat; unsigned char texte[] = "RPL/2 version "; + unsigned char tampon[256 + 1]; (*s_etat_processus).erreur_execution = d_ex; @@ -499,16 +500,12 @@ instruction_version(struct_processus *s_ return; } - if (((*(*l_element_courant).donnee).objet = malloc((strlen(d_date_en_rpl) - + 1) * sizeof(unsigned char))) == NULL) + if (((*(*l_element_courant).donnee).objet = date_compilation()) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } - strcpy((unsigned char *) (*(*l_element_courant).donnee).objet, - d_date_en_rpl); - /* * Ajout des options de compilation */ @@ -830,8 +827,8 @@ instruction_version(struct_processus *s_ return; } -#ifdef DEBUG - if (((*(*l_element_courant).donnee).objet = malloc(6 * +#ifdef RPLCAS + if (((*(*l_element_courant).donnee).objet = malloc(8 * sizeof(unsigned char))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -839,9 +836,9 @@ instruction_version(struct_processus *s_ } strcpy((unsigned char *) (*(*l_element_courant).donnee).objet, - "DEBUG"); + "RPL/CAS"); #else - if (((*(*l_element_courant).donnee).objet = malloc(15 * + if (((*(*l_element_courant).donnee).objet = malloc(17 * sizeof(unsigned char))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -849,7 +846,7 @@ instruction_version(struct_processus *s_ } strcpy((unsigned char *) (*(*l_element_courant).donnee).objet, - "DEBUG DISABLED"); + "RPL/CAS DISABLED"); #endif if (((*l_element_courant).suivant = @@ -891,6 +888,58 @@ instruction_version(struct_processus *s_ "EXPERIMENTAL CODE DISABLED"); #endif + if (((*l_element_courant).suivant = + allocation_maillon(s_etat_processus)) == NULL) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } + + l_element_courant = (*l_element_courant).suivant; + (*l_element_courant).suivant = NULL; + + if (((*l_element_courant).donnee = allocation(s_etat_processus, CHN)) + == NULL) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } + + sprintf(tampon, "%zu BITS ABI", sizeof(void *) * 8); + + if (((*(*l_element_courant).donnee).objet = malloc((strlen(tampon) + 1 ) + * sizeof(unsigned char))) == NULL) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } + + strcpy((unsigned char *) (*(*l_element_courant).donnee).objet, tampon); + + if (((*l_element_courant).suivant = + allocation_maillon(s_etat_processus)) == NULL) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } + + l_element_courant = (*l_element_courant).suivant; + (*l_element_courant).suivant = NULL; + + if (((*l_element_courant).donnee = allocation(s_etat_processus, CHN)) + == NULL) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } + + if (((*(*l_element_courant).donnee).objet = conversion_majuscule(HOST)) + == NULL) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } + /* * Empilement du résultat */ @@ -974,18 +1023,18 @@ instruction_vars(struct_processus *s_eta (*s_objet_resultat).objet = NULL; l_element_precedent = NULL; - nb_variables = nombre_variables(s_etat_processus, - (*s_etat_processus).s_arbre_variables); + nb_variables = nombre_variables(s_etat_processus); if ((tableau = malloc(nb_variables * sizeof(struct_tableau_variables))) == NULL) { + liberation_mutexes_arbre_variables_partagees(s_etat_processus, + (*(*s_etat_processus).s_arbre_variables_partagees)); (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } - liste_variables(s_etat_processus, tableau, 0, - (*s_etat_processus).s_arbre_variables); + liste_variables(s_etat_processus, tableau); for(i = 0; i < nb_variables; i++) { @@ -1039,26 +1088,12 @@ instruction_vars(struct_processus *s_eta if (tableau[i].objet == NULL) { - if (pthread_mutex_lock(&((*(*s_etat_processus) - .s_liste_variables_partagees).mutex)) != 0) - { - (*s_etat_processus).erreur_systeme = d_es_processus; - return; - } - if (recherche_variable_partagee(s_etat_processus, tableau[i].nom, tableau[i].variable_partagee, - tableau[i].origine) == d_faux) + tableau[i].origine) == NULL) { // La variable partagée n'existe plus. - if (pthread_mutex_unlock(&((*(*s_etat_processus) - .s_liste_variables_partagees).mutex)) != 0) - { - (*s_etat_processus).erreur_systeme = d_es_processus; - return; - } - continue; } @@ -1080,7 +1115,7 @@ instruction_vars(struct_processus *s_eta if (variable_partagee == d_vrai) { if (pthread_mutex_unlock(&((*(*s_etat_processus) - .s_liste_variables_partagees).mutex)) != 0) + .pointeur_variable_partagee_courante).mutex)) != 0) { (*s_etat_processus).erreur_systeme = d_es_processus; return; @@ -1103,7 +1138,7 @@ instruction_vars(struct_processus *s_eta if (variable_partagee == d_vrai) { if (pthread_mutex_unlock(&((*(*s_etat_processus) - .s_liste_variables_partagees).mutex)) != 0) + .pointeur_variable_partagee_courante).mutex)) != 0) { (*s_etat_processus).erreur_systeme = d_es_processus; return; @@ -1129,7 +1164,7 @@ instruction_vars(struct_processus *s_eta if (variable_partagee == d_vrai) { if (pthread_mutex_unlock(&((*(*s_etat_processus) - .s_liste_variables_partagees).mutex)) != 0) + .pointeur_variable_partagee_courante).mutex)) != 0) { (*s_etat_processus).erreur_systeme = d_es_processus; return; @@ -1147,7 +1182,7 @@ instruction_vars(struct_processus *s_eta if (variable_partagee == d_vrai) { if (pthread_mutex_unlock(&((*(*s_etat_processus) - .s_liste_variables_partagees).mutex)) != 0) + .pointeur_variable_partagee_courante).mutex)) != 0) { (*s_etat_processus).erreur_systeme = d_es_processus; return; @@ -1173,7 +1208,7 @@ instruction_vars(struct_processus *s_eta if (variable_partagee == d_vrai) { if (pthread_mutex_unlock(&((*(*s_etat_processus) - .s_liste_variables_partagees).mutex)) != 0) + .pointeur_variable_partagee_courante).mutex)) != 0) { (*s_etat_processus).erreur_systeme = d_es_processus; return; @@ -1191,13 +1226,11 @@ instruction_vars(struct_processus *s_eta if (((*(*(*((struct_liste_chainee *) (*((struct_objet *) (*l_element_courant).donnee)).objet)).suivant).suivant) .donnee = copie_objet(s_etat_processus, - (*(*s_etat_processus) - .s_liste_variables_partagees).table[(*(*s_etat_processus) - .s_liste_variables_partagees).position_variable].objet, - 'P')) == NULL) + (*(*s_etat_processus).pointeur_variable_partagee_courante) + .objet, 'P')) == NULL) { if (pthread_mutex_unlock(&((*(*s_etat_processus) - .s_liste_variables_partagees).mutex)) != 0) + .pointeur_variable_partagee_courante).mutex)) != 0) { (*s_etat_processus).erreur_systeme = d_es_processus; return; @@ -1208,7 +1241,7 @@ instruction_vars(struct_processus *s_eta } if (pthread_mutex_unlock(&((*(*s_etat_processus) - .s_liste_variables_partagees).mutex)) != 0) + .pointeur_variable_partagee_courante).mutex)) != 0) { (*s_etat_processus).erreur_systeme = d_es_processus; return; @@ -1261,9 +1294,20 @@ instruction_vars(struct_processus *s_eta return; } - strcpy((unsigned char *) (*(*(*(*(*((struct_liste_chainee *) - (*((struct_objet *) (*l_element_courant).donnee)).objet)) - .suivant).suivant) .suivant).donnee).objet, "STATIC"); + if (tableau[i].variable_masquee == d_vrai) + { + strcpy((unsigned char *) (*(*(*(*(*((struct_liste_chainee *) + (*((struct_objet *) (*l_element_courant).donnee)) + .objet)).suivant).suivant).suivant).donnee).objet, + "SHADOW"); + } + else + { + strcpy((unsigned char *) (*(*(*(*(*((struct_liste_chainee *) + (*((struct_objet *) (*l_element_courant).donnee)) + .objet)).suivant).suivant).suivant).donnee).objet, + "STATIC"); + } } else {