Skip to content

Commit

Permalink
Improve macros
Browse files Browse the repository at this point in the history
  • Loading branch information
MaJerle committed Aug 24, 2023
1 parent c3761f6 commit 73862cb
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions lwdtc/src/lwdtc/lwdtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,19 @@
#endif /* defined(LWDTC_DEV) */

/* Internal defines */
#define ASSERT_PARAM(c) \
#define ASSERT_WITH_RETURN(c, retval) \
if (!(c)) { \
return lwdtcERRPAR; \
}
#define ASSERT_TOKEN_VALID(c) \
if (!(c)) { \
return lwdtcERRTOKEN; \
}
#define ASSERT_ACTION(c) \
if (!(c)) { \
return lwdtcERR; \
return retval; \
}
#define ASSERT_PARAM(c) ASSERT_WITH_RETURN(c, lwdtcERRPAR)
#define ASSERT_TOKEN_VALID(c) ASSERT_WITH_RETURN(c, lwdtcERRTOKEN)
#define ASSERT_ACTION(c) ASSERT_WITH_RETURN(c, lwdtcERR)

#define CHAR_IS_NUM(c) ((c) >= '0' && (c) <= '9')
#define CHAR_TO_NUM(c) ((c) - '0')
#define CHAR_IS_NUM(c) ((c) >= '0' && (c) <= '9')
#define CHAR_TO_NUM(c) ((c) - '0')

#define BIT_IS_SET(map, pos) ((map)[(pos) >> 3] & (1 << ((pos)&0x07)))
#define BIT_SET(map, pos) (map)[(pos) >> 3] |= (1 << ((pos)&0x07))
#define BIT_IS_SET(map, pos) ((map)[(pos) >> 3] & (1 << ((pos)&0x07)))
#define BIT_SET(map, pos) (map)[(pos) >> 3] |= (1 << ((pos)&0x07))

/**
* \brief Private structure to parse cron input
Expand Down

0 comments on commit 73862cb

Please sign in to comment.