]> mj.ucw.cz Git - libucw.git/blobdiff - lib/fastbuf.h
Introduced obuck_get_pos(), converted gatherd limits to use it.
[libucw.git] / lib / fastbuf.h
index 01e7f60a28f05a154c3c7996b08f164c9a4013d4..cd08fa8a9b88839800729f81cde5141850d2cbd8 100644 (file)
@@ -268,7 +268,7 @@ static inline void bput5(struct fastbuf *f, u64 l)
     bput5_slow(f, l);
 }
 
     bput5_slow(f, l);
 }
 
-uns bread_slow(struct fastbuf *f, void *b, uns l);
+uns bread_slow(struct fastbuf *f, void *b, uns l, uns check);
 static inline uns bread(struct fastbuf *f, void *b, uns l)
 {
   if (f->bptr + l <= f->bstop)
 static inline uns bread(struct fastbuf *f, void *b, uns l)
 {
   if (f->bptr + l <= f->bstop)
@@ -278,7 +278,19 @@ static inline uns bread(struct fastbuf *f, void *b, uns l)
       return l;
     }
   else
       return l;
     }
   else
-    return bread_slow(f, b, l);
+    return bread_slow(f, b, l, 0);
+}
+
+static inline uns breadb(struct fastbuf *f, void *b, uns l)
+{
+  if (f->bptr + l <= f->bstop)
+    {
+      memcpy(b, f->bptr, l);
+      f->bptr += l;
+      return l;
+    }
+  else
+    return bread_slow(f, b, l, 1);
 }
 
 void bwrite_slow(struct fastbuf *f, void *b, uns l);
 }
 
 void bwrite_slow(struct fastbuf *f, void *b, uns l);
@@ -294,6 +306,7 @@ static inline void bwrite(struct fastbuf *f, void *b, uns l)
 }
 
 byte *bgets(struct fastbuf *f, byte *b, uns l);        /* Non-std */
 }
 
 byte *bgets(struct fastbuf *f, byte *b, uns l);        /* Non-std */
+byte *bgets0(struct fastbuf *f, byte *b, uns l);
 
 static inline void
 bputs(struct fastbuf *f, byte *b)
 
 static inline void
 bputs(struct fastbuf *f, byte *b)
@@ -327,11 +340,15 @@ void bdirect_write_commit(struct fastbuf *f, byte *pos);
 #define bputo(f,l) bput5(f,l)
 #define bgetp(f) bgetq(f)
 #define bputp(f,l) bputq(f,l)
 #define bputo(f,l) bput5(f,l)
 #define bgetp(f) bgetq(f)
 #define bputp(f,l) bputq(f,l)
+#define FASTBUF_BYTES_PER_O 5
+#define FASTBUF_BYTES_PER_P 8
 #else
 #define bgeto(f) bgetl(f)
 #define bputo(f,l) bputl(f,l)
 #define bgetp(f) bgetl(f)
 #define bputp(f,l) bputl(f,l)
 #else
 #define bgeto(f) bgetl(f)
 #define bputo(f,l) bputl(f,l)
 #define bgetp(f) bgetl(f)
 #define bputp(f,l) bputl(f,l)
+#define FASTBUF_BYTES_PER_O 4
+#define FASTBUF_BYTES_PER_P 4
 #endif
 
 #endif
 #endif
 
 #endif