#include #include #include #include #include #include #include int errno; #include #include /* extern void gilbraltar_serial_write(const char *, size_t); extern void gilbraltar_serial_puts(const char *); extern uint32_t gilbraltar_system_clock(void); */ static size_t console_write(FILE *f __attribute__((unused)), const char *str, size_t len) { gilbraltar_serial_write(str, len); return (len); } static FILE console = { .write = console_write }; FILE *stderr = &console; FILE *stdout = &console; ssize_t write(int fd, const void *buf, size_t count) { if (fd == 1 || fd == 2) { gilbraltar_serial_write(buf, count); return (count); } errno = ENOSYS; return (-1); } void exit(int status) { while (1) __asm__ __volatile("wfi"); } void abort(void) { gilbraltar_serial_puts("Aborted\r\n"); while (1) __asm__ __volatile("wfi"); } #if defined(__aarch64__) int __getauxval(int unused) { errno = ENOENT; return (0); } #endif clock_t times(struct tms *buf) { memset(buf, 0, sizeof(*buf)); return ((clock_t) gilbraltar_system_clock()); } #define NSEC_PER_SEC 1000000000ULL int gettimeofday(struct timeval *tv, struct timezone *tz) { if (tv != NULL) { uint32_t now = gilbraltar_system_clock(); tv->tv_sec = now / NSEC_PER_SEC; tv->tv_usec = (now % NSEC_PER_SEC) / 1000ULL; } if (tz != NULL) { memset(tz, 0, sizeof(*tz)); } return 0; }