diff --git a/Sming/third-party/axtls-8266/replacements/time.c b/Sming/third-party/axtls-8266/replacements/time.c index 4972119bb4..f6f44f8fbf 100644 --- a/Sming/third-party/axtls-8266/replacements/time.c +++ b/Sming/third-party/axtls-8266/replacements/time.c @@ -24,17 +24,19 @@ extern uint64_t system_mktime(uint32_t year, uint32_t mon, uint32_t day, uint32_ static int errno_var = 0; -int* __errno(void) { +#define WEAK_ATTR __attribute__((weak)) + +int* WEAK_ATTR __errno(void) { // DEBUGV("__errno is called last error: %d (not current)\n", errno_var); return &errno_var; } -unsigned long millis(void) +unsigned long WEAK_ATTR millis(void) { return system_get_time() / 1000UL; } -unsigned long micros(void) +unsigned long WEAK_ATTR micros(void) { return system_get_time(); } @@ -79,7 +81,7 @@ static void setServer(int id, const char* name_or_ip) } } -void configTime(int timezone, int daylightOffset_sec, const char* server1, const char* server2, const char* server3) +void WEAK_ATTR configTime(int timezone, int daylightOffset_sec, const char* server1, const char* server2, const char* server3) { sntp_stop(); @@ -93,7 +95,7 @@ void configTime(int timezone, int daylightOffset_sec, const char* server1, const sntp_init(); } -int clock_gettime(clockid_t unused, struct timespec *tp) +int WEAK_ATTR clock_gettime(clockid_t unused, struct timespec *tp) { tp->tv_sec = millis() / 1000; tp->tv_nsec = micros() * 1000; @@ -101,14 +103,14 @@ int clock_gettime(clockid_t unused, struct timespec *tp) } // seconds since 1970 -time_t mktime(struct tm *t) +time_t WEAK_ATTR mktime(struct tm *t) { // system_mktime expects month in range 1..12 #define START_MONTH 1 return DIFF1900TO1970 + system_mktime(t->tm_year, t->tm_mon + START_MONTH, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec); } -time_t time(time_t * t) +time_t WEAK_ATTR time(time_t * t) { time_t seconds = sntp_get_current_timestamp(); if (t) @@ -118,24 +120,24 @@ time_t time(time_t * t) return seconds; } -char* asctime(const struct tm *t) +char* WEAK_ATTR asctime(const struct tm *t) { return sntp_asctime(t); } -struct tm* localtime(const time_t *clock) +struct tm* WEAK_ATTR localtime(const time_t *clock) { return sntp_localtime(clock); } -char* ctime(const time_t *t) +char* WEAK_ATTR ctime(const time_t *t) { struct tm* p_tm = localtime(t); char* result = asctime(p_tm); return result; } -int gettimeofday(struct timeval *tp, void *tzp) +int WEAK_ATTR gettimeofday(struct timeval *tp, void *tzp) { if (tp) {