version 1.13, 2010/03/17 14:14:36
|
version 1.18, 2010/04/21 13:45:50
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.0.13 |
RPL/2 (R) version 4.0.15 |
Copyright (C) 1989-2010 Dr. BERTRAND Joël |
Copyright (C) 1989-2010 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
Line 102 rplinit(int argc, char *argv[], unsigned
|
Line 102 rplinit(int argc, char *argv[], unsigned
|
setvbuf(stdout, NULL, _IOLBF, 0); |
setvbuf(stdout, NULL, _IOLBF, 0); |
setvbuf(stderr, NULL, _IOLBF, 0); |
setvbuf(stderr, NULL, _IOLBF, 0); |
|
|
|
# ifndef SEMAPHORES_NOMMES |
sem_init(&semaphore_liste_threads, 0, 1); |
sem_init(&semaphore_liste_threads, 0, 1); |
sem_init(&semaphore_gestionnaires_signaux, 0, 0); |
sem_init(&semaphore_gestionnaires_signaux, 0, 0); |
sem_init(&semaphore_gestionnaires_signaux_atomique, 0, 1); |
sem_init(&semaphore_gestionnaires_signaux_atomique, 0, 1); |
|
# else |
|
semaphore_liste_threads = sem_init2(1, sem_liste_threads); |
|
semaphore_gestionnaires_signaux = sem_init2(0, sem_gestionnaires_signaux); |
|
semaphore_gestionnaires_signaux_atomique = sem_init2(1, |
|
sem_gestionnaires_signaux_atomique); |
|
|
|
if ((semaphore_liste_threads == SEM_FAILED) || |
|
(semaphore_gestionnaires_signaux == SEM_FAILED) || |
|
(semaphore_gestionnaires_signaux_atomique == SEM_FAILED)) |
|
{ |
|
erreur = d_es_allocation_memoire; |
|
|
|
if ((langue = getenv("LANG")) != NULL) |
|
{ |
|
if (strncmp(langue, "fr", 2) == 0) |
|
{ |
|
uprintf("+++Système : Mémoire insuffisante\n"); |
|
} |
|
else |
|
{ |
|
uprintf("+++System : Not enough memory\n"); |
|
} |
|
} |
|
else |
|
{ |
|
uprintf("+++System : Not enough memory\n"); |
|
} |
|
|
|
return(EXIT_FAILURE); |
|
} |
|
# endif |
|
|
if ((s_etat_processus = malloc(sizeof(struct_processus))) == NULL) |
if ((s_etat_processus = malloc(sizeof(struct_processus))) == NULL) |
{ |
{ |
erreur = d_es_allocation_memoire; |
erreur = d_es_allocation_memoire; |
|
|
if ((*s_etat_processus).langue == 'F') |
if ((langue = getenv("LANG")) != NULL) |
{ |
{ |
printf("+++Système : Mémoire insuffisante\n"); |
if (strncmp(langue, "fr", 2) == 0) |
|
{ |
|
uprintf("+++Système : Mémoire insuffisante\n"); |
|
} |
|
else |
|
{ |
|
uprintf("+++System : Not enough memory\n"); |
|
} |
} |
} |
else |
else |
{ |
{ |
printf("+++System : Not enough memory\n"); |
uprintf("+++System : Not enough memory\n"); |
} |
} |
|
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
|
if ((langue = getenv("LANG")) != NULL) |
|
{ |
|
(*s_etat_processus).langue = (strncmp(langue, "fr", 2) == 0) |
|
? 'F' : 'E'; |
|
} |
|
else |
|
{ |
|
(*s_etat_processus).langue = 'E'; |
|
} |
|
|
(*s_etat_processus).exception = d_ep; |
(*s_etat_processus).exception = d_ep; |
(*s_etat_processus).erreur_systeme = d_es; |
(*s_etat_processus).erreur_systeme = d_es; |
(*s_etat_processus).erreur_execution = d_ex; |
(*s_etat_processus).erreur_execution = d_ex; |
Line 135 rplinit(int argc, char *argv[], unsigned
|
Line 184 rplinit(int argc, char *argv[], unsigned
|
pthread_mutex_init(&((*s_etat_processus).mutex), &attributs_mutex); |
pthread_mutex_init(&((*s_etat_processus).mutex), &attributs_mutex); |
pthread_mutexattr_destroy(&attributs_mutex); |
pthread_mutexattr_destroy(&attributs_mutex); |
|
|
|
# ifndef SEMAPHORES_NOMMES |
sem_init(&((*s_etat_processus).semaphore_fork), 0, 0); |
sem_init(&((*s_etat_processus).semaphore_fork), 0, 0); |
|
# else |
|
if (((*s_etat_processus).semaphore_fork = sem_init2(0, sem_fork)) == |
|
SEM_FAILED) |
|
{ |
|
if ((*s_etat_processus).langue == 'F') |
|
{ |
|
uprintf("+++Système : Mémoire insuffisante\n"); |
|
} |
|
else |
|
{ |
|
uprintf("+++System : Not enough memory\n"); |
|
} |
|
|
|
return(EXIT_FAILURE); |
|
} |
|
# endif |
|
|
pthread_mutexattr_init(&attributs_mutex); |
pthread_mutexattr_init(&attributs_mutex); |
pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL); |
pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL); |
Line 155 rplinit(int argc, char *argv[], unsigned
|
Line 221 rplinit(int argc, char *argv[], unsigned
|
.mutex), &attributs_mutex); |
.mutex), &attributs_mutex); |
pthread_mutexattr_destroy(&attributs_mutex); |
pthread_mutexattr_destroy(&attributs_mutex); |
|
|
if ((langue = getenv("LANG")) != NULL) |
|
{ |
|
(*s_etat_processus).langue = (strncmp(langue, "fr", 2) == 0) |
|
? 'F' : 'E'; |
|
} |
|
else |
|
{ |
|
(*s_etat_processus).langue = 'E'; |
|
} |
|
|
|
localisation_courante(s_etat_processus); |
localisation_courante(s_etat_processus); |
|
(*s_etat_processus).erreur_systeme = d_es; |
|
|
if ((*s_etat_processus).erreur_systeme != d_es) |
if ((*s_etat_processus).localisation == NULL) |
{ |
{ |
if ((*s_etat_processus).langue == 'F') |
if (((*s_etat_processus).localisation = malloc((strlen(d_locale) + 1) * |
{ |
sizeof(unsigned char))) == NULL) |
uprintf("+++Système : Mémoire insuffisante\n"); |
|
} |
|
else |
|
{ |
{ |
uprintf("+++System : Not enough memory\n"); |
if ((*s_etat_processus).langue == 'F') |
|
{ |
|
uprintf("+++Système : Mémoire insuffisante\n"); |
|
} |
|
else |
|
{ |
|
uprintf("+++System : Not enough memory\n"); |
|
} |
|
|
|
return(EXIT_FAILURE); |
} |
} |
|
|
return(EXIT_FAILURE); |
strcpy((*s_etat_processus).localisation, d_locale); |
} |
} |
|
|
printf("+++RPL/2 (R) version %s (%s)\n", d_version_rpl, |
printf("+++RPL/2 (R) version %s (%s)\n", d_version_rpl, |
Line 231 rplinit(int argc, char *argv[], unsigned
|
Line 294 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
|
# ifndef SEMAPHORES_NOMMES |
if (pthread_setspecific(semaphore_fork_processus_courant, |
if (pthread_setspecific(semaphore_fork_processus_courant, |
&((*s_etat_processus).semaphore_fork)) != 0) |
&((*s_etat_processus).semaphore_fork)) != 0) |
|
# else |
|
if (pthread_setspecific(semaphore_fork_processus_courant, |
|
(*s_etat_processus).semaphore_fork) != 0) |
|
# endif |
{ |
{ |
if ((*s_etat_processus).langue == 'F') |
if ((*s_etat_processus).langue == 'F') |
{ |
{ |
Line 1272 rplinit(int argc, char *argv[], unsigned
|
Line 1340 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
|
free(type_debug); |
break; |
break; |
} |
} |
|
|
Line 1623 rplinit(int argc, char *argv[], unsigned
|
Line 1692 rplinit(int argc, char *argv[], unsigned
|
(*s_etat_processus).affichage_arguments = 'N'; |
(*s_etat_processus).affichage_arguments = 'N'; |
(*s_etat_processus).autorisation_conversion_chaine = 'Y'; |
(*s_etat_processus).autorisation_conversion_chaine = 'Y'; |
(*s_etat_processus).autorisation_evaluation_nom = 'Y'; |
(*s_etat_processus).autorisation_evaluation_nom = 'Y'; |
|
(*s_etat_processus).autorisation_nom_implicite = 'Y'; |
(*s_etat_processus).autorisation_empilement_programme = 'N'; |
(*s_etat_processus).autorisation_empilement_programme = 'N'; |
(*s_etat_processus).requete_arret = 'N'; |
(*s_etat_processus).requete_arret = 'N'; |
(*s_etat_processus).evaluation_forcee = 'N'; |
(*s_etat_processus).evaluation_forcee = 'N'; |
Line 3330 rplinit(int argc, char *argv[], unsigned
|
Line 3400 rplinit(int argc, char *argv[], unsigned
|
retrait_thread(s_etat_processus); |
retrait_thread(s_etat_processus); |
|
|
pthread_mutex_destroy(&((*s_etat_processus).mutex)); |
pthread_mutex_destroy(&((*s_etat_processus).mutex)); |
|
# ifndef SEMAPHORES_NOMMES |
sem_post(&((*s_etat_processus).semaphore_fork)); |
sem_post(&((*s_etat_processus).semaphore_fork)); |
sem_destroy(&((*s_etat_processus).semaphore_fork)); |
sem_destroy(&((*s_etat_processus).semaphore_fork)); |
|
# else |
|
sem_post((*s_etat_processus).semaphore_fork); |
|
sem_destroy2((*s_etat_processus).semaphore_fork, sem_fork); |
|
# endif |
|
|
free((*s_etat_processus).localisation); |
free((*s_etat_processus).localisation); |
free(s_etat_processus); |
free(s_etat_processus); |
|
|
|
# ifndef SEMAPHORES_NOMMES |
sem_destroy(&semaphore_liste_threads); |
sem_destroy(&semaphore_liste_threads); |
|
# else |
|
sem_destroy2(semaphore_liste_threads, sem_liste_threads); |
|
# endif |
|
# ifndef SEMAPHORES_NOMMES |
sem_post(&semaphore_gestionnaires_signaux); |
sem_post(&semaphore_gestionnaires_signaux); |
sem_destroy(&semaphore_gestionnaires_signaux); |
sem_destroy(&semaphore_gestionnaires_signaux); |
sem_destroy(&semaphore_gestionnaires_signaux_atomique); |
sem_destroy(&semaphore_gestionnaires_signaux_atomique); |
|
# else |
|
sem_post(semaphore_gestionnaires_signaux); |
|
sem_destroy2(semaphore_gestionnaires_signaux, sem_gestionnaires_signaux); |
|
sem_destroy2(semaphore_gestionnaires_signaux_atomique, |
|
sem_gestionnaires_signaux_atomique); |
|
# endif |
|
|
# ifdef DEBUG_MEMOIRE |
# ifdef DEBUG_MEMOIRE |
debug_memoire_verification(s_etat_processus); |
debug_memoire_verification(s_etat_processus); |