version 1.128, 2016/03/15 16:31:40
|
version 1.154, 2025/04/15 10:17:51
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.1.25 |
RPL/2 (R) version 4.1.36 |
Copyright (C) 1989-2016 Dr. BERTRAND Joël |
Copyright (C) 1989-2025 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
|
|
Line 106 initialisation_allocateur(struct_process
|
Line 106 initialisation_allocateur(struct_process
|
(*s_etat_processus).pointeur_int = 0; |
(*s_etat_processus).pointeur_int = 0; |
(*s_etat_processus).pointeur_mat = 0; |
(*s_etat_processus).pointeur_mat = 0; |
(*s_etat_processus).pointeur_nom = 0; |
(*s_etat_processus).pointeur_nom = 0; |
|
(*s_etat_processus).pointeur_rec = 0; |
(*s_etat_processus).pointeur_rel = 0; |
(*s_etat_processus).pointeur_rel = 0; |
(*s_etat_processus).pointeur_tab = 0; |
(*s_etat_processus).pointeur_tab = 0; |
(*s_etat_processus).pointeur_vec = 0; |
(*s_etat_processus).pointeur_vec = 0; |
Line 141 liberation_allocateur(struct_processus *
|
Line 142 liberation_allocateur(struct_processus *
|
free((*s_etat_processus).objets_mat[i++])); |
free((*s_etat_processus).objets_mat[i++])); |
for(i = 0; i < (*s_etat_processus).pointeur_nom; |
for(i = 0; i < (*s_etat_processus).pointeur_nom; |
free((*s_etat_processus).objets_nom[i++])); |
free((*s_etat_processus).objets_nom[i++])); |
|
for(i = 0; i < (*s_etat_processus).pointeur_rec; |
|
free((*s_etat_processus).objets_rec[i++])); |
for(i = 0; i < (*s_etat_processus).pointeur_rel; |
for(i = 0; i < (*s_etat_processus).pointeur_rel; |
free((*s_etat_processus).objets_rel[i++])); |
free((*s_etat_processus).objets_rel[i++])); |
for(i = 0; i < (*s_etat_processus).pointeur_tab; |
for(i = 0; i < (*s_etat_processus).pointeur_tab; |
Line 343 allocation(struct_processus *s_etat_proc
|
Line 346 allocation(struct_processus *s_etat_proc
|
} |
} |
|
|
(*s_objet).type = type; |
(*s_objet).type = type; |
|
(*s_objet).extension_type = 0; |
|
(*s_objet).descripteur_bibliotheque = NULL; |
|
|
switch(type) |
switch(type) |
{ |
{ |
Line 434 allocation(struct_processus *s_etat_proc
|
Line 439 allocation(struct_processus *s_etat_proc
|
break; |
break; |
} |
} |
|
|
|
case EXT : |
|
{ |
|
// Aucune allocation |
|
break; |
|
} |
|
|
case FCT : |
case FCT : |
{ |
{ |
if ((*s_etat_processus).pointeur_fct > 0) |
if ((*s_etat_processus).pointeur_fct > 0) |
Line 615 allocation(struct_processus *s_etat_proc
|
Line 626 allocation(struct_processus *s_etat_proc
|
break; |
break; |
} |
} |
|
|
|
case REC : |
|
{ |
|
if ((*s_etat_processus).pointeur_rec > 0) |
|
{ |
|
(*s_objet).objet = (*s_etat_processus).objets_rec |
|
[--(*s_etat_processus).pointeur_rec]; |
|
} |
|
else |
|
{ |
|
if (((*s_objet).objet = malloc(sizeof(struct_record))) |
|
== NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
free(s_objet); |
|
return(NULL); |
|
} |
|
} |
|
|
|
break; |
|
} |
|
|
case REL : |
case REL : |
{ |
{ |
if ((*s_etat_processus).pointeur_rel > 0) |
if ((*s_etat_processus).pointeur_rel > 0) |
Line 821 liberation(struct_processus *s_etat_proc
|
Line 854 liberation(struct_processus *s_etat_proc
|
struct_liste_chainee *l_element_suivant; |
struct_liste_chainee *l_element_suivant; |
|
|
integer8 i; |
integer8 i; |
|
integer8 (*__type_drop)(struct_processus *, |
|
void **); |
|
|
if (s_objet == NULL) |
if (s_objet == NULL) |
{ |
{ |
Line 1263 liberation(struct_processus *s_etat_proc
|
Line 1298 liberation(struct_processus *s_etat_proc
|
break; |
break; |
} |
} |
|
|
|
case REC : |
|
{ |
|
liberation(s_etat_processus, |
|
(*((struct_record *) (*s_objet).objet)).noms); |
|
liberation(s_etat_processus, |
|
(*((struct_record *) (*s_objet).objet)).donnees); |
|
|
|
if (decrementation_atomique(s_objet) > 0) |
|
{ |
|
return; |
|
} |
|
|
|
if ((*s_etat_processus).pointeur_rec < TAILLE_CACHE) |
|
{ |
|
(*s_etat_processus).objets_rec |
|
[(*s_etat_processus).pointeur_rec++] = (*s_objet).objet; |
|
} |
|
else |
|
{ |
|
free((struct_record *) ((*s_objet).objet)); |
|
} |
|
|
|
break; |
|
} |
|
|
case REL : |
case REL : |
{ |
{ |
if (decrementation_atomique(s_objet) > 0) |
if (decrementation_atomique(s_objet) > 0) |
Line 1493 liberation(struct_processus *s_etat_proc
|
Line 1553 liberation(struct_processus *s_etat_proc
|
break; |
break; |
} |
} |
|
|
|
case EXT: |
|
{ |
|
if (decrementation_atomique(s_objet) > 0) |
|
{ |
|
return; |
|
} |
|
|
|
// Appel de la fonction de liberation associée à l'objet |
|
// externe. Le descripteur de bibliothèque est directement |
|
// associé à la structure objet. |
|
|
|
l_element_courant = (*s_etat_processus).s_bibliotheques; |
|
|
|
while(l_element_courant != NULL) |
|
{ |
|
if ((*((struct_bibliotheque *) (*l_element_courant).donnee)) |
|
.descripteur == (*s_objet).descripteur_bibliotheque) |
|
{ |
|
if ((__type_drop = dlsym((*s_objet) |
|
.descripteur_bibliotheque, "__type_drop")) == NULL) |
|
{ |
|
// La fonction de libération n'existe pas dans la |
|
// bibliothèque. |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_type_externe_drop; |
|
} |
|
else |
|
{ |
|
if (__type_drop(s_etat_processus, (void **) &s_objet) |
|
== 0) |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_type_externe_drop; |
|
} |
|
} |
|
|
|
break; |
|
} |
|
|
|
l_element_courant = (*l_element_courant).suivant; |
|
} |
|
|
|
if (l_element_courant == NULL) |
|
{ |
|
(*s_etat_processus).erreur_execution = d_ex_type_externe_drop; |
|
} |
|
|
|
break; |
|
} |
|
|
default : |
default : |
{ |
{ |
if (pthread_mutex_unlock(&((*s_objet).mutex)) != 0) |
if (pthread_mutex_unlock(&((*s_objet).mutex)) != 0) |
Line 1591 copie_objet(struct_processus *s_etat_pro
|
Line 1702 copie_objet(struct_processus *s_etat_pro
|
|
|
integer8 i; |
integer8 i; |
integer8 j; |
integer8 j; |
|
integer8 (*__type_dup)(struct_processus *, void **); |
|
|
if (pthread_mutex_lock(&((*s_objet).mutex)) != 0) |
if (pthread_mutex_lock(&((*s_objet).mutex)) != 0) |
{ |
{ |
Line 2372 copie_objet(struct_processus *s_etat_pro
|
Line 2484 copie_objet(struct_processus *s_etat_pro
|
break; |
break; |
} |
} |
|
|
|
case REC : |
|
{ |
|
if (type != 'P') |
|
{ |
|
if ((s_nouvel_objet = allocation(s_etat_processus, REC)) |
|
== NULL) |
|
{ |
|
return(NULL); |
|
} |
|
|
|
if (((*((struct_record *) (*s_nouvel_objet).objet)).noms = |
|
copie_objet(s_etat_processus, (*((struct_record *) |
|
(*s_objet).objet)).noms, 'P')) == NULL) |
|
{ |
|
return(NULL); |
|
} |
|
|
|
if (((*((struct_record *) (*s_nouvel_objet).objet)).donnees = |
|
copie_objet(s_etat_processus, (*((struct_record *) |
|
(*s_objet).objet)).donnees, type)) == NULL) |
|
{ |
|
return(NULL); |
|
} |
|
} |
|
else |
|
{ |
|
incrementation_atomique(s_objet); |
|
(*((struct_record *) (*s_objet).objet)).noms = |
|
copie_objet(s_etat_processus, (*((struct_record *) |
|
(*s_objet).objet)).noms, 'P'); |
|
(*((struct_record *) (*s_objet).objet)).donnees = |
|
copie_objet(s_etat_processus, (*((struct_record *) |
|
(*s_objet).objet)).donnees, 'P'); |
|
|
|
return(s_objet); |
|
} |
|
|
|
break; |
|
} |
|
|
case REL : |
case REL : |
{ |
{ |
if (type != 'O') |
if (type != 'O') |
Line 2812 copie_objet(struct_processus *s_etat_pro
|
Line 2964 copie_objet(struct_processus *s_etat_pro
|
break; |
break; |
} |
} |
|
|
|
case EXT: |
|
{ |
|
if (type != 'O') |
|
{ |
|
incrementation_atomique(s_objet); |
|
return(s_objet); |
|
} |
|
|
|
// Appel de la fonction de duplication associée à l'objet |
|
// externe. Le descripteur de bibliothèque est directement |
|
// associé à la structure objet. |
|
|
|
l_element_courant = (*s_etat_processus).s_bibliotheques; |
|
|
|
while(l_element_courant != NULL) |
|
{ |
|
if ((*((struct_bibliotheque *) (*l_element_courant).donnee)) |
|
.descripteur == (*s_objet).descripteur_bibliotheque) |
|
{ |
|
if ((__type_dup = dlsym((*s_objet).descripteur_bibliotheque, |
|
"__type_dup")) == NULL) |
|
{ |
|
// La fonction de duplication n'existe pas dans la |
|
// bibliothèque. |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_type_externe_dup; |
|
return(NULL); |
|
} |
|
|
|
s_nouvel_objet = s_objet; |
|
|
|
if (__type_dup(s_etat_processus, (void **) &s_nouvel_objet) |
|
== 0) |
|
{ |
|
return(NULL); |
|
} |
|
|
|
break; |
|
} |
|
|
|
l_element_courant = (*l_element_courant).suivant; |
|
} |
|
|
|
if (l_element_courant == NULL) |
|
{ |
|
(*s_etat_processus).erreur_execution = d_ex_type_externe_dup; |
|
return(NULL); |
|
} |
|
|
|
break; |
|
} |
|
|
default : |
default : |
{ |
{ |
return(NULL); |
return(NULL); |
Line 2869 copie_etat_processus(struct_processus *s
|
Line 3074 copie_etat_processus(struct_processus *s
|
return(NULL); |
return(NULL); |
} |
} |
|
|
|
|
|
if (pthread_mutex_lock(&((*s_etat_processus).mutex_interruptions)) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return(NULL); |
|
} |
|
|
|
if (pthread_mutex_lock(&((*s_etat_processus).mutex_signaux)) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return(NULL); |
|
} |
|
|
(*s_nouvel_etat_processus) = (*s_etat_processus); |
(*s_nouvel_etat_processus) = (*s_etat_processus); |
|
|
|
if (pthread_mutex_unlock(&((*s_etat_processus).mutex_signaux)) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return(NULL); |
|
} |
|
|
|
if (pthread_mutex_unlock(&((*s_etat_processus).mutex_interruptions)) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return(NULL); |
|
} |
|
|
// On réinitialise les allocateurs. |
// On réinitialise les allocateurs. |
|
|
pthread_mutexattr_init(&attributs_mutex); |
pthread_mutexattr_init(&attributs_mutex); |
Line 3736 debug_memoire_ajout(size_t taille, const
|
Line 3966 debug_memoire_ajout(size_t taille, const
|
sizeof(unsigned char))) == NULL) |
sizeof(unsigned char))) == NULL) |
{ |
{ |
pthread_mutex_unlock(&mutex_allocation); |
pthread_mutex_unlock(&mutex_allocation); |
|
|
|
uprintf("[%d-%llu] ILLEGAL POINTER (malloc) $%016X\n", |
|
getpid(), (unsigned long long) pthread_self(), NULL); |
|
# ifdef __BACKTRACE |
|
BACKTRACE(PROFONDEUR_PILE); |
|
# endif |
|
|
return(NULL); |
return(NULL); |
} |
} |
|
|
Line 3796 debug_memoire_modification(void *pointeu
|
Line 4033 debug_memoire_modification(void *pointeu
|
{ |
{ |
pthread_mutex_unlock(&mutex_allocation); |
pthread_mutex_unlock(&mutex_allocation); |
|
|
uprintf("[%d-%llu] ILLEGAL POINTER (realloc)\n", |
uprintf("[%d-%llu] ILLEGAL POINTER (realloc) $%016X\n", |
getpid(), (unsigned long long) pthread_self()); |
getpid(), (unsigned long long) pthread_self(), |
|
pointeur); |
# ifdef __BACKTRACE |
# ifdef __BACKTRACE |
BACKTRACE(PROFONDEUR_PILE); |
BACKTRACE(PROFONDEUR_PILE); |
# endif |
# endif |
Line 3893 debug_memoire_retrait(void *pointeur)
|
Line 4131 debug_memoire_retrait(void *pointeur)
|
|
|
if (element_courant == NULL) |
if (element_courant == NULL) |
{ |
{ |
uprintf("[%d-%llu] ILLEGAL POINTER (free)\n", |
uprintf("[%d-%llu] ILLEGAL POINTER (free) $%016X\n", |
getpid(), (unsigned long long) pthread_self()); |
getpid(), (unsigned long long) pthread_self(), pointeur); |
# ifdef __BACKTRACE |
# ifdef __BACKTRACE |
BACKTRACE(PROFONDEUR_PILE); |
BACKTRACE(PROFONDEUR_PILE); |
# endif |
# endif |
Line 4011 debug_memoire_verification()
|
Line 4249 debug_memoire_verification()
|
} |
} |
|
|
pid_t |
pid_t |
debug_fork() |
debug_fork(struct_processus *s_etat_processus) |
{ |
{ |
pid_t pid; |
pid_t pid; |
|
|