File:  [local] / rpl / src / instructions_p7.c
Revision 1.84: download - view: text, annotated - select for diffs - revision graph
Fri Jan 10 11:15:47 2020 UTC (4 years, 3 months ago) by bertrand
Branches: MAIN
CVS tags: rpl-4_1_32, HEAD
Modification du copyright.

    1: /*
    2: ================================================================================
    3:   RPL/2 (R) version 4.1.32
    4:   Copyright (C) 1989-2020 Dr. BERTRAND Joël
    5: 
    6:   This file is part of RPL/2.
    7: 
    8:   RPL/2 is free software; you can redistribute it and/or modify it
    9:   under the terms of the CeCILL V2 License as published by the french
   10:   CEA, CNRS and INRIA.
   11:  
   12:   RPL/2 is distributed in the hope that it will be useful, but WITHOUT
   13:   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   14:   FITNESS FOR A PARTICULAR PURPOSE.  See the CeCILL V2 License
   15:   for more details.
   16:  
   17:   You should have received a copy of the CeCILL License
   18:   along with RPL/2. If not, write to info@cecill.info.
   19: ================================================================================
   20: */
   21: 
   22: 
   23: #include "rpl-conv.h"
   24: 
   25: 
   26: /*
   27: ================================================================================
   28:   Fonction 'protect'
   29: ================================================================================
   30:   Entrées :
   31: --------------------------------------------------------------------------------
   32:   Sorties :
   33: --------------------------------------------------------------------------------
   34:   Effets de bord : néant
   35: ================================================================================
   36: */
   37: 
   38: void
   39: instruction_protect(struct_processus *s_etat_processus)
   40: {
   41:     struct_liste_chainee                *l_element_courant;
   42: 
   43:     struct_objet                        *s_objet;
   44: 
   45:     (*s_etat_processus).erreur_execution = d_ex;
   46: 
   47:     if ((*s_etat_processus).affichage_arguments == 'Y')
   48:     {
   49:         printf("\n  PROTECT ");
   50: 
   51:         if ((*s_etat_processus).langue == 'F')
   52:         {
   53:             printf("(verrouille une variable)\n\n");
   54:         }
   55:         else
   56:         {
   57:             printf("(lock a variable)\n\n");
   58:         }
   59: 
   60:         printf("    1: %s, %s\n", d_NOM, d_LST);
   61: 
   62:         return;
   63:     }
   64:     else if ((*s_etat_processus).test_instruction == 'Y')
   65:     {
   66:         (*s_etat_processus).nombre_arguments = -1;
   67:         return;
   68:     }
   69:     
   70:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
   71:     {
   72:         if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
   73:         {
   74:             return;
   75:         }
   76:     }
   77: 
   78:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
   79:             &s_objet) == d_erreur)
   80:     {
   81:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
   82:         return;
   83:     }
   84: 
   85:     if ((*s_objet).type == NOM)
   86:     {
   87:         if (recherche_variable(s_etat_processus, ((*((struct_nom *)
   88:                 (*s_objet).objet)).nom)) == d_faux)
   89:         {
   90:             liberation(s_etat_processus, s_objet);
   91: 
   92:             (*s_etat_processus).erreur_systeme = d_es;
   93:             (*s_etat_processus).erreur_execution = d_ex_variable_non_definie;
   94:             return;
   95:         }
   96: 
   97:         (*(*s_etat_processus).pointeur_variable_courante)
   98:                 .variable_verrouillee = d_vrai;
   99:     }
  100:     else if ((*s_objet).type == LST)
  101:     {
  102:         l_element_courant = (struct_liste_chainee *) (*s_objet).objet;
  103: 
  104:         while(l_element_courant != NULL)
  105:         {
  106:             if ((*(*l_element_courant).donnee).type != NOM)
  107:             {
  108:                 liberation(s_etat_processus, s_objet);
  109: 
  110:                 (*s_etat_processus).erreur_execution = d_ex_nom_invalide;
  111:                 return;
  112:             }
  113: 
  114:             if (recherche_variable(s_etat_processus, (*((struct_nom *)
  115:                     (*(*l_element_courant).donnee).objet)).nom) == d_faux)
  116:             {
  117:                 liberation(s_etat_processus, s_objet);
  118: 
  119:                 (*s_etat_processus).erreur_systeme = d_es;
  120:                 (*s_etat_processus).erreur_execution =
  121:                         d_ex_variable_non_definie;
  122:                 return;
  123:             }
  124: 
  125:             (*(*s_etat_processus).pointeur_variable_courante)
  126:                     .variable_verrouillee = d_vrai;
  127: 
  128:             l_element_courant = (*l_element_courant).suivant;
  129:         }
  130:     }
  131:     else
  132:     {
  133:         liberation(s_etat_processus, s_objet);
  134: 
  135:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
  136:         return;
  137:     }
  138: 
  139:     liberation(s_etat_processus, s_objet);
  140: 
  141:     return;
  142: }
  143: 
  144: 
  145: /*
  146: ================================================================================
  147:   Fonction 'parameter'
  148: ================================================================================
  149:   Entrées :
  150: --------------------------------------------------------------------------------
  151:   Sorties :
  152: --------------------------------------------------------------------------------
  153:   Effets de bord : néant
  154: ================================================================================
  155: */
  156: 
  157: void
  158: instruction_parameter(struct_processus *s_etat_processus)
  159: {
  160:     struct_liste_chainee                *l_element_courant;
  161: 
  162:     struct_objet                        *s_objet;
  163: 
  164:     (*s_etat_processus).erreur_execution = d_ex;
  165: 
  166:     if ((*s_etat_processus).affichage_arguments == 'Y')
  167:     {
  168:         printf("\n  PARAMETER ");
  169: 
  170:         if ((*s_etat_processus).langue == 'F')
  171:         {
  172:             printf("(verrouille une variable globale)\n\n");
  173:         }
  174:         else
  175:         {
  176:             printf("(lock a global variable)\n\n");
  177:         }
  178: 
  179:         printf("    1: %s, %s\n", d_NOM, d_LST);
  180: 
  181:         return;
  182:     }
  183:     else if ((*s_etat_processus).test_instruction == 'Y')
  184:     {
  185:         (*s_etat_processus).nombre_arguments = -1;
  186:         return;
  187:     }
  188:     
  189:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
  190:     {
  191:         if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
  192:         {
  193:             return;
  194:         }
  195:     }
  196: 
  197:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  198:             &s_objet) == d_erreur)
  199:     {
  200:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
  201:         return;
  202:     }
  203: 
  204:     if ((*s_objet).type == NOM)
  205:     {
  206:         if (recherche_variable_globale(s_etat_processus, ((*((struct_nom *)
  207:                 (*s_objet).objet)).nom)) == d_faux)
  208:         {
  209:             liberation(s_etat_processus, s_objet);
  210: 
  211:             (*s_etat_processus).erreur_systeme = d_es;
  212:             (*s_etat_processus).erreur_execution = d_ex_variable_non_definie;
  213:             return;
  214:         }
  215: 
  216:         (*(*s_etat_processus).pointeur_variable_courante)
  217:                 .variable_verrouillee = d_vrai;
  218:     }
  219:     else if ((*s_objet).type == LST)
  220:     {
  221:         l_element_courant = (struct_liste_chainee *) (*s_objet).objet;
  222: 
  223:         while(l_element_courant != NULL)
  224:         {
  225:             if ((*(*l_element_courant).donnee).type != NOM)
  226:             {
  227:                 liberation(s_etat_processus, s_objet);
  228: 
  229:                 (*s_etat_processus).erreur_execution = d_ex_nom_invalide;
  230:                 return;
  231:             }
  232: 
  233:             if (recherche_variable_globale(s_etat_processus, (*((struct_nom *)
  234:                     (*(*l_element_courant).donnee).objet)).nom) == d_faux)
  235:             {
  236:                 liberation(s_etat_processus, s_objet);
  237: 
  238:                 (*s_etat_processus).erreur_systeme = d_es;
  239:                 (*s_etat_processus).erreur_execution =
  240:                         d_ex_variable_non_definie;
  241:                 return;
  242:             }
  243: 
  244:             (*(*s_etat_processus).pointeur_variable_courante)
  245:                     .variable_verrouillee = d_vrai;
  246: 
  247:             l_element_courant = (*l_element_courant).suivant;
  248:         }
  249:     }
  250:     else
  251:     {
  252:         liberation(s_etat_processus, s_objet);
  253: 
  254:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
  255:         return;
  256:     }
  257: 
  258:     liberation(s_etat_processus, s_objet);
  259: 
  260:     return;
  261: }
  262: 
  263: 
  264: /*
  265: ================================================================================
  266:   Fonction 'pshcntxt'
  267: ================================================================================
  268:   Entrées :
  269: --------------------------------------------------------------------------------
  270:   Sorties :
  271: --------------------------------------------------------------------------------
  272:   Effets de bord : néant
  273: ================================================================================
  274: */
  275: 
  276: void
  277: instruction_pshcntxt(struct_processus *s_etat_processus)
  278: {
  279:     struct_objet                *s_objet;
  280: 
  281:     (*s_etat_processus).erreur_execution = d_ex;
  282: 
  283:     if ((*s_etat_processus).affichage_arguments == 'Y')
  284:     {
  285:         printf("\n  PSHCNTXT ");
  286: 
  287:         if ((*s_etat_processus).langue == 'F')
  288:         {
  289:             printf("(sauvegarde de contexte)\n\n");
  290:             printf("  Aucun argument\n");
  291:         }
  292:         else
  293:         {
  294:             printf("(pushes context)\n\n");
  295:             printf("  No argument\n");
  296:         }
  297: 
  298:         return;
  299:     }
  300:     else if ((*s_etat_processus).test_instruction == 'Y')
  301:     {
  302:         (*s_etat_processus).nombre_arguments = -1;
  303:         return;
  304:     }
  305: 
  306:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
  307:     {
  308:         if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
  309:         {
  310:             return;
  311:         }
  312:     }
  313: 
  314:     if ((s_objet = allocation(s_etat_processus, LST)) == NULL)
  315:     {
  316:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  317:         return;
  318:     }
  319: 
  320:     (*s_objet).objet = (*s_etat_processus).l_base_pile;
  321: 
  322:     if (empilement(s_etat_processus, &((*s_etat_processus).
  323:             l_base_pile_contextes), s_objet) == d_erreur)
  324:     {
  325:         return;
  326:     }
  327: 
  328:     if ((s_objet = allocation(s_etat_processus, INT)) == NULL)
  329:     {
  330:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  331:         return;
  332:     }
  333: 
  334:     (*((integer8 *) (*s_objet).objet)) = (*s_etat_processus)
  335:             .hauteur_pile_operationnelle;
  336: 
  337:     if (empilement(s_etat_processus, &((*s_etat_processus)
  338:             .l_base_pile_taille_contextes), s_objet) == d_erreur)
  339:     {
  340:         return;
  341:     }
  342: 
  343:     /*
  344:      * Vidage de la pile opérationnelle
  345:      */
  346: 
  347:     (*s_etat_processus).l_base_pile = NULL;
  348:     (*s_etat_processus).hauteur_pile_operationnelle = 0;
  349: 
  350:     return;
  351: }
  352: 
  353: 
  354: /*
  355: ================================================================================
  356:   Fonction 'pulcntxt'
  357: ================================================================================
  358:   Entrées :
  359: --------------------------------------------------------------------------------
  360:   Sorties :
  361: --------------------------------------------------------------------------------
  362:   Effets de bord : néant
  363: ================================================================================
  364: */
  365: 
  366: void
  367: instruction_pulcntxt(struct_processus *s_etat_processus)
  368: {
  369:     struct_objet                    *s_objet;
  370: 
  371:     (*s_etat_processus).erreur_execution = d_ex;
  372: 
  373:     if ((*s_etat_processus).affichage_arguments == 'Y')
  374:     {
  375:         printf("\n  PULCNTXT ");
  376: 
  377:         if ((*s_etat_processus).langue == 'F')
  378:         {
  379:             printf("(restauration de contexte)\n\n");
  380:             printf("  Aucun argument\n");
  381:         }
  382:         else
  383:         {
  384:             printf("(pulls context)\n\n");
  385:             printf("  No argument\n");
  386:         }
  387: 
  388:         return;
  389:     }
  390:     else if ((*s_etat_processus).test_instruction == 'Y')
  391:     {
  392:         (*s_etat_processus).nombre_arguments = -1;
  393:         return;
  394:     }
  395: 
  396:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
  397:     {
  398:         if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
  399:         {
  400:             return;
  401:         }
  402:     }
  403: 
  404:     if (((*s_etat_processus).l_base_pile_contextes == NULL) ||
  405:             ((*s_etat_processus).l_base_pile_taille_contextes == NULL))
  406:     {
  407:         (*s_etat_processus).erreur_execution = d_ex_contexte;
  408:         return;
  409:     }
  410: 
  411:     instruction_clear(s_etat_processus);
  412: 
  413:     if (depilement(s_etat_processus, &((*s_etat_processus)
  414:             .l_base_pile_contextes), &s_objet) == d_erreur)
  415:     {
  416:         return;
  417:     }
  418: 
  419:     if ((*s_objet).type != LST)
  420:     {
  421:         (*s_etat_processus).erreur_systeme = d_es_contexte;
  422:         return;
  423:     }
  424: 
  425:     (*s_etat_processus).l_base_pile = (*s_objet).objet;
  426: 
  427:     BUG((*s_objet).nombre_occurrences != 1,
  428:             printf("(*s_objet).nombre_occurrences=%ld\n",
  429:             (*s_objet).nombre_occurrences));
  430:     free(s_objet);
  431: 
  432:     if (depilement(s_etat_processus, &((*s_etat_processus)
  433:             .l_base_pile_taille_contextes), &s_objet) == d_erreur)
  434:     {
  435:         return;
  436:     }
  437: 
  438:     if ((*s_objet).type != INT)
  439:     {
  440:         (*s_etat_processus).erreur_systeme = d_es_contexte;
  441:         return;
  442:     }
  443: 
  444:     if ((*((integer8 *) (*s_objet).objet)) < 0)
  445:     {
  446:         (*s_etat_processus).erreur_systeme = d_es_contexte;
  447:         return;
  448:     }
  449: 
  450:     (*s_etat_processus).hauteur_pile_operationnelle =
  451:             (*((integer8 *) (*s_objet).objet));
  452:     liberation(s_etat_processus, s_objet);
  453: 
  454:     return;
  455: }
  456: 
  457: 
  458: /*
  459: ================================================================================
  460:   Fonction 'peek'
  461: ================================================================================
  462:   Entrées :
  463: --------------------------------------------------------------------------------
  464:   Sorties :
  465: --------------------------------------------------------------------------------
  466:   Effets de bord : néant
  467: ================================================================================
  468: */
  469: 
  470: void
  471: instruction_peek(struct_processus *s_etat_processus)
  472: {
  473:     sig_atomic_t                registre;
  474: 
  475:     struct_objet                *s_objet;
  476:     struct_objet                *s_objet_drapeau;
  477: 
  478:     (*s_etat_processus).erreur_execution = d_ex;
  479: 
  480:     if ((*s_etat_processus).affichage_arguments == 'Y')
  481:     {
  482:         printf("\n  PEEK ");
  483: 
  484:         if ((*s_etat_processus).langue == 'F')
  485:         {
  486:             printf("(réception de données d'un processus père)\n\n");
  487:         }
  488:         else
  489:         {
  490:             printf("(data reception from parent process)\n\n");
  491:         }
  492: 
  493:         printf("->  1: %s (0)\n\n", d_INT);
  494: 
  495:         printf("->  2: %s, %s, %s, %s, %s, %s,\n"
  496:                 "       %s, %s, %s, %s, %s,\n"
  497:                 "       %s, %s, %s, %s\n",
  498:                 d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX,
  499:                 d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN);
  500:         printf("    1: %s (-1)\n", d_INT);
  501: 
  502:         return;
  503:     }
  504:     else if ((*s_etat_processus).test_instruction == 'Y')
  505:     {
  506:         (*s_etat_processus).nombre_arguments = -1;
  507:         return;
  508:     }
  509:     
  510:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
  511:     {
  512:         if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
  513:         {
  514:             return;
  515:         }
  516:     }
  517: 
  518:     if ((*s_etat_processus).presence_pipes == d_faux)
  519:     {
  520:         (*s_etat_processus).erreur_execution =
  521:                 d_ex_absence_processus_pere;
  522:         return;
  523:     }
  524: 
  525:     if ((s_objet_drapeau = allocation(s_etat_processus, INT)) == NULL)
  526:     {
  527:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  528:         return;
  529:     }
  530: 
  531:     if ((*s_etat_processus).nombre_objets_injectes > 0)
  532:     {
  533:         registre = (*s_etat_processus).var_volatile_traitement_retarde_stop;
  534:         (*s_etat_processus).var_volatile_traitement_retarde_stop = 1;
  535: 
  536:         if ((*s_etat_processus).profilage == d_vrai)
  537:         {
  538:             profilage(s_etat_processus, "Interprocess or interthread "
  539:                     "communications (PEEK)");
  540: 
  541:             if ((*s_etat_processus).erreur_systeme != d_es)
  542:             {
  543:                 return;
  544:             }
  545:         }
  546: 
  547:         if ((s_objet = lecture_pipe(s_etat_processus,
  548:                 (*s_etat_processus).pipe_injections)) == NULL)
  549:         {
  550:             if (registre == 0)
  551:             {
  552:                 if ((*s_etat_processus).var_volatile_traitement_retarde_stop
  553:                         == -1)
  554:                 {
  555:                     (*s_etat_processus).var_volatile_requete_arret = -1;
  556:                 }
  557: 
  558:                 (*s_etat_processus).var_volatile_traitement_retarde_stop
  559:                         = registre;
  560:             }
  561: 
  562:             if ((*s_etat_processus).profilage == d_vrai)
  563:             {
  564:                 profilage(s_etat_processus, NULL);
  565:             }
  566: 
  567:             return;
  568:         }
  569: 
  570:         if ((*s_etat_processus).profilage == d_vrai)
  571:         {
  572:             profilage(s_etat_processus, NULL);
  573:         }
  574: 
  575:         if (registre == 0)
  576:         {
  577:             if ((*s_etat_processus).var_volatile_traitement_retarde_stop == -1)
  578:             {
  579:                 (*s_etat_processus).var_volatile_requete_arret = -1;
  580:             }
  581: 
  582:             (*s_etat_processus).var_volatile_traitement_retarde_stop = registre;
  583:         }
  584: 
  585:         (*s_etat_processus).nombre_objets_injectes--;
  586: 
  587:         if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  588:                 s_objet) == d_erreur)
  589:         {
  590:             return;
  591:         }
  592: 
  593:         (*((integer8 *) (*s_objet_drapeau).objet)) = -1;
  594:     }
  595:     else
  596:     {
  597:         (*((integer8 *) (*s_objet_drapeau).objet)) = 0;
  598:     }
  599: 
  600:     if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  601:             s_objet_drapeau) == d_erreur)
  602:     {
  603:         return;
  604:     }
  605: 
  606:     return;
  607: }
  608: 
  609: 
  610: /*
  611: ================================================================================
  612:   Fonction 'poke'
  613: ================================================================================
  614:   Entrées :
  615: --------------------------------------------------------------------------------
  616:   Sorties :
  617: --------------------------------------------------------------------------------
  618:   Effets de bord : néant
  619: ================================================================================
  620: */
  621: 
  622: void
  623: instruction_poke(struct_processus *s_etat_processus)
  624: {
  625:     sig_atomic_t                registre_stop;
  626: 
  627:     ssize_t                     longueur_ecriture;
  628: 
  629:     struct sigaction            action;
  630:     struct sigaction            registre;
  631: 
  632:     struct_liste_chainee        *l_element_courant;
  633: 
  634:     struct_objet                *s_objet_argument_1;
  635:     struct_objet                *s_objet_argument_2;
  636: 
  637:     (*s_etat_processus).erreur_execution = d_ex;
  638: 
  639:     if ((*s_etat_processus).affichage_arguments == 'Y')
  640:     {
  641:         printf("\n  POKE ");
  642: 
  643:         if ((*s_etat_processus).langue == 'F')
  644:         {
  645:             printf("(envoi d'une donnée à un processus fils)\n\n");
  646:         }
  647:         else
  648:         {
  649:             printf("(send data to child process)\n\n");
  650:         }
  651: 
  652:         printf("    2: %s, %s, %s, %s, %s, %s,\n"
  653:                 "       %s, %s, %s, %s, %s,\n"
  654:                 "       %s, %s, %s, %s, %s\n",
  655:                 d_INT, d_REL, d_CPL, d_VIN, d_VRL, d_VCX, d_MIN, d_MRL, d_MCX,
  656:                 d_BIN, d_NOM, d_CHN, d_LST, d_ALG, d_RPN, d_TAB);
  657:         printf("    1: %s\n", d_PRC);
  658: 
  659:         return;
  660:     }
  661:     else if ((*s_etat_processus).test_instruction == 'Y')
  662:     {
  663:         (*s_etat_processus).nombre_arguments = -1;
  664:         return;
  665:     }
  666:     
  667:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
  668:     {
  669:         if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
  670:         {
  671:             return;
  672:         }
  673:     }
  674: 
  675:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  676:             &s_objet_argument_1) == d_erreur)
  677:     {
  678:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
  679:         return;
  680:     }
  681: 
  682:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  683:             &s_objet_argument_2) == d_erreur)
  684:     {
  685:         liberation(s_etat_processus, s_objet_argument_1);
  686: 
  687:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
  688:         return;
  689:     }
  690: 
  691:     if ((*s_objet_argument_1).type == PRC)
  692:     {
  693:         /*
  694:          * Vérification du type de la donnée transmise
  695:          */
  696: 
  697:         if (((*s_objet_argument_2).type != INT) &&
  698:                 ((*s_objet_argument_2).type != REL) &&
  699:                 ((*s_objet_argument_2).type != CPL) &&
  700:                 ((*s_objet_argument_2).type != VIN) &&
  701:                 ((*s_objet_argument_2).type != VRL) &&
  702:                 ((*s_objet_argument_2).type != VCX) &&
  703:                 ((*s_objet_argument_2).type != MIN) &&
  704:                 ((*s_objet_argument_2).type != MRL) &&
  705:                 ((*s_objet_argument_2).type != MCX) &&
  706:                 ((*s_objet_argument_2).type != BIN) &&
  707:                 ((*s_objet_argument_2).type != NOM) &&
  708:                 ((*s_objet_argument_2).type != CHN) &&
  709:                 ((*s_objet_argument_2).type != LST) &&
  710:                 ((*s_objet_argument_2).type != ALG) &&
  711:                 ((*s_objet_argument_2).type != RPN) &&
  712:                 ((*s_objet_argument_2).type != TBL))
  713:         {
  714:             liberation(s_etat_processus, s_objet_argument_1);
  715:             liberation(s_etat_processus, s_objet_argument_2);
  716: 
  717:             (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
  718:             return;
  719:         }
  720: 
  721:         if (pthread_mutex_lock(&((*s_etat_processus).mutex_pile_processus))
  722:                 != 0)
  723:         {
  724:             (*s_etat_processus).erreur_systeme = d_es_processus;
  725:             return;
  726:         }
  727: 
  728:         l_element_courant = (struct_liste_chainee *)
  729:                 (*s_etat_processus).l_base_pile_processus;
  730: 
  731:         while(l_element_courant != NULL)
  732:         {
  733:             if ((*(*((struct_processus_fils *) (*s_objet_argument_1).objet))
  734:                     .thread).processus_detache == d_vrai)
  735:             {
  736:                 if ((*(*((struct_processus_fils *) (*(*l_element_courant)
  737:                         .donnee).objet)).thread).processus_detache == d_faux)
  738:                 {
  739:                     l_element_courant = (*l_element_courant).suivant;
  740:                     continue;
  741:                 }
  742: 
  743:                 if ((*(*((struct_processus_fils *) (*s_objet_argument_1).objet))
  744:                         .thread).pid == (*(*((struct_processus_fils *)
  745:                         (*(*l_element_courant).donnee).objet)).thread).pid)
  746:                 {
  747:                     // Envoi des données
  748:                     // Attention : si le processus n'existe plus, il n'y a plus
  749:                     // de lecteur et on peut se prendre un SIGPIPE dans la
  750:                     // figure !
  751: 
  752:                     action.sa_handler = SIG_IGN;
  753:                     action.sa_flags = 0;
  754: 
  755: #                   ifndef SEMAPHORES_NOMMES
  756:                         if (sem_post(&((*s_etat_processus).semaphore_fork))
  757:                                 != 0)
  758: #                   else
  759:                         if (sem_post((*s_etat_processus).semaphore_fork) != 0)
  760: #                   endif
  761:                     {
  762:                         (*s_etat_processus).erreur_systeme = d_es_processus;
  763:                         return;
  764:                     }
  765: 
  766:                     if (pthread_mutex_lock(&mutex_sigaction) != 0)
  767:                     {
  768:                         (*s_etat_processus).erreur_systeme = d_es_processus;
  769:                         return;
  770:                     }
  771: 
  772:                     if (sigaction(SIGPIPE, &action, &registre) != 0)
  773:                     {
  774:                         pthread_mutex_unlock(&mutex_sigaction);
  775:                         pthread_mutex_unlock(&((*s_etat_processus)
  776:                                 .mutex_pile_processus));
  777: 
  778:                         (*s_etat_processus).erreur_systeme = d_es_signal;
  779:                         return;
  780:                     }
  781: 
  782:                     // Validation des données. On envoie un signal pour
  783:                     // débloquer les instructions de type WF* pour les
  784:                     // lectures bloquantes.
  785: 
  786:                     if (envoi_signal_processus((*(*((struct_processus_fils *)
  787:                             (*(*l_element_courant).donnee).objet))
  788:                             .thread).pid, rpl_siginject, d_faux) != 0)
  789:                     {
  790:                         // Le processus fils peut s'être terminé.
  791:                         break;
  792:                     }
  793: 
  794:                     registre_stop = (*s_etat_processus)
  795:                             .var_volatile_traitement_retarde_stop;
  796:                     (*s_etat_processus).var_volatile_traitement_retarde_stop
  797:                             = 1;
  798: 
  799:                     if ((*s_etat_processus).profilage == d_vrai)
  800:                     {
  801:                         profilage(s_etat_processus,
  802:                                 "Interprocess communications (POKE)");
  803: 
  804:                         if ((*s_etat_processus).erreur_systeme != d_es)
  805:                         {
  806:                             pthread_mutex_unlock(&mutex_sigaction);
  807:                             pthread_mutex_unlock(&((*s_etat_processus)
  808:                                     .mutex_pile_processus));
  809:                             return;
  810:                         }
  811:                     }
  812: 
  813:                     while((longueur_ecriture = write_atomic(s_etat_processus,
  814:                             (*(*((struct_processus_fils *)
  815:                             (*(*l_element_courant).donnee).objet)).thread)
  816:                             .pipe_nombre_injections[1], "-",
  817:                             sizeof(unsigned char))) != sizeof(unsigned char))
  818:                     {
  819:                         if (longueur_ecriture == -1)
  820:                         {
  821:                             pthread_mutex_unlock(&mutex_sigaction);
  822:                             pthread_mutex_unlock(&((*s_etat_processus)
  823:                                     .mutex_pile_processus));
  824: 
  825:                             liberation(s_etat_processus, s_objet_argument_1);
  826:                             liberation(s_etat_processus, s_objet_argument_2);
  827: 
  828:                             if (registre_stop == 0)
  829:                             {
  830:                                 if ((*s_etat_processus)
  831:                                         .var_volatile_traitement_retarde_stop
  832:                                         == -1)
  833:                                 {
  834:                                     (*s_etat_processus)
  835:                                             .var_volatile_requete_arret = -1;
  836:                                 }
  837: 
  838:                                 (*s_etat_processus)
  839:                                         .var_volatile_traitement_retarde_stop
  840:                                         = registre_stop;
  841:                             }
  842: 
  843:                             if ((*s_etat_processus).profilage == d_vrai)
  844:                             {
  845:                                 profilage(s_etat_processus, NULL);
  846:                             }
  847: 
  848:                             if (sigaction(SIGPIPE, &registre, NULL) != 0)
  849:                             {
  850:                                 pthread_mutex_unlock(&mutex_sigaction);
  851:                                 (*s_etat_processus).erreur_systeme =
  852:                                         d_es_signal;
  853:                                 return;
  854:                             }
  855: 
  856:                             return;
  857:                         }
  858:                     }
  859: 
  860:                     if (ecriture_pipe(s_etat_processus,
  861:                             (*(*((struct_processus_fils *)
  862:                             (*(*l_element_courant).donnee).objet)).thread)
  863:                             .pipe_injections[1], s_objet_argument_2)
  864:                             == d_erreur)
  865:                     {
  866:                         // Le processus fils peut s'être terminé.
  867: 
  868:                         if ((*s_etat_processus).erreur_systeme != d_es)
  869:                         {
  870:                             (*s_etat_processus).erreur_systeme = d_es;
  871:                         }
  872:                     }
  873: 
  874:                     if (registre_stop == 0)
  875:                     {
  876:                         if ((*s_etat_processus)
  877:                                 .var_volatile_traitement_retarde_stop
  878:                                 == -1)
  879:                         {
  880:                             (*s_etat_processus).var_volatile_requete_arret = -1;
  881:                         }
  882: 
  883:                         (*s_etat_processus).var_volatile_traitement_retarde_stop
  884:                                 = registre_stop;
  885:                     }
  886: 
  887:                     if ((*s_etat_processus).profilage == d_vrai)
  888:                     {
  889:                         profilage(s_etat_processus, NULL);
  890:                     }
  891: 
  892:                     if (sigaction(SIGPIPE, &registre, NULL) != 0)
  893:                     {
  894:                         pthread_mutex_unlock(&mutex_sigaction);
  895:                         pthread_mutex_unlock(&((*s_etat_processus)
  896:                                 .mutex_pile_processus));
  897: 
  898:                         (*s_etat_processus).erreur_systeme = d_es_signal;
  899:                         return;
  900:                     }
  901: 
  902:                     if (pthread_mutex_unlock(&mutex_sigaction) != 0)
  903:                     {
  904:                         (*s_etat_processus).erreur_systeme = d_es_processus;
  905:                         return;
  906:                     }
  907: 
  908: #                   ifndef SEMAPHORES_NOMMES
  909:                         while(sem_wait(&((*s_etat_processus).semaphore_fork))
  910:                                 != 0)
  911: #                   else
  912:                         while(sem_wait((*s_etat_processus).semaphore_fork) != 0)
  913: #                   endif
  914:                     {
  915:                         if (errno != EINTR)
  916:                         {
  917:                             (*s_etat_processus).erreur_systeme = d_es_processus;
  918:                             return;
  919:                         }
  920:                     }
  921: 
  922:                     break;
  923:                 }
  924:             }
  925:             else
  926:             {
  927:                 if ((*(*((struct_processus_fils *) (*(*l_element_courant)
  928:                         .donnee).objet)).thread).processus_detache == d_vrai)
  929:                 {
  930:                     l_element_courant = (*l_element_courant).suivant;
  931:                     continue;
  932:                 }
  933: 
  934:                 if (((pthread_equal((*(*((struct_processus_fils *)
  935:                         (*s_objet_argument_1).objet)).thread).tid,
  936:                         (*(*((struct_processus_fils *)
  937:                         (*(*l_element_courant).donnee).objet)).thread).tid)
  938:                         != 0)) && ((*(*((struct_processus_fils *)
  939:                         (*s_objet_argument_1).objet)).thread).pid ==
  940:                         (*(*((struct_processus_fils *)
  941:                         (*(*l_element_courant).donnee).objet)).thread).pid))
  942:                 {
  943:                     // Envoi des données
  944:                     // Attention : si le processus n'existe plus, il n'y a plus
  945:                     // de lecteur et on peut se prendre un SIGPIPE dans la
  946:                     // figure !
  947: 
  948: #                   ifndef SEMAPHORES_NOMMES
  949:                         if (sem_post(&((*s_etat_processus).semaphore_fork))
  950:                                 != 0)
  951: #                   else
  952:                         if (sem_post((*s_etat_processus).semaphore_fork) != 0)
  953: #                   endif
  954:                     {
  955:                         (*s_etat_processus).erreur_systeme = d_es_processus;
  956:                         return;
  957:                     }
  958: 
  959:                     if (pthread_mutex_lock(&mutex_sigaction) != 0)
  960:                     {
  961: #                       ifndef SEMAPHORES_NOMMES
  962:                             while(sem_wait(&((*s_etat_processus)
  963:                                     .semaphore_fork)) != 0)
  964: #                       else
  965:                             while(sem_wait((*s_etat_processus)
  966:                                     .semaphore_fork) != 0)
  967: #                       endif
  968:                         {
  969:                             if (errno != EINTR)
  970:                             {
  971:                                 (*s_etat_processus).erreur_systeme =
  972:                                         d_es_processus;
  973:                                 return;
  974:                             }
  975:                         }
  976: 
  977:                         (*s_etat_processus).erreur_systeme = d_es_processus;
  978:                         return;
  979:                     }
  980: 
  981:                     action.sa_handler = SIG_IGN;
  982:                     action.sa_flags = 0;
  983: 
  984:                     if (sigaction(SIGPIPE, &action, &registre) != 0)
  985:                     {
  986: #                       ifndef SEMAPHORES_NOMMES
  987:                             while(sem_wait(&((*s_etat_processus)
  988:                                     .semaphore_fork)) != 0)
  989: #                       else
  990:                             while(sem_wait((*s_etat_processus)
  991:                                     .semaphore_fork) != 0)
  992: #                       endif
  993:                         {
  994:                             if (errno != EINTR)
  995:                             {
  996:                                 (*s_etat_processus).erreur_systeme =
  997:                                         d_es_processus;
  998:                                 return;
  999:                             }
 1000:                         }
 1001: 
 1002:                         pthread_mutex_unlock(&mutex_sigaction);
 1003:                         pthread_mutex_unlock(&((*s_etat_processus)
 1004:                                 .mutex_pile_processus));
 1005: 
 1006:                         (*s_etat_processus).erreur_systeme = d_es_signal;
 1007:                         return;
 1008:                     }
 1009: 
 1010:                     // Validation des données. On envoie un signal pour
 1011:                     // débloquer les instructions de type WF* pour les
 1012:                     // lectures bloquantes.
 1013: 
 1014:                     if (pthread_mutex_lock(&((*(*((struct_processus_fils *)
 1015:                             (*(*l_element_courant).donnee).objet)).thread)
 1016:                             .mutex)) != 0)
 1017:                     {
 1018: #                       ifndef SEMAPHORES_NOMMES
 1019:                             while(sem_wait(&((*s_etat_processus)
 1020:                                     .semaphore_fork)) != 0)
 1021: #                       else
 1022:                             while(sem_wait((*s_etat_processus)
 1023:                                     .semaphore_fork) != 0)
 1024: #                       endif
 1025:                         {
 1026:                             if (errno != EINTR)
 1027:                             {
 1028:                                 (*s_etat_processus).erreur_systeme =
 1029:                                         d_es_processus;
 1030:                                 return;
 1031:                             }
 1032:                         }
 1033: 
 1034:                         pthread_mutex_unlock(&mutex_sigaction);
 1035:                         (*s_etat_processus).erreur_systeme = d_es_processus;
 1036:                         return;
 1037:                     }
 1038: 
 1039:                     if ((*(*((struct_processus_fils *)
 1040:                             (*(*l_element_courant).donnee).objet)).thread)
 1041:                             .thread_actif == d_vrai)
 1042:                     {
 1043:                         if (envoi_signal_thread(NULL,
 1044:                                 (*(*((struct_processus_fils *)
 1045:                                 (*(*l_element_courant).donnee).objet)).thread)
 1046:                                 .tid, rpl_siginject) != 0)
 1047:                         {
 1048:                             // Le processus fils peut s'être terminé.
 1049: 
 1050:                             if (pthread_mutex_unlock(
 1051:                                     &((*(*((struct_processus_fils *)
 1052:                                     (*(*l_element_courant).donnee).objet))
 1053:                                     .thread).mutex)) != 0)
 1054:                             {
 1055: #                               ifndef SEMAPHORES_NOMMES
 1056:                                     while(sem_wait(&((*s_etat_processus)
 1057:                                             .semaphore_fork)) != 0)
 1058: #                               else
 1059:                                     while(sem_wait((*s_etat_processus)
 1060:                                             .semaphore_fork) != 0)
 1061: #                               endif
 1062:                                 {
 1063:                                     if (errno != EINTR)
 1064:                                     {
 1065:                                         (*s_etat_processus).erreur_systeme =
 1066:                                                 d_es_processus;
 1067:                                         return;
 1068:                                     }
 1069:                                 }
 1070: 
 1071:                                 pthread_mutex_unlock(&mutex_sigaction);
 1072:                                 (*s_etat_processus).erreur_systeme =
 1073:                                         d_es_processus;
 1074:                                 return;
 1075:                             }
 1076: 
 1077:                             break;
 1078:                         }
 1079:                     }
 1080:                     else
 1081:                     {
 1082:                         if (pthread_mutex_unlock(
 1083:                                 &((*(*((struct_processus_fils *)
 1084:                                 (*(*l_element_courant).donnee).objet))
 1085:                                 .thread).mutex)) != 0)
 1086:                         {
 1087: #                           ifndef SEMAPHORES_NOMMES
 1088:                                 while(sem_wait(&((*s_etat_processus)
 1089:                                         .semaphore_fork)) != 0)
 1090: #                           else
 1091:                                 while(sem_wait((*s_etat_processus)
 1092:                                         .semaphore_fork) != 0)
 1093: #                           endif
 1094:                             {
 1095:                                 if (errno != EINTR)
 1096:                                 {
 1097:                                     (*s_etat_processus).erreur_systeme =
 1098:                                             d_es_processus;
 1099:                                     return;
 1100:                                 }
 1101:                             }
 1102: 
 1103:                             pthread_mutex_unlock(&mutex_sigaction);
 1104:                             (*s_etat_processus).erreur_systeme = d_es_processus;
 1105:                             return;
 1106:                         }
 1107: 
 1108:                         break;
 1109:                     }
 1110: 
 1111:                     if (pthread_mutex_unlock(&((*(*((struct_processus_fils *)
 1112:                             (*(*l_element_courant).donnee).objet)).thread)
 1113:                             .mutex)) != 0)
 1114:                     {
 1115: #                       ifndef SEMAPHORES_NOMMES
 1116:                             while(sem_wait(&((*s_etat_processus)
 1117:                                     .semaphore_fork)) != 0)
 1118: #                       else
 1119:                             while(sem_wait((*s_etat_processus)
 1120:                                     .semaphore_fork) != 0)
 1121: #                       endif
 1122:                         {
 1123:                             if (errno != EINTR)
 1124:                             {
 1125:                                 (*s_etat_processus).erreur_systeme =
 1126:                                         d_es_processus;
 1127:                                 return;
 1128:                             }
 1129:                         }
 1130: 
 1131:                         pthread_mutex_unlock(&mutex_sigaction);
 1132:                         (*s_etat_processus).erreur_systeme = d_es_processus;
 1133:                         return;
 1134:                     }
 1135: 
 1136:                     registre_stop = (*s_etat_processus)
 1137:                             .var_volatile_traitement_retarde_stop;
 1138:                     (*s_etat_processus).var_volatile_traitement_retarde_stop
 1139:                             = 1;
 1140: 
 1141:                     if ((*s_etat_processus).profilage == d_vrai)
 1142:                     {
 1143:                         profilage(s_etat_processus,
 1144:                                 "Interthread communications (POKE)");
 1145: 
 1146:                         if ((*s_etat_processus).erreur_systeme != d_es)
 1147:                         {
 1148: #                           ifndef SEMAPHORES_NOMMES
 1149:                                 while(sem_wait(&((*s_etat_processus)
 1150:                                         .semaphore_fork)) != 0)
 1151: #                           else
 1152:                                 while(sem_wait((*s_etat_processus)
 1153:                                         .semaphore_fork) != 0)
 1154: #                           endif
 1155:                             {
 1156:                                 if (errno != EINTR)
 1157:                                 {
 1158:                                     (*s_etat_processus).erreur_systeme =
 1159:                                             d_es_processus;
 1160:                                     return;
 1161:                                 }
 1162:                             }
 1163: 
 1164:                             pthread_mutex_unlock(&mutex_sigaction);
 1165:                             pthread_mutex_unlock(&((*s_etat_processus)
 1166:                                     .mutex_pile_processus));
 1167:                             return;
 1168:                         }
 1169:                     }
 1170: 
 1171:                     while((longueur_ecriture = write_atomic(s_etat_processus,
 1172:                             (*(*((struct_processus_fils *)
 1173:                             (*(*l_element_courant).donnee).objet)).thread)
 1174:                             .pipe_nombre_injections[1], "-",
 1175:                             sizeof(unsigned char))) != sizeof(unsigned char))
 1176:                     {
 1177:                         if (longueur_ecriture == -1)
 1178:                         {
 1179:                             pthread_mutex_unlock(&((*s_etat_processus)
 1180:                                     .mutex_pile_processus));
 1181: 
 1182:                             liberation(s_etat_processus, s_objet_argument_1);
 1183:                             liberation(s_etat_processus, s_objet_argument_2);
 1184: 
 1185:                             if (registre_stop == 0)
 1186:                             {
 1187:                                 if ((*s_etat_processus)
 1188:                                         .var_volatile_traitement_retarde_stop
 1189:                                         == -1)
 1190:                                 {
 1191:                                     (*s_etat_processus)
 1192:                                             .var_volatile_requete_arret = -1;
 1193:                                 }
 1194: 
 1195:                                 (*s_etat_processus)
 1196:                                         .var_volatile_traitement_retarde_stop
 1197:                                         = registre_stop;
 1198:                             }
 1199: 
 1200:                             if ((*s_etat_processus).profilage == d_vrai)
 1201:                             {
 1202:                                 profilage(s_etat_processus, NULL);
 1203:                             }
 1204: 
 1205:                             if (sigaction(SIGPIPE, &registre, NULL) != 0)
 1206:                             {
 1207: #                               ifndef SEMAPHORES_NOMMES
 1208:                                     while(sem_wait(&((*s_etat_processus)
 1209:                                             .semaphore_fork)) != 0)
 1210: #                               else
 1211:                                     while(sem_wait((*s_etat_processus)
 1212:                                             .semaphore_fork) != 0)
 1213: #                               endif
 1214:                                 {
 1215:                                     if (errno != EINTR)
 1216:                                     {
 1217:                                         (*s_etat_processus).erreur_systeme =
 1218:                                                 d_es_processus;
 1219:                                         return;
 1220:                                     }
 1221:                                 }
 1222: 
 1223:                                 pthread_mutex_unlock(&mutex_sigaction);
 1224:                                 (*s_etat_processus).erreur_systeme =
 1225:                                         d_es_signal;
 1226:                                 return;
 1227:                             }
 1228: 
 1229: #                           ifndef SEMAPHORES_NOMMES
 1230:                                 while(sem_wait(&((*s_etat_processus)
 1231:                                         .semaphore_fork)) != 0)
 1232: #                           else
 1233:                                 while(sem_wait((*s_etat_processus)
 1234:                                         .semaphore_fork) != 0)
 1235: #                           endif
 1236:                             {
 1237:                                 if (errno != EINTR)
 1238:                                 {
 1239:                                     (*s_etat_processus).erreur_systeme =
 1240:                                             d_es_processus;
 1241:                                     return;
 1242:                                 }
 1243:                             }
 1244: 
 1245:                             pthread_mutex_unlock(&mutex_sigaction);
 1246:                             return;
 1247:                         }
 1248:                     }
 1249: 
 1250:                     if (ecriture_pipe(s_etat_processus,
 1251:                             (*(*((struct_processus_fils *)
 1252:                             (*(*l_element_courant).donnee).objet)).thread)
 1253:                             .pipe_injections[1], s_objet_argument_2)
 1254:                             == d_erreur)
 1255:                     {
 1256:                         // Le processus fils peut s'être terminé.
 1257: 
 1258:                         if ((*s_etat_processus).erreur_systeme != d_es)
 1259:                         {
 1260:                             (*s_etat_processus).erreur_systeme = d_es;
 1261:                         }
 1262:                     }
 1263: 
 1264:                     if (registre_stop == 0)
 1265:                     {
 1266:                         if ((*s_etat_processus)
 1267:                                 .var_volatile_traitement_retarde_stop
 1268:                                 == -1)
 1269:                         {
 1270:                             (*s_etat_processus).var_volatile_requete_arret = -1;
 1271:                         }
 1272: 
 1273:                         (*s_etat_processus).var_volatile_traitement_retarde_stop
 1274:                                 = registre_stop;
 1275:                     }
 1276: 
 1277:                     if ((*s_etat_processus).profilage == d_vrai)
 1278:                     {
 1279:                         profilage(s_etat_processus, NULL);
 1280:                     }
 1281: 
 1282:                     if (sigaction(SIGPIPE, &registre, NULL) != 0)
 1283:                     {
 1284: #                       ifndef SEMAPHORES_NOMMES
 1285:                             while(sem_wait(&((*s_etat_processus)
 1286:                                     .semaphore_fork)) != 0)
 1287: #                       else
 1288:                             while(sem_wait((*s_etat_processus)
 1289:                                     .semaphore_fork) != 0)
 1290: #                       endif
 1291:                         {
 1292:                             if (errno != EINTR)
 1293:                             {
 1294:                                 (*s_etat_processus).erreur_systeme =
 1295:                                         d_es_processus;
 1296:                                 return;
 1297:                             }
 1298:                         }
 1299: 
 1300:                         pthread_mutex_unlock(&mutex_sigaction);
 1301:                         pthread_mutex_unlock(&((*s_etat_processus)
 1302:                                 .mutex_pile_processus));
 1303: 
 1304:                         (*s_etat_processus).erreur_systeme = d_es_signal;
 1305:                         return;
 1306:                     }
 1307: 
 1308:                     if (pthread_mutex_unlock(&mutex_sigaction) != 0)
 1309:                     {
 1310: #                       ifndef SEMAPHORES_NOMMES
 1311:                             while(sem_wait(&((*s_etat_processus)
 1312:                                     .semaphore_fork)) != 0)
 1313: #                       else
 1314:                             while(sem_wait((*s_etat_processus)
 1315:                                     .semaphore_fork) != 0)
 1316: #                       endif
 1317:                         {
 1318:                             if (errno != EINTR)
 1319:                             {
 1320:                                 (*s_etat_processus).erreur_systeme =
 1321:                                         d_es_processus;
 1322:                                 return;
 1323:                             }
 1324:                         }
 1325: 
 1326:                         (*s_etat_processus).erreur_systeme = d_es_processus;
 1327:                         return;
 1328:                     }
 1329: 
 1330: #                   ifndef SEMAPHORES_NOMMES
 1331:                         while(sem_wait(&((*s_etat_processus).semaphore_fork))
 1332:                                 != 0)
 1333: #                   else
 1334:                         while(sem_wait((*s_etat_processus).semaphore_fork) != 0)
 1335: #                   endif
 1336:                     {
 1337:                         if (errno != EINTR)
 1338:                         {
 1339:                             (*s_etat_processus).erreur_systeme = d_es_processus;
 1340:                             return;
 1341:                         }
 1342:                     }
 1343: 
 1344:                     break;
 1345:                 }
 1346:             }
 1347: 
 1348:             l_element_courant = (*l_element_courant).suivant;
 1349:         }
 1350: 
 1351:         if (pthread_mutex_unlock(&((*s_etat_processus).mutex_pile_processus))
 1352:                 != 0)
 1353:         {
 1354:             (*s_etat_processus).erreur_systeme = d_es_processus;
 1355:             return;
 1356:         }
 1357: 
 1358:         if (l_element_courant == NULL)
 1359:         {
 1360:             liberation(s_etat_processus, s_objet_argument_1);
 1361:             liberation(s_etat_processus, s_objet_argument_2);
 1362: 
 1363:             (*s_etat_processus).erreur_execution = d_ex_processus;
 1364:             return;
 1365:         }
 1366:     }
 1367:     else
 1368:     {
 1369:         liberation(s_etat_processus, s_objet_argument_1);
 1370:         liberation(s_etat_processus, s_objet_argument_2);
 1371: 
 1372:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
 1373:         return;
 1374:     }
 1375: 
 1376:     liberation(s_etat_processus, s_objet_argument_1);
 1377:     liberation(s_etat_processus, s_objet_argument_2);
 1378: 
 1379:     return;
 1380: }
 1381: 
 1382: 
 1383: /*
 1384: ================================================================================
 1385:   Fonction 'private'
 1386: ================================================================================
 1387:   Entrées :
 1388: --------------------------------------------------------------------------------
 1389:   Sorties :
 1390: --------------------------------------------------------------------------------
 1391:   Effets de bord : néant
 1392: ================================================================================
 1393: */
 1394: 
 1395: void
 1396: instruction_private(struct_processus *s_etat_processus)
 1397: {
 1398:     struct_liste_chainee                *l_element_courant;
 1399: 
 1400:     struct_objet                        *s_objet;
 1401: 
 1402:     (*s_etat_processus).erreur_execution = d_ex;
 1403: 
 1404:     if ((*s_etat_processus).affichage_arguments == 'Y')
 1405:     {
 1406:         printf("\n  PRIVATE ");
 1407: 
 1408:         if ((*s_etat_processus).langue == 'F')
 1409:         {
 1410:             printf("(rend privée une variable partagée)\n\n");
 1411:         }
 1412:         else
 1413:         {
 1414:             printf("(switch a shared variable to private one)\n\n");
 1415:         }
 1416: 
 1417:         printf("    1: %s, %s\n", d_NOM, d_LST);
 1418: 
 1419:         return;
 1420:     }
 1421:     else if ((*s_etat_processus).test_instruction == 'Y')
 1422:     {
 1423:         (*s_etat_processus).nombre_arguments = -1;
 1424:         return;
 1425:     }
 1426:     
 1427:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 1428:     {
 1429:         if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
 1430:         {
 1431:             return;
 1432:         }
 1433:     }
 1434: 
 1435:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
 1436:             &s_objet) == d_erreur)
 1437:     {
 1438:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
 1439:         return;
 1440:     }
 1441: 
 1442:     if ((*s_objet).type == NOM)
 1443:     {
 1444:         if (recherche_variable(s_etat_processus, ((*((struct_nom *)
 1445:                 (*s_objet).objet)).nom)) == d_faux)
 1446:         {
 1447:             liberation(s_etat_processus, s_objet);
 1448: 
 1449:             (*s_etat_processus).erreur_systeme = d_es;
 1450:             (*s_etat_processus).erreur_execution = d_ex_variable_non_definie;
 1451:             return;
 1452:         }
 1453: 
 1454:         if (recherche_variable_partagee(s_etat_processus, ((*((struct_nom *)
 1455:                 (*s_objet).objet)).nom), (*(*s_etat_processus)
 1456:                 .pointeur_variable_courante).variable_partagee,
 1457:                 (*(*s_etat_processus).pointeur_variable_courante).origine)
 1458:                 == NULL)
 1459:         {
 1460:             liberation(s_etat_processus, s_objet);
 1461: 
 1462:             (*s_etat_processus).erreur_systeme = d_es;
 1463:             return;
 1464:         }
 1465: 
 1466:         (*(*s_etat_processus).pointeur_variable_courante).objet =
 1467:                 (*(*s_etat_processus).pointeur_variable_partagee_courante)
 1468:                 .objet;
 1469:         (*(*s_etat_processus).pointeur_variable_partagee_courante).objet = NULL;
 1470: 
 1471:         if (retrait_variable_partagee(s_etat_processus,
 1472:                 (*((struct_nom *) (*s_objet).objet)).nom,
 1473:                 (*(*s_etat_processus).pointeur_variable_courante)
 1474:                 .variable_partagee) == d_erreur)
 1475:         {
 1476:             liberation(s_etat_processus, s_objet);
 1477:             return;
 1478:         }
 1479: 
 1480:         if ((*(*s_etat_processus).pointeur_variable_courante).origine == 'P')
 1481:         {
 1482:             (*(*s_etat_processus).pointeur_variable_courante)
 1483:                     .variable_partagee.adresse = 0;
 1484:         }
 1485:         else
 1486:         {
 1487:             (*(*s_etat_processus).pointeur_variable_courante)
 1488:                     .variable_partagee.pointeur = NULL;
 1489:         }
 1490:     }
 1491:     else if ((*s_objet).type == LST)
 1492:     {
 1493:         l_element_courant = (struct_liste_chainee *) (*s_objet).objet;
 1494: 
 1495:         while(l_element_courant != NULL)
 1496:         {
 1497:             if ((*(*l_element_courant).donnee).type != NOM)
 1498:             {
 1499:                 liberation(s_etat_processus, s_objet);
 1500: 
 1501:                 (*s_etat_processus).erreur_execution = d_ex_nom_invalide;
 1502:                 return;
 1503:             }
 1504: 
 1505:             if (recherche_variable(s_etat_processus, ((*((struct_nom *)
 1506:                     (*s_objet).objet)).nom)) == d_faux)
 1507:             {
 1508:                 liberation(s_etat_processus, s_objet);
 1509: 
 1510:                 (*s_etat_processus).erreur_systeme = d_es;
 1511:                 (*s_etat_processus).erreur_execution =
 1512:                         d_ex_variable_non_definie;
 1513:                 return;
 1514:             }
 1515: 
 1516:             if (recherche_variable_partagee(s_etat_processus, ((*((struct_nom *)
 1517:                     (*s_objet).objet)).nom), (*(*s_etat_processus)
 1518:                     .pointeur_variable_courante).variable_partagee,
 1519:                     (*(*s_etat_processus).pointeur_variable_courante).origine)
 1520:                     == NULL)
 1521:             {
 1522:                 liberation(s_etat_processus, s_objet);
 1523: 
 1524:                 (*s_etat_processus).erreur_systeme = d_es;
 1525:                 (*s_etat_processus).erreur_execution =
 1526:                         d_ex_variable_non_definie;
 1527:                 return;
 1528:             }
 1529: 
 1530:             (*(*s_etat_processus).pointeur_variable_courante).objet =
 1531:                     (*(*s_etat_processus).pointeur_variable_partagee_courante)
 1532:                     .objet;
 1533:             (*(*s_etat_processus).pointeur_variable_partagee_courante).objet
 1534:                     = NULL;
 1535: 
 1536:             if ((*(*s_etat_processus).pointeur_variable_courante).origine
 1537:                     == 'P')
 1538:             {
 1539:                 (*(*s_etat_processus).pointeur_variable_courante)
 1540:                         .variable_partagee.adresse = 0;
 1541:             }
 1542:             else
 1543:             {
 1544:                 (*(*s_etat_processus).pointeur_variable_courante)
 1545:                         .variable_partagee.pointeur = NULL;
 1546:             }
 1547: 
 1548:             if (retrait_variable_partagee(s_etat_processus,
 1549:                     (*((struct_nom *) (*s_objet).objet)).nom,
 1550:                     (*(*s_etat_processus).pointeur_variable_courante)
 1551:                     .variable_statique) == d_erreur)
 1552:             {
 1553:                 liberation(s_etat_processus, s_objet);
 1554:                 return;
 1555:             }
 1556: 
 1557:             l_element_courant = (*l_element_courant).suivant;
 1558:         }
 1559:     }
 1560:     else
 1561:     {
 1562:         liberation(s_etat_processus, s_objet);
 1563: 
 1564:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
 1565:         return;
 1566:     }
 1567: 
 1568:     liberation(s_etat_processus, s_objet);
 1569: 
 1570:     return;
 1571: }
 1572: 
 1573: 
 1574: /*
 1575: ================================================================================
 1576:   Fonction 'pshprfl'
 1577: ================================================================================
 1578:   Entrées : pointeur sur une structure struct_processus
 1579: --------------------------------------------------------------------------------
 1580:   Sorties :
 1581: --------------------------------------------------------------------------------
 1582:   Effets de bord : néant
 1583: ================================================================================
 1584: */
 1585: 
 1586: void
 1587: instruction_pshprfl(struct_processus *s_etat_processus)
 1588: {
 1589:     struct_objet            *s_objet_argument;
 1590: 
 1591:     (*s_etat_processus).erreur_execution = d_ex;
 1592: 
 1593:     if ((*s_etat_processus).affichage_arguments == 'Y')
 1594:     {
 1595:         printf("\n  PSHPRFL ");
 1596: 
 1597:         if ((*s_etat_processus).langue == 'F')
 1598:         {
 1599:             printf("(empilement d'un point de profilage)\n\n");
 1600:         }
 1601:         else
 1602:         {
 1603:             printf("(push profile data)\n\n");
 1604:         }
 1605: 
 1606:         printf("    1: %s\n", d_CHN);
 1607: 
 1608:         return;
 1609:     }
 1610:     else if ((*s_etat_processus).test_instruction == 'Y')
 1611:     {
 1612:         (*s_etat_processus).nombre_arguments = -1;
 1613:         return;
 1614:     }
 1615: 
 1616:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 1617:     {
 1618:         if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
 1619:         {
 1620:             return;
 1621:         }
 1622:     }
 1623: 
 1624:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
 1625:             &s_objet_argument) == d_erreur)
 1626:     {
 1627:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
 1628:         return;
 1629:     }
 1630: 
 1631:     if ((*s_objet_argument).type == CHN)
 1632:     {
 1633:         if ((*s_etat_processus).profilage == d_vrai)
 1634:         {
 1635:             profilage(s_etat_processus, (unsigned char *)
 1636:                     (*s_objet_argument).objet);
 1637:         }
 1638:     }
 1639:     else
 1640:     {
 1641:         liberation(s_etat_processus, s_objet_argument);
 1642: 
 1643:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
 1644:         return;
 1645:     }
 1646: 
 1647:     liberation(s_etat_processus, s_objet_argument);
 1648: 
 1649:     return;
 1650: }
 1651: 
 1652: 
 1653: /*
 1654: ================================================================================
 1655:   Fonction 'pulprfl'
 1656: ================================================================================
 1657:   Entrées : pointeur sur une structure struct_processus
 1658: --------------------------------------------------------------------------------
 1659:   Sorties :
 1660: --------------------------------------------------------------------------------
 1661:   Effets de bord : néant
 1662: ================================================================================
 1663: */
 1664: 
 1665: void
 1666: instruction_pulprfl(struct_processus *s_etat_processus)
 1667: {
 1668:     (*s_etat_processus).erreur_execution = d_ex;
 1669: 
 1670:     if ((*s_etat_processus).affichage_arguments == 'Y')
 1671:     {
 1672:         printf("\n  PULPRFL ");
 1673: 
 1674:         if ((*s_etat_processus).langue == 'F')
 1675:         {
 1676:             printf("(dépilement d'un point de profilage)\n\n");
 1677:             printf("  Aucun argument\n");
 1678:         }
 1679:         else
 1680:         {
 1681:             printf("(pull profile data)\n\n");
 1682:             printf("  No argument\n");
 1683:         }
 1684: 
 1685:         return;
 1686:     }
 1687:     else if ((*s_etat_processus).test_instruction == 'Y')
 1688:     {
 1689:         (*s_etat_processus).nombre_arguments = -1;
 1690:         return;
 1691:     }
 1692: 
 1693:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 1694:     {
 1695:         if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
 1696:         {
 1697:             return;
 1698:         }
 1699:     }
 1700: 
 1701:     if ((*s_etat_processus).profilage == d_vrai)
 1702:     {
 1703:         profilage(s_etat_processus, NULL);
 1704:     }
 1705: 
 1706:     return;
 1707: }
 1708: 
 1709: 
 1710: /*
 1711: ================================================================================
 1712:   Fonction 'plot'
 1713: ================================================================================
 1714:   Entrées : pointeur sur une structure struct_processus
 1715: --------------------------------------------------------------------------------
 1716:   Sorties :
 1717: --------------------------------------------------------------------------------
 1718:   Effets de bord : néant
 1719: ================================================================================
 1720: */
 1721: 
 1722: void
 1723: instruction_plot(struct_processus *s_etat_processus)
 1724: {
 1725:     (*s_etat_processus).erreur_execution = d_ex;
 1726: 
 1727:     if ((*s_etat_processus).affichage_arguments == 'Y')
 1728:     {
 1729:         printf("\n  PLOT ");
 1730: 
 1731:         if ((*s_etat_processus).langue == 'F')
 1732:         {
 1733:             printf("(affiche les données graphiques mémorisées)\n\n");
 1734:             printf("  Aucun argument\n");
 1735:         }
 1736:         else
 1737:         {
 1738:             printf("(plot buffered graphic)\n\n");
 1739:             printf("  No argument\n");
 1740:         }
 1741: 
 1742:         return;
 1743:     }
 1744:     else if ((*s_etat_processus).test_instruction == 'Y')
 1745:     {
 1746:         (*s_etat_processus).nombre_arguments = -1;
 1747:         return;
 1748:     }
 1749: 
 1750:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 1751:     {
 1752:         if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
 1753:         {
 1754:             return;
 1755:         }
 1756:     }
 1757: 
 1758:     if ((*s_etat_processus).fichiers_graphiques != NULL)
 1759:     {
 1760:         appel_gnuplot(s_etat_processus, 'N');
 1761:     }
 1762: 
 1763:     (*s_etat_processus).mise_a_jour_trace_requise = d_faux;
 1764: 
 1765:     return;
 1766: }
 1767: 
 1768: 
 1769: /*
 1770: ================================================================================
 1771:   Fonction 'procid'
 1772: ================================================================================
 1773:   Entrées : pointeur sur une structure struct_processus
 1774: --------------------------------------------------------------------------------
 1775:   Sorties :
 1776: --------------------------------------------------------------------------------
 1777:   Effets de bord : néant
 1778: ================================================================================
 1779: */
 1780: 
 1781: void
 1782: instruction_procid(struct_processus *s_etat_processus)
 1783: {
 1784:     pthread_mutexattr_t     attributs_mutex;
 1785: 
 1786:     struct_objet            *s_objet;
 1787: 
 1788:     (*s_etat_processus).erreur_execution = d_ex;
 1789: 
 1790:     if ((*s_etat_processus).affichage_arguments == 'Y')
 1791:     {
 1792:         printf("\n  PROCID ");
 1793: 
 1794:         if ((*s_etat_processus).langue == 'F')
 1795:         {
 1796:             printf("(identifiant du processus)\n\n");
 1797:         }
 1798:         else
 1799:         {
 1800:             printf("(process identifier)\n\n");
 1801:         }
 1802: 
 1803:         printf("->  1: %s\n", d_PRC);
 1804: 
 1805:         return;
 1806:     }
 1807:     else if ((*s_etat_processus).test_instruction == 'Y')
 1808:     {
 1809:         (*s_etat_processus).nombre_arguments = -1;
 1810:         return;
 1811:     }
 1812: 
 1813:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
 1814:     {
 1815:         if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
 1816:         {
 1817:             return;
 1818:         }
 1819:     }
 1820: 
 1821:     if ((s_objet = allocation(s_etat_processus, PRC)) == NULL)
 1822:     {
 1823:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 1824:         return;
 1825:     }
 1826: 
 1827:     if (((*((struct_processus_fils *) (*s_objet).objet)).thread =
 1828:             malloc(sizeof(struct_descripteur_thread))) == NULL)
 1829:     {
 1830:         (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
 1831:         return;
 1832:     }
 1833: 
 1834:     (*(*((struct_processus_fils *) (*s_objet).objet)).thread)
 1835:             .nombre_references = 1;
 1836:     (*(*((struct_processus_fils *) (*s_objet).objet)).thread)
 1837:             .pid = getpid();
 1838:     (*(*((struct_processus_fils *) (*s_objet).objet)).thread)
 1839:             .tid = pthread_self();
 1840:     (*(*((struct_processus_fils *) (*s_objet).objet)).thread)
 1841:             .processus_detache = (*s_etat_processus).processus_detache;
 1842:     (*(*((struct_processus_fils *) (*s_objet).objet)).thread)
 1843:             .argument = NULL;
 1844: 
 1845:     pthread_mutexattr_init(&attributs_mutex);
 1846:     pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_RECURSIVE);
 1847:     pthread_mutex_init(&((*(*((struct_processus_fils *)
 1848:             (*s_objet).objet)).thread).mutex), &attributs_mutex);
 1849:     pthread_mutexattr_destroy(&attributs_mutex);
 1850: 
 1851:     pthread_mutexattr_init(&attributs_mutex);
 1852:     pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_RECURSIVE);
 1853:     pthread_mutex_init(&((*(*((struct_processus_fils *)
 1854:             (*s_objet).objet)).thread).mutex_nombre_references),
 1855:             &attributs_mutex);
 1856:     pthread_mutexattr_destroy(&attributs_mutex);
 1857: 
 1858:     if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
 1859:             s_objet) == d_erreur)
 1860:     {
 1861:         return;
 1862:     }
 1863: 
 1864:     return;
 1865: }
 1866: 
 1867: // vim: ts=4

CVSweb interface <joel.bertrand@systella.fr>