Skip to content

Commit

Permalink
Merge pull request contiki-ng#2575 from pjonsson/energest-shrink
Browse files Browse the repository at this point in the history
energest: inline functions when disabled
  • Loading branch information
arurke authored Aug 18, 2023
2 parents e7ac0f6 + a88997b commit 8ca4cff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
19 changes: 0 additions & 19 deletions os/sys/energest.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,4 @@ energest_get_total_time(void)
energest_type_time(ENERGEST_TYPE_LPM) +
energest_type_time(ENERGEST_TYPE_DEEP_LPM);
}
/*---------------------------------------------------------------------------*/
#else /* ENERGEST_CONF_ON */

void
energest_init(void)
{
}

void
energest_flush(void)
{
}

uint64_t
energest_get_total_time(void)
{
return 0;
}

#endif /* ENERGEST_CONF_ON */
12 changes: 10 additions & 2 deletions os/sys/energest.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,15 @@
#endif /* ENERGEST_SECOND */

#ifndef ENERGEST_GET_TOTAL_TIME
#if ENERGEST_CONF_ON
#ifdef ENERGEST_CONF_GET_TOTAL_TIME
#define ENERGEST_GET_TOTAL_TIME ENERGEST_CONF_GET_TOTAL_TIME
#else /* ENERGEST_CONF_GET_TOTAL_TIME */
#define ENERGEST_GET_TOTAL_TIME energest_get_total_time
#endif /* ENERGEST_CONF_GET_TOTAL_TIME */
#else /* ENERGEST_CONF_ON */
#define ENERGEST_GET_TOTAL_TIME()
#endif /* ENERGEST_CONF_ON */
#endif /* ENERGEST_GET_TOTAL_TIME */

/*
Expand Down Expand Up @@ -106,13 +110,13 @@ typedef enum energest_type {
ENERGEST_TYPE_MAX
} energest_type_t;

#if ENERGEST_CONF_ON

void energest_init(void);
void energest_flush(void);

uint64_t ENERGEST_GET_TOTAL_TIME(void);

#if ENERGEST_CONF_ON

extern uint64_t energest_total_time[ENERGEST_TYPE_MAX];
extern ENERGEST_TIME_T energest_current_time[ENERGEST_TYPE_MAX];
extern unsigned char energest_current_mode[ENERGEST_TYPE_MAX];
Expand Down Expand Up @@ -168,6 +172,10 @@ energest_switch(energest_type_t type_off, energest_type_t type_on)

#else /* ENERGEST_CONF_ON */

static inline void energest_init(void) { }

static inline void energest_flush(void) { }

static inline uint64_t energest_type_time(energest_type_t type) { return 0; }

static inline void energest_type_set(energest_type_t type, uint64_t time) { }
Expand Down

0 comments on commit 8ca4cff

Please sign in to comment.