- /* FIXME: These functions should handle buckets with no fb and only name. */
- ASSERT(b->fb);
- return b->fb;
-}
-
-struct fastbuf *
-sbuck_open_write(struct sort_bucket *b)
-{
- if (!b->fb)
- b->fb = bopen_tmp(sorter_stream_bufsize);
- return b->fb;
-}
-
-void
-sbuck_close_read(struct sort_bucket *b)
-{
- if (!b)
- return;
- ASSERT(b->fb);
- bclose(b->fb);
- b->fb = NULL;
-}
-
-void
-sbuck_close_write(struct sort_bucket *b)
-{
- if (b->fb)
- {
- b->size = btell(b->fb);
- brewind(b->fb);
- }
-}
-
-void
-sorter_alloc_buf(struct sort_context *ctx)
-{
- if (ctx->big_buf)
- return;
- u64 bs = MAX(sorter_bufsize/2, 1);
- bs = ALIGN_TO(bs, (u64)CPU_PAGE_SIZE);
- ctx->big_buf = big_alloc(2*bs);
- ctx->big_buf_size = 2*bs;
- ctx->big_buf_half = ((byte*) ctx->big_buf) + bs;
- ctx->big_buf_half_size = bs;
- SORT_XTRACE("Allocated sorting buffer (%jd bytes)", (uintmax_t) bs);
-}
-
-void
-sorter_free_buf(struct sort_context *ctx)
-{
- if (!ctx->big_buf)
- return;
- big_free(ctx->big_buf, ctx->big_buf_size);
- ctx->big_buf = NULL;
- SORT_XTRACE("Freed sorting buffer");
-}
-
-static int sorter_presort(struct sort_context *ctx, struct sort_bucket *in, struct sort_bucket *out, struct sort_bucket *out_only)
-{
- /* FIXME: Mode with no presorting (mostly for debugging) */