mirror of
https://github.com/raspberrypi/pico-sdk.git
synced 2025-12-10 07:14:36 +01:00
Fixes to picolibc_interface (#1795)
* Fixes to picolibc_interface - Don't include bindings for tinystdio if picolibc was compiled with POSIX_IO. - Add times() function, which seems to be missed, in the same pattern as settimeofday/gettimeofday.
This commit is contained in:
parent
d0db3780fd
commit
d6e3fa06f1
1 changed files with 15 additions and 2 deletions
|
|
@ -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
|
||||
|
|
@ -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) {
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue