Diff for /rpl/src/Attic/siginfo.c between versions 1.4 and 1.5

version 1.4, 2010/09/02 07:51:48 version 1.5, 2010/09/06 16:50:17
Line 30 Line 30
   
 static int              *fifos;  static int              *fifos;
 static int              markov;  static int              markov;
 static int              segment;  
 static sem_t            *semaphores[nombre_queues];  static sem_t            *semaphores[nombre_queues];
 static sem_t            *semaphore_global;  static sem_t            *semaphore_global;
   
 #ifdef IPCS_SYSV  #ifdef IPCS_SYSV
   #ifndef OS2
 static unsigned char    *chemin = NULL;  static unsigned char    *chemin = NULL;
 #endif  #endif
   #endif
   
   #ifdef OS2
   PVOID                   ptr_os2;
   #else
   static int              segment;
   #endif
   
 static unsigned char *  static unsigned char *
 nom_segment(unsigned char *chemin, pid_t pid)  nom_segment(unsigned char *chemin, pid_t pid)
Line 44  nom_segment(unsigned char *chemin, pid_t Line 51  nom_segment(unsigned char *chemin, pid_t
     unsigned char               *fichier;      unsigned char               *fichier;
   
 #   ifdef IPCS_SYSV  #   ifdef IPCS_SYSV
   
   #   ifndef OS2
   
     if ((fichier = malloc((strlen(chemin) + 1 + 256 + 1) *      if ((fichier = malloc((strlen(chemin) + 1 + 256 + 1) *
             sizeof(unsigned char))) == NULL)              sizeof(unsigned char))) == NULL)
     {      {
Line 51  nom_segment(unsigned char *chemin, pid_t Line 61  nom_segment(unsigned char *chemin, pid_t
     }      }
   
     sprintf(fichier, "%s/RPL-SIGQUEUES-%d", chemin, (int) pid);      sprintf(fichier, "%s/RPL-SIGQUEUES-%d", chemin, (int) pid);
   
   #   else
   
       if ((fichier = malloc((10 + 256 + 1) * sizeof(unsigned char))) == NULL)
       {
           return(NULL);
       }
   
       sprintf(fichier, "\\SHAREMEM\\RPL-SIGQUEUES-%d", (int) pid);
   
   #   endif
 #   else  #   else
   
     if ((fichier = malloc((1 + 256 + 1) *      if ((fichier = malloc((1 + 256 + 1) *
             sizeof(unsigned char))) == NULL)              sizeof(unsigned char))) == NULL)
     {      {
Line 59  nom_segment(unsigned char *chemin, pid_t Line 81  nom_segment(unsigned char *chemin, pid_t
     }      }
   
     sprintf(fichier, "/RPL-SIGQUEUES-%d", (int) pid);      sprintf(fichier, "/RPL-SIGQUEUES-%d", (int) pid);
   
 #   endif  #   endif
   
     return(fichier);      return(fichier);
Line 74  nom_semaphore(pid_t pid, int queue) Line 97  nom_semaphore(pid_t pid, int queue)
         return(NULL);          return(NULL);
     }      }
   
     sprintf(fichier, "/RPL-SIGESMAPHORES-%d-%d", (int) pid, queue);      sprintf(fichier, "/RPL-SIGSEMAPHORES-%d-%d", (int) pid, queue);
   
     return(fichier);      return(fichier);
 }  }
Line 174  creation_fifos_signaux(struct_processus Line 197  creation_fifos_signaux(struct_processus
     free(nom);      free(nom);
   
 #   else // SystemV  #   else // SystemV
   #   ifndef OS2
   
     file                            *desc;      file                            *desc;
   
Line 228  creation_fifos_signaux(struct_processus Line 252  creation_fifos_signaux(struct_processus
         return;          return;
     }      }
   
   #   else
   
       if ((nom = nom_segment(NULL, getpid())) == NULL)
       {
           (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
           return;
       }
   
       if (DosAllocSharedMem(&ptr_os2, nom, nombre_queues *
               ((2 * longueur_queue) + 4) * sizeof(int),
               PAG_WRITE | PAG_READ | PAG_COMMIT) != 0)
       {
           free(nom);
           (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
           return;
       }
   
       free(nom);
       fifos = ptr_os2;
   
   #   endif
 #   endif  #   endif
   
     /*      /*
Line 301  liberation_fifos_signaux(struct_processu Line 346  liberation_fifos_signaux(struct_processu
     int                 i;      int                 i;
   
 #   ifdef IPCS_SYSV // SystemV  #   ifdef IPCS_SYSV // SystemV
   #   ifndef OS2
   
     if (shmdt(fifos) == -1)      if (shmdt(fifos) == -1)
     {      {
Line 308  liberation_fifos_signaux(struct_processu Line 354  liberation_fifos_signaux(struct_processu
         return;          return;
     }      }
   
   #   else
   
       if (DosFreeMem(fifos) != 0)
       {
           (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
           return;
       }
   
   #   endif
 #   else // POSIX  #   else // POSIX
   
     if (munmap(fifos, nombre_queues * ((2 * longueur_queue) + 4) * sizeof(int))      if (munmap(fifos, nombre_queues * ((2 * longueur_queue) + 4) * sizeof(int))
Line 345  destruction_fifos_signaux(struct_process Line 400  destruction_fifos_signaux(struct_process
     unsigned char       *nom;      unsigned char       *nom;
   
 #   ifdef IPCS_SYSV // SystemV  #   ifdef IPCS_SYSV // SystemV
   #   ifndef OS2
   
     if (shmdt(fifos) == -1)      if (shmdt(fifos) == -1)
     {      {
Line 368  destruction_fifos_signaux(struct_process Line 424  destruction_fifos_signaux(struct_process
     unlink(nom);      unlink(nom);
     free(nom);      free(nom);
   
   #   else
   
       if (DosFreeMem(fifos) != 0)
       {
           (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
           return;
       }
   
   #   endif
 #   else // POSIX  #   else // POSIX
   
     if (munmap(fifos, nombre_queues * ((2 * longueur_queue) + 4) * sizeof(int))      if (munmap(fifos, nombre_queues * ((2 * longueur_queue) + 4) * sizeof(int))
Line 448  queue_in(pid_t pid, int signal) Line 513  queue_in(pid_t pid, int signal)
     int             *base;      int             *base;
     int             *buffer;      int             *buffer;
     int             horodatage_initial;      int             horodatage_initial;
   #   ifndef OS2
     int             identifiant;      int             identifiant;
   #   endif
     int             *projection_fifos;      int             *projection_fifos;
   
     sem_t           *semaphore;      sem_t           *semaphore;
Line 502  queue_in(pid_t pid, int signal) Line 569  queue_in(pid_t pid, int signal)
   
 #   else // Traitement à l'aide d'IPCS SystemV  #   else // Traitement à l'aide d'IPCS SystemV
   
   #   ifndef OS2
     key_t           clef;      key_t           clef;
   
     struct stat     s_stat;      struct stat     s_stat;
   #   endif
   
       // Dans le cas de SIGSTART, premier signal envoyé à un processus fils,
       // il convient d'attendre que le fichier support soit effectivement
       // accessible. Dans tous les autres cas, ce fichier doit exister. S'il
       // n'existe plus, le processus associé n'existe plus.
   
   #   ifndef OS2
   
     // Ouverture des projections      // Ouverture des projections
   
Line 513  queue_in(pid_t pid, int signal) Line 589  queue_in(pid_t pid, int signal)
         return(-1);          return(-1);
     }      }
   
     // Dans le cas de SIGSTART, premier signal envoyé à un processus fils,  
     // il convient d'attendre que le fichier support soit effectivement  
     // accessible. Dans tous les autres cas, ce fichier doit exister. S'il  
     // n'existe plus, le processus associé n'existe plus.  
   
     if (signal == SIGSTART)      if (signal == SIGSTART)
     {      {
         // On attend que le fichier sois présent          // On attend que le fichier sois présent
Line 563  queue_in(pid_t pid, int signal) Line 634  queue_in(pid_t pid, int signal)
         return(-1);          return(-1);
     }      }
   
   #   else
   
       // Ouverture des projections
   
       if ((nom = nom_segment(NULL, pid)) == NULL)
       {
           return(-1);
       }
   
       if (signal == SIGSTART)
       {
           horodatage_initial = horodatage();
   
           while(DosGetNamedSharedMem(&ptr_os2, nom,
                   PAG_READ | PAG_WRITE | PAG_COMMIT) != 0)
           {
               if (abs(horodatage_initial - horodatage()) > 500)
               {
                   return(-1);
               }
           }
       }
       else
       {
           if (DosGetNamedSharedMem(&ptr_os2, nom,
                   PAG_READ | PAG_WRITE) != 0)
           {
               return(-1);
           }
       }
   
       projection_fifos = ptr_os2;
       
   #   endif
 #   endif  #   endif
   
     if ((nom = nom_semaphore(pid, queue)) == NULL)      if ((nom = nom_semaphore(pid, queue)) == NULL)
     {      {
 #       ifdef IPCS_SYSV  #       ifdef IPCS_SYSV
   #       ifndef OS2
         shmdt(projection_fifos);          shmdt(projection_fifos);
 #       else  #       else
           DosFreeMem(projection_fifos);
   #       endif
   #       else
         munmap(projection_fifos, nombre_queues * ((2 * longueur_queue) + 4)          munmap(projection_fifos, nombre_queues * ((2 * longueur_queue) + 4)
                 * sizeof(int));                  * sizeof(int));
 #       endif  #       endif
Line 584  queue_in(pid_t pid, int signal) Line 693  queue_in(pid_t pid, int signal)
         if (errno != EINTR)          if (errno != EINTR)
         {          {
 #           ifdef IPCS_SYSV  #           ifdef IPCS_SYSV
   #           ifndef OS2
             shmdt(projection_fifos);              shmdt(projection_fifos);
 #           else  #           else
               DosFreeMem(projection_fifos);
   #           endif
   #           else
             munmap(projection_fifos, nombre_queues * ((2 * longueur_queue) + 4)              munmap(projection_fifos, nombre_queues * ((2 * longueur_queue) + 4)
                     * sizeof(int));                      * sizeof(int));
 #           endif  #           endif
Line 603  queue_in(pid_t pid, int signal) Line 716  queue_in(pid_t pid, int signal)
         sem_post(semaphore);          sem_post(semaphore);
         sem_close(semaphore);          sem_close(semaphore);
 #       ifdef IPCS_SYSV  #       ifdef IPCS_SYSV
   #       ifndef OS2
         shmdt(projection_fifos);          shmdt(projection_fifos);
 #       else  #       else
           DosFreeMem(projection_fifos);
   #       endif
   #       else
         munmap(projection_fifos, nombre_queues * ((2 * longueur_queue) + 4)          munmap(projection_fifos, nombre_queues * ((2 * longueur_queue) + 4)
                 * sizeof(int));                  * sizeof(int));
 #       endif  #       endif
Line 622  queue_in(pid_t pid, int signal) Line 739  queue_in(pid_t pid, int signal)
     if (sem_post(semaphore) != 0)      if (sem_post(semaphore) != 0)
     {      {
 #       ifdef IPCS_SYSV  #       ifdef IPCS_SYSV
   #       ifndef OS2
         shmdt(projection_fifos);          shmdt(projection_fifos);
 #       else  #       else
           DosFreeMem(projection_fifos);
   #       endif
   #       else
         munmap(projection_fifos, nombre_queues * ((2 * longueur_queue) + 4)          munmap(projection_fifos, nombre_queues * ((2 * longueur_queue) + 4)
                 * sizeof(int));                  * sizeof(int));
 #       endif  #       endif
Line 635  queue_in(pid_t pid, int signal) Line 756  queue_in(pid_t pid, int signal)
   
     // Fermeture des projections      // Fermeture des projections
 #   ifdef IPCS_SYSV  #   ifdef IPCS_SYSV
   #   ifndef OS2
     shmdt(projection_fifos);      shmdt(projection_fifos);
 #   else  #   else
       DosFreeMem(projection_fifos);
   #   endif
   #   else
     munmap(projection_fifos, nombre_queues * ((2 * longueur_queue) + 4)      munmap(projection_fifos, nombre_queues * ((2 * longueur_queue) + 4)
             * sizeof(int));              * sizeof(int));
 #   endif  #   endif

Removed from v.1.4  
changed lines
  Added in v.1.5


CVSweb interface <joel.bertrand@systella.fr>