X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Ffastbuf.h;h=2948830ee4e0331e305a9c5a9ceb66486ca738db;hb=95e9dd4f86747dfacc24e990947717979f48cb17;hp=1488f74045c59c0aac641f9194fb5c25c73f162f;hpb=66696bd7b7d5eb9ecb78ad3b3668b1937da896b3;p=libucw.git diff --git a/lib/fastbuf.h b/lib/fastbuf.h index 1488f740..2948830e 100644 --- a/lib/fastbuf.h +++ b/lib/fastbuf.h @@ -11,6 +11,8 @@ #include #endif +#include + #include "lib/unaligned.h" /* @@ -57,6 +59,7 @@ struct fastbuf { /* FastIO on standard files */ struct fastbuf *bopen(byte *name, uns mode, uns buffer); +struct fastbuf *bopen_tmp(uns buffer); struct fastbuf *bfdopen(int fd, uns buffer); void bbcopy(struct fastbuf *f, struct fastbuf *t, uns l); @@ -89,13 +92,13 @@ static inline int bpeekc(struct fastbuf *f) return (f->bptr < f->bstop) ? (int) *f->bptr : bpeekc_slow(f); } -static inline void bungetc(struct fastbuf *f, byte c) +static inline void bungetc(struct fastbuf *f) { - *--f->bptr = c; + f->bptr--; } -void bputc_slow(struct fastbuf *f, byte c); -static inline void bputc(struct fastbuf *f, byte c) +void bputc_slow(struct fastbuf *f, uns c); +static inline void bputc(struct fastbuf *f, uns c) { if (f->bptr < f->bufend) *f->bptr++ = c; @@ -103,10 +106,10 @@ static inline void bputc(struct fastbuf *f, byte c) bputc_slow(f, c); } -word bgetw_slow(struct fastbuf *f); -static inline word bgetw(struct fastbuf *f) +int bgetw_slow(struct fastbuf *f); +static inline int bgetw(struct fastbuf *f) { - word w; + int w; if (f->bptr + 2 <= f->bstop) { w = GET_U16(f->bptr); @@ -159,8 +162,8 @@ static inline u64 bget5(struct fastbuf *f) return bget5_slow(f); } -void bputw_slow(struct fastbuf *f, word w); -static inline void bputw(struct fastbuf *f, word w) +void bputw_slow(struct fastbuf *f, uns w); +static inline void bputw(struct fastbuf *f, uns w) { if (f->bptr + 2 <= f->bufend) {