--- rpl/src/rpl.h 2011/09/20 08:56:24 1.128 +++ rpl/src/rpl.h 2011/12/01 15:23:49 1.150 @@ -1,6 +1,6 @@ /* ================================================================================ - RPL/2 (R) version 4.1.3 + RPL/2 (R) version 4.1.5 Copyright (C) 1989-2011 Dr. BERTRAND Joël This file is part of RPL/2. @@ -43,7 +43,6 @@ #ifdef OS2 # ifndef __RPLCAS # define _BSD_SOURCE -# define _XOPEN_SOURCE 600 # endif # include @@ -92,6 +91,7 @@ # include # include # include +# include # ifdef OS2 # undef pthread_mutexattr_settype @@ -99,54 +99,55 @@ # endif # include -# include +# ifdef SHARED_MEMORY +# include +# endif -# ifndef __RPLCAS -# ifndef IPCS_SYSV -# include -# else -# include -# include +# ifndef IPCS_SYSV +# include +# else +# include +# include -# ifdef OS2 -# define INCL_DOSSEMAPHORES -# define INCL_DOSMEMMGR -# define INCL_DOSERRORS -# include - - typedef struct _OS2SEM - { - HMTX hmtx; - HEV hev; - ULONG shared; - ULONG *cnt; - ULONG *nopened; - ULONG allocated; - } sem_t; -# else // IPCS_SYSV - typedef struct - { - int sem; - int alloue; - unsigned char *path; - pid_t pid; - } sem_t; -# endif - -# ifndef SEM_FAILED -# define SEM_FAILED NULL -# endif - - sem_t *sem_open_SysV(const char *nom, int oflag, ...); - int sem_init_SysV(sem_t *sem, int shared, unsigned int value); - int sem_close_SysV(sem_t *sem); - int sem_wait_SysV(sem_t *sem); - int sem_trywait_SysV(sem_t *sem); - int sem_post_SysV(sem_t *sem); - int sem_getvalue_SysV(sem_t *sem, int *value); - int sem_unlink_SysV(const char *nom); - int sem_destroy_SysV(sem_t *sem); +# ifdef OS2 +# define INCL_DOSSEMAPHORES +# define INCL_DOSMEMMGR +# define INCL_DOSERRORS +# include + + typedef struct _OS2SEM + { + HMTX hmtx; + HEV hev; + ULONG shared; + ULONG *cnt; + ULONG *nopened; + ULONG allocated; + } sem_t; +# else // IPCS_SYSV + typedef struct + { + int sem; + int alloue; + unsigned char *path; + pid_t pid; + pthread_t tid; + } sem_t; # endif + +# ifndef SEM_FAILED +# define SEM_FAILED NULL +# endif + + sem_t *sem_open_SysV(const char *nom, int oflag, ...); + int sem_init_SysV(sem_t *sem, int shared, unsigned int value); + int sem_close_SysV(sem_t *sem); + int sem_wait_SysV(sem_t *sem); + int sem_trywait_SysV(sem_t *sem); + int sem_post_SysV(sem_t *sem); + int sem_getvalue_SysV(sem_t *sem, int *value); + int sem_unlink_SysV(const char *nom); + int sem_destroy_SysV(sem_t *sem); # endif # include @@ -163,6 +164,11 @@ # include "openssl/evp.h" # include "sqlite3.h" +# include "sigsegv.h" +# ifdef OS2 + // Bug de libsigsegv +# undef HAVE_STACK_OVERFLOW_RECOVERY +# endif # define HAVE_INLINE # define GSL_RANGE_CHECK_OFF @@ -242,6 +248,7 @@ enum signaux_rpl // Elle est projetée dans un segment de mémoire partagée pour qu'elle soit // accessible à la fois du père et des fils. +#ifndef RPLARGS typedef struct queue_signaux { # ifndef IPCS_SYSV @@ -262,7 +269,6 @@ typedef struct queue_signaux } queue[LONGUEUR_QUEUE_SIGNAUX]; } struct_queue_signaux; -#ifndef RPLARGS # ifndef MAIN_RPL extern struct_queue_signaux *s_queue_signaux; extern int f_queue_signaux; @@ -278,13 +284,6 @@ typedef struct queue_signaux # endif #endif -#ifdef OpenBSD -# ifdef PTHREAD_SCOPE_SYSTEM -# undef PTHREAD_SCOPE_SYSTEM -# endif -# define PTHREAD_SCOPE_SYSTEM 0 -#endif - #ifdef OS2 # define readline(s) readline_wrapper(s) unsigned char *readline_wrapper(unsigned char *s); @@ -300,6 +299,13 @@ union semun }; #endif +#ifndef RTLD_LOCAL +# define RTLD_LOCAL 0 +#endif + +#ifndef SIGSTKSZ +# define SIGSTKSZ 65536 +#endif /* ================================================================================ @@ -332,9 +338,8 @@ union semun // SIGINT // SIGTSTP // SIGCONT -// SIGURG // SIGPIPE -// SIGALRM +// SIGUSR1 et SIGUSR2 sont utilisé par libsigsegv. # define SIGTEST SIGUSR1 @@ -404,7 +409,8 @@ typedef unsigned char t_8_bits; # endif # ifndef MAIN_RPL - extern jmp_buf contexte; + extern jmp_buf contexte_ecriture; + extern jmp_buf contexte_impression; extern jmp_buf contexte_initial; extern jmp_buf contexte_processus; extern jmp_buf contexte_thread; @@ -425,8 +431,11 @@ typedef unsigned char t_8_bits; * # endif semaphore_gestionnaires_signaux; + + extern volatile int routine_recursive; # else - jmp_buf contexte; + jmp_buf contexte_ecriture; + jmp_buf contexte_impression; jmp_buf contexte_initial; jmp_buf contexte_processus; jmp_buf contexte_thread; @@ -450,14 +459,21 @@ typedef unsigned char t_8_bits; * # endif semaphore_gestionnaires_signaux; + + volatile int routine_recursive; # endif #endif #ifdef SEMAPHORES_NOMMES -sem_t *sem_init2(unsigned int valeur, pid_t pid); -int sem_destroy2(sem_t *semaphore_p, pid_t pid); +#define SEM_FORK 0 +#define SEM_QUEUE 1 +#define SEM_SIGNAUX 2 +sem_t *sem_init2(unsigned int valeur, pid_t pid, int ordre); +sem_t *sem_init3(unsigned int valeur, pid_t pid, pthread_t tid, int ordre); +int sem_destroy2(sem_t *semaphore_p, pid_t pid, int ordre); +int sem_destroy3(sem_t *semaphore_p, pid_t pid, pthread_t tid, int ordre); int sem_getvalue2(sem_t *semaphore, int *valeur); -sem_t *sem_open2(pid_t pid); +sem_t *sem_open2(pid_t pid, int ordre); // Le mutex est là uniquement pour pouvoir émuler le comportement // de sem_getvalue() sur un système comme MacOS X qui ne possède pas @@ -740,7 +756,7 @@ pid_t debug_fork(); Erreurs système -------------------------------------------------------------------------------- */ -#define DEBUG_ERREURS + #ifdef DEBUG_ERREURS # ifdef MESSAGES # define __erreur(i) i @@ -781,6 +797,7 @@ pid_t debug_fork(); # define d_es_contexte __erreur(2013) # define d_es_somme_controle __erreur(2014) # define d_es_semaphore __erreur(2015) +# define d_es_mutex_acquis_autre_thread __erreur(2016) #endif /* @@ -919,6 +936,9 @@ pid_t debug_fork(); # define d_ex_version_bibliotheque __erreur(82) # define d_ex_creation_variable_globale __erreur(83) # define d_ex_erreur_interne_rplcas __erreur(84) +# define d_ex_fichier_corrompu __erreur(85) +# define d_ex_mutex_acquis_autre_thread __erreur(86) +# define d_ex_expression_reguliere __erreur(87) #endif @@ -1106,6 +1126,7 @@ typedef struct fichier typedef struct rpl_mutex { pthread_mutex_t mutex; + pthread_t tid; } struct_mutex; #endif @@ -1816,20 +1837,6 @@ typedef struct processus pthread_t thread_fusible; pthread_t thread_surveille_par_fusible; -# if !defined(Cygwin) -# if !(OpenBSD) - stack_t pile_signal; -# else -# ifdef SA_ONSTACK -# undef SA_ONSTACK -# endif -# define SA_ONSTACK 0 -# endif -# else -# define SA_ONSTACK 0 -# define RTLD_LOCAL 0 -# endif - volatile int pointeur_signal_ecriture; volatile int pointeur_signal_lecture; volatile enum signaux_rpl signaux_en_queue[LONGUEUR_QUEUE_SIGNAUX]; @@ -2050,7 +2057,6 @@ typedef struct processus /* Traitement des erreurs */ - unsigned int compteur_violation_d_acces; unsigned int erreur_compilation; unsigned int erreur_execution; unsigned int erreur_systeme; @@ -2178,13 +2184,21 @@ typedef struct processus pthread_mutex_t mutex_allocation; // Mutex autorisant les fork() - sem_t semaphore_fork; + sem_t +# ifdef SEMAPHORES_NOMMES + * +# endif + semaphore_fork; /* Mutexes */ struct_liste_chainee *liste_mutexes; pthread_mutex_t protection_liste_mutexes; +/* Drapeau nécessaire à RESTART */ + + volatile logical1 requete_redemarrage; + /* Gestion optimisée de la mémoire */ double estimation_taille_pile_tampon; @@ -2628,9 +2642,11 @@ void instruction_read(struct_processus * void instruction_recode(struct_processus *s_etat_processus); void instruction_recv(struct_processus *s_etat_processus); void instruction_redraw(struct_processus *s_etat_processus); +void instruction_regex(struct_processus *s_etat_processus); void instruction_relax(struct_processus *s_etat_processus); void instruction_remove(struct_processus *s_etat_processus); void instruction_res(struct_processus *s_etat_processus); +void instruction_restart(struct_processus *s_etat_processus); void instruction_recall(struct_processus *s_etat_processus); void instruction_regv(struct_processus *s_etat_processus); void instruction_repeat(struct_processus *s_etat_processus); @@ -2823,6 +2839,8 @@ void appel_gnuplot(struct_processus *s_e void cf(struct_processus *s_etat_processus, unsigned char indice_drapeau); void cond(struct_processus *s_etat_processus, struct_matrice *s_matrice, real8 *condition); +void conversion_chaine(struct_processus *s_etat_processus, + unsigned char *chaine, unsigned char type); void conversion_decimal_vers_hms(real8 *angle); void conversion_degres_vers_radians(real8 *angle); void conversion_element_tex(unsigned char **element, unsigned char *fonction); @@ -2898,6 +2916,8 @@ void interruption2(int signal); void interruption3(int signal); void interruption4(int signal); void interruption5(int signal); +void interruption6(int signal); +void interruption_depassement_pile(int urgence, stackoverflow_context_t scp); void inversion_matrice(struct_processus *s_etat_processus, struct_matrice *s_matrice); void lancement_daemon(struct_processus *s_etat_processus); @@ -2931,7 +2951,11 @@ void retrait_thread(struct_processus *s_ void retrait_thread_surveillance(struct_processus *s_etat_processus, struct_descripteur_thread *s_argument_thread); void rplcore(struct_processus *s_etat_processus); +#endif + void scrutation_injection(struct_processus *s_etat_processus); + +#ifndef RPLARGS void scrutation_interruptions(struct_processus *s_etat_processus); void sf(struct_processus *s_etat_processus, unsigned char indice_drapeau); void *surveillance_processus(void *argument); @@ -2994,7 +3018,8 @@ complex16 sommation_vecteur_complexe(com */ #ifndef RPLARGS -int rplinit(int argc, char *argv[], unsigned char ***resultats, char *rpl_home); +int rplinit(int argc, char *argv[], char *envp[], + unsigned char ***resultats, char *rpl_home); #endif /* @@ -3058,6 +3083,7 @@ unsigned char *compactage(unsigned char unsigned char *conversion_majuscule(unsigned char *chaine); unsigned char *creation_nom_fichier(struct_processus *s_etat_processus, unsigned char *chemin); +unsigned char *date_compilation(); unsigned char *extraction_chaine(unsigned char *chaine, unsigned long i, unsigned long j); unsigned char *formateur(struct_processus *s_etat_processus, long offset, @@ -3071,6 +3097,9 @@ unsigned char *formateur_flux(struct_pro unsigned char *formateur_fichier_nombre(struct_processus *s_etat_processus, void *valeur_numerique, unsigned char type, long longueur, long longueur_champ, unsigned char format); +unsigned char *formateur_fichier_binaire_nombre(struct_processus + *s_etat_processus, void *valeur_numerique, unsigned char type, + long longueur, long *longueur_conversion); unsigned char *formateur_fichier_reel(struct_processus *s_etat_processus, void *valeur_numerique, unsigned char type, long longueur, long longueur_champ, unsigned char format); @@ -3079,6 +3108,8 @@ unsigned char *formateur_nombre(struct_p unsigned char *formateur_reel(struct_processus *s_etat_processus, void *valeur_numerique, unsigned char type); unsigned char *messages(struct_processus *s_etat_processus); +unsigned char *pointeur_ieme_caractere(struct_processus *s_etat_processus, + unsigned char *chaine, integer8 position); unsigned char *purification_chaine(unsigned char *chaine); unsigned char *reencodage(struct_processus *s_etat_processus, unsigned char *chaine_entree, unsigned char *codage_entree, @@ -3101,6 +3132,8 @@ logical1 caracteristiques_fichier(struct unsigned long *unite); logical1 controle(struct_processus *s_etat_processus, unsigned char *fichier, unsigned char *type, unsigned char *somme_candidate); +logical1 controle_integrite(struct_processus *s_etat_processus, + unsigned char *executable_candidat, unsigned char *executable); logical1 creation_variable(struct_processus *s_etat_processus, struct_variable *s_variable, unsigned char autorisation_creation_variable_statique, @@ -3164,6 +3197,7 @@ logical1 test_cfsf(struct_processus *s_e unsigned char indice_drapeau); logical1 test_expression_rpn(unsigned char *chaine); logical1 test_fonction(unsigned char *chaine); +logical1 validation_chaine(unsigned char *chaine); #endif /* @@ -3186,11 +3220,14 @@ ssize_t write_atomic(struct_processus *s */ int alsprintf(unsigned char **strp, const char *fmt, ...); +int interruption_violation_access(void *adresse_fautive, int gravite); +#ifndef RPLARGS int liste_variables(struct_processus *s_etat_processus, struct_tableau_variables *tableau, int position, struct_arbre_variables *l_element_courant); int nombre_variables(struct_processus *s_etat_processus, struct_arbre_variables *l_element_courant); +#endif int tex_fprintf(struct_processus *s_etat_processus, file *flux, const char *format, ...); int transliterated_fprintf(struct_processus *s_etat_processus, file *flux, @@ -3207,7 +3244,6 @@ int wrapper_instruction_intrinseque(void #ifndef RPLARGS unsigned char longueur_entiers_binaires(struct_processus *s_etat_processus); -unsigned char recherche_longueur_optimale(integer8 parametre); #endif /* @@ -3228,6 +3264,10 @@ logical8 masque_entiers_binaires(struct_ #ifndef RPLARGS integer8 occupation_memoire(struct_objet *s_objet); +integer8 longueur_chaine(struct_processus *s_etat_processus, + unsigned char *chaine); +integer8 position_caractere_de_chaine(struct_processus *s_etat_processus, + unsigned char *chaine, unsigned char *position); #endif /* @@ -3272,8 +3312,8 @@ struct_descripteur_fichier *descripteur_ struct_objet *copie_objet(struct_processus *s_etat_processus, struct_objet *s_objet, unsigned char type); -#ifndef RPLARGS struct_objet *allocation(struct_processus *s_etat_processus, enum t_type type); +#ifndef RPLARGS struct_objet *formateur_date(struct_processus *s_etat_processus, struct timeval *temps); struct_objet *lecture_pipe(struct_processus *s_etat_processus, int pipe);