Added copyright information

This commit is contained in:
2026-03-21 17:37:43 +01:00
parent 3a15342a29
commit 7d41473a8b
16 changed files with 752 additions and 864 deletions

View File

@@ -21,153 +21,127 @@
*/
/* Includes */
#include <sys/stat.h>
#include <stdlib.h>
#include <errno.h>
#include <stdio.h>
#include <signal.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/times.h>
#include <time.h>
/* Variables */
extern int __io_putchar(int ch) __attribute__((weak));
extern int __io_getchar(void) __attribute__((weak));
char *__env[1] = { 0 };
char *__env[1] = {0};
char **environ = __env;
/* Functions */
void initialise_monitor_handles()
{
}
void initialise_monitor_handles() {}
int _getpid(void)
{
return 1;
}
int _getpid(void) { return 1; }
int _kill(int pid, int sig)
{
int _kill(int pid, int sig) {
(void)pid;
(void)sig;
errno = EINVAL;
return -1;
}
void _exit (int status)
{
void _exit(int status) {
_kill(status, -1);
while (1) {} /* Make sure we hang here */
while (1) {
} /* Make sure we hang here */
}
__attribute__((weak)) int _read(int file, char *ptr, int len)
{
__attribute__((weak)) int _read(int file, char *ptr, int len) {
(void)file;
int DataIdx;
for (DataIdx = 0; DataIdx < len; DataIdx++)
{
for (DataIdx = 0; DataIdx < len; DataIdx++) {
*ptr++ = __io_getchar();
}
return len;
}
__attribute__((weak)) int _write(int file, char *ptr, int len)
{
__attribute__((weak)) int _write(int file, char *ptr, int len) {
(void)file;
int DataIdx;
for (DataIdx = 0; DataIdx < len; DataIdx++)
{
for (DataIdx = 0; DataIdx < len; DataIdx++) {
__io_putchar(*ptr++);
}
return len;
}
int _close(int file)
{
int _close(int file) {
(void)file;
return -1;
}
int _fstat(int file, struct stat *st)
{
int _fstat(int file, struct stat *st) {
(void)file;
st->st_mode = S_IFCHR;
return 0;
}
int _isatty(int file)
{
int _isatty(int file) {
(void)file;
return 1;
}
int _lseek(int file, int ptr, int dir)
{
int _lseek(int file, int ptr, int dir) {
(void)file;
(void)ptr;
(void)dir;
return 0;
}
int _open(char *path, int flags, ...)
{
int _open(char *path, int flags, ...) {
(void)path;
(void)flags;
/* Pretend like we always fail */
return -1;
}
int _wait(int *status)
{
int _wait(int *status) {
(void)status;
errno = ECHILD;
return -1;
}
int _unlink(char *name)
{
int _unlink(char *name) {
(void)name;
errno = ENOENT;
return -1;
}
clock_t _times(struct tms *buf)
{
clock_t _times(struct tms *buf) {
(void)buf;
return -1;
}
int _stat(const char *file, struct stat *st)
{
int _stat(const char *file, struct stat *st) {
(void)file;
st->st_mode = S_IFCHR;
return 0;
}
int _link(char *old, char *new)
{
int _link(char *old, char *new) {
(void)old;
(void)new;
errno = EMLINK;
return -1;
}
int _fork(void)
{
int _fork(void) {
errno = EAGAIN;
return -1;
}
int _execve(char *name, char **argv, char **env)
{
int _execve(char *name, char **argv, char **env) {
(void)name;
(void)argv;
(void)env;
@@ -185,11 +159,10 @@ int _execve(char *name, char **argv, char **env)
* @param file FILE stream pointer (ignored).
* @retval int The character written.
*/
static int starm_putc(char c, FILE *file)
{
(void) file;
static int starm_putc(char c, FILE *file) {
(void)file;
__io_putchar(c);
return c;
return c;
}
/**
@@ -198,31 +171,30 @@ static int starm_putc(char c, FILE *file)
* @param file FILE stream pointer (ignored).
* @retval int The character read, cast to an unsigned char then int.
*/
static int starm_getc(FILE *file)
{
unsigned char c;
(void) file;
static int starm_getc(FILE *file) {
unsigned char c;
(void)file;
c = __io_getchar();
return c;
return c;
}
// Define and initialize the standard I/O streams for Picolibc.
// FDEV_SETUP_STREAM connects the starm_putc and starm_getc helper functions to a FILE structure.
// _FDEV_SETUP_RW indicates the stream is for reading and writing.
static FILE __stdio = FDEV_SETUP_STREAM(starm_putc,
starm_getc,
NULL,
_FDEV_SETUP_RW);
// FDEV_SETUP_STREAM connects the starm_putc and starm_getc helper functions to
// a FILE structure. _FDEV_SETUP_RW indicates the stream is for reading and
// writing.
static FILE __stdio =
FDEV_SETUP_STREAM(starm_putc, starm_getc, NULL, _FDEV_SETUP_RW);
// Assign the standard stream pointers (stdin, stdout, stderr) to the initialized stream.
// Picolibc uses these pointers for standard I/O operations (printf, scanf, etc.).
// Assign the standard stream pointers (stdin, stdout, stderr) to the
// initialized stream. Picolibc uses these pointers for standard I/O operations
// (printf, scanf, etc.).
FILE *const stdin = &__stdio;
__strong_reference(stdin, stdout);
__strong_reference(stdin, stderr);
// Create strong aliases mapping standard C library function names (without underscore)
// to the implemented system call stubs (with underscore). Picolibc uses these
// standard names internally, so this linking is required.
// Create strong aliases mapping standard C library function names (without
// underscore) to the implemented system call stubs (with underscore). Picolibc
// uses these standard names internally, so this linking is required.
__strong_reference(_read, read);
__strong_reference(_write, write);
__strong_reference(_times, times);