Vehicle Control Unit 0.01
This is the c library for controlling the car.
Loading...
Searching...
No Matches
syscalls.c
Go to the documentation of this file.
1
23/* Includes */
24#include <sys/stat.h>
25#include <stdlib.h>
26#include <errno.h>
27#include <stdio.h>
28#include <signal.h>
29#include <time.h>
30#include <sys/time.h>
31#include <sys/times.h>
32
33
34/* Variables */
35extern int __io_putchar(int ch) __attribute__((weak));
36extern int __io_getchar(void) __attribute__((weak));
37
38
39char *__env[1] = { 0 };
40char **environ = __env;
41
42
43/* Functions */
45{
46}
47
48int _getpid(void)
49{
50 return 1;
51}
52
53int _kill(int pid, int sig)
54{
55 (void)pid;
56 (void)sig;
57 errno = EINVAL;
58 return -1;
59}
60
61void _exit (int status)
62{
63 _kill(status, -1);
64 while (1) {} /* Make sure we hang here */
65}
66
67__attribute__((weak)) int _read(int file, char *ptr, int len)
68{
69 (void)file;
70 int DataIdx;
71
72 for (DataIdx = 0; DataIdx < len; DataIdx++)
73 {
74 *ptr++ = __io_getchar();
75 }
76
77 return len;
78}
79
80__attribute__((weak)) int _write(int file, char *ptr, int len)
81{
82 (void)file;
83 int DataIdx;
84
85 for (DataIdx = 0; DataIdx < len; DataIdx++)
86 {
87 __io_putchar(*ptr++);
88 }
89 return len;
90}
91
92int _close(int file)
93{
94 (void)file;
95 return -1;
96}
97
98
99int _fstat(int file, struct stat *st)
100{
101 (void)file;
102 st->st_mode = S_IFCHR;
103 return 0;
104}
105
106int _isatty(int file)
107{
108 (void)file;
109 return 1;
110}
111
112int _lseek(int file, int ptr, int dir)
113{
114 (void)file;
115 (void)ptr;
116 (void)dir;
117 return 0;
118}
119
120int _open(char *path, int flags, ...)
121{
122 (void)path;
123 (void)flags;
124 /* Pretend like we always fail */
125 return -1;
126}
127
128int _wait(int *status)
129{
130 (void)status;
131 errno = ECHILD;
132 return -1;
133}
134
135int _unlink(char *name)
136{
137 (void)name;
138 errno = ENOENT;
139 return -1;
140}
141
142int _times(struct tms *buf)
143{
144 (void)buf;
145 return -1;
146}
147
148int _stat(char *file, struct stat *st)
149{
150 (void)file;
151 st->st_mode = S_IFCHR;
152 return 0;
153}
154
155int _link(char *old, char *new)
156{
157 (void)old;
158 (void)new;
159 errno = EMLINK;
160 return -1;
161}
162
163int _fork(void)
164{
165 errno = EAGAIN;
166 return -1;
167}
168
169int _execve(char *name, char **argv, char **env)
170{
171 (void)name;
172 (void)argv;
173 (void)env;
174 errno = ENOMEM;
175 return -1;
176}
int _write(int file, char *data, int len)
Definition: main.c:1162
int _kill(int pid, int sig)
Definition: syscalls.c:53
void initialise_monitor_handles()
Definition: syscalls.c:44
int _open(char *path, int flags,...)
Definition: syscalls.c:120
int _link(char *old, char *new)
Definition: syscalls.c:155
int _fstat(int file, struct stat *st)
Definition: syscalls.c:99
int _stat(char *file, struct stat *st)
Definition: syscalls.c:148
int _close(int file)
Definition: syscalls.c:92
int _fork(void)
Definition: syscalls.c:163
int _unlink(char *name)
Definition: syscalls.c:135
int _lseek(int file, int ptr, int dir)
Definition: syscalls.c:112
int _getpid(void)
Definition: syscalls.c:48
char ** environ
Definition: syscalls.c:40
int __io_putchar(int ch) __attribute__((weak))
int _times(struct tms *buf)
Definition: syscalls.c:142
void _exit(int status)
Definition: syscalls.c:61
int __io_getchar(void)
Definition: syscalls.c:36
int _execve(char *name, char **argv, char **env)
Definition: syscalls.c:169
int _isatty(int file)
Definition: syscalls.c:106
int _wait(int *status)
Definition: syscalls.c:128
__attribute__((weak))
Definition: syscalls.c:67