--- rpl/src/instructions_n2.c 2017/08/03 17:17:47 1.61 +++ rpl/src/instructions_n2.c 2017/08/21 12:17:20 1.62 @@ -350,4 +350,72 @@ instruction_nrproc(struct_processus *s_e return; } + +/* +================================================================================ + Fonction 'nbrcpus' +================================================================================ + Entrées : structure processus +-------------------------------------------------------------------------------- + Sorties : +-------------------------------------------------------------------------------- + Effets de bord : néant +================================================================================ +*/ + +void +instruction_nbrcpus(struct_processus *s_etat_processus) +{ + struct_objet *s_objet_resultat; + + (*s_etat_processus).erreur_execution = d_ex; + + if ((*s_etat_processus).affichage_arguments == 'Y') + { + printf("\n NBRCPUS "); + + if ((*s_etat_processus).langue == 'F') + { + printf("(nombre de processeurs sur le système)\n\n"); + printf("-> 1: %s\n", d_INT); + } + else + { + printf("(number of processors on system)\n\n"); + printf("-> 1: %s\n", d_INT); + } + + return; + } + else if ((*s_etat_processus).test_instruction == 'Y') + { + (*s_etat_processus).nombre_arguments = -1; + return; + } + + if (test_cfsf(s_etat_processus, 31) == d_vrai) + { + if (empilement_pile_last(s_etat_processus, 0) == d_erreur) + { + return; + } + } + + if ((s_objet_resultat = allocation(s_etat_processus, INT)) == NULL) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } + + (*((integer8 *) (*s_objet_resultat).objet)) = omp_get_num_procs(); + + if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile), + s_objet_resultat) == d_erreur) + { + return; + } + + return; +} + // vim: ts=4