#endif
};
-unsigned int data_stack_frame = 0;
+data_stack_frame_t data_stack_frame = 0;
static bool data_stack_initialized = FALSE;
static int frame_pos = BLOCK_FRAME_COUNT-1; /* in current_frame_block */
}
}
-unsigned int t_push(const char *marker)
+data_stack_frame_t t_push(const char *marker)
{
struct stack_frame_block *frame_block;
return data_stack_frame++;
}
-unsigned int t_push_named(const char *format, ...)
+data_stack_frame_t t_push_named(const char *format, ...)
{
- unsigned int ret = t_push(NULL);
+ data_stack_frame_t ret = t_push(NULL);
#ifdef DEBUG
va_list args;
va_start(args, format);
}
#endif
-unsigned int t_pop(void)
+data_stack_frame_t t_pop(void)
{
struct stack_frame_block *frame_block;
return --data_stack_frame;
}
-void t_pop_check(unsigned int *id)
+void t_pop_check(data_stack_frame_t *id)
{
if (unlikely(t_pop() != *id))
i_panic("Leaked t_pop() call");
overflows.
*/
-extern unsigned int data_stack_frame;
+typedef unsigned int data_stack_frame_t;
+
+extern data_stack_frame_t data_stack_frame;
/* All t_..() allocations between t_push*() and t_pop() are freed after t_pop()
is called. Returns the current stack frame number, which can be used
but is safe to call in a loop as it performs the allocation within its own
frame. However, you should always prefer to use T_BEGIN { ... } T_END below.
*/
-unsigned int t_push(const char *marker) ATTR_HOT;
-unsigned int t_push_named(const char *format, ...) ATTR_HOT ATTR_FORMAT(1, 2);
-unsigned int t_pop(void) ATTR_HOT;
+data_stack_frame_t t_push(const char *marker) ATTR_HOT;
+data_stack_frame_t t_push_named(const char *format, ...) ATTR_HOT ATTR_FORMAT(1, 2);
+data_stack_frame_t t_pop(void) ATTR_HOT;
/* Simplifies the if (t_pop() != x) check by comparing it internally and
panicking if it doesn't match. */
-void t_pop_check(unsigned int *id) ATTR_HOT;
+void t_pop_check(data_stack_frame_t *id) ATTR_HOT;
/* Usage: T_BEGIN { code } T_END */
#ifndef DEBUG
#define T_BEGIN \
- STMT_START { unsigned int _data_stack_cur_id = t_push(NULL);
+ STMT_START { data_stack_frame_t _data_stack_cur_id = t_push(NULL);
#elif defined (__GNUC__) && !defined (__STRICT_ANSI__)
#define T_BEGIN \
- STMT_START { unsigned int _data_stack_cur_id = t_push(__FUNCTION__);
+ STMT_START { data_stack_frame_t _data_stack_cur_id = t_push(__FUNCTION__);
#else
#define T_CAT2(a,b) (a ":" #b)
#define T_BEGIN \
- STMT_START { unsigned int _data_stack_cur_id = t_push(T_CAT2(__FILE__,__LINE__));
+ STMT_START { data_stack_frame_t _data_stack_cur_id = t_push(T_CAT2(__FILE__,__LINE__));
#endif
#define T_END \
t_pop_check(&_data_stack_cur_id); } STMT_END
{
struct priorityq_item *item;
struct timeval tv, tv_call, prev_ioloop_timeval = ioloop_timeval;
- unsigned int t_id;
+ data_stack_frame_t t_id;
if (gettimeofday(&ioloop_timeval, NULL) < 0)
i_fatal("gettimeofday(): %m");
void io_loop_call_io(struct io *io)
{
struct ioloop *ioloop = io->ioloop;
- unsigned int t_id;
+ data_stack_frame_t t_id;
if (io->pending) {
i_assert(ioloop->io_pending_count > 0);
struct pool pool;
int refcount;
- unsigned int data_stack_frame;
+ data_stack_frame_t data_stack_frame;
};
pool_t pool_datastack_create(void)
char **ps;
char tag[2] = { depth+1, '\0' };
int try_fails = 0;
- unsigned int t_id = t_push_named("test_ds_recurse[%i]", depth);
+ data_stack_frame_t t_id = t_push_named("test_ds_recurse[%i]", depth);
ps = t_buffer_get_type(char *, number);
i_assert(ps != NULL);
t_buffer_alloc_type(char *, number);
enum fatal_test_state fatal_data_stack(int stage)
{
#ifdef DEBUG
+#define NONEXISTENT_STACK_FRAME_ID (data_stack_frame_t)999999999
/* If we abort, then we'll be left with a dangling t_push()
keep a record of our temporary stack id, so we can clean up. */
- static unsigned int t_id = 999999999;
+ static data_stack_frame_t t_id = NONEXISTENT_STACK_FRAME_ID;
static unsigned char *undo_ptr = NULL;
static unsigned char undo_data;
static bool things_are_messed_up = FALSE;
undo_ptr = NULL;
/* t_pop musn't abort, that would cause recursion */
things_are_messed_up = TRUE;
- if (t_id != 999999999 && t_pop() != t_id)
+ if (t_id != NONEXISTENT_STACK_FRAME_ID && t_pop() != t_id)
return FATAL_TEST_ABORT; /* abort, things are messed up with us */
things_are_messed_up = FALSE;
- t_id = 999999999;
+ t_id = NONEXISTENT_STACK_FRAME_ID;
test_end();
}
*undo_ptr = '*';
/* t_pop will now fail */
(void)t_pop();
- t_id = 999999999; /* We're FUBAR, mustn't pop next entry */
+ t_id = NONEXISTENT_STACK_FRAME_ID; /* We're FUBAR, mustn't pop next entry */
return FATAL_TEST_FAILURE;
}
*undo_ptr = '*';
/* t_pop will now fail */
(void)t_pop();
- t_id = 999999999; /* We're FUBAR, mustn't pop next entry */
+ t_id = NONEXISTENT_STACK_FRAME_ID; /* We're FUBAR, mustn't pop next entry */
return FATAL_TEST_FAILURE;
}