diff options
Diffstat (limited to 'source/base/base_io.h')
| -rw-r--r-- | source/base/base_io.h | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/source/base/base_io.h b/source/base/base_io.h index ece4d7c..85fedc7 100644 --- a/source/base/base_io.h +++ b/source/base/base_io.h | |||
| @@ -1,11 +1,38 @@ | |||
| 1 | #ifndef BASE_IO_H | 1 | #ifndef BASE_IO_H |
| 2 | #define BASE_IO_H | 2 | #define BASE_IO_H |
| 3 | 3 | ||
| 4 | #define STDIN_FD 0 | ||
| 5 | #define STDOUT_FD 1 | ||
| 6 | #define STDERR_FD 2 | ||
| 7 | |||
| 8 | internal s64 | ||
| 9 | os_write(s32 fd, void const *buf, u64 count) | ||
| 10 | { | ||
| 11 | return syscall(SYS_write, fd, buf, count); | ||
| 12 | } | ||
| 13 | |||
| 14 | internal s64 | ||
| 15 | os_read(s32 fd, void *buf, u64 count) | ||
| 16 | { | ||
| 17 | return syscall(SYS_read, fd, buf, count); | ||
| 18 | } | ||
| 19 | |||
| 4 | internal void | 20 | internal void |
| 5 | input_read() | 21 | print_s8(string8 s) |
| 6 | { | 22 | { |
| 23 | os_write(STDOUT_FILENO, s.data, s.size); | ||
| 24 | } | ||
| 7 | 25 | ||
| 26 | internal void | ||
| 27 | print(const char *str) | ||
| 28 | { | ||
| 29 | s32 len = 0; | ||
| 30 | while (str[len]) len++; | ||
| 31 | os_write(STDOUT_FILENO, str, len); | ||
| 8 | 32 | ||
| 9 | } | 33 | } |
| 10 | 34 | ||
| 35 | #define Os_read(buffer, buffer_count) | ||
| 36 | |||
| 37 | |||
| 11 | #endif /* BASE_IO_H */ | 38 | #endif /* BASE_IO_H */ |
