diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index ac24e0d8e3c2bcf8fdefab456780b15141d3f708..706c69956ee17426a220dcb2139685194b412b3b 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 2.8) project (dap_core) -set(CORE_SRCS dap_common.c dap_config.c) +set(CORE_SRCS dap_common.c dap_config.c dap_math_ops.h) add_library(${PROJECT_NAME} STATIC ${CORE_SRCS}) diff --git a/core/dap_common.h b/core/dap_common.h index f4750ccad508abee1e15f07937ae5c1d766d7388..32269cf3dcad28b0c10babe2ac016700d6056b7a 100644 --- a/core/dap_common.h +++ b/core/dap_common.h @@ -13,6 +13,13 @@ #define DAP_DUP(a) (__typeof(a) ret = memcpy(ret,a,sizeof(*a)) ) + + +#if defined(__GNUC__) ||defined (__clang__) +#define DAP_ALIGN_PACKED __attribute__((aligned(1),packed)) +#endif + + enum log_level{L_CRITICAL=5,L_ERROR=4, L_WARNING=3,L_NOTICE=2,L_INFO=1,L_DEBUG=0}; extern enum log_level log_level; @@ -30,8 +37,13 @@ void _vlog_it(const char * log_tag, enum log_level, const char * format, va_list const char * log_error(); + + + #ifdef __GNUC__ char *itoa(int i); + + #elif _MSC_VER char *strndup(const char *s, size_t n); #endif diff --git a/core/dap_math_ops.h b/core/dap_math_ops.h new file mode 100644 index 0000000000000000000000000000000000000000..0a8b8690c1e09c0a5613101c7a53cea411539eb4 --- /dev/null +++ b/core/dap_math_ops.h @@ -0,0 +1,23 @@ +#ifndef _DAP_MATH_OPS_H_ +#define _DAP_MATH_OPS_H_ + +#include <stdint.h> + +#if defined(__GNUC__) ||defined (__clang__) + +#if __SIZEOF_INT128__ == 16 + +#define DAP_GLOBAL_IS_INT128 +typedef __int128 _dap_int128_t; + +#endif +#endif + +typedef union dap_uint128{ + uint8_t data_raw[16]; +#if defined(DAP_GLOBAL_IS_INT128) + _dap_int128_t data_int128; +#endif +} dap_uint128_t; + +#endif