+ sh_off_t pos; /* Position of bstop in the file */
+ int (*refill)(struct fastbuf *); /* Get a buffer with new data */
+ void (*spout)(struct fastbuf *); /* Write buffer data to the file */
+ void (*seek)(struct fastbuf *, sh_off_t, int); /* Slow path for bseek(), buffer already flushed */
+ void (*close)(struct fastbuf *); /* Close the stream */
+ int (*config)(struct fastbuf *, uns, int); /* Configure the stream */
+ int can_overwrite_buffer; /* Can the buffer be altered? (see discussion above) 0=never, 1=temporarily, 2=permanently */
+};
+
+/* FastIO on standard files (specify buffer size 0 to enable mmaping) */
+
+struct fastbuf *bopen(byte *name, uns mode, uns buflen);
+struct fastbuf *bopen_try(byte *name, uns mode, uns buflen);
+struct fastbuf *bopen_tmp(uns buflen);
+struct fastbuf *bfdopen(int fd, uns buflen);
+struct fastbuf *bfdopen_shared(int fd, uns buflen);
+void bfilesync(struct fastbuf *b);
+
+#define TEMP_FILE_NAME_LEN 256
+void temp_file_name(byte *name);
+
+/* FastIO on in-memory streams */
+
+struct fastbuf *fbmem_create(unsigned blocksize); /* Create stream and return its writing fastbuf */
+struct fastbuf *fbmem_clone_read(struct fastbuf *); /* Create reading fastbuf */
+
+/* FastIO on memory mapped files */
+
+struct fastbuf *bopen_mm(byte *name, uns mode);
+
+/* FastIO on files opened with O_DIRECT (see fb-direct.c for description) */
+
+struct asio_queue;
+struct fastbuf *fbdir_open(byte *name, uns mode, struct asio_queue *io_queue);
+struct fastbuf *fbdir_open_try(byte *name, uns mode, struct asio_queue *io_queue);
+struct fastbuf *fbdir_open_fd(int fd, struct asio_queue *io_queue);
+struct fastbuf *fbdir_open_tmp(struct asio_queue *io_queue);
+
+/* FastI on file descriptors with limit */
+
+struct fastbuf *bopen_limited_fd(int fd, uns bufsize, uns limit);
+
+/* FastIO on static buffers */
+
+void fbbuf_init_read(struct fastbuf *f, byte *buffer, uns size, uns can_overwrite);
+void fbbuf_init_write(struct fastbuf *f, byte *buffer, uns size);
+static inline uns
+fbbuf_count_written(struct fastbuf *f)
+{
+ return f->bptr - f->bstop;
+}
+
+/* FastIO on recyclable growing buffers */
+
+struct fastbuf *fbgrow_create(unsigned basic_size);
+void fbgrow_reset(struct fastbuf *b); /* Reset stream and prepare for writing */
+void fbgrow_rewind(struct fastbuf *b); /* Prepare for reading */
+
+/* FastO with atomic writes for multi-threaded programs */
+
+struct fb_atomic {
+ struct fastbuf fb;
+ struct fb_atomic_file *af;
+ byte *expected_max_bptr;
+ uns slack_size;