--- rpl/src/rpl.h 2018/12/24 15:56:37 1.323 +++ rpl/src/rpl.h 2024/01/09 07:33:55 1.351 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.1.30 - Copyright (C) 1989-2018 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.35 + Copyright (C) 1989-2024 Dr. BERTRAND Joël This file is part of RPL/2. @@ -186,38 +186,40 @@ # include "zlib.h" # include "openssl/evp.h" -# ifndef OPENSSL_NO_MD2 -# include "openssl/md2.h" -# endif -# ifndef OPENSSL_NO_MD4 -# include "openssl/md4.h" -# endif -# ifndef OPENSSL_NO_MD5 -# include "openssl/md5.h" -# endif -# ifndef OPENSSL_NO_MDC2 -# include "openssl/mdc2.h" -# endif -# ifndef OPENSSL_NO_RIPEMD -# include "openssl/ripemd.h" -# endif -# ifndef OPENSSL_NO_SHA -# include "openssl/sha.h" -# endif -# ifndef OPENSSL_NO_WHIRLPOOL -# include "openssl/whrlpool.h" -# endif -# ifndef OPENSSL_NO_AES -# include "openssl/aes.h" -# endif -# ifndef OPENSSL_NO_CAMELLIA -# include "openssl/camellia.h" -# endif -# ifndef OPENSSL_NO_RC2 -# include "openssl/rc2.h" -# endif -# ifndef OPENSSL_NO_IDEA -# include "openssl/idea.h" +# ifndef RPLCXX +# ifndef OPENSSL_NO_MD2 +# include "openssl/md2.h" +# endif +# ifndef OPENSSL_NO_MD4 +# include "openssl/md4.h" +# endif +# ifndef OPENSSL_NO_MD5 +# include "openssl/md5.h" +# endif +# ifndef OPENSSL_NO_MDC2 +# include "openssl/mdc2.h" +# endif +# ifndef OPENSSL_NO_RIPEMD +# include "openssl/ripemd.h" +# endif +# ifndef OPENSSL_NO_SHA +# include "openssl/sha.h" +# endif +# ifndef OPENSSL_NO_WHIRLPOOL +# include "openssl/whrlpool.h" +# endif +# ifndef OPENSSL_NO_AES +# include "openssl/aes.h" +# endif +# ifndef OPENSSL_NO_CAMELLIA +# include "openssl/camellia.h" +# endif +# ifndef OPENSSL_NO_RC2 +# include "openssl/rc2.h" +# endif +# ifndef OPENSSL_NO_IDEA +# include "openssl/idea.h" +# endif # endif # include "sqlite3.h" @@ -269,8 +271,11 @@ #ifndef RPLARGS # ifndef UNIX_PATH_MAX - struct sockaddr_un sizecheck; +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wunused-variable" + static struct sockaddr_un sizecheck; # define UNIX_PATH_MAX sizeof(sizecheck.sun_path) +# pragma GCC diagnostic pop # endif #endif @@ -325,7 +330,8 @@ enum signaux_rpl rpl_sighup, rpl_sigtstp, rpl_sigexcept, - rpl_sigmax + rpl_sigmax, + rpl_siguser // Base des signaux à la discrétion de l'utilisateur }; #define LONGUEUR_QUEUE_SIGNAUX 1024 @@ -394,23 +400,40 @@ union semun #ifdef IPCS_SYSV # ifdef DEBUG_SEMAPHORES +# define sem_init(a, b, c) ({ \ + uprintf("[%d-%llu] Semaphore %s (%p) "\ + "initialization at %s() " \ + "line #%d <%d>\n", (int) getpid(), (unsigned long long) \ + pthread_self(), \ + #a, a, __FUNCTION__, __LINE__, value), fflush(stdout); \ + sem_init_SysV(a, b, c); }) # define sem_wait(a) ({ int value; sem_getvalue(a, &value); \ uprintf("[%d-%llu] Semaphore %s (%p) "\ "waiting at %s() " \ - "line #%d\n", (int) getpid(), (unsigned long long) i\ + "line #%d <%d>\n", (int) getpid(), (unsigned long long) i\ pthread_self(), \ - #a, a, __FUNCTION__, __LINE__), fflush(stdout); \ - if (value > 1) BUG(1, uprintf("Value %d\n", value)); \ + #a, a, __FUNCTION__, __LINE__, value), fflush(stdout); \ sem_wait_SysV(a); }) -# define sem_post(a) ({ int value; sem_getvalue(a, &value); \ +# define sem_trywait(a) ({ int value; sem_getvalue(a, &value); \ + uprintf("[%d-%llu] Semaphore %s (%p) "\ + "trywaiting at %s() " \ + "line #%d <%d>\n", (int) getpid(), (unsigned long long) i\ + pthread_self(), \ + #a, a, __FUNCTION__, __LINE__, value), fflush(stdout); \ + sem_trywait_SysV(a); }) +# define sem_post(a) ({ int value; sem_getvalue(a, &value); \ uprintf("[%d-%llu] Semaphore %s (%p) "\ "posting at %s() " \ - "line #%d\n", (int) getpid(), (unsigned long long) \ + "line #%d <%d>\n", (int) getpid(), (unsigned long long) \ pthread_self(), \ - #a, a, __FUNCTION__, __LINE__), fflush(stdout); \ - if (value > 0) BUG(1, uprintf("Value %d\n", value)); \ + #a, a, __FUNCTION__, __LINE__, value), fflush(stdout); \ sem_post_SysV(a); }) -# define sem_destroy(a) ({ int value; sem_getvalue(a, &value); \ +# define sem_destroy(a) ({ int value; sem_getvalue(a, &value); \ + uprintf("[%d-%llu] Semaphore %s (%p) "\ + "destroying at %s() " \ + "line #%d <%d>\n", (int) getpid(), (unsigned long long) \ + pthread_self(), \ + #a, a, __FUNCTION__, __LINE__, value), fflush(stdout); \ if (value == 0) BUG(1, uprintf("Value %d\n", value)); \ sem_destroy_SysV(a); }) # else @@ -428,21 +451,40 @@ union semun # define sem_unlink(a) sem_unlink_SysV(a) #else # ifdef DEBUG_SEMAPHORES +# define sem_init(a, b, c) ({ \ + uprintf("[%d-%llu] Semaphore %s (%p) "\ + "initialization at %s() " \ + "line #%d <%d>\n", (int) getpid(), (unsigned long long) \ + pthread_self(), \ + #a, a, __FUNCTION__, __LINE__, c), fflush(stdout); \ + sem_init(a, b, c); }) # define sem_wait(a) ({ int value; sem_getvalue(a, &value); \ uprintf("[%d-%llu] Semaphore %s (%p) "\ "waiting at %s() " \ - "line #%d\n", (int) getpid(), (unsigned long long) \ + "line #%d <%d>\n", (int) getpid(), (unsigned long long) \ + pthread_self(), \ + #a, a, __FUNCTION__, __LINE__, value), fflush(stdout); \ + sem_wait(a); }) +# define sem_trywait(a) ({ int value; sem_getvalue(a, &value); \ + uprintf("[%d-%llu] Semaphore %s (%p) "\ + "trywaiting at %s() " \ + "line #%d <%d>\n", (int) getpid(), (unsigned long long) \ pthread_self(), \ - #a, a, __FUNCTION__, __LINE__), fflush(stdout); \ - if (value > 1) BUG(1, uprintf("Value %d\n", value)); sem_wait(a); }) + #a, a, __FUNCTION__, __LINE__, value), fflush(stdout); \ + sem_trywait(a); }) # define sem_post(a) ({ int value; sem_getvalue(a, &value); \ uprintf("[%d-%llu] Semaphore %s (%p) "\ "posting at %s() " \ - "line #%d\n", (int) getpid(), (unsigned long long) \ + "line #%d <%d>\n", (int) getpid(), (unsigned long long) \ pthread_self(), \ - #a, a, __FUNCTION__, __LINE__), fflush(stdout); \ - if (value > 0) BUG(1, uprintf("Value %d\n", value)); sem_post(a); }) + #a, a, __FUNCTION__, __LINE__, value), fflush(stdout); \ + sem_post(a); }) # define sem_destroy(a) ({ int value; sem_getvalue(a, &value); \ + uprintf("[%d-%llu] Semaphore %s (%p) "\ + "destroying at %s() " \ + "line #%d <%d>\n", (int) getpid(), (unsigned long long) \ + pthread_self(), \ + #a, a, __FUNCTION__, __LINE__, value), fflush(stdout); \ if (value == 0) BUG(1, uprintf("Value %d\n", value)); \ sem_destroy(a); }) # endif @@ -531,7 +573,9 @@ union semun __EXTERN__ pid_t pid_processus_pere; + __EXTERN__ pthread_mutex_t mutex_sigaction; __EXTERN__ pthread_mutex_t mutex_liste_threads; + __EXTERN__ pthread_mutex_t mutex_liste_threads_surveillance; __EXTERN__ pthread_mutex_t mutex_creation_variable_partagee __STATIC_MUTEX_INITIALIZATION__; __EXTERN__ pthread_mutex_t mutex_sections_critiques; @@ -539,7 +583,7 @@ union semun __EXTERN__ pthread_mutex_t mutex_sem __STATIC_MUTEX_INITIALIZATION__; __EXTERN__ volatile int routine_recursive; - __EXTERN__ volatile int nombre_thread_surveillance_processus; + __EXTERN__ volatile int nombre_threads_surveillance_processus; # define SEM_FORK 0 # define SEM_QUEUE 1 @@ -692,13 +736,29 @@ void *debug_memoire_modification(void *p void debug_memoire_retrait(void *ptr); void debug_memoire_verification(); -pid_t debug_fork(); - -#define malloc(s) debug_memoire_ajout(s, __FUNCTION__, __LINE__, #s) #define free(s) debug_memoire_retrait(s) -#define realloc(s, t) debug_memoire_modification(s, t, \ - __FUNCTION__, __LINE__, #t) -#define fork() debug_fork() +#ifdef RPLCXX +# define malloc(s) debug_memoire_ajout(s, \ + const_cast \ + (reinterpret_cast \ + (const_cast(__FUNCTION__))), __LINE__, \ + const_cast \ + (reinterpret_cast \ + (const_cast(#s)))) +# define realloc(s, t) debug_memoire_modification(s, t, \ + const_cast \ + (reinterpret_cast \ + (const_cast(__FUNCTION__))), __LINE__, \ + const_cast \ + (reinterpret_cast \ + (const_cast(#t)))) +#else +# define malloc(s) debug_memoire_ajout(s, __FUNCTION__, __LINE__, \ + (const unsigned char *) #s) +# define realloc(s, t) debug_memoire_modification(s, t, \ + __FUNCTION__, __LINE__, (const unsigned char *) #t) +#endif +#define fork() debug_fork(s_etat_processus) #endif #ifdef DEBUG_RETURN @@ -1023,6 +1083,7 @@ pid_t debug_fork(); # define d_ex_taille_message __erreur(92) # define d_ex_type_externe_dup __erreur(93) # define d_ex_type_externe_drop __erreur(94) +# define d_ex_simplification __erreur(95) #endif @@ -1075,7 +1136,8 @@ pid_t debug_fork(); #define VIN __RPL_VIN #define VRL __RPL_VRL -enum t_rplcas_commandes { RPLCAS_INTEGRATION = 0, RPLCAS_LIMITE }; +enum t_rplcas_commandes { RPLCAS_INTEGRATION = 0, RPLCAS_LIMITE, + RPLCAS_SIMPLIFICATION }; enum t_type { ADR = 0, ALG, BIN, CHN, CPL, EXT, FCH, FCT, INT, LST, MCX, MIN, MRL, MTX, NOM, NON, PRC, REC, REL, RPN, SCK, @@ -1584,6 +1646,7 @@ typedef struct liste_pile_systeme logical1 creation_variables_statiques; logical1 creation_variables_partagees; logical1 evaluation_expression; + logical1 debug_programme; unsigned char clause; @@ -2516,6 +2579,10 @@ typedef struct processus } struct_processus; #endif +#ifdef DEBUG_MEMOIRE +pid_t debug_fork(struct_processus *s_etat_processus); +#endif + /* ================================================================================ @@ -2607,6 +2674,7 @@ void instruction_clrcntxt(struct_process void instruction_clrerr(struct_processus *s_etat_processus); void instruction_clrfuse(struct_processus *s_etat_processus); void instruction_clrmtx(struct_processus *s_etat_processus); +void instruction_clrsock(struct_processus *s_etat_processus); void instruction_clrsmphr(struct_processus *s_etat_processus); void instruction_clrswi(struct_processus *s_etat_processus); void instruction_cls(struct_processus *s_etat_processus); @@ -3283,7 +3351,8 @@ int envoi_signal_contexte(struct_process enum signaux_rpl signal); int envoi_signal_processus(pid_t pid, enum signaux_rpl signal, logical1 test_ouverture); -int envoi_signal_thread(pthread_t tid, enum signaux_rpl signal); +int envoi_signal_thread(struct_processus *s_etat_processus, + pthread_t tid, enum signaux_rpl signal); #endif /* @@ -3519,6 +3588,8 @@ logical1 validation_chaine(unsigned char #ifndef RPLARGS ssize_t read_atomic(struct_processus *s_etat_processus, int fd, void *buf, size_t count); +ssize_t read_atomic_signal(struct_processus *s_etat_processus, + int fd, void *buf, size_t count); ssize_t write_atomic(struct_processus *s_etat_processus, int fd, void *buf, size_t count); #endif