From b1938c065da507482339fd5194589d06718d50de Mon Sep 17 00:00:00 2001 From: Gregory Nutt <gnutt@nuttx.org> Date: Thu, 31 Dec 2015 09:05:35 -0600 Subject: [PATCH] sys/time.h: Fix timersub macro; time_t is unsigned --- ChangeLog | 1 + include/pthread.h | 6 +++--- include/signal.h | 7 ++++--- include/sys/time.h | 6 +++--- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 519fc28770..b23a599c80 100755 --- a/ChangeLog +++ b/ChangeLog @@ -11263,3 +11263,4 @@ struct sigevent. This initial implementation will only work in the FLAT build. See the top-level TODO file for additional details (2015-12-30). + diff --git a/include/pthread.h b/include/pthread.h index 9cc2b44a41..00cd95772d 100644 --- a/include/pthread.h +++ b/include/pthread.h @@ -50,7 +50,7 @@ #include <stdbool.h> /* C99 boolean types */ #include <unistd.h> /* For getpid */ #include <semaphore.h> /* Needed for sem_t */ -#include <signal.h> /* Needed for sigset_t */ +#include <signal.h> /* Needed for sigset_t, includes this file */ #include <time.h> /* Needed for struct timespec */ /******************************************************************************** @@ -441,8 +441,8 @@ int pthread_sigmask(int how, FAR const sigset_t *set, FAR sigset_t *oset); #include <sys/types.h> #include <stdbool.h> -/* Avoid a circular dependencies by assuring that simple type definitions - * are avaiable in any inclusion ordering. +/* Avoid circular dependencies by assuring that simple type definitions are + * available in any inclusion ordering. */ #ifndef __PTHREAD_KEY_T_DEFINED diff --git a/include/signal.h b/include/signal.h index 742720cf6b..57c5742d83 100644 --- a/include/signal.h +++ b/include/signal.h @@ -45,8 +45,9 @@ #include <stdint.h> #include <time.h> + #ifdef CONFIG_SIG_EVTHREAD -# include <pthread.h> /* Needed for pthread_attr_t */ +# include <pthread.h> /* Needed for pthread_attr_t, includes this file */ #endif /******************************************************************************** @@ -320,8 +321,8 @@ int sigqueue(int pid, int signo, FAR void *sival_ptr); #include <stdint.h> -/* Avoid a circular dependencies by assuring that simple type definitions - * are avaiable in any inclusion ordering. +/* Avoid circular dependencies by assuring that simple type definitions are + * available in any inclusion ordering. */ #ifndef __SIGSET_T_DEFINED diff --git a/include/sys/time.h b/include/sys/time.h index ecc2fc8401..b36e30fca9 100644 --- a/include/sys/time.h +++ b/include/sys/time.h @@ -78,12 +78,12 @@ do \ { \ (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \ - (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \ - if ((vvp)->tv_usec < 0) \ + if ((uvp)->tv_usec > (tvp)->tv_usec) \ { \ (vvp)->tv_sec--; \ - (vvp)->tv_usec += 1000000; \ + (tvp)->tv_usec += 1000000; \ } \ + (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \ } \ while (0) -- GitLab