Skip to content

Commit

Permalink
core: timer - use uint type instead of short for flags and slow index
Browse files Browse the repository at this point in the history
- get rid of unused padding field
  • Loading branch information
miconda committed Nov 28, 2017
1 parent 7bdf8f0 commit 3d22063
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/core/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ static inline int _timer_add(ticks_t t, struct timer_ln* tl)
ticks_t delta;

#ifdef USE_SLOW_TIMER
tl->flags&=~((unsigned short)F_TIMER_ON_SLOW_LIST);
tl->flags&=~(F_TIMER_ON_SLOW_LIST);
tl->slow_idx=0;
#endif
delta=tl->initial_timeout;
Expand Down
12 changes: 4 additions & 8 deletions src/core/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#ifdef USE_SLOW_TIMER
#include <sys/types.h>

typedef unsigned short slow_idx_t; /* type fot the slow index */
typedef unsigned int slow_idx_t; /* type fot the slow index */
extern pid_t slow_timer_pid;
#endif

Expand Down Expand Up @@ -102,11 +102,9 @@ struct timer_ln{ /* timer_link already used in tm */
ticks_t initial_timeout;
void* data;
timer_handler_f* f;
volatile unsigned short flags;
volatile unsigned int flags;
#ifdef USE_SLOW_TIMER
volatile slow_idx_t slow_idx;
#else
unsigned short reserved;
#endif
#ifdef TIMER_DEBUG
unsigned int expires_no; /* timer handler calls */
Expand Down Expand Up @@ -144,15 +142,13 @@ void timer_free(struct timer_ln* t);
/* use for a deleted/expired timer that you want to add again */
#define timer_reinit(tl) \
do{ \
(tl)->flags&=~((unsigned short)(F_TIMER_ON_SLOW_LIST | \
F_TIMER_ACTIVE));\
(tl)->flags&=~(F_TIMER_ON_SLOW_LIST | F_TIMER_ACTIVE);\
(tl)->init++; \
}while(0)
#else
/* use for a deleted/expired timer that you want to add again */
#define timer_reinit(tl) \
(tl)->flags&=~((unsigned short)(F_TIMER_ON_SLOW_LIST | \
F_TIMER_ACTIVE))
(tl)->flags&=~(F_TIMER_ON_SLOW_LIST | F_TIMER_ACTIVE)
#endif

#define timer_init(tl, fun, param, flgs) \
Expand Down

0 comments on commit 3d22063

Please sign in to comment.