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"
12 #include "lib/ff-binary.h"
14 int bgetw_slow(struct fastbuf *f)
24 return (w1 << 8) | w2;
26 return w1 | (w2 << 8);
30 u32 bgetl_slow(struct fastbuf *f)
32 u32 l = bgetc_slow(f);
34 l = (l << 8) | bgetc_slow(f);
35 l = (l << 8) | bgetc_slow(f);
36 return (l << 8) | bgetc_slow(f);
38 l = (bgetc_slow(f) << 8) | l;
39 l = (bgetc_slow(f) << 16) | l;
40 return (bgetc_slow(f) << 24) | l;
44 u64 bgetq_slow(struct fastbuf *f)
54 return ((u64) h << 32) | l;
57 u64 bget5_slow(struct fastbuf *f)
67 return ((u64) h << 32) | l;
70 void bputw_slow(struct fastbuf *f, uns w)
73 bputc_slow(f, w >> 8);
77 bputc_slow(f, w >> 8);
81 void bputl_slow(struct fastbuf *f, u32 l)
84 bputc_slow(f, l >> 24);
85 bputc_slow(f, l >> 16);
86 bputc_slow(f, l >> 8);
90 bputc_slow(f, l >> 8);
91 bputc_slow(f, l >> 16);
92 bputc_slow(f, l >> 24);
96 void bputq_slow(struct fastbuf *f, u64 q)
99 bputl_slow(f, q >> 32);
103 bputl_slow(f, q >> 32);
107 void bput5_slow(struct fastbuf *f, u64 o)
111 #ifdef CPU_BIG_ENDIAN