--- rpl/src/analyse.c 2010/07/31 10:34:17 1.24 +++ rpl/src/analyse.c 2011/09/26 15:57:09 1.58 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.0.18 - Copyright (C) 1989-2010 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.4 + 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" /* @@ -35,7 +35,6 @@ ================================================================================ */ - static void creation_instruction(struct_processus *s_etat_processus, unsigned char *instruction, void (*routine)()) @@ -61,7 +60,7 @@ creation_instruction(struct_processus *s (*(*s_etat_processus).arbre_instructions).feuille = NULL; - if (((*(*s_etat_processus).arbre_instructions).noeud = + if (((*(*s_etat_processus).arbre_instructions).noeuds = malloc((*s_etat_processus).nombre_caracteres * sizeof(struct_instruction))) == NULL) { @@ -71,7 +70,7 @@ creation_instruction(struct_processus *s for(i = 0; i < (*s_etat_processus).nombre_caracteres; i++) { - (*(*s_etat_processus).arbre_instructions).noeud[i] = NULL; + (*(*s_etat_processus).arbre_instructions).noeuds[i] = NULL; } } @@ -84,12 +83,12 @@ creation_instruction(struct_processus *s printf("Instruction=\"%s\", (*ptr)='%c'\n", instruction, *ptr)); - if ((*l_instruction_courante).noeud[(*s_etat_processus) + if ((*l_instruction_courante).noeuds[(*s_etat_processus) .pointeurs_caracteres[*ptr]] == NULL) { // Le noeud suivant n'existe pas, on le crée. - if (((*l_instruction_courante).noeud[(*s_etat_processus) + if (((*l_instruction_courante).noeuds[(*s_etat_processus) .pointeurs_caracteres[*ptr]] = malloc(sizeof(struct_instruction))) == NULL) { @@ -97,11 +96,11 @@ creation_instruction(struct_processus *s return; } - (*(*l_instruction_courante).noeud[(*s_etat_processus) + (*(*l_instruction_courante).noeuds[(*s_etat_processus) .pointeurs_caracteres[*ptr]]).feuille = NULL; - if (((*(*l_instruction_courante).noeud[(*s_etat_processus) - .pointeurs_caracteres[*ptr]]).noeud = + if (((*(*l_instruction_courante).noeuds[(*s_etat_processus) + .pointeurs_caracteres[*ptr]]).noeuds = malloc((*s_etat_processus).nombre_caracteres * sizeof(struct_instruction))) == NULL) { @@ -111,12 +110,12 @@ creation_instruction(struct_processus *s for(i = 0; i < (*s_etat_processus).nombre_caracteres; i++) { - (*(*l_instruction_courante).noeud[(*s_etat_processus) - .pointeurs_caracteres[*ptr]]).noeud[i] = NULL; + (*(*l_instruction_courante).noeuds[(*s_etat_processus) + .pointeurs_caracteres[*ptr]]).noeuds[i] = NULL; } } - l_instruction_courante = (*l_instruction_courante).noeud + l_instruction_courante = (*l_instruction_courante).noeuds [(*s_etat_processus).pointeurs_caracteres[*ptr]]; ptr++; } @@ -138,13 +137,13 @@ liberation_arbre_instructions(struct_pro for(i = 0; i < (*s_etat_processus).nombre_caracteres; i++) { - if ((*arbre).noeud[i] != NULL) + if ((*arbre).noeuds[i] != NULL) { - liberation_arbre_instructions(s_etat_processus, (*arbre).noeud[i]); + liberation_arbre_instructions(s_etat_processus, (*arbre).noeuds[i]); } } - free((*arbre).noeud); + free((*arbre).noeuds); free(arbre); return; @@ -459,13 +458,16 @@ initialisation_instructions(struct_proce INSTRUCTION("INCR", instruction_incr); //INSTRUCTION("ISOL"); INSTRUCTION("ISWI", instruction_iswi); +# ifndef OS2 INSTRUCTION("KILL", instruction_kill); +# endif INSTRUCTION("KIND", instruction_kind); INSTRUCTION("LAST", instruction_last); INSTRUCTION("LEGV", instruction_legv); INSTRUCTION("LINE", instruction_line); INSTRUCTION("LNP1", instruction_lnp1); INSTRUCTION("LOCK", instruction_lock); + INSTRUCTION("L->T", instruction_l_vers_t); INSTRUCTION("MANT", instruction_mant); INSTRUCTION("MARK", instruction_mark); //INSTRUCTION("MAXR") @@ -486,7 +488,9 @@ initialisation_instructions(struct_proce INSTRUCTION("PLOT", instruction_plot); INSTRUCTION("PMAX", instruction_pmax); INSTRUCTION("PMIN", instruction_pmin); +# ifndef OS2 INSTRUCTION("POKE", instruction_poke); +# endif INSTRUCTION("PPAR", instruction_ppar); INSTRUCTION("PRMD", instruction_prmd); INSTRUCTION("PRST", instruction_prst); @@ -540,6 +544,7 @@ initialisation_instructions(struct_proce INSTRUCTION("SPAR", instruction_spar); INSTRUCTION("SQRT", instruction_sqrt); //INSTRUCTION("SRAD"); + INSTRUCTION("SREV", instruction_srev); //INSTRUCTION("SRNM") //Instruction HP48 (renvoie la norme spectrale d'un tableau. Pour une //matrice, @@ -552,7 +557,9 @@ initialisation_instructions(struct_proce INSTRUCTION("STO-", instruction_sto_moins); INSTRUCTION("STO/", instruction_sto_division); INSTRUCTION("STOF", instruction_stof); +# ifndef OS2 INSTRUCTION("STOP", instruction_stop); +# endif INSTRUCTION("STOS", instruction_stos); INSTRUCTION("STWS", instruction_stws); INSTRUCTION("SWAP", instruction_swap); @@ -565,6 +572,7 @@ initialisation_instructions(struct_proce INSTRUCTION("TRNC", instruction_trnc); INSTRUCTION("TRUE", instruction_true); INSTRUCTION("TYPE", instruction_type); + INSTRUCTION("T->L", instruction_t_vers_l); INSTRUCTION("UTPC", instruction_utpc); INSTRUCTION("UTPF", instruction_utpf); INSTRUCTION("UTPN", instruction_utpn); @@ -645,6 +653,7 @@ initialisation_instructions(struct_proce INSTRUCTION("LCASE", instruction_lcase); INSTRUCTION("LCHOL", instruction_lchol); INSTRUCTION("LCD->", instruction_lcd_fleche); + INSTRUCTION("LIMIT", instruction_limit); //INSTRUCTION("NDIST") //Instruction HP48 (distribution normale, prend la moyenne au niveau 3, //la variance au niveau 2, un réel x au niveau 1 et renvoie la probabilité @@ -685,7 +694,9 @@ initialisation_instructions(struct_proce INSTRUCTION("SLICE", instruction_slice); //INSTRUCTION("SLIST") //Instruction HP48 (somme des termes d'une liste) +# ifndef OS2 INSTRUCTION("SPAWN", instruction_spawn); +# endif INSTRUCTION("START", instruction_start); INSTRUCTION("STORE", instruction_store); INSTRUCTION("STR->", instruction_str_fleche); @@ -722,7 +733,9 @@ initialisation_instructions(struct_proce INSTRUCTION("CLRSWI", instruction_clrswi); INSTRUCTION("CREATE", instruction_create); INSTRUCTION("DELETE", instruction_delete); +# ifndef OS2 INSTRUCTION("DETACH", instruction_detach); +# endif INSTRUCTION("DIAG->", instruction_diag_fleche); //INSTRUCTION("DOLIST") //Instruction HP48 (application d'une fonction à une liste) @@ -816,10 +829,13 @@ initialisation_instructions(struct_proce INSTRUCTION("CLRCNTXT", instruction_clrcntxt); INSTRUCTION("CLRSMPHR", instruction_clrsmphr); +# ifndef OS2 INSTRUCTION("CONTINUE", instruction_continue); +# endif INSTRUCTION("DUPCNTXT", instruction_dupcntxt); INSTRUCTION("FUNCTION", instruction_function); INSTRUCTION("IMPLICIT", instruction_implicit); + INSTRUCTION("INFINITY", instruction_sensible_infinity); INSTRUCTION("KEYLABEL", instruction_keylabel); INSTRUCTION("KEYTITLE", instruction_keytitle); INSTRUCTION("LOGSCALE", instruction_logscale); @@ -884,7 +900,7 @@ initialisation_instructions(struct_proce } -extern inline void * +void * analyse_instruction(struct_processus *s_etat_processus, unsigned char *ptr) { int pointeur; @@ -904,14 +920,14 @@ analyse_instruction(struct_processus *s_ return(NULL); } - if ((*l_instruction_courante).noeud[pointeur] == NULL) + if ((*l_instruction_courante).noeuds[pointeur] == NULL) { // Le chemin de l'instruction candidate n'existe pas. return(NULL); } - l_instruction_courante = (*l_instruction_courante).noeud[pointeur]; + l_instruction_courante = (*l_instruction_courante).noeuds[pointeur]; ptr++; if ((l_instruction_courante == NULL) && ((*ptr) != d_code_fin_chaine)) @@ -970,28 +986,20 @@ analyse(struct_processus *s_etat_process */ # ifndef SEMAPHORES_NOMMES - if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) - { - (*s_etat_processus).erreur_systeme = d_es_processus; - return; - } - - while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) - { - if (errno != EINTR) - { - (*s_etat_processus).erreur_systeme = d_es_processus; - return; - } - } + if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) # else - if (sem_post((*s_etat_processus).semaphore_fork) != 0) + if (sem_post((*s_etat_processus).semaphore_fork) != 0) +# endif { (*s_etat_processus).erreur_systeme = d_es_processus; return; } - while(sem_wait((*s_etat_processus).semaphore_fork) == -1) +# ifndef SEMAPHORES_NOMMES + while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) +# else + while(sem_wait((*s_etat_processus).semaphore_fork) != 0) +# endif { if (errno != EINTR) { @@ -999,7 +1007,6 @@ analyse(struct_processus *s_etat_process return; } } -# endif scrutation_injection(s_etat_processus); @@ -1144,6 +1151,7 @@ analyse(struct_processus *s_etat_process -------------------------------------------------------------------------------- */ +# ifndef OS2 if ((*s_etat_processus).pourcentage_maximal_cpu < 100) { getrusage(RUSAGE_SELF, &usage_final); @@ -1199,6 +1207,7 @@ analyse(struct_processus *s_etat_process usage_initial = usage_final; } } +# endif /* --------------------------------------------------------------------------------