2023-03-17 07:42:15 +00:00
|
|
|
//
|
|
|
|
// Created by xajhuang on 2023/3/17.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef VCPE_COMMON_H
|
|
|
|
#define VCPE_COMMON_H
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define _STR(s) #s
|
|
|
|
#define STR(s) _STR(s)
|
|
|
|
|
2023-04-07 07:56:38 +00:00
|
|
|
#ifndef MIN
|
|
|
|
#define MIN(a, b) \
|
|
|
|
({ \
|
|
|
|
typeof(a) __min1__ = (a); \
|
|
|
|
typeof(b) __min2__ = (b); \
|
|
|
|
(void)(&__min1__ == &__min2__); \
|
|
|
|
__min1__ < __min2__ ? __min1__ : __min2__; \
|
|
|
|
})
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef MAX
|
|
|
|
#define MAX(a, b) \
|
|
|
|
({ \
|
|
|
|
typeof(a) __max1__ = (a); \
|
|
|
|
typeof(b) __max2__ = (b); \
|
|
|
|
(void)(&__max1__ == &__max2__); \
|
|
|
|
__max1__ < __max2__ ? __max1__ : __max2__; \
|
|
|
|
})
|
|
|
|
#endif
|
|
|
|
|
2023-03-17 07:42:15 +00:00
|
|
|
#ifndef ARRAY_SIZE
|
|
|
|
//#ifdef __cplusplus
|
|
|
|
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
|
|
|
//#else
|
|
|
|
//#define ARRAY_SIZE_TYPE_CHECK(a) (sizeof(typeof(int[1 - 2 * !!__builtin_types_compatible_p(typeof(a), typeof(&a[0]))])))
|
|
|
|
//#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]) + ARRAY_SIZE_TYPE_CHECK(a) * 0)
|
|
|
|
//#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef UNUSED
|
|
|
|
#define UNUSED(x) UNUSED_##x __attribute__((__unused__))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef MAX_PATH
|
|
|
|
#define MAX_PATH (512)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef TRUE
|
|
|
|
#define TRUE (1)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef FALSE
|
|
|
|
#define FALSE (0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define VERIFY_STRING(s) (((s) != NULL) && (strlen(s) > 0))
|
|
|
|
#define SAFETY_STR_STRING(s) ((s) == NULL ? "NULL" : (s))
|
|
|
|
|
|
|
|
#define MAX_IP_V4_STR (16)
|
|
|
|
#define MAX_MAC_ADDR_STR (18)
|
|
|
|
|
|
|
|
#define DEBUG_CODE_LINE() LOG_MSG(debug, "\n")
|
|
|
|
|
|
|
|
typedef unsigned char U8;
|
|
|
|
typedef unsigned short U16;
|
|
|
|
typedef unsigned int U32;
|
|
|
|
typedef unsigned long long U64;
|
2023-04-07 07:56:38 +00:00
|
|
|
typedef char S8;
|
|
|
|
typedef short S16;
|
|
|
|
typedef int S32;
|
|
|
|
typedef long long S64;
|
2023-03-17 07:42:15 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif //VCPE_COMMON_H
|