Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to picolibc_interface #1795

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/rp2_common/pico_clib_interface/picolibc_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/times.h>

#include "pico.h"
#if LIB_PICO_STDIO
Expand Down Expand Up @@ -39,6 +40,7 @@ static int picolibc_getc(__unused FILE *file) {
#if LIB_PICO_STDIO
return stdio_getchar();
#endif
return -1;
}

static int picolibc_flush(__unused FILE *file) {
Expand Down Expand Up @@ -93,6 +95,17 @@ __weak int settimeofday(__unused const struct timeval *tv, __unused const struct
return 0;
}

__weak clock_t times(struct tms *tms) {
#if CLOCKS_PER_SEC >= 1000000
tms->tms_utime = (clock_t)(to_us_since_boot(get_absolute_time()) * (CLOCKS_PER_SEC / 1000000));
#else
tms->tms_utime = (clock_t)(to_us_since_boot(get_absolute_time()) / (1000000 / CLOCKS_PER_SEC));
#endif
tms->tms_stime = 0;
tms->tms_cutime = 0;
tms->tms_cstime = 0;
return 0;
}

void runtime_init(void) {
#ifndef NDEBUG
Expand All @@ -118,9 +131,9 @@ __weak void runtime_init_pre_core_tls_setup(void) {
// for now we just set the same global area on both cores
// note: that this is superfluous with the stock picolibc it seems, since it is itself
// using a version of __aeabi_read_tp that returns the same pointer on both cores
extern void __tls_base;
extern char __tls_base[];
extern void _set_tls(void *tls);
_set_tls(&__tls_base);
_set_tls(__tls_base);
}
#endif

Expand Down