wip. enhancing log and error handling support

This commit is contained in:
hyung-hwan 2019-01-24 17:22:04 +00:00
parent a6d1122e33
commit e19231b104
2 changed files with 45 additions and 24 deletions

View File

@ -29,6 +29,29 @@
#include "mio-cmn.h"
#define MIO_CONST_SWAP16(x) \
((mio_uint16_t)((((mio_uint16_t)(x) & (mio_uint16_t)0x00ffU) << 8) | \
(((mio_uint16_t)(x) & (mio_uint16_t)0xff00U) >> 8) ))
#define MIO_CONST_SWAP32(x) \
((mio_uint32_t)((((mio_uint32_t)(x) & (mio_uint32_t)0x000000ffUL) << 24) | \
(((mio_uint32_t)(x) & (mio_uint32_t)0x0000ff00UL) << 8) | \
(((mio_uint32_t)(x) & (mio_uint32_t)0x00ff0000UL) >> 8) | \
(((mio_uint32_t)(x) & (mio_uint32_t)0xff000000UL) >> 24) ))
#if defined(MIO_ENDIAN_LITTLE)
# define MIO_CONST_NTOH16(x) MIO_CONST_SWAP16(x)
# define MIO_CONST_HTON16(x) MIO_CONST_SWAP16(x)
# define MIO_CONST_NTOH32(x) MIO_CONST_SWAP32(x)
# define MIO_CONST_HTON32(x) MIO_CONST_SWAP32(x)
#elif defined(MIO_ENDIAN_BIG)
# define MIO_CONST_NTOH16(x) (x)
# define MIO_CONST_HTON16(x) (x)
# define MIO_CONST_NTOH32(x) (x)
# define MIO_CONST_HTON32(x) (x)
#else
# error UNKNOWN ENDIAN
#endif
#ifdef __cplusplus
extern "C" {

View File

@ -44,29 +44,10 @@ struct mio_devaddr_t
void* ptr;
};
#define MIO_CONST_SWAP16(x) \
((mio_uint16_t)((((mio_uint16_t)(x) & (mio_uint16_t)0x00ffU) << 8) | \
(((mio_uint16_t)(x) & (mio_uint16_t)0xff00U) >> 8) ))
#define MIO_ERRMSG_CAPA (2048)
#define MIO_CONST_SWAP32(x) \
((mio_uint32_t)((((mio_uint32_t)(x) & (mio_uint32_t)0x000000ffUL) << 24) | \
(((mio_uint32_t)(x) & (mio_uint32_t)0x0000ff00UL) << 8) | \
(((mio_uint32_t)(x) & (mio_uint32_t)0x00ff0000UL) >> 8) | \
(((mio_uint32_t)(x) & (mio_uint32_t)0xff000000UL) >> 24) ))
#if defined(MIO_ENDIAN_LITTLE)
# define MIO_CONST_NTOH16(x) MIO_CONST_SWAP16(x)
# define MIO_CONST_HTON16(x) MIO_CONST_SWAP16(x)
# define MIO_CONST_NTOH32(x) MIO_CONST_SWAP32(x)
# define MIO_CONST_HTON32(x) MIO_CONST_SWAP32(x)
#elif defined(MIO_ENDIAN_BIG)
# define MIO_CONST_NTOH16(x) (x)
# define MIO_CONST_HTON16(x) (x)
# define MIO_CONST_NTOH32(x) (x)
# define MIO_CONST_HTON32(x) (x)
#else
# error UNKNOWN ENDIAN
#endif
/* [NOTE] ensure that it is a power of 2 */
#define MIO_LOG_CAPA_ALIGN 512
/* ========================================================================= */
@ -125,8 +106,6 @@ enum mio_errnum_t
};
typedef enum mio_errnum_t mio_errnum_t;
#define MIO_ERRMSG_CAPA (2048)
struct mio_errinf_t
{
mio_errnum_t num;
@ -418,6 +397,25 @@ struct mio_t
mio_stopreq_t stopreq; /* stop request to abort mio_loop() */
struct
{
mio_ooch_t* ptr;
mio_oow_t len;
mio_oow_t capa;
mio_bitmask_t last_mask;
mio_bitmask_t default_type_mask;
} log;
struct
{
struct
{
mio_ooch_t* ptr;
mio_oow_t capa;
mio_oow_t len;
} xbuf; /* buffer to support sprintf */
} sprintf;
struct
{
mio_dev_t* head;