--- rpl/src/rpl.h 2019/02/06 14:23:26 1.327 +++ rpl/src/rpl.h 2019/02/07 21:44:15 1.328 @@ -18,7 +18,8 @@ along with RPL/2. If not, write to info@cecill.info. ================================================================================ */ - +#define DEBUG_ERREURS +#define DEBUG_SEMAPHORES #ifndef INCLUSION_RPL #define INCLUSION_RPL @@ -401,14 +402,26 @@ union semun pthread_self(), \ #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 <%d>\n", (int) getpid(), (unsigned long long) \ pthread_self(), \ #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 @@ -433,6 +446,13 @@ union semun 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__, 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() " \ @@ -441,6 +461,11 @@ union semun #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