; Data for the stdio file stream.
;
- .export __filetab, _stdin, _stdout, _stderr
+ .export __filetab
+
+ .include "stdio.inc"
+ .include "fcntl.inc"
+ .include "_file.inc"
+
+;----------------------------------------------------------------------------
+; File data
.data
__filetab:
-in: .byte 0, 1 ; stdin
-out: .byte 1, 1 ; stdout
-err: .byte 2, 1 ; stderr
- .byte 0, 0 ; free slot
- .byte 0, 0 ; free slot
- .byte 0, 0 ; free slot
- .byte 0, 0 ; free slot
- .byte 0, 0 ; free slot
+ .byte 0, _FOPEN, 0 ; stdin
+ .byte 1, _FOPEN, 0 ; stdout
+ .byte 2, _FOPEN, 0 ; stderr
+.repeat FOPEN_MAX - 3
+ .byte 0, _FCLOSED, 0 ; free slot
+.endrepeat
+
+
+; Standard file descriptors
_stdin:
- .word in
+ .word __filetab + (STDIN_FILENO * .sizeof(_FILE))
_stdout:
- .word out
+ .word __filetab + (STDOUT_FILENO * .sizeof(_FILE))
_stderr:
- .word err
+ .word __filetab + (STDERR_FILENO * .sizeof(_FILE))
+
+