include/nuttx/clock.h: Change ?SEC2TICK macros to round up and fix nxstyle errors

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
This commit is contained in:
Jukka Laitinen 2023-01-30 12:13:16 +04:00 committed by Xiang Xiao
parent 3904fd775a
commit 4dd8187afe

View File

@ -145,41 +145,49 @@
* preferred for that reason (at the risk of overflow)
*/
#define TICK_PER_HOUR (USEC_PER_HOUR / USEC_PER_TICK) /* Truncates! */
#define TICK_PER_MIN (USEC_PER_MIN / USEC_PER_TICK) /* Truncates! */
#define TICK_PER_SEC (USEC_PER_SEC / USEC_PER_TICK) /* Truncates! */
#define TICK_PER_MSEC (USEC_PER_MSEC / USEC_PER_TICK) /* Truncates! */
#define TICK_PER_DSEC (USEC_PER_DSEC / USEC_PER_TICK) /* Truncates! */
#define TICK_PER_HSEC (USEC_PER_HSEC / USEC_PER_TICK) /* Truncates! */
/* TICK_PER_* truncates! */
#define MSEC_PER_TICK (USEC_PER_TICK / USEC_PER_MSEC) /* Truncates! */
#define NSEC_PER_TICK (USEC_PER_TICK * NSEC_PER_USEC) /* Exact */
#define TICK_PER_HOUR (USEC_PER_HOUR / USEC_PER_TICK)
#define TICK_PER_MIN (USEC_PER_MIN / USEC_PER_TICK)
#define TICK_PER_SEC (USEC_PER_SEC / USEC_PER_TICK)
#define TICK_PER_MSEC (USEC_PER_MSEC / USEC_PER_TICK)
#define TICK_PER_DSEC (USEC_PER_DSEC / USEC_PER_TICK)
#define TICK_PER_HSEC (USEC_PER_HSEC / USEC_PER_TICK)
#define NSEC2TICK(nsec) (((nsec)+(NSEC_PER_TICK/2))/NSEC_PER_TICK) /* Rounds */
#define USEC2TICK(usec) (((usec)+(USEC_PER_TICK/2))/USEC_PER_TICK) /* Rounds */
/* MSEC_PER_TICK truncates! */
#define MSEC_PER_TICK (USEC_PER_TICK / USEC_PER_MSEC)
#define NSEC_PER_TICK (USEC_PER_TICK * NSEC_PER_USEC)
/* ?SEC2TIC rounds up */
#define NSEC2TICK(nsec) (((nsec) + (NSEC_PER_TICK - 1)) / NSEC_PER_TICK)
#define USEC2TICK(usec) (((usec) + (USEC_PER_TICK - 1)) / USEC_PER_TICK)
#if (MSEC_PER_TICK * USEC_PER_MSEC) == USEC_PER_TICK
# define MSEC2TICK(msec) (((msec)+(MSEC_PER_TICK/2))/MSEC_PER_TICK) /* Rounds */
# define MSEC2TICK(msec) (((msec) + (MSEC_PER_TICK - 1)) / MSEC_PER_TICK)
#else
# define MSEC2TICK(msec) USEC2TICK((msec) * USEC_PER_MSEC) /* Rounds */
# define MSEC2TICK(msec) USEC2TICK((msec) * USEC_PER_MSEC)
#endif
#define DSEC2TICK(dsec) MSEC2TICK((dsec) * MSEC_PER_DSEC) /* Rounds */
#define HSEC2TICK(dsec) MSEC2TICK((dsec) * MSEC_PER_HSEC) /* Rounds */
#define SEC2TICK(sec) MSEC2TICK((sec) * MSEC_PER_SEC) /* Rounds */
#define DSEC2TICK(dsec) MSEC2TICK((dsec) * MSEC_PER_DSEC)
#define HSEC2TICK(dsec) MSEC2TICK((dsec) * MSEC_PER_HSEC)
#define SEC2TICK(sec) MSEC2TICK((sec) * MSEC_PER_SEC)
#define TICK2NSEC(tick) ((tick) * NSEC_PER_TICK) /* Exact */
#define TICK2USEC(tick) ((tick) * USEC_PER_TICK) /* Exact */
#define TICK2NSEC(tick) ((tick) * NSEC_PER_TICK)
#define TICK2USEC(tick) ((tick) * USEC_PER_TICK)
#if (MSEC_PER_TICK * USEC_PER_MSEC) == USEC_PER_TICK
# define TICK2MSEC(tick) ((tick)*MSEC_PER_TICK) /* Exact */
# define TICK2MSEC(tick) ((tick) * MSEC_PER_TICK)
#else
# define TICK2MSEC(tick) (((tick)*USEC_PER_TICK)/USEC_PER_MSEC) /* Rounds */
# define TICK2MSEC(tick) (((tick) * USEC_PER_TICK) / USEC_PER_MSEC)
#endif
#define TICK2DSEC(tick) (((tick)+(TICK_PER_DSEC/2))/TICK_PER_DSEC) /* Rounds */
#define TICK2HSEC(tick) (((tick)+(TICK_PER_HSEC/2))/TICK_PER_HSEC) /* Rounds */
#define TICK2SEC(tick) (((tick)+(TICK_PER_SEC/2))/TICK_PER_SEC) /* Rounds */
/* TIC2?SEC rounds to nearest */
#define TICK2DSEC(tick) (((tick) + (TICK_PER_DSEC / 2)) / TICK_PER_DSEC)
#define TICK2HSEC(tick) (((tick) + (TICK_PER_HSEC / 2)) / TICK_PER_HSEC)
#define TICK2SEC(tick) (((tick) + (TICK_PER_SEC / 2)) / TICK_PER_SEC)
#if defined(CONFIG_DEBUG_FEATURES) && defined(CONFIG_SYSTEM_TIME64) && \
!defined(CONFIG_SCHED_TICKLESS)