queue problems

This commit is contained in:
Ellen Arvidsson 2025-04-11 23:16:29 +02:00
parent 2ac5491b44
commit 8dd2fe0e34
10 changed files with 427 additions and 59 deletions

67
include/spho/err.h Normal file
View file

@ -0,0 +1,67 @@
#ifndef _SPHO_ERR_H
#define _SPHO_ERR_H
#define SPHO_ERR_SYSTEM 0x000001
#define SPHO_ERR_INTERNAL 0x010001
#define SPHO_ERR_IS_SYSERR(err) (SPHO_ERR_SYSTEM == err)
#ifdef SPHO_DEBUG
#define SPHO_ERR(ctx, err) \
do { \
ctx->err = err; \
if (err == SPHO_ERR_SYSTEM) \
ctx->err_info = errno; \
snprintf(ctx->filebuf, sizeof(ctx->filebuf), "%s", \
__FILE__); \
ctx->errline = __LINE__; \
} while (0)
#else /* SPHO_DEBUG */
#define SPHO_ERR(ctx, err) \
do { \
ctx->err = err; \
if (err == SPHO_ERR_SYSTEM) \
ctx->err_info = errno; \
} while (0)
#endif /* SPHO_DEBUG */
/* debug stuff */
#ifdef SPHO_DEBUG
/* PRECOND/ASSERT/POSTCOND */
#define SPHO_PRECOND(cond) do { \
if (! (cond) ) { \
fprintf(stderr, "SPHO_PRECOND(" #cond ")@" __FILE__ ":" __LINE__ \
" failed. Aborting."); \
abort(); \
} \
} while (0)
#define SPHO_ASSERT(cond) do { \
if (! (cond) ) { \
fprintf(stderr, "SPHO_ASSERT(" #cond ")@" __FILE__ ":" __LINE__ \
" failed. Aborting."); \
abort(); \
} \
} while (0)
#define SPHO_POSTCOND(cond) do { \
if (! (cond) ) { \
fprintf(stderr, "SPHO_POSTCOND(" #cond ")@" __FILE__ ":" __LINE__ \
" failed. Aborting."); \
abort(); \
} \
} while (0)
#else
#define SPHO_PRECOND(cond)
#define SPHO_ASSERT(cond)
#define SPHO_POSTCOND(cond)
#endif
#endif