(load "lib/gcc.l") (gcc "nb" NIL 'eagain 'block 'rdx 'wrx) //(eagain) -> 'cnt any eagain(any ex __attribute__((unused))) { return boxCnt(-EAGAIN); } //(block 'any 'flg) -> 'flg any block(any ex) { int sd = (int)evCnt(ex,cdr(ex)); any y = EVAL(caddr(ex)); bool flg = isNil(y) ? NO : YES; blocking(flg, ex, sd); return y; } //(rdx 'lst 'cnt ['cnt]) -> 'cnt|NIL any rdx(any ex) { any lst = EVAL(cadr(ex)); int cnt = (int)evCnt(ex,cddr(ex)); int off = isNil(cadddr(ex)) ? 0 : (int)evCnt(ex,cdddr(ex)); int i = 0; int j = 0; NeedLst(ex,lst); byte buf[cnt]; int n = read(InFile->fd, buf, cnt); if (0 < n) { for (; j < off && isCell(lst); lst = cdr(lst), j++); for (; i < n && i < cnt && isCell(lst); lst = cdr(lst), i++) { lst->car = boxCnt(buf[i]); } } return n == 0 ? Nil : boxCnt(n < 0 ? -errno : i); } //(wrx 'lst 'cnt ['cnt]) -> 'cnt|NIL any wrx(any ex) { any lst = EVAL(cadr(ex)); int cnt = (int)evCnt(ex,cddr(ex)); int off = isNil(cadddr(ex)) ? 0 : (int)evCnt(ex,cdddr(ex)); int i = 0; int j = 0; NeedLst(ex,lst); byte buf[cnt]; for (; j < off && isCell(lst); lst = cdr(lst), j++); for (; i < cnt && isCell(lst); lst = cdr(lst), i++) { buf[i] = (byte)evCnt(ex,lst); } int n = write(OutFile->fd, buf, i); return n == 0 ? Nil : boxCnt(n < 0 ? -errno : n); } /**/