--- rpl/src/rpl.h 2010/08/12 14:22:37 1.54 +++ rpl/src/rpl.h 2010/08/17 14:15:20 1.58 @@ -31,6 +31,10 @@ # define _DARWIN_C_SOURCE #endif +#ifdef OpenBSD +# define _BSD_SOURCE +#endif + #ifdef OS2 # define _BSD_SOURCE # define _XOPEN_SOURCE 600 @@ -64,11 +68,11 @@ #ifndef RPLARGS # include +# include # include # include # include # include -# include # include # include # include @@ -89,20 +93,37 @@ # include +# ifdef _BROKEN_SIGINFO +# include +# include +# endif + # ifndef SEMAPHORES_SYSV # include # else -# include -# define SEM_FAILED NULL - typedef int sem_t; - -# ifndef SEM_A -# define SEM_A 0200 -# endif -# ifndef SEM_R -# define SEM_R 0400 +# 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 +# include +# include + typedef int sem_t; # endif +# define SEM_FAILED NULL + 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); @@ -166,6 +187,38 @@ #include "librplprototypes.h" +#ifndef UNIX_PATH_MAX + struct sockaddr_un sizecheck; +# define UNIX_PATH_MAX sizeof(sizecheck.sun_path) +#endif + +#ifdef _BROKEN_SIGINFO +# define SIGHANDLER_ARGS int signal +# ifdef SA_SIGINFO +# undef SA_SIGINFO +# endif +# define SA_SIGINFO 0 + +# define kill(pid, signal) rpl_kill(pid, signal) +# define pthread_kill(tid, signal) rpl_pthread_kill(tid, signal) + int rpl_kill(pid_t pid, int signal); + int rpl_pthread_kill(pthread_t tid, int signal); +#else +# define SIGHANDLER_ARGS int signal, siginfo_t *siginfo, void *context +#endif + +#define ftok(path, proj) \ + ({ \ + key_t key; \ + struct stat s; \ + while(stat(path, &s) != 0); \ + errno = 0; \ + key = ftok(path, proj); \ + if (key != -1) \ + key |= ((((key_t) s.st_dev) & 0xFF) << 8) | \ + ((((key_t) s.st_ino) & 0xFFFF) << 16); \ + key; \ + }) /* ================================================================================ @@ -193,9 +246,14 @@ */ #ifndef RPLARGS -# if defined(Darwin) -# define SIGPOLL SIGINFO -# endif + +// Signaux utilisés par défaut : +// SIGINT +// SIGTSTP +// SIGCONT +// SIGURG +// SIGPIPE +// SIGALRM // Arrêt par STOP # define SIGFSTOP SIGUSR1 @@ -204,9 +262,19 @@ // Injection de données # define SIGINJECT SIGQUIT // Arrêt général -# define SIGABORT SIGPROF +# ifndef OpenBSD +// La libpthread d'OpenBSD utilise SIGPROF +# define SIGABORT SIGPROF +# else +# define SIGABORT SIGTHR +# endif // Arrêt d'un processus fils depuis autre chose que STOP -# define SIGFABORT SIGPOLL +# if defined(Darwin) || defined(OpenBSD) +# define SIGFABORT SIGINFO +# else +# define SIGFABORT SIGPOLL +# endif + // Nombre d'interruptions disponibles # define d_NOMBRE_INTERRUPTIONS 64 #endif @@ -271,7 +339,12 @@ typedef unsigned char t_8_bits; # ifdef SEMAPHORES_NOMMES # define LONGUEUR_NOM_SEMAPHORE 64 # endif + # ifndef MAIN_RPL +# ifdef _BROKEN_SIGINFO + extern int *fifos_signaux; +# endif + extern jmp_buf contexte; extern jmp_buf contexte_initial; @@ -308,6 +381,10 @@ typedef unsigned char t_8_bits; extern sem_t *semaphores_nommes[4]; # endif # else +# ifdef _BROKEN_SIGINFO + int *fifos_signaux; +# endif + jmp_buf contexte; jmp_buf contexte_initial; @@ -636,7 +713,7 @@ pid_t debug_fork(); # define __erreur(i) i # else # define __erreur(i) ({ if (strstr(__FUNCTION__, "recherche_variable") \ - == NULL) fprintf(stderr, "ERROR %d AT %s() LINE %d\n", \ + == NULL) ufprintf(stderr, "ERROR %d AT %s() LINE %d\n", \ i, __FUNCTION__, __LINE__); i; }) # endif #else @@ -812,6 +889,42 @@ pid_t debug_fork(); -------------------------------------------------------------------------------- */ +#ifdef MIN +# undef MIN +#endif + +#ifdef MAX +# undef MAX +#endif + +#define ADR __RPL_ADR +#define ALG __RPL_ALG +#define BIN __RPL_BIN +#define CHN __RPL_CHN +#define CPL __RPL_CPL +#define FCH __RPL_FCH +#define FCT __RPL_FCT +#define INT __RPL_INT +#define LST __RPL_LST +#define MCX __RPL_MCX +#define MIN __RPL_MIN +#define MRL __RPL_MRL +#define MTX __RPL_MTX +#define NOM __RPL_NOM +#define NON __RPL_NON +#define PRC __RPL_PRC +#define REL __RPL_REL +#define RPN __RPL_RPN +#define SCK __RPL_SCK +#define SLB __RPL_SLB +#define SPH __RPL_SPH +#define SQL __RPL_SQL +#define TBL __RPL_TBL +#define VCX __RPL_VCX +#define VIN __RPL_VIN +#define VRL __RPL_VRL + + enum t_type { ADR = 0, ALG, BIN, CHN, CPL, FCH, FCT, INT, LST, MCX, MIN, MRL, MTX, NOM, NON, PRC, REL, RPN, SCK, SLB, SPH, SQL, TBL, VCX, VIN, VRL }; @@ -1597,7 +1710,14 @@ typedef struct processus 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 @@ -2642,17 +2762,17 @@ void insertion_thread_surveillance(struc void integrale_romberg(struct_processus *s_etat_processus, struct_objet *s_expression, unsigned char *variable, real8 a, real8 b, real8 precision); -void interruption1(int signal, siginfo_t *siginfo, void *context); -void interruption2(int signal, siginfo_t *siginfo, void *context); -void interruption3(int signal, siginfo_t *siginfo, void *context); -void interruption4(int signal, siginfo_t *siginfo, void *context); -void interruption5(int signal, siginfo_t *siginfo, void *context); -void interruption6(int signal, siginfo_t *siginfo, void *context); -void interruption7(int signal, siginfo_t *siginfo, void *context); -void interruption8(int signal, siginfo_t *siginfo, void *context); -void interruption9(int signal, siginfo_t *siginfo, void *context); -void interruption10(int signal, siginfo_t *siginfo, void *context); -void interruption11(int signal, siginfo_t *siginfo, void *context); +void interruption1(SIGHANDLER_ARGS); +void interruption2(SIGHANDLER_ARGS); +void interruption3(SIGHANDLER_ARGS); +void interruption4(SIGHANDLER_ARGS); +void interruption5(SIGHANDLER_ARGS); +void interruption6(SIGHANDLER_ARGS); +void interruption7(SIGHANDLER_ARGS); +void interruption8(SIGHANDLER_ARGS); +void interruption9(SIGHANDLER_ARGS); +void interruption10(SIGHANDLER_ARGS); +void interruption11(SIGHANDLER_ARGS); void inversion_matrice(struct_processus *s_etat_processus, struct_matrice *s_matrice); void lancement_daemon(struct_processus *s_etat_processus); @@ -2711,6 +2831,14 @@ void valeurs_singulieres(struct_processu void verrouillage_threads_concurrents(struct_processus *s_etat_processus); #endif +#ifndef RPLARGS +#ifdef _BROKEN_SIGINFO +void creation_fifos_signaux(struct_processus *s_etat_processus); +void destruction_fifos_signaux(struct_processus *s_etat_processus); +void liberation_fifos_signaux(struct_processus *s_etat_processus); +#endif +#endif + /* -------------------------------------------------------------------------------- Fonctions de sommation de vecteur dans perte de précision