Browse Source

lib: newlib: fix _gettimeofday hook

The time() function works correctly with the minimal libc, but always
returns -1 with the newlib libc. This is due to the _gettimeofday hook
being implemented that way.

Fix that by calling gettimeofday in the _gettimeofday hook instead of
returning -1.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
pull/35797/head
Aurelien Jarno 4 years ago committed by Kumar Gala
parent
commit
9fdd3f2bac
  1. 8
      lib/libc/newlib/libc-hooks.c

8
lib/libc/newlib/libc-hooks.c

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
#include <sys/sem.h>
#include <sys/mutex.h>
#include <sys/mem_manage.h>
#include <sys/time.h>
#define LIBC_BSS K_APP_BMEM(z_libc_partition)
#define LIBC_DATA K_APP_DMEM(z_libc_partition)
@ -402,12 +403,7 @@ void *_sbrk_r(struct _reent *r, int count) @@ -402,12 +403,7 @@ void *_sbrk_r(struct _reent *r, int count)
}
#endif /* CONFIG_XTENSA */
struct timeval;
int _gettimeofday(struct timeval *__tp, void *__tzp)
{
ARG_UNUSED(__tp);
ARG_UNUSED(__tzp);
return -1;
return gettimeofday(__tp, __tzp);
}

Loading…
Cancel
Save