mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Fix clang-tidy cppcoreguidelines-macro-usage findings (macro functions)
This commit is contained in:
parent
ad99a6821e
commit
460fe24a9a
23 changed files with 75 additions and 47 deletions
|
@ -2,6 +2,8 @@ Checks: [-*,
|
||||||
bugprone-*,
|
bugprone-*,
|
||||||
performance-*,
|
performance-*,
|
||||||
|
|
||||||
|
cppcoreguidelines-macro-usage,
|
||||||
|
cppcoreguidelines-misleading-capture-default-by-value,
|
||||||
cppcoreguidelines-virtual-class-destructor,
|
cppcoreguidelines-virtual-class-destructor,
|
||||||
|
|
||||||
# Skipping these temporarily because they are very noisy
|
# Skipping these temporarily because they are very noisy
|
||||||
|
|
|
@ -742,6 +742,8 @@ ValPtr BinaryExpr::Fold(Val* v1, Val* v2) const {
|
||||||
RuntimeErrorWithCallStack("bad type in BinaryExpr::Fold");
|
RuntimeErrorWithCallStack("bad type in BinaryExpr::Fold");
|
||||||
|
|
||||||
switch ( tag ) {
|
switch ( tag ) {
|
||||||
|
// Once we have C++20, these macros can become templated lambdas.
|
||||||
|
// NOLINTBEGIN(cppcoreguidelines-macro-usage)
|
||||||
#define DO_INT_FOLD(op) \
|
#define DO_INT_FOLD(op) \
|
||||||
if ( is_integral ) \
|
if ( is_integral ) \
|
||||||
i3 = i1 op i2; \
|
i3 = i1 op i2; \
|
||||||
|
@ -771,6 +773,7 @@ ValPtr BinaryExpr::Fold(Val* v1, Val* v2) const {
|
||||||
i3 = u1 op u2; \
|
i3 = u1 op u2; \
|
||||||
else \
|
else \
|
||||||
i3 = d1 op d2;
|
i3 = d1 op d2;
|
||||||
|
// NOLINTEND(cppcoreguidelines-macro-usage)
|
||||||
|
|
||||||
case EXPR_ADD:
|
case EXPR_ADD:
|
||||||
case EXPR_ADD_TO: DO_FOLD(+); break;
|
case EXPR_ADD_TO: DO_FOLD(+); break;
|
||||||
|
@ -892,13 +895,13 @@ ValPtr BinaryExpr::StringFold(Val* v1, Val* v2) const {
|
||||||
|
|
||||||
switch ( tag ) {
|
switch ( tag ) {
|
||||||
#undef DO_FOLD
|
#undef DO_FOLD
|
||||||
// NOLINTBEGIN(bugprone-macro-parentheses)
|
// NOLINTBEGIN(bugprone-macro-parentheses, cppcoreguidelines-macro-usage)
|
||||||
#define DO_FOLD(sense) \
|
#define DO_FOLD(sense) \
|
||||||
{ \
|
{ \
|
||||||
result = Bstr_cmp(s1, s2) sense 0; \
|
result = Bstr_cmp(s1, s2) sense 0; \
|
||||||
break; \
|
break; \
|
||||||
}
|
}
|
||||||
// NOLINTEND(bugprone-macro-parentheses)
|
// NOLINTEND(bugprone-macro-parentheses, cppcoreguidelines-macro-usage)
|
||||||
|
|
||||||
case EXPR_LT: DO_FOLD(<)
|
case EXPR_LT: DO_FOLD(<)
|
||||||
case EXPR_LE: DO_FOLD(<=)
|
case EXPR_LE: DO_FOLD(<=)
|
||||||
|
|
|
@ -69,6 +69,7 @@ Type::Type(TypeTag t, bool arg_base_type)
|
||||||
is_network_order(zeek::is_network_order(t)),
|
is_network_order(zeek::is_network_order(t)),
|
||||||
base_type(arg_base_type) {}
|
base_type(arg_base_type) {}
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||||
#define CHECK_TYPE_TAG(tag_type, func_name) CHECK_TAG(tag, tag_type, func_name, type_name)
|
#define CHECK_TYPE_TAG(tag_type, func_name) CHECK_TAG(tag, tag_type, func_name, type_name)
|
||||||
|
|
||||||
const TypeList* Type::AsTypeList() const {
|
const TypeList* Type::AsTypeList() const {
|
||||||
|
|
|
@ -53,6 +53,8 @@ Val::~Val() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOLINTBEGIN(cppcoreguidelines-macro-usage)
|
||||||
|
|
||||||
#define CONVERTER(tag, ctype, name) \
|
#define CONVERTER(tag, ctype, name) \
|
||||||
ctype name() { \
|
ctype name() { \
|
||||||
CHECK_TAG(type->Tag(), tag, "Val::CONVERTER", type_name) \
|
CHECK_TAG(type->Tag(), tag, "Val::CONVERTER", type_name) \
|
||||||
|
@ -69,6 +71,8 @@ Val::~Val() {
|
||||||
CONVERTER(tag, ctype, name) \
|
CONVERTER(tag, ctype, name) \
|
||||||
CONST_CONVERTER(tag, ctype, name)
|
CONST_CONVERTER(tag, ctype, name)
|
||||||
|
|
||||||
|
// NOLINTEND(cppcoreguidelines-macro-usage)
|
||||||
|
|
||||||
CONVERTERS(TYPE_FUNC, FuncVal*, Val::AsFuncVal)
|
CONVERTERS(TYPE_FUNC, FuncVal*, Val::AsFuncVal)
|
||||||
CONVERTERS(TYPE_FILE, FileVal*, Val::AsFileVal)
|
CONVERTERS(TYPE_FILE, FileVal*, Val::AsFileVal)
|
||||||
CONVERTERS(TYPE_PATTERN, PatternVal*, Val::AsPatternVal)
|
CONVERTERS(TYPE_PATTERN, PatternVal*, Val::AsPatternVal)
|
||||||
|
|
|
@ -456,7 +456,7 @@ void BitTorrentTracker_Analyzer::ResponseBody(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int BitTorrentTracker_Analyzer::ResponseParseBenc(void) {
|
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||||
#define VIOLATION_IF(expr, msg) \
|
#define VIOLATION_IF(expr, msg) \
|
||||||
{ \
|
{ \
|
||||||
if ( expr ) { \
|
if ( expr ) { \
|
||||||
|
@ -466,12 +466,12 @@ int BitTorrentTracker_Analyzer::ResponseParseBenc(void) {
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define INC_COUNT \
|
int BitTorrentTracker_Analyzer::ResponseParseBenc(void) {
|
||||||
{ \
|
auto INC_COUNT = [this]() {
|
||||||
unsigned int count = benc_count.back(); \
|
unsigned int count = benc_count.back();
|
||||||
benc_count.pop_back(); \
|
benc_count.pop_back();
|
||||||
benc_count.push_back(count + 1); \
|
benc_count.push_back(count + 1);
|
||||||
}
|
};
|
||||||
|
|
||||||
for ( unsigned int len = res_buf_len - (res_buf_pos - res_buf); len; --len, ++res_buf_pos ) {
|
for ( unsigned int len = res_buf_len - (res_buf_pos - res_buf); len; --len, ++res_buf_pos ) {
|
||||||
switch ( benc_state ) {
|
switch ( benc_state ) {
|
||||||
|
@ -551,7 +551,7 @@ int BitTorrentTracker_Analyzer::ResponseParseBenc(void) {
|
||||||
benc_count.pop_back();
|
benc_count.pop_back();
|
||||||
|
|
||||||
if ( benc_stack.size() )
|
if ( benc_stack.size() )
|
||||||
INC_COUNT
|
INC_COUNT();
|
||||||
else { // benc parsing successful
|
else { // benc parsing successful
|
||||||
++res_buf_pos;
|
++res_buf_pos;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -612,7 +612,7 @@ int BitTorrentTracker_Analyzer::ResponseParseBenc(void) {
|
||||||
else
|
else
|
||||||
VIOLATION_IF(1, "BitTorrentTracker: no valid bencoding")
|
VIOLATION_IF(1, "BitTorrentTracker: no valid bencoding")
|
||||||
|
|
||||||
INC_COUNT
|
INC_COUNT();
|
||||||
benc_state = detail::BENC_STATE_EMPTY;
|
benc_state = detail::BENC_STATE_EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -686,7 +686,7 @@ int BitTorrentTracker_Analyzer::ResponseParseBenc(void) {
|
||||||
++len;
|
++len;
|
||||||
}
|
}
|
||||||
|
|
||||||
INC_COUNT
|
INC_COUNT();
|
||||||
benc_state = detail::BENC_STATE_EMPTY;
|
benc_state = detail::BENC_STATE_EMPTY;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include "zeek/analyzer/protocol/login/events.bif.h"
|
#include "zeek/analyzer/protocol/login/events.bif.h"
|
||||||
#include "zeek/analyzer/protocol/tcp/TCP.h"
|
#include "zeek/analyzer/protocol/tcp/TCP.h"
|
||||||
|
|
||||||
#define IS_3_BYTE_OPTION(c) ((c) >= 251 && (c) <= 254)
|
constexpr bool IS_3_BYTE_OPTION(unsigned int code) { return code >= 251 && code <= 254; }
|
||||||
|
|
||||||
static constexpr uint8_t TELNET_OPT_SB = 250;
|
static constexpr uint8_t TELNET_OPT_SB = 250;
|
||||||
static constexpr uint8_t TELNET_OPT_SE = 240;
|
static constexpr uint8_t TELNET_OPT_SE = 240;
|
||||||
|
@ -411,17 +411,13 @@ void NVT_Analyzer::DeliverChunk(int& len, const u_char*& data) {
|
||||||
if ( binary_mode && c != TELNET_IAC )
|
if ( binary_mode && c != TELNET_IAC )
|
||||||
c &= 0x7f;
|
c &= 0x7f;
|
||||||
|
|
||||||
#define EMIT_LINE \
|
|
||||||
{ \
|
|
||||||
buf[offset] = '\0'; \
|
|
||||||
ForwardStream(offset, buf, IsOrig()); \
|
|
||||||
offset = 0; \
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ( c ) {
|
switch ( c ) {
|
||||||
case '\r':
|
case '\r':
|
||||||
if ( CRLFAsEOL() & CR_as_EOL )
|
if ( CRLFAsEOL() & CR_as_EOL ) {
|
||||||
EMIT_LINE
|
buf[offset] = '\0';
|
||||||
|
ForwardStream(offset, buf, IsOrig());
|
||||||
|
offset = 0;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
buf[offset++] = c;
|
buf[offset++] = c;
|
||||||
break;
|
break;
|
||||||
|
@ -433,12 +429,17 @@ void NVT_Analyzer::DeliverChunk(int& len, const u_char*& data) {
|
||||||
;
|
;
|
||||||
else {
|
else {
|
||||||
--offset; // remove '\r'
|
--offset; // remove '\r'
|
||||||
EMIT_LINE
|
buf[offset] = '\0';
|
||||||
|
ForwardStream(offset, buf, IsOrig());
|
||||||
|
offset = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ( CRLFAsEOL() & LF_as_EOL )
|
else if ( CRLFAsEOL() & LF_as_EOL ) {
|
||||||
EMIT_LINE
|
buf[offset] = '\0';
|
||||||
|
ForwardStream(offset, buf, IsOrig());
|
||||||
|
offset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
if ( Conn()->FlagEvent(SINGULAR_LF) )
|
if ( Conn()->FlagEvent(SINGULAR_LF) )
|
||||||
|
|
|
@ -9,11 +9,6 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#define xbyte(b, n) (((const u_char*)(b))[n])
|
|
||||||
#define extract_uint16(little_endian, bytes) \
|
|
||||||
((little_endian) ? uint16(xbyte(bytes, 0)) | ((uint16(xbyte(bytes, 1))) << 8) : \
|
|
||||||
uint16(xbyte(bytes, 1)) | ((uint16(xbyte(bytes, 0))) << 8))
|
|
||||||
|
|
||||||
namespace zeek::analyzer::ncp {
|
namespace zeek::analyzer::ncp {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
|
|
|
@ -10,14 +10,15 @@
|
||||||
#include "zeek/analyzer/protocol/netbios/events.bif.h"
|
#include "zeek/analyzer/protocol/netbios/events.bif.h"
|
||||||
#include "zeek/session/Manager.h"
|
#include "zeek/session/Manager.h"
|
||||||
|
|
||||||
constexpr double netbios_ssn_session_timeout = 15.0;
|
static constexpr double netbios_ssn_session_timeout = 15.0;
|
||||||
|
|
||||||
#define MAKE_INT16(dest, src) \
|
static constexpr void MAKE_INT16(uint16_t& dest, const u_char*& src) {
|
||||||
(dest) = *(src); \
|
dest = *src;
|
||||||
(dest) <<= 8; \
|
dest <= 8;
|
||||||
(src)++; \
|
src++;
|
||||||
(dest) |= *(src); \
|
dest |= *src;
|
||||||
(src)++;
|
src++;
|
||||||
|
}
|
||||||
|
|
||||||
namespace zeek::analyzer::netbios_ssn {
|
namespace zeek::analyzer::netbios_ssn {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
|
@ -24,8 +24,6 @@ static const char* pop3_cmd_word[] = {
|
||||||
#include "POP3_cmd.def"
|
#include "POP3_cmd.def"
|
||||||
};
|
};
|
||||||
|
|
||||||
#define POP3_CMD_WORD(code) (((code) >= 0) ? pop3_cmd_word[code] : "(UNKNOWN)")
|
|
||||||
|
|
||||||
POP3_Analyzer::POP3_Analyzer(Connection* conn) : analyzer::tcp::TCP_ApplicationAnalyzer("POP3", conn) {
|
POP3_Analyzer::POP3_Analyzer(Connection* conn) : analyzer::tcp::TCP_ApplicationAnalyzer("POP3", conn) {
|
||||||
masterState = detail::POP3_START;
|
masterState = detail::POP3_START;
|
||||||
subState = detail::POP3_WOK;
|
subState = detail::POP3_WOK;
|
||||||
|
|
|
@ -14,13 +14,15 @@
|
||||||
#undef SMTP_CMD_DEF
|
#undef SMTP_CMD_DEF
|
||||||
#define SMTP_CMD_DEF(cmd) #cmd,
|
#define SMTP_CMD_DEF(cmd) #cmd,
|
||||||
|
|
||||||
|
// This could be constexpr too but it would require changing the macro above. It doesn't
|
||||||
|
// matter that much though.
|
||||||
static const char* smtp_cmd_word[] = {
|
static const char* smtp_cmd_word[] = {
|
||||||
#include "SMTP_cmd.def"
|
#include "SMTP_cmd.def"
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char* unknown_cmd = "(UNKNOWN)";
|
static constexpr char unknown_cmd[] = "(UNKNOWN)";
|
||||||
|
|
||||||
#define SMTP_CMD_WORD(code) (((code) >= 0) ? smtp_cmd_word[code] : unknown_cmd)
|
static constexpr const char* SMTP_CMD_WORD(int code) { return code >= 0 ? smtp_cmd_word[code] : unknown_cmd; }
|
||||||
|
|
||||||
namespace zeek::analyzer::smtp {
|
namespace zeek::analyzer::smtp {
|
||||||
|
|
||||||
|
|
|
@ -400,8 +400,6 @@ struct opt_mapping {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define WITH_OPT_MAPPING(broker_name, zeek_name) if ( auto opt = opt_mapping{&config, broker_name, zeek_name}; true )
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
class BrokerState {
|
class BrokerState {
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "zeek/iosource/IOSource.h"
|
#include "zeek/iosource/IOSource.h"
|
||||||
#include "zeek/iosource/Manager.h"
|
#include "zeek/iosource/Manager.h"
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||||
#define BROKER_WS_DEBUG(...) \
|
#define BROKER_WS_DEBUG(...) \
|
||||||
do { \
|
do { \
|
||||||
DBG_LOG(DBG_BROKER, __VA_ARGS__); \
|
DBG_LOG(DBG_BROKER, __VA_ARGS__); \
|
||||||
|
|
|
@ -52,6 +52,8 @@ enum class InprocTag : uint8_t {
|
||||||
|
|
||||||
constexpr DebugFlag operator&(uint8_t x, DebugFlag y) { return static_cast<DebugFlag>(x & static_cast<uint8_t>(y)); }
|
constexpr DebugFlag operator&(uint8_t x, DebugFlag y) { return static_cast<DebugFlag>(x & static_cast<uint8_t>(y)); }
|
||||||
|
|
||||||
|
// NOLINTBEGIN(cppcoreguidelines-macro-usage)
|
||||||
|
|
||||||
#define ZEROMQ_DEBUG(...) PLUGIN_DBG_LOG(zeek::plugin::Zeek_Cluster_Backend_ZeroMQ::plugin, __VA_ARGS__)
|
#define ZEROMQ_DEBUG(...) PLUGIN_DBG_LOG(zeek::plugin::Zeek_Cluster_Backend_ZeroMQ::plugin, __VA_ARGS__)
|
||||||
|
|
||||||
#define ZEROMQ_THREAD_PRINTF(...) \
|
#define ZEROMQ_THREAD_PRINTF(...) \
|
||||||
|
@ -66,6 +68,8 @@ constexpr DebugFlag operator&(uint8_t x, DebugFlag y) { return static_cast<Debug
|
||||||
} \
|
} \
|
||||||
} while ( 0 )
|
} while ( 0 )
|
||||||
|
|
||||||
|
// NOLINTEND(cppcoreguidelines-macro-usage)
|
||||||
|
|
||||||
ZeroMQBackend::ZeroMQBackend(std::unique_ptr<EventSerializer> es, std::unique_ptr<LogSerializer> ls,
|
ZeroMQBackend::ZeroMQBackend(std::unique_ptr<EventSerializer> es, std::unique_ptr<LogSerializer> ls,
|
||||||
std::unique_ptr<detail::EventHandlingStrategy> ehs)
|
std::unique_ptr<detail::EventHandlingStrategy> ehs)
|
||||||
: ThreadedBackend("ZeroMQ", std::move(es), std::move(ls), std::move(ehs)) {
|
: ThreadedBackend("ZeroMQ", std::move(es), std::move(ls), std::move(ehs)) {
|
||||||
|
|
|
@ -22,6 +22,7 @@ extern Plugin plugin;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||||
#define SERIALIZER_DEBUG(...) PLUGIN_DBG_LOG(zeek::plugin::Zeek_Binary_Serializer::plugin, __VA_ARGS__)
|
#define SERIALIZER_DEBUG(...) PLUGIN_DBG_LOG(zeek::plugin::Zeek_Binary_Serializer::plugin, __VA_ARGS__)
|
||||||
|
|
||||||
bool detail::BinarySerializationFormatLogSerializer::SerializeLogWrite(byte_buffer& buf,
|
bool detail::BinarySerializationFormatLogSerializer::SerializeLogWrite(byte_buffer& buf,
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include "rapidjson/document.h"
|
#include "rapidjson/document.h"
|
||||||
#include "rapidjson/rapidjson.h"
|
#include "rapidjson/rapidjson.h"
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||||
#define WS_DEBUG(...) PLUGIN_DBG_LOG(zeek::plugin::Cluster_WebSocket::plugin, __VA_ARGS__)
|
#define WS_DEBUG(...) PLUGIN_DBG_LOG(zeek::plugin::Cluster_WebSocket::plugin, __VA_ARGS__)
|
||||||
|
|
||||||
namespace zeek {
|
namespace zeek {
|
||||||
|
|
|
@ -129,8 +129,8 @@ constexpr uint32_t CLASS_C = 0xc0000000;
|
||||||
constexpr uint32_t CLASS_D = 0xe0000000;
|
constexpr uint32_t CLASS_D = 0xe0000000;
|
||||||
constexpr uint32_t CLASS_E = 0xf0000000;
|
constexpr uint32_t CLASS_E = 0xf0000000;
|
||||||
|
|
||||||
#define CHECK_CLASS(addr, class) (((addr) & (class)) == (class))
|
|
||||||
char addr_to_class(uint32_t addr) {
|
char addr_to_class(uint32_t addr) {
|
||||||
|
auto CHECK_CLASS = [](uint32_t addr, uint32_t cls) { return (addr & cls) == cls; };
|
||||||
if ( CHECK_CLASS(addr, CLASS_E) )
|
if ( CHECK_CLASS(addr, CLASS_E) )
|
||||||
return 'E';
|
return 'E';
|
||||||
else if ( CHECK_CLASS(addr, CLASS_D) )
|
else if ( CHECK_CLASS(addr, CLASS_D) )
|
||||||
|
|
|
@ -41,6 +41,8 @@ void TCPStateStats::PrintStats(File* file, const char* prefix) {
|
||||||
file->Write(prefix);
|
file->Write(prefix);
|
||||||
|
|
||||||
switch ( i ) {
|
switch ( i ) {
|
||||||
|
// This macro really doesn't save us much typing, if that was the intention
|
||||||
|
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||||
#define STATE_STRING(state, str) \
|
#define STATE_STRING(state, str) \
|
||||||
case state: file->Write(str); break;
|
case state: file->Write(str); break;
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,8 @@ static VectorTypePtr base_vector_type__CPP(const VectorTypePtr& vt, bool is_bool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOLINTBEGIN(cppcoreguidelines-macro-usage)
|
||||||
|
|
||||||
// The kernel used for unary vector operations.
|
// The kernel used for unary vector operations.
|
||||||
#define VEC_OP1_KERNEL(accessor, type, op) \
|
#define VEC_OP1_KERNEL(accessor, type, op) \
|
||||||
for ( unsigned int i = 0; i < v->Size(); ++i ) { \
|
for ( unsigned int i = 0; i < v->Size(); ++i ) { \
|
||||||
|
@ -90,6 +92,8 @@ static VectorTypePtr base_vector_type__CPP(const VectorTypePtr& vt, bool is_bool
|
||||||
break; \
|
break; \
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// NOLINTEND(cppcoreguidelines-macro-usage)
|
||||||
|
|
||||||
// The unary operations supported for vectors.
|
// The unary operations supported for vectors.
|
||||||
VEC_OP1_WITH_DOUBLE(pos, +)
|
VEC_OP1_WITH_DOUBLE(pos, +)
|
||||||
VEC_OP1_WITH_DOUBLE(neg, -)
|
VEC_OP1_WITH_DOUBLE(neg, -)
|
||||||
|
@ -98,6 +102,7 @@ VEC_OP1(comp, ~, )
|
||||||
|
|
||||||
// A kernel for applying a binary operation element-by-element to two
|
// A kernel for applying a binary operation element-by-element to two
|
||||||
// vectors of a given low-level type.
|
// vectors of a given low-level type.
|
||||||
|
// NOLINTBEGIN(cppcoreguidelines-macro-usage)
|
||||||
// NOLINTBEGIN(bugprone-macro-parentheses)
|
// NOLINTBEGIN(bugprone-macro-parentheses)
|
||||||
#define VEC_OP2_KERNEL(accessor, type, op, zero_check) \
|
#define VEC_OP2_KERNEL(accessor, type, op, zero_check) \
|
||||||
for ( unsigned int i = 0; i < v1->Size(); ++i ) { \
|
for ( unsigned int i = 0; i < v1->Size(); ++i ) { \
|
||||||
|
@ -167,6 +172,7 @@ VEC_OP1(comp, ~, )
|
||||||
break; \
|
break; \
|
||||||
}, \
|
}, \
|
||||||
zero_check)
|
zero_check)
|
||||||
|
// NOLINTEND(cppcoreguidelines-macro-usage)
|
||||||
|
|
||||||
// The binary operations supported for vectors.
|
// The binary operations supported for vectors.
|
||||||
VEC_OP2_WITH_DOUBLE(add, +, 0)
|
VEC_OP2_WITH_DOUBLE(add, +, 0)
|
||||||
|
@ -184,6 +190,7 @@ VEC_OP2_WITH_INT(rshift, >>, , 0)
|
||||||
|
|
||||||
// A version of VEC_OP2 that instead supports relational operations, so
|
// A version of VEC_OP2 that instead supports relational operations, so
|
||||||
// the result type is always vector-of-bool.
|
// the result type is always vector-of-bool.
|
||||||
|
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||||
#define VEC_REL_OP(name, op) \
|
#define VEC_REL_OP(name, op) \
|
||||||
VectorValPtr vec_op_##name##__CPP(const VectorValPtr& v1, const VectorValPtr& v2) { \
|
VectorValPtr vec_op_##name##__CPP(const VectorValPtr& v1, const VectorValPtr& v2) { \
|
||||||
if ( ! check_vec_sizes__CPP(v1, v2) ) \
|
if ( ! check_vec_sizes__CPP(v1, v2) ) \
|
||||||
|
|
|
@ -188,6 +188,8 @@ static void vec_exec(ZOp op, TypePtr t, VectorVal*& v1, const VectorVal* v2, con
|
||||||
|
|
||||||
static void vec_exec(ZOp op, TypePtr t, VectorVal*& v1, const VectorVal* v2, const VectorVal* v3, const ZInst& z);
|
static void vec_exec(ZOp op, TypePtr t, VectorVal*& v1, const VectorVal* v2, const VectorVal* v3, const ZInst& z);
|
||||||
|
|
||||||
|
auto false_func = [](double x) { return false; };
|
||||||
|
|
||||||
// Vector coercion.
|
// Vector coercion.
|
||||||
#define VEC_COERCE(tag, lhs_type, cast, rhs_accessor, ov_check, ov_err) \
|
#define VEC_COERCE(tag, lhs_type, cast, rhs_accessor, ov_check, ov_err) \
|
||||||
VectorVal* vec_coerce_##tag(VectorVal* vec, std::shared_ptr<ZAMLocInfo> z_loc) { \
|
VectorVal* vec_coerce_##tag(VectorVal* vec, std::shared_ptr<ZAMLocInfo> z_loc) { \
|
||||||
|
@ -216,8 +218,6 @@ static void vec_exec(ZOp op, TypePtr t, VectorVal*& v1, const VectorVal* v2, con
|
||||||
return res_zv; \
|
return res_zv; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define false_func(x) false
|
|
||||||
|
|
||||||
VEC_COERCE(DI, TYPE_DOUBLE, double, AsInt(), false_func, "")
|
VEC_COERCE(DI, TYPE_DOUBLE, double, AsInt(), false_func, "")
|
||||||
VEC_COERCE(DU, TYPE_DOUBLE, double, AsCount(), false_func, "")
|
VEC_COERCE(DU, TYPE_DOUBLE, double, AsCount(), false_func, "")
|
||||||
VEC_COERCE(ID, TYPE_INT, zeek_int_t, AsDouble(), double_to_int_would_overflow, "double to signed")
|
VEC_COERCE(ID, TYPE_INT, zeek_int_t, AsDouble(), double_to_int_would_overflow, "double to signed")
|
||||||
|
|
|
@ -13,11 +13,13 @@ using namespace zeek;
|
||||||
using namespace zeek::spicy;
|
using namespace zeek::spicy;
|
||||||
using namespace zeek::spicy::rt;
|
using namespace zeek::spicy::rt;
|
||||||
|
|
||||||
|
// NOLINTBEGIN(cppcoreguidelines-macro-usage)
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define STATE_DEBUG_MSG(...) DebugMsg(__VA_ARGS__)
|
#define STATE_DEBUG_MSG(...) DebugMsg(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define STATE_DEBUG_MSG(...)
|
#define STATE_DEBUG_MSG(...)
|
||||||
#endif
|
#endif
|
||||||
|
// NOLINTEND(cppcoreguidelines-macro-usage)
|
||||||
|
|
||||||
void FileState::debug(const std::string& msg) { spicy::rt::debug(_cookie, msg); }
|
void FileState::debug(const std::string& msg) { spicy::rt::debug(_cookie, msg); }
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,13 @@ using namespace zeek;
|
||||||
using namespace zeek::spicy;
|
using namespace zeek::spicy;
|
||||||
using namespace zeek::spicy::rt;
|
using namespace zeek::spicy::rt;
|
||||||
|
|
||||||
|
// NOLINTBEGIN(cppcoreguidelines-macro-usage)
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define STATE_DEBUG_MSG(...) DebugMsg(__VA_ARGS__)
|
#define STATE_DEBUG_MSG(...) DebugMsg(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define STATE_DEBUG_MSG(...)
|
#define STATE_DEBUG_MSG(...)
|
||||||
#endif
|
#endif
|
||||||
|
// NOLINTEND(cppcoreguidelines-macro-usage)
|
||||||
|
|
||||||
void PacketState::debug(const std::string& msg) { spicy::rt::debug(_cookie, msg); }
|
void PacketState::debug(const std::string& msg) { spicy::rt::debug(_cookie, msg); }
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,13 @@ using namespace zeek;
|
||||||
using namespace zeek::spicy;
|
using namespace zeek::spicy;
|
||||||
using namespace zeek::spicy::rt;
|
using namespace zeek::spicy::rt;
|
||||||
|
|
||||||
|
// NOLINTBEGIN(cppcoreguidelines-macro-usage)
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define STATE_DEBUG_MSG(...) DebugMsg(__VA_ARGS__)
|
#define STATE_DEBUG_MSG(...) DebugMsg(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define STATE_DEBUG_MSG(...)
|
#define STATE_DEBUG_MSG(...)
|
||||||
#endif
|
#endif
|
||||||
|
// NOLINTEND(cppcoreguidelines-macro-usage)
|
||||||
|
|
||||||
void EndpointState::debug(const std::string& msg) { spicy::rt::debug(_cookie, msg); }
|
void EndpointState::debug(const std::string& msg) { spicy::rt::debug(_cookie, msg); }
|
||||||
|
|
||||||
|
|
|
@ -44,11 +44,13 @@ extern "C" {
|
||||||
#include "zeek/util.h"
|
#include "zeek/util.h"
|
||||||
#include "zeek/zeek-affinity.h"
|
#include "zeek/zeek-affinity.h"
|
||||||
|
|
||||||
|
// NOLINTBEGIN(cppcoreguidelines-macro-usage)
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define DBG_STEM(...) stem->LogDebug(__VA_ARGS__);
|
#define DBG_STEM(...) stem->LogDebug(__VA_ARGS__);
|
||||||
#else
|
#else
|
||||||
#define DBG_STEM(...)
|
#define DBG_STEM(...)
|
||||||
#endif
|
#endif
|
||||||
|
// NOLINTEND(cppcoreguidelines-macro-usage)
|
||||||
|
|
||||||
using namespace zeek;
|
using namespace zeek;
|
||||||
using zeek::detail::SupervisedNode;
|
using zeek::detail::SupervisedNode;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue