CFLAGS="$CFLAGS -D__DARWIN_UNIX03 -DIPHONE"
fi])
+#XXXX020 We should make these enabled or not, before 0.2.0.x-final
AC_ARG_ENABLE(cell-pool,
AS_HELP_STRING(--disable-cell-pool, disable pool allocator for cells))
+AC_ARG_ENABLE(buf-freelists,
+ AS_HELP_STRING(--disable-buf-freelists, disable freelists for buffer RAM))
if test x$enable_cell_pool != xno; then
AC_DEFINE(ENABLE_CELL_POOL, 1,
[Defined if we try to use the pool allocator for queued cells])
fi
+if test x$enable_buf_freelists != xno; then
+ AC_DEFINE(ENABLE_BUF_FREELISTS, 1,
+ [Defined if we try to use freelists for buffer RAM chunks])
+fi
AC_ARG_ENABLE(transparent,
AS_HELP_STRING(--disable-transparent, disable transparent proxy support),
chunk->data = &chunk->mem[0];
}
+#ifdef ENABLE_BUF_FREELISTS
/** A freelist of chunks. */
typedef struct chunk_freelist_t {
size_t alloc_size; /**< What size chunks does this freelist hold? */
ch->data = &ch->mem[0];
return ch;
}
+#else
+static void
+chunk_free(chunk_t *chunk)
+{
+ tor_free(chunk);
+}
+static INLINE chunk_t *
+chunk_new_with_alloc_size(size_t alloc)
+{
+ chunk_t *ch;
+ ch = tor_malloc_roundup(&alloc);
+ ch->next = NULL;
+ ch->datalen = 0;
+ ch->memlen = CHUNK_SIZE_WITH_ALLOC(alloc);
+ ch->data = &ch->mem[0];
+ return ch;
+}
+#endif
/** Allocate a new chunk with memory size of <b>sz</b>. */
#define chunk_new_with_capacity(sz) \
preferred_chunk_size(size_t target)
{
/* XXXX020 use log2 code, maybe. */
+ /* XXXX020 or make sizing code more fine-grained! */
size_t sz = MIN_CHUNK_ALLOC;
while (CHUNK_SIZE_WITH_ALLOC(sz) < target) {
sz <<= 1;
void
buf_shrink_freelists(int free_all)
{
+#ifdef ENABLE_BUF_FREELISTS
int i;
for (i = 0; freelists[i].alloc_size; ++i) {
int slack = freelists[i].slack;
freelists[i].lowest_length = freelists[i].cur_length;
assert_freelist_ok(&freelists[i]);
}
+#else
+ (void) free_all;
+#endif
}
/** Describe the current status of the freelists at log level <b>severity</b>.
void
buf_dump_freelist_sizes(int severity)
{
+#ifdef ENABLE_BUF_FREELISTS
int i;
log(severity, LD_MM, "====== Buffer freelists:");
for (i = 0; freelists[i].alloc_size; ++i) {
}
log(severity, LD_MM, U64_FORMAT" allocations in non-freelist sizes",
U64_PRINTF_ARG(n_freelist_miss));
+#else
+ (void)severity;
+#endif
}
/** Magic value for buf_t.magic, to catch pointer errors. */
}
}
+#ifdef ENABLE_BUF_FREELISTS
/** Log an error and exit if <b>fl</b> is corrupted.
*/
static void
tor_assert(n >= fl->lowest_length);
tor_assert(n <= fl->max_length);
}
+#endif