Skip to content

Commit 66f84a6

Browse files
authored
Define sys_now macro as a function (#58)
* Define sys_now macro as a function * :oops: declare millis()
1 parent 679577b commit 66f84a6

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

glue-lwip/arch/cc.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,21 @@ typedef uint32_t sys_prot_t;
8585
///////////////////////////////
8686
//// MISSING
8787

88-
// transparent wrapper for millis()'s return value type from ulong to u32
88+
// Arduino Core exposes time func with a generic type
8989
#ifdef __cplusplus
90-
extern "C" {
90+
extern "C"
91+
{
9192
#endif
92-
extern unsigned long millis(void); // arduino definition
93-
inline __attribute__((always_inline)) u32_t sys_now (void) { return (u32_t)millis(); }
93+
unsigned long millis(void);
9494
#ifdef __cplusplus
9595
}
9696
#endif
9797

98+
// b/c we have conflicting typedefs of u32_t and ulong and can't substitute funcs,
99+
// forcibly cast the `millis()` result to lwip's version of u32_t
100+
// (previous version was `#define sys_now millis`)
101+
#define sys_now() ((u32_t)millis())
102+
98103
#define LWIP_RAND r_rand // old lwip uses this useful undocumented function
99104
#define IPSTR "%d.%d.%d.%d"
100105
#define IP2STR(ipaddr) ip4_addr1_16(ipaddr), \

0 commit comments

Comments
 (0)