Fix the build

This commit is contained in:
Justine Tunney 2022-09-13 02:28:07 -07:00
parent df08b541af
commit 446a1f7c5a
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
2 changed files with 30 additions and 8 deletions

View file

@ -7,20 +7,37 @@
http://creativecommons.org/publicdomain/zero/1.0/ │ http://creativecommons.org/publicdomain/zero/1.0/ │
*/ */
#endif #endif
#include "libc/math.h" #include "libc/calls/calls.h"
#include "libc/calls/termios.h" #include "libc/calls/termios.h"
#include "libc/isystem/unistd.h" #include "libc/isystem/unistd.h"
#include "libc/str/str.h" #include "libc/math.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/termios.h" #include "libc/sysv/consts/termios.h"
/**
* @fileoverview Bare Metal VGA TTY demo.
*
* This program can boot as an operating system. Try it out:
*
* make -j8 o//examples/vga.com
* qemu-system-x86_64 -hda o//examples/vga.com -serial stdio
*
* Please note that, by default, APE binaries only use the serial port
* for stdio. To get the VGA console as an added bonus:
*
* STATIC_YOINK("vga_console");
*
* Should be added to the top of your main() program source file.
*/
STATIC_YOINK("vga_console"); STATIC_YOINK("vga_console");
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
volatile long double x = -.5; volatile long double x = -.5;
volatile long double y = 1.5; volatile long double y = 1.5;
struct termios tio; struct termios tio;
char buf[4]; char buf[16];
ssize_t res; ssize_t res;
if (tcgetattr(0, &tio) != -1) { if (tcgetattr(0, &tio) != -1) {
tio.c_lflag &= ~(ECHO | ICANON); tio.c_lflag &= ~(ECHO | ICANON);
@ -33,5 +50,11 @@ int main(int argc, char *argv[]) {
return -1; return -1;
} }
printf("Hello World! %.19Lg\n", atan2l(x, y)); printf("Hello World! %.19Lg\n", atan2l(x, y));
return 0;
// read/print loop so machine doesn't reset on metal
for (;;) {
if ((res = readansi(0, buf, 16)) > 0) {
printf("got %`'.*s\r\n", res, buf);
}
}
} }

View file

@ -37,10 +37,9 @@ ssize_t sys_readv_metal(struct Fd *fd, const struct iovec *iov, int iovlen) {
* escape sequences, in response to requests sent to it via write(). * escape sequences, in response to requests sent to it via write().
* Read & return these if they are available. * Read & return these if they are available.
*/ */
if (weaken(sys_readv_vga)) { if (_weaken(sys_readv_vga)) {
ssize_t res = weaken(sys_readv_vga)(fd, iov, iovlen); ssize_t res = _weaken(sys_readv_vga)(fd, iov, iovlen);
if (res > 0) if (res > 0) return res;
return res;
} }
/* fall through */ /* fall through */
case kFdSerial: case kFdSerial: