Implemented simple FILE struct and stdin/stdout/stderr
This commit is contained in:
parent
d51ae9135b
commit
a9f58fc92a
|
@ -2,6 +2,6 @@
|
|||
|
||||
int main() {
|
||||
char hellostr[] = "Hello, World!\n";
|
||||
sys_write(1, hellostr, sizeof(hellostr));
|
||||
sys_write(stdout, hellostr, sizeof(hellostr));
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
int main() {
|
||||
char str[10];
|
||||
sys_read(2, str, 10);
|
||||
sys_write(1, str, sizeof(str));
|
||||
sys_write(stdout, str, sizeof(str));
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -6,13 +6,13 @@ LIBFILE=../builds/liblinux.a
|
|||
|
||||
lib:
|
||||
mkdir -p ../builds/liblinux
|
||||
$(CC) -c liblinux.c $(CFLAGS) -o ../builds/liblinux.o
|
||||
$(CC) -c liblinux.c $(CFLAGS) -o ../builds/liblinux.o -g
|
||||
$(CC) -c liblinux/syscall.c $(CFLAGS) -o ../builds/liblinux/syscall.o
|
||||
$(CC) -c liblinux/start.c $(CFLAGS) -o ../builds/liblinux/start.o
|
||||
ar ruv $(LIBFILE) $(OBJFILES)
|
||||
ranlib $(LIBFILE)
|
||||
|
||||
examples:
|
||||
$(CC) ../examples/hello.c $(CFLAGS) -Iinclude -L../builds -l:$(LIBFILE) -o ../builds/hello
|
||||
$(CC) ../examples/hello.c $(CFLAGS) -Iinclude -L../builds -l:$(LIBFILE) -o ../builds/hello -g
|
||||
$(CC) ../examples/input.c $(CFLAGS) -Iinclude -L../builds -l:$(LIBFILE) -o ../builds/input
|
||||
|
||||
|
|
|
@ -4,7 +4,19 @@
|
|||
#include <liblinux/syscall.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
#include <bits/types/FILE.h>
|
||||
|
||||
struct FILE {
|
||||
int fd;
|
||||
};
|
||||
typedef struct FILE FILE;
|
||||
|
||||
extern FILE *stdin;
|
||||
extern FILE *stdout;
|
||||
extern FILE *stderr;
|
||||
|
||||
#define stdin stdin
|
||||
#define stdout stdout
|
||||
#define stderr stderr
|
||||
|
||||
void sys_exit(int status); // FIXME: noreturn
|
||||
int sys_open(const char *pathname, int flags);
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
#include <liblinux.h>
|
||||
#include <liblinux/syscall.h>
|
||||
|
||||
FILE *stdin = {0}; // FIXME
|
||||
FILE *stdout = {1};
|
||||
FILE *stderr = {2};
|
||||
|
||||
void sys_exit(int status) {
|
||||
syscall(__NR_exit, status);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue