2 * UCW Library -- Fast Buffered I/O: Binary Numbers
4 * (c) 1997--2006 Martin Mares <mj@ucw.cz>
6 * This software may be freely distributed and used according to the terms
7 * of the GNU Lesser General Public License.
11 #include "lib/fastbuf.h"
13 int bgetw_slow(struct fastbuf *f)
23 return (w1 << 8) | w2;
25 return w1 | (w2 << 8);
29 u32 bgetl_slow(struct fastbuf *f)
31 u32 l = bgetc_slow(f);
33 l = (l << 8) | bgetc_slow(f);
34 l = (l << 8) | bgetc_slow(f);
35 return (l << 8) | bgetc_slow(f);
37 l = (bgetc_slow(f) << 8) | l;
38 l = (bgetc_slow(f) << 16) | l;
39 return (bgetc_slow(f) << 24) | l;
43 u64 bgetq_slow(struct fastbuf *f)
53 return ((u64) h << 32) | l;
56 u64 bget5_slow(struct fastbuf *f)
66 return ((u64) h << 32) | l;
69 void bputw_slow(struct fastbuf *f, uns w)
72 bputc_slow(f, w >> 8);
76 bputc_slow(f, w >> 8);
80 void bputl_slow(struct fastbuf *f, u32 l)
83 bputc_slow(f, l >> 24);
84 bputc_slow(f, l >> 16);
85 bputc_slow(f, l >> 8);
89 bputc_slow(f, l >> 8);
90 bputc_slow(f, l >> 16);
91 bputc_slow(f, l >> 24);
95 void bputq_slow(struct fastbuf *f, u64 q)
98 bputl_slow(f, q >> 32);
102 bputl_slow(f, q >> 32);
106 void bput5_slow(struct fastbuf *f, u64 o)
110 #ifdef CPU_BIG_ENDIAN