diff --git a/auxil/bifcl b/auxil/bifcl index 66442960aa..c76100f46f 160000 --- a/auxil/bifcl +++ b/auxil/bifcl @@ -1 +1 @@ -Subproject commit 66442960aa29ca5478c924872e4b4c0da437958d +Subproject commit c76100f46f38573d3d79eea684410e9fb983bff0 diff --git a/auxil/gen-zam b/auxil/gen-zam index 698d6ae19b..91dd2edaa8 160000 --- a/auxil/gen-zam +++ b/auxil/gen-zam @@ -1 +1 @@ -Subproject commit 698d6ae19b4a042094c30d5ac0b272adc4fbd845 +Subproject commit 91dd2edaa89b7d8f1e05104d6b4c147b7e3ec111 diff --git a/src/Attr.cc b/src/Attr.cc index 66c82d0e06..46d90ee2b9 100644 --- a/src/Attr.cc +++ b/src/Attr.cc @@ -161,7 +161,7 @@ void Attr::DescribeReST(ODesc* d, bool shorten) const void Attr::AddTag(ODesc* d) const { if ( d->IsBinary() ) - d->Add(static_cast(Tag())); + d->Add(static_cast(Tag())); else d->Add(attr_name(Tag())); } diff --git a/src/CompHash.cc b/src/CompHash.cc index 376ce39c97..6eb39e67e7 100644 --- a/src/CompHash.cc +++ b/src/CompHash.cc @@ -158,7 +158,7 @@ bool CompositeHash::RecoverOneVal(const HashKey& hk, Type* t, ValPtr* pval, bool { case TYPE_INTERNAL_INT: { - bro_int_t i; + zeek_int_t i; hk.Read("int", i); if ( tag == TYPE_ENUM ) @@ -179,7 +179,7 @@ bool CompositeHash::RecoverOneVal(const HashKey& hk, Type* t, ValPtr* pval, bool case TYPE_INTERNAL_UNSIGNED: { - bro_uint_t u; + zeek_uint_t u; hk.Read("unsigned", u); switch ( tag ) @@ -783,11 +783,11 @@ bool CompositeHash::ReserveSingleTypeKeySize(HashKey& hk, Type* bt, const Val* v switch ( t ) { case TYPE_INTERNAL_INT: - hk.ReserveType("int"); + hk.ReserveType("int"); break; case TYPE_INTERNAL_UNSIGNED: - hk.ReserveType("unsigned"); + hk.ReserveType("unsigned"); break; case TYPE_INTERNAL_ADDR: diff --git a/src/Desc.h b/src/Desc.h index a7dbb46be4..9cc86fef20 100644 --- a/src/Desc.h +++ b/src/Desc.h @@ -8,7 +8,7 @@ #include #include "zeek/ZeekString.h" // for byte_vec -#include "zeek/util.h" // for bro_int_t +#include "zeek/util.h" // for zeek_int_t namespace zeek { @@ -118,7 +118,7 @@ public: SP(); } - void AddCount(bro_int_t n) + void AddCount(zeek_int_t n) { if ( ! IsReadable() ) { diff --git a/src/Expr.cc b/src/Expr.cc index 7f1d7ea40f..becf1c80bb 100644 --- a/src/Expr.cc +++ b/src/Expr.cc @@ -318,8 +318,8 @@ const char* assign_to_index(ValPtr v1, ValPtr v2, ValPtr v3, bool& iterators_inv if ( lv->Length() > 1 ) { auto len = v1_vect->Size(); - bro_int_t first = get_slice_index(lv->Idx(0)->CoerceToInt(), len); - bro_int_t last = get_slice_index(lv->Idx(1)->CoerceToInt(), len); + zeek_int_t first = get_slice_index(lv->Idx(0)->CoerceToInt(), len); + zeek_int_t last = get_slice_index(lv->Idx(1)->CoerceToInt(), len); // Remove the elements from the vector within the slice. for ( auto idx = first; idx < last; idx++ ) @@ -828,8 +828,8 @@ ValPtr BinaryExpr::Fold(Val* v1, Val* v2) const if ( it == TYPE_INTERNAL_SUBNET ) return SubNetFold(v1, v2); - bro_int_t i1 = 0, i2 = 0, i3 = 0; - bro_uint_t u1 = 0, u2 = 0, u3 = 0; + zeek_int_t i1 = 0, i2 = 0, i3 = 0; + zeek_uint_t u1 = 0, u2 = 0, u3 = 0; double d1 = 0.0, d2 = 0.0, d3 = 0.0; bool is_integral = false; bool is_unsigned = false; @@ -1414,7 +1414,7 @@ IncrExpr::IncrExpr(BroExprTag arg_tag, ExprPtr arg_op) : UnaryExpr(arg_tag, arg_ ValPtr IncrExpr::DoSingleEval(Frame* f, Val* v) const { - bro_int_t k = v->CoerceToInt(); + zeek_int_t k = v->CoerceToInt(); if ( Tag() == EXPR_INCR ) ++k; @@ -3052,7 +3052,7 @@ StringValPtr index_string(const String* s, const ListVal* lv) if ( lv->Length() == 1 ) { - bro_int_t idx = lv->Idx(0)->AsInt(); + zeek_int_t idx = lv->Idx(0)->AsInt(); if ( idx < 0 ) idx += len; @@ -3062,9 +3062,9 @@ StringValPtr index_string(const String* s, const ListVal* lv) } else { - bro_int_t first = get_slice_index(lv->Idx(0)->AsInt(), len); - bro_int_t last = get_slice_index(lv->Idx(1)->AsInt(), len); - bro_int_t substring_len = last - first; + zeek_int_t first = get_slice_index(lv->Idx(0)->AsInt(), len); + zeek_int_t last = get_slice_index(lv->Idx(1)->AsInt(), len); + zeek_int_t substring_len = last - first; if ( substring_len < 0 ) substring = nullptr; @@ -3087,15 +3087,15 @@ VectorValPtr index_slice(VectorVal* vect, int _first, int _last) size_t len = vect->Size(); auto result = make_intrusive(vect->GetType()); - bro_int_t first = get_slice_index(_first, len); - bro_int_t last = get_slice_index(_last, len); - bro_int_t sub_length = last - first; + zeek_int_t first = get_slice_index(_first, len); + zeek_int_t last = get_slice_index(_last, len); + zeek_int_t sub_length = last - first; if ( sub_length >= 0 ) { result->Resize(sub_length); - for ( bro_int_t idx = first; idx < last; idx++ ) + for ( zeek_int_t idx = first; idx < last; idx++ ) result->Assign(idx - first, vect->ValAt(idx)); } diff --git a/src/Frag.h b/src/Frag.h index 991f150a9d..7b8c2cac23 100644 --- a/src/Frag.h +++ b/src/Frag.h @@ -8,7 +8,7 @@ #include "zeek/IPAddr.h" #include "zeek/Reassem.h" #include "zeek/Timer.h" -#include "zeek/util.h" // for bro_uint_t +#include "zeek/util.h" // for zeek_uint_t namespace zeek { @@ -26,7 +26,7 @@ namespace detail class FragReassembler; class FragTimer; -using FragReassemblerKey = std::tuple; +using FragReassemblerKey = std::tuple; class FragReassembler : public Reassembler { diff --git a/src/Hash.cc b/src/Hash.cc index a81ad750f9..9e07af5041 100644 --- a/src/Hash.cc +++ b/src/Hash.cc @@ -119,12 +119,12 @@ HashKey::HashKey(int i) Set(i); } -HashKey::HashKey(bro_int_t bi) +HashKey::HashKey(zeek_int_t bi) { Set(bi); } -HashKey::HashKey(bro_uint_t bu) +HashKey::HashKey(zeek_uint_t bu) { Set(bu); } @@ -273,16 +273,16 @@ void HashKey::Set(int i) size = write_size = sizeof(i); } -void HashKey::Set(bro_int_t bi) +void HashKey::Set(zeek_int_t bi) { key_u.bi = bi; key = reinterpret_cast(&key_u); size = write_size = sizeof(bi); } -void HashKey::Set(bro_uint_t bu) +void HashKey::Set(zeek_uint_t bu) { - key_u.bi = bro_int_t(bu); + key_u.bi = zeek_int_t(bu); key = reinterpret_cast(&key_u); size = write_size = sizeof(bu); } @@ -350,7 +350,7 @@ void HashKey::Write(const char* tag, int i, bool align) Write(tag, &i, sizeof(i), align ? sizeof(i) : 0); } -void HashKey::Write(const char* tag, bro_int_t bi, bool align) +void HashKey::Write(const char* tag, zeek_int_t bi, bool align) { if ( ! IsAllocated() ) { @@ -361,7 +361,7 @@ void HashKey::Write(const char* tag, bro_int_t bi, bool align) Write(tag, &bi, sizeof(bi), align ? sizeof(bi) : 0); } -void HashKey::Write(const char* tag, bro_uint_t bu, bool align) +void HashKey::Write(const char* tag, zeek_uint_t bu, bool align) { if ( ! IsAllocated() ) { @@ -464,12 +464,12 @@ void HashKey::Read(const char* tag, int& i, bool align) const Read(tag, &i, sizeof(i), align ? sizeof(i) : 0); } -void HashKey::Read(const char* tag, bro_int_t& i, bool align) const +void HashKey::Read(const char* tag, zeek_int_t& i, bool align) const { Read(tag, &i, sizeof(i), align ? sizeof(i) : 0); } -void HashKey::Read(const char* tag, bro_uint_t& u, bool align) const +void HashKey::Read(const char* tag, zeek_uint_t& u, bool align) const { Read(tag, &u, sizeof(u), align ? sizeof(u) : 0); } diff --git a/src/Hash.h b/src/Hash.h index 37ce6fb240..48ef1b877a 100644 --- a/src/Hash.h +++ b/src/Hash.h @@ -21,7 +21,7 @@ #include -#include "zeek/util.h" // for bro_int_t +#include "zeek/util.h" // for zeek_int_t // to allow bro_md5_hmac access to the hmac seed #include "zeek/ZeekArgs.h" @@ -234,8 +234,8 @@ public: explicit HashKey() { } explicit HashKey(bool b); explicit HashKey(int i); - explicit HashKey(bro_int_t bi); - explicit HashKey(bro_uint_t bu); + explicit HashKey(zeek_int_t bi); + explicit HashKey(zeek_uint_t bu); explicit HashKey(uint32_t u); HashKey(const uint32_t u[], size_t n); explicit HashKey(double d); @@ -297,8 +297,8 @@ public: // at the current marker. void Write(const char* tag, bool b); void Write(const char* tag, int i, bool align = true); - void Write(const char* tag, bro_int_t bi, bool align = true); - void Write(const char* tag, bro_uint_t bu, bool align = true); + void Write(const char* tag, zeek_int_t bi, bool align = true); + void Write(const char* tag, zeek_uint_t bu, bool align = true); void Write(const char* tag, uint32_t u, bool align = true); void Write(const char* tag, double d, bool align = true); @@ -325,8 +325,8 @@ public: // to the read of the item is controlled by the align boolean. void Read(const char* tag, bool& b) const; void Read(const char* tag, int& i, bool align = true) const; - void Read(const char* tag, bro_int_t& bi, bool align = true) const; - void Read(const char* tag, bro_uint_t& bu, bool align = true) const; + void Read(const char* tag, zeek_int_t& bi, bool align = true) const; + void Read(const char* tag, zeek_uint_t& bu, bool align = true) const; void Read(const char* tag, uint32_t& u, bool align = true) const; void Read(const char* tag, double& d, bool align = true) const; @@ -351,8 +351,8 @@ protected: // use the key_u union for storage. void Set(bool b); void Set(int i); - void Set(bro_int_t bi); - void Set(bro_uint_t bu); + void Set(zeek_int_t bi); + void Set(zeek_uint_t bu); void Set(uint32_t u); void Set(double d); void Set(const void* p); @@ -360,7 +360,7 @@ protected: union { bool b; int i; - bro_int_t bi; + zeek_int_t bi; uint32_t u32; double d; const void* p; diff --git a/src/NetVar.cc b/src/NetVar.cc index 586b81c07e..64d51cbf3f 100644 --- a/src/NetVar.cc +++ b/src/NetVar.cc @@ -191,9 +191,9 @@ int check_for_unused_event_handlers; int record_all_packets; -bro_uint_t bits_per_uid; +zeek_uint_t bits_per_uid; -bro_uint_t tunnel_max_changes_per_connection; +zeek_uint_t tunnel_max_changes_per_connection; } // namespace zeek::detail. The namespace has be closed here before we include the netvar_def // files. diff --git a/src/NetVar.h b/src/NetVar.h index e3c3521c7e..c56d57f5d4 100644 --- a/src/NetVar.h +++ b/src/NetVar.h @@ -92,9 +92,9 @@ extern int check_for_unused_event_handlers; extern int record_all_packets; -extern bro_uint_t bits_per_uid; +extern zeek_uint_t bits_per_uid; -extern bro_uint_t tunnel_max_changes_per_connection; +extern zeek_uint_t tunnel_max_changes_per_connection; // Initializes globals that don't pertain to network/event analysis. extern void init_general_global_var(); diff --git a/src/Overflow.h b/src/Overflow.h index 412f3f25ce..e3a3504042 100644 --- a/src/Overflow.h +++ b/src/Overflow.h @@ -12,7 +12,7 @@ inline bool double_to_count_would_overflow(double v) return v < 0.0 || v > static_cast(UINT64_MAX); } -inline bool int_to_count_would_overflow(bro_int_t v) +inline bool int_to_count_would_overflow(zeek_int_t v) { return v < 0.0; } @@ -22,7 +22,7 @@ inline bool double_to_int_would_overflow(double v) return v < static_cast(INT64_MIN) || v > static_cast(INT64_MAX); } -inline bool count_to_int_would_overflow(bro_uint_t v) +inline bool count_to_int_would_overflow(zeek_uint_t v) { return v > INT64_MAX; } diff --git a/src/Type.cc b/src/Type.cc index 77ecd5c679..222d84c62d 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -1624,7 +1624,7 @@ void EnumType::AddName(const string& module_name, const char* name, bool is_expo counter++; } -void EnumType::AddName(const string& module_name, const char* name, bro_int_t val, bool is_export, +void EnumType::AddName(const string& module_name, const char* name, zeek_int_t val, bool is_export, detail::Expr* deprecation, bool from_redef) { /* explicit value specified */ @@ -1638,7 +1638,7 @@ void EnumType::AddName(const string& module_name, const char* name, bro_int_t va CheckAndAddName(module_name, name, val, is_export, deprecation, from_redef); } -void EnumType::CheckAndAddName(const string& module_name, const char* name, bro_int_t val, +void EnumType::CheckAndAddName(const string& module_name, const char* name, zeek_int_t val, bool is_export, detail::Expr* deprecation, bool from_redef) { if ( from_redef ) @@ -1696,14 +1696,14 @@ void EnumType::CheckAndAddName(const string& module_name, const char* name, bro_ t->AsEnumType()->AddNameInternal(module_name, name, val, is_export); } -void EnumType::AddNameInternal(const string& module_name, const char* name, bro_int_t val, +void EnumType::AddNameInternal(const string& module_name, const char* name, zeek_int_t val, bool is_export) { string fullname = detail::make_full_var_name(module_name.c_str(), name); names[fullname] = val; } -void EnumType::AddNameInternal(const string& full_name, bro_int_t val) +void EnumType::AddNameInternal(const string& full_name, zeek_int_t val) { names[full_name] = val; @@ -1711,12 +1711,12 @@ void EnumType::AddNameInternal(const string& full_name, bro_int_t val) vals[val] = make_intrusive(IntrusivePtr{NewRef{}, this}, val); } -bro_int_t EnumType::Lookup(const string& module_name, const char* name) const +zeek_int_t EnumType::Lookup(const string& module_name, const char* name) const { return Lookup(detail::make_full_var_name(module_name.c_str(), name)); } -bro_int_t EnumType::Lookup(const string& full_name) const +zeek_int_t EnumType::Lookup(const string& full_name) const { NameMap::const_iterator pos = names.find(full_name.c_str()); @@ -1726,7 +1726,7 @@ bro_int_t EnumType::Lookup(const string& full_name) const return pos->second; } -const char* EnumType::Lookup(bro_int_t value) const +const char* EnumType::Lookup(zeek_int_t value) const { for ( NameMap::const_iterator iter = names.begin(); iter != names.end(); ++iter ) if ( iter->second == value ) @@ -1744,7 +1744,7 @@ EnumType::enum_name_list EnumType::Names() const return n; } -const EnumValPtr& EnumType::GetEnumVal(bro_int_t i) +const EnumValPtr& EnumType::GetEnumVal(zeek_int_t i) { auto it = vals.find(i); @@ -1784,7 +1784,7 @@ void EnumType::DescribeReST(ODesc* d, bool roles_only) const // Create temporary, reverse name map so that enums can be documented // in ascending order of their actual integral value instead of by name. - using RevNameMap = std::map; + using RevNameMap = std::map; RevNameMap rev; for ( NameMap::const_iterator it = names.begin(); it != names.end(); ++it ) diff --git a/src/Type.h b/src/Type.h index 9afa347f18..28febf5025 100644 --- a/src/Type.h +++ b/src/Type.h @@ -766,7 +766,7 @@ protected: class EnumType final : public Type { public: - using enum_name_list = std::list>; + using enum_name_list = std::list>; explicit EnumType(const EnumType* e); explicit EnumType(const std::string& arg_name); @@ -781,15 +781,15 @@ public: // The value of this name is set to val. Once a value has been // explicitly assigned using this method, no further names can be // added that aren't likewise explicitly initalized. - void AddName(const std::string& module_name, const char* name, bro_int_t val, bool is_export, + void AddName(const std::string& module_name, const char* name, zeek_int_t val, bool is_export, detail::Expr* deprecation = nullptr, bool from_redef = false); // -1 indicates not found. Second version is for full names // that already incorporate the module. - bro_int_t Lookup(const std::string& module_name, const char* name) const; - bro_int_t Lookup(const std::string& full_name) const; + zeek_int_t Lookup(const std::string& module_name, const char* name) const; + zeek_int_t Lookup(const std::string& full_name) const; - const char* Lookup(bro_int_t value) const; // Returns 0 if not found + const char* Lookup(zeek_int_t value) const; // Returns 0 if not found // Returns the list of defined names with their values. The names // will be fully qualified with their module name. @@ -799,30 +799,30 @@ public: void DescribeReST(ODesc* d, bool roles_only = false) const override; - const EnumValPtr& GetEnumVal(bro_int_t i); + const EnumValPtr& GetEnumVal(zeek_int_t i); // Only for use by C++-generated code. Non-protected because we // don't know in advance the names of the functions that will // access it. - void AddNameInternal(const std::string& full_name, bro_int_t val); + void AddNameInternal(const std::string& full_name, zeek_int_t val); protected: - void AddNameInternal(const std::string& module_name, const char* name, bro_int_t val, + void AddNameInternal(const std::string& module_name, const char* name, zeek_int_t val, bool is_export); - void CheckAndAddName(const std::string& module_name, const char* name, bro_int_t val, + void CheckAndAddName(const std::string& module_name, const char* name, zeek_int_t val, bool is_export, detail::Expr* deprecation = nullptr, bool from_redef = false); void DoDescribe(ODesc* d) const override; - using NameMap = std::map; + using NameMap = std::map; NameMap names; // Whether any of the elements of the enum were added via redef's. bool has_redefs = false; - using ValMap = std::unordered_map; + using ValMap = std::unordered_map; ValMap vals; // The counter is initialized to 0 and incremented on every implicit @@ -831,7 +831,7 @@ protected: // specified, the counter is set to -1. This way counter can be used // as a flag to prevent mixing of auto-increment and explicit // enumerator specifications. - bro_int_t counter; + zeek_int_t counter; }; class VectorType final : public Type diff --git a/src/UID.cc b/src/UID.cc index bc0ddd0bc2..43a7d38c1a 100644 --- a/src/UID.cc +++ b/src/UID.cc @@ -12,15 +12,15 @@ using namespace std; namespace zeek { -void UID::Set(bro_uint_t bits, const uint64_t* v, size_t n) +void UID::Set(zeek_uint_t bits, const uint64_t* v, size_t n) { initialized = true; - for ( size_t i = 0; i < BRO_UID_LEN; ++i ) + for ( size_t i = 0; i < UID_LEN; ++i ) uid[i] = 0; - if ( bits > BRO_UID_LEN * 64 ) - bits = BRO_UID_LEN * 64; + if ( bits > UID_LEN * 64 ) + bits = UID_LEN * 64; div_t res = div(bits, 64); size_t size = res.rem ? res.quot + 1 : res.quot; @@ -38,7 +38,7 @@ std::string UID::Base62(std::string prefix) const reporter->InternalError("use of uninitialized UID"); char tmp[sizeof(uid) * 8 + 1]; // enough for even binary representation - for ( size_t i = 0; i < BRO_UID_LEN; ++i ) + for ( size_t i = 0; i < UID_LEN; ++i ) prefix.append(util::uitoa_n(uid[i], tmp, sizeof(tmp), 62)); return prefix; diff --git a/src/UID.h b/src/UID.h index 25fdb1ba73..326d568f9f 100644 --- a/src/UID.h +++ b/src/UID.h @@ -5,13 +5,13 @@ #include #include -#include "zeek/util.h" // for bro_int_t - -#define BRO_UID_LEN 2 +#include "zeek/util.h" // for zeek_int_t namespace zeek { +constexpr int UID_LEN = 2; + /** * A class for creating/managing UIDs of arbitrary bit-length and converting * them to human-readable strings in Base62 format. @@ -28,7 +28,7 @@ public: * Construct a UID of a given bit-length, optionally from given values. * @see UID::Set */ - explicit UID(bro_uint_t bits, const uint64_t* v = nullptr, size_t n = 0) { Set(bits, v, n); } + explicit UID(zeek_uint_t bits, const uint64_t* v = nullptr, size_t n = 0) { Set(bits, v, n); } /** * Copy constructor. @@ -38,7 +38,7 @@ public: /** * Initialize a UID of a given bit-length, optionally from given values. * @param bits The desired length in bits of the UID, up to a max of - * BRO_UID_LEN * 64. + * UID_LEN * 64. * @param v A pointer to an array of values with which to initialize the * UID. If empty or doesn't contain enough values to satisfy * \a bits, then values are automatically generated using @@ -46,7 +46,7 @@ public: * 64, then a value is truncated to bit in desired bit-length. * @param n number of 64-bit elements in array pointed to by \a v. */ - void Set(bro_uint_t bits, const uint64_t* v = nullptr, size_t n = 0); + void Set(zeek_uint_t bits, const uint64_t* v = nullptr, size_t n = 0); /** * Returns a base62 (characters 0-9, A-Z, a-z) representation of the UID. @@ -80,7 +80,7 @@ public: friend bool operator!=(const UID& u1, const UID& u2) { return ! (u1 == u2); } private: - uint64_t uid[BRO_UID_LEN]; + uint64_t uid[UID_LEN]; bool initialized; // Since technically uid == 0 is a legit UID }; @@ -98,3 +98,5 @@ inline UID& UID::operator=(const UID& other) } } // namespace zeek + +constexpr int BRO_UID_LEN [[deprecated("Remove in v6.1. Use zeek::UID_LEN")]] = zeek::UID_LEN; diff --git a/src/Val.cc b/src/Val.cc index e50932b807..faf2c2ea5f 100644 --- a/src/Val.cc +++ b/src/Val.cc @@ -160,20 +160,20 @@ bool Val::IsOne() const } } -bro_int_t Val::InternalInt() const +zeek_int_t Val::InternalInt() const { if ( type->InternalType() == TYPE_INTERNAL_INT ) return AsInt(); else if ( type->InternalType() == TYPE_INTERNAL_UNSIGNED ) // ### should check here for overflow - return static_cast(AsCount()); + return static_cast(AsCount()); else InternalWarning("bad request for InternalInt"); return 0; } -bro_uint_t Val::InternalUnsigned() const +zeek_uint_t Val::InternalUnsigned() const { if ( type->InternalType() == TYPE_INTERNAL_UNSIGNED ) return AsCount(); @@ -193,28 +193,28 @@ double Val::InternalDouble() const return 0.0; } -bro_int_t Val::CoerceToInt() const +zeek_int_t Val::CoerceToInt() const { if ( type->InternalType() == TYPE_INTERNAL_INT ) return AsInt(); else if ( type->InternalType() == TYPE_INTERNAL_UNSIGNED ) - return static_cast(AsCount()); + return static_cast(AsCount()); else if ( type->InternalType() == TYPE_INTERNAL_DOUBLE ) - return static_cast(AsDouble()); + return static_cast(AsDouble()); else InternalWarning("bad request for CoerceToInt"); return 0; } -bro_uint_t Val::CoerceToUnsigned() const +zeek_uint_t Val::CoerceToUnsigned() const { if ( type->InternalType() == TYPE_INTERNAL_UNSIGNED ) return AsCount(); else if ( type->InternalType() == TYPE_INTERNAL_INT ) - return static_cast(AsInt()); + return static_cast(AsInt()); else if ( type->InternalType() == TYPE_INTERNAL_DOUBLE ) - return static_cast(AsDouble()); + return static_cast(AsDouble()); else InternalWarning("bad request for CoerceToUnsigned"); @@ -722,7 +722,7 @@ uint32_t PortVal::Mask(uint32_t port_num, TransportProto port_type) return port_num; } -PortVal::PortVal(uint32_t p) : UnsignedValImplementation(base_type(TYPE_PORT), bro_uint_t(p)) { } +PortVal::PortVal(uint32_t p) : UnsignedValImplementation(base_type(TYPE_PORT), zeek_uint_t(p)) { } uint32_t PortVal::Port() const { @@ -3911,12 +3911,12 @@ ValPtr Val::MakeBool(bool b) return make_intrusive(b); } -ValPtr Val::MakeInt(bro_int_t i) +ValPtr Val::MakeInt(zeek_int_t i) { return make_intrusive(i); } -ValPtr Val::MakeCount(bro_uint_t u) +ValPtr Val::MakeCount(zeek_uint_t u) { return make_intrusive(u); } diff --git a/src/Val.h b/src/Val.h index 8a01be9924..d66df55797 100644 --- a/src/Val.h +++ b/src/Val.h @@ -112,12 +112,12 @@ public: bool IsZero() const; bool IsOne() const; - bro_int_t InternalInt() const; - bro_uint_t InternalUnsigned() const; + zeek_int_t InternalInt() const; + zeek_uint_t InternalUnsigned() const; double InternalDouble() const; - bro_int_t CoerceToInt() const; - bro_uint_t CoerceToUnsigned() const; + zeek_int_t CoerceToInt() const; + zeek_uint_t CoerceToUnsigned() const; double CoerceToDouble() const; // Returns a new Val with the "size" of this Val. What constitutes @@ -153,10 +153,10 @@ public: #define UNDERLYING_ACCESSOR_DECL(ztype, ctype, name) ctype name() const; - UNDERLYING_ACCESSOR_DECL(detail::IntValImplementation, bro_int_t, AsInt) + UNDERLYING_ACCESSOR_DECL(detail::IntValImplementation, zeek_int_t, AsInt) UNDERLYING_ACCESSOR_DECL(BoolVal, bool, AsBool) UNDERLYING_ACCESSOR_DECL(EnumVal, int, AsEnum) - UNDERLYING_ACCESSOR_DECL(detail::UnsignedValImplementation, bro_uint_t, AsCount) + UNDERLYING_ACCESSOR_DECL(detail::UnsignedValImplementation, zeek_uint_t, AsCount) UNDERLYING_ACCESSOR_DECL(detail::DoubleValImplementation, double, AsDouble) UNDERLYING_ACCESSOR_DECL(TimeVal, double, AsTime) UNDERLYING_ACCESSOR_DECL(IntervalVal, double, AsInterval) @@ -251,8 +251,8 @@ protected: virtual void ValDescribeReST(ODesc* d) const; static ValPtr MakeBool(bool b); - static ValPtr MakeInt(bro_int_t i); - static ValPtr MakeCount(bro_uint_t u); + static ValPtr MakeInt(zeek_int_t i); + static ValPtr MakeCount(zeek_uint_t u); explicit Val(TypePtr t) noexcept : type(std::move(t)) { } @@ -298,11 +298,11 @@ protected: class ValManager { public: - static constexpr bro_uint_t PREALLOCATED_COUNTS = 4096; - static constexpr bro_uint_t PREALLOCATED_INTS = 512; - static constexpr bro_int_t PREALLOCATED_INT_LOWEST = -255; - static constexpr bro_int_t PREALLOCATED_INT_HIGHEST = PREALLOCATED_INT_LOWEST + - PREALLOCATED_INTS - 1; + static constexpr zeek_uint_t PREALLOCATED_COUNTS = 4096; + static constexpr zeek_uint_t PREALLOCATED_INTS = 512; + static constexpr zeek_int_t PREALLOCATED_INT_LOWEST = -255; + static constexpr zeek_int_t PREALLOCATED_INT_HIGHEST = PREALLOCATED_INT_LOWEST + + PREALLOCATED_INTS - 1; ValManager(); @@ -353,23 +353,23 @@ namespace detail class IntValImplementation : public Val { public: - IntValImplementation(TypePtr t, bro_int_t v) : Val(std::move(t)), int_val(v) { } + IntValImplementation(TypePtr t, zeek_int_t v) : Val(std::move(t)), int_val(v) { } - bro_int_t Get() const { return int_val; } + zeek_int_t Get() const { return int_val; } protected: - bro_int_t int_val; + zeek_int_t int_val; }; class UnsignedValImplementation : public Val { public: - UnsignedValImplementation(TypePtr t, bro_uint_t v) : Val(std::move(t)), uint_val(v) { } + UnsignedValImplementation(TypePtr t, zeek_uint_t v) : Val(std::move(t)), uint_val(v) { } - bro_uint_t Get() const { return uint_val; } + zeek_uint_t Get() const { return uint_val; } protected: - bro_uint_t uint_val; + zeek_uint_t uint_val; }; class DoubleValImplementation : public Val @@ -388,7 +388,7 @@ protected: class IntVal final : public detail::IntValImplementation { public: - IntVal(bro_int_t v) : detail::IntValImplementation(base_type(TYPE_INT), v) { } + IntVal(zeek_int_t v) : detail::IntValImplementation(base_type(TYPE_INT), v) { } // No Get() method since in the current implementation the // inherited one serves that role. @@ -397,7 +397,7 @@ public: class BoolVal final : public detail::IntValImplementation { public: - BoolVal(bro_int_t v) : detail::IntValImplementation(base_type(TYPE_BOOL), v) { } + BoolVal(zeek_int_t v) : detail::IntValImplementation(base_type(TYPE_BOOL), v) { } bool Get() const { return static_cast(int_val); } }; @@ -405,7 +405,7 @@ public: class CountVal : public detail::UnsignedValImplementation { public: - CountVal(bro_uint_t v) : detail::UnsignedValImplementation(base_type(TYPE_COUNT), v) { } + CountVal(zeek_uint_t v) : detail::UnsignedValImplementation(base_type(TYPE_COUNT), v) { } // Same as for IntVal: no Get() method needed. }; @@ -1118,13 +1118,13 @@ public: // The following provide efficient record field assignments. void Assign(int field, bool new_val) { - (*record_val)[field] = ZVal(bro_int_t(new_val)); + (*record_val)[field] = ZVal(zeek_int_t(new_val)); AddedField(field); } void Assign(int field, int new_val) { - (*record_val)[field] = ZVal(bro_int_t(new_val)); + (*record_val)[field] = ZVal(zeek_int_t(new_val)); AddedField(field); } @@ -1133,12 +1133,12 @@ public: // than the other. void Assign(int field, uint32_t new_val) { - (*record_val)[field] = ZVal(bro_uint_t(new_val)); + (*record_val)[field] = ZVal(zeek_uint_t(new_val)); AddedField(field); } void Assign(int field, uint64_t new_val) { - (*record_val)[field] = ZVal(bro_uint_t(new_val)); + (*record_val)[field] = ZVal(zeek_uint_t(new_val)); AddedField(field); } @@ -1469,7 +1469,7 @@ protected: template friend IntrusivePtr make_intrusive(Ts&&... args); - EnumVal(EnumTypePtr t, bro_int_t i) : detail::IntValImplementation(std::move(t), i) { } + EnumVal(EnumTypePtr t, zeek_int_t i) : detail::IntValImplementation(std::move(t), i) { } void ValDescribe(ODesc* d) const override; ValPtr DoClone(CloneState* state) override; @@ -1607,8 +1607,8 @@ public: * @param index The position in the vector of the element to return. * @return The element's underlying value. */ - bro_int_t IntAt(unsigned int index) const { return (*vector_val)[index]->int_val; } - bro_uint_t CountAt(unsigned int index) const { return (*vector_val)[index]->uint_val; } + zeek_int_t IntAt(unsigned int index) const { return (*vector_val)[index]->int_val; } + zeek_uint_t CountAt(unsigned int index) const { return (*vector_val)[index]->uint_val; } double DoubleAt(unsigned int index) const { return (*vector_val)[index]->double_val; } const RecordVal* RecordValAt(unsigned int index) const { @@ -1689,10 +1689,10 @@ private: #define UNDERLYING_ACCESSOR_DEF(ztype, ctype, name) \ inline ctype Val::name() const { return static_cast(this)->Get(); } -UNDERLYING_ACCESSOR_DEF(detail::IntValImplementation, bro_int_t, AsInt) +UNDERLYING_ACCESSOR_DEF(detail::IntValImplementation, zeek_int_t, AsInt) UNDERLYING_ACCESSOR_DEF(BoolVal, bool, AsBool) UNDERLYING_ACCESSOR_DEF(EnumVal, int, AsEnum) -UNDERLYING_ACCESSOR_DEF(detail::UnsignedValImplementation, bro_uint_t, AsCount) +UNDERLYING_ACCESSOR_DEF(detail::UnsignedValImplementation, zeek_uint_t, AsCount) UNDERLYING_ACCESSOR_DEF(detail::DoubleValImplementation, double, AsDouble) UNDERLYING_ACCESSOR_DEF(TimeVal, double, AsTime) UNDERLYING_ACCESSOR_DEF(IntervalVal, double, AsInterval) diff --git a/src/ZVal.h b/src/ZVal.h index c8ada1eccd..202659d17b 100644 --- a/src/ZVal.h +++ b/src/ZVal.h @@ -63,8 +63,8 @@ class ZBody; ZVal(const TypePtr& t); // Construct directly. - ZVal(bro_int_t v) { int_val = v; } - ZVal(bro_uint_t v) { uint_val = v; } + ZVal(zeek_int_t v) { int_val = v; } + ZVal(zeek_uint_t v) { uint_val = v; } ZVal(double v) { double_val = v; } ZVal(StringVal* v) { string_val = v; } @@ -96,8 +96,8 @@ class ZBody; // ensure that they're providing the correct type. ValPtr ToVal(const TypePtr& t) const; - bro_int_t AsInt() const { return int_val; } - bro_uint_t AsCount() const { return uint_val; } + zeek_int_t AsInt() const { return int_val; } + zeek_uint_t AsCount() const { return uint_val; } double AsDouble() const { return double_val; } StringVal* AsString() const { return string_val; } @@ -119,8 +119,8 @@ class ZBody; // The following return references that can be used to // populate the ZVal. Handy for compiled ZAM code. - bro_int_t& AsIntRef() { return int_val; } - bro_uint_t& AsCountRef() { return uint_val; } + zeek_int_t& AsIntRef() { return int_val; } + zeek_uint_t& AsCountRef() { return uint_val; } double& AsDoubleRef() { return double_val; } StringVal*& AsStringRef() { return string_val; } AddrVal*& AsAddrRef() { return addr_val; } @@ -168,10 +168,10 @@ private: friend class zeek::detail::ZBody; // Used for bool, int, enum. - bro_int_t int_val; + zeek_int_t int_val; // Used for count and port. - bro_uint_t uint_val; + zeek_uint_t uint_val; // Used for double, time, interval. double double_val; diff --git a/src/analyzer/protocol/bittorrent/BitTorrentTracker.cc b/src/analyzer/protocol/bittorrent/BitTorrentTracker.cc index 09f86a54fa..a929a41317 100644 --- a/src/analyzer/protocol/bittorrent/BitTorrentTracker.cc +++ b/src/analyzer/protocol/bittorrent/BitTorrentTracker.cc @@ -490,7 +490,7 @@ void BitTorrentTracker_Analyzer::ResponseBenc(int name_len, char* name, detail:: } void BitTorrentTracker_Analyzer::ResponseBenc(int name_len, char* name, detail::BTT_BencTypes type, - bro_int_t value) + zeek_int_t value) { auto benc_value = make_intrusive(bittorrent_benc_value); auto name_ = make_intrusive(name_len, name); diff --git a/src/analyzer/protocol/bittorrent/BitTorrentTracker.h b/src/analyzer/protocol/bittorrent/BitTorrentTracker.h index 3b57d1461e..26cdcb09d2 100644 --- a/src/analyzer/protocol/bittorrent/BitTorrentTracker.h +++ b/src/analyzer/protocol/bittorrent/BitTorrentTracker.h @@ -90,7 +90,7 @@ protected: void ResponseBody(); void ResponseBenc(int name_len, char* name, detail::BTT_BencTypes type, int value_len, char* value); - void ResponseBenc(int name_len, char* name, detail::BTT_BencTypes type, bro_int_t value); + void ResponseBenc(int name_len, char* name, detail::BTT_BencTypes type, zeek_int_t value); int ResponseParseBenc(); void EmitResponse(); @@ -113,7 +113,7 @@ protected: char res_buf[BTTRACKER_BUF]; char* res_buf_pos; unsigned int res_buf_len; - bro_uint_t res_status; + zeek_uint_t res_status; TableVal* res_val_headers; TableVal* res_val_peers; TableVal* res_val_benc; @@ -135,7 +135,7 @@ protected: unsigned int benc_str_have; char* benc_int; - bro_int_t benc_int_val; + zeek_int_t benc_int_val; // True on protocol violation. bool stop_orig, stop_resp; diff --git a/src/analyzer/protocol/krb/KRB.cc b/src/analyzer/protocol/krb/KRB.cc index fcfb248ac9..16240642e7 100644 --- a/src/analyzer/protocol/krb/KRB.cc +++ b/src/analyzer/protocol/krb/KRB.cc @@ -88,7 +88,7 @@ void KRB_Analyzer::DeliverPacket(int len, const u_char* data, bool orig, uint64_ } StringValPtr KRB_Analyzer::GetAuthenticationInfo(const String* principal, const String* ciphertext, - const bro_uint_t enctype) + const zeek_uint_t enctype) { #ifdef USE_KRB5 if ( ! krb_available ) diff --git a/src/analyzer/protocol/krb/KRB.h b/src/analyzer/protocol/krb/KRB.h index 9dad969595..eb6b6f18e8 100644 --- a/src/analyzer/protocol/krb/KRB.h +++ b/src/analyzer/protocol/krb/KRB.h @@ -29,7 +29,7 @@ public: static analyzer::Analyzer* Instantiate(Connection* conn) { return new KRB_Analyzer(conn); } StringValPtr GetAuthenticationInfo(const String* principal, const String* ciphertext, - const bro_uint_t enctype); + const zeek_uint_t enctype); protected: binpac::KRB::KRB_Conn* interp; diff --git a/src/analyzer/protocol/krb/KRB_TCP.h b/src/analyzer/protocol/krb/KRB_TCP.h index ef144ed98c..ccb541fb48 100644 --- a/src/analyzer/protocol/krb/KRB_TCP.h +++ b/src/analyzer/protocol/krb/KRB_TCP.h @@ -24,7 +24,7 @@ public: void EndpointEOF(bool is_orig) override; StringValPtr GetAuthenticationInfo(const String* principal, const String* ciphertext, - const bro_uint_t enctype) + const zeek_uint_t enctype) { return val_mgr->EmptyString(); } diff --git a/src/analyzer/protocol/rpc/NFS.cc b/src/analyzer/protocol/rpc/NFS.cc index 89ea8834d2..e4432c93b8 100644 --- a/src/analyzer/protocol/rpc/NFS.cc +++ b/src/analyzer/protocol/rpc/NFS.cc @@ -177,7 +177,7 @@ bool NFS_Interp::RPC_BuildReply(RPC_CallInfo* c, BifEnum::rpc_status rpc_status, break; case BifEnum::NFS3::PROC_READ: - bro_uint_t offset; + zeek_uint_t offset; offset = c->RequestVal()->AsRecordVal()->GetFieldAs(1); reply = nfs3_read_reply(buf, n, nfs_status, offset); event = nfs_proc_read; @@ -546,7 +546,7 @@ RecordValPtr NFS_Interp::nfs3_readargs(const u_char*& buf, int& n) } RecordValPtr NFS_Interp::nfs3_read_reply(const u_char*& buf, int& n, BifEnum::NFS3::status_t status, - bro_uint_t offset) + zeek_uint_t offset) { auto rep = make_intrusive(BifType::Record::NFS3::read_reply_t); diff --git a/src/analyzer/protocol/rpc/NFS.h b/src/analyzer/protocol/rpc/NFS.h index 3518a6c74e..571fc04148 100644 --- a/src/analyzer/protocol/rpc/NFS.h +++ b/src/analyzer/protocol/rpc/NFS.h @@ -53,7 +53,7 @@ protected: RecordValPtr nfs3_lookup_reply(const u_char*& buf, int& n, BifEnum::NFS3::status_t status); RecordValPtr nfs3_readargs(const u_char*& buf, int& n); RecordValPtr nfs3_read_reply(const u_char*& buf, int& n, BifEnum::NFS3::status_t status, - bro_uint_t offset); + zeek_uint_t offset); RecordValPtr nfs3_readlink_reply(const u_char*& buf, int& n, BifEnum::NFS3::status_t status); RecordValPtr nfs3_link_reply(const u_char*& buf, int& n, BifEnum::NFS3::status_t status); RecordValPtr nfs3_writeargs(const u_char*& buf, int& n); diff --git a/src/input/Manager.cc b/src/input/Manager.cc index 9e93314f5f..0a801d2424 100644 --- a/src/input/Manager.cc +++ b/src/input/Manager.cc @@ -2414,7 +2414,7 @@ Val* Manager::ValueToVal(const Stream* i, const Value* val, Type* request_type, // Well, this is kind of stupid, because EnumType just // mangles the module name and the var name together again... // but well. - bro_int_t index = request_type->AsEnumType()->Lookup(module, var.c_str()); + zeek_int_t index = request_type->AsEnumType()->Lookup(module, var.c_str()); if ( index == -1 ) { Warning(i, "Value '%s' for stream '%s' is not a valid enum.", enum_string.c_str(), diff --git a/src/logging/Manager.cc b/src/logging/Manager.cc index 4b1fb07b59..1947828449 100644 --- a/src/logging/Manager.cc +++ b/src/logging/Manager.cc @@ -1041,7 +1041,7 @@ threading::Value* Manager::ValToLogVal(Val* val, Type* ty) lval->val.set_val.size = set->Length(); lval->val.set_val.vals = new threading::Value*[lval->val.set_val.size]; - for ( bro_int_t i = 0; i < lval->val.set_val.size; i++ ) + for ( zeek_int_t i = 0; i < lval->val.set_val.size; i++ ) lval->val.set_val.vals[i] = ValToLogVal(set->Idx(i).get()); break; @@ -1053,7 +1053,7 @@ threading::Value* Manager::ValToLogVal(Val* val, Type* ty) lval->val.vector_val.size = vec->Size(); lval->val.vector_val.vals = new threading::Value*[lval->val.vector_val.size]; - for ( bro_int_t i = 0; i < lval->val.vector_val.size; i++ ) + for ( zeek_int_t i = 0; i < lval->val.vector_val.size; i++ ) { lval->val.vector_val.vals[i] = ValToLogVal(vec->ValAt(i).get(), vec->GetType()->Yield().get()); diff --git a/src/logging/writers/sqlite/SQLite.cc b/src/logging/writers/sqlite/SQLite.cc index 95bf5d4a6a..f92c3f6e74 100644 --- a/src/logging/writers/sqlite/SQLite.cc +++ b/src/logging/writers/sqlite/SQLite.cc @@ -296,7 +296,7 @@ int SQLite::AddParams(Value* val, int pos) if ( ! val->val.set_val.size ) desc.Add(empty_field); else - for ( bro_int_t j = 0; j < val->val.set_val.size; j++ ) + for ( zeek_int_t j = 0; j < val->val.set_val.size; j++ ) { if ( j > 0 ) desc.AddRaw(set_separator); @@ -319,7 +319,7 @@ int SQLite::AddParams(Value* val, int pos) if ( ! val->val.vector_val.size ) desc.Add(empty_field); else - for ( bro_int_t j = 0; j < val->val.vector_val.size; j++ ) + for ( zeek_int_t j = 0; j < val->val.vector_val.size; j++ ) { if ( j > 0 ) desc.AddRaw(set_separator); diff --git a/src/packet_analysis/protocol/ip/IPBasedAnalyzer.cc b/src/packet_analysis/protocol/ip/IPBasedAnalyzer.cc index 6e83984ae7..6cbbae649f 100644 --- a/src/packet_analysis/protocol/ip/IPBasedAnalyzer.cc +++ b/src/packet_analysis/protocol/ip/IPBasedAnalyzer.cc @@ -139,7 +139,7 @@ bool IPBasedAnalyzer::CheckHeaderTrunc(size_t min_hdr_len, size_t remaining, Pac bool IPBasedAnalyzer::IsLikelyServerPort(uint32_t port) const { // We keep a cached in-core version of the table to speed up the lookup. - static std::set port_cache; + static std::set port_cache; static bool have_cache = false; if ( ! have_cache ) diff --git a/src/packet_analysis/protocol/skip/Skip.h b/src/packet_analysis/protocol/skip/Skip.h index ef885fec87..1a280ccd60 100644 --- a/src/packet_analysis/protocol/skip/Skip.h +++ b/src/packet_analysis/protocol/skip/Skip.h @@ -23,7 +23,7 @@ public: } private: - bro_uint_t skip_bytes = 0; + zeek_uint_t skip_bytes = 0; }; } diff --git a/src/packet_analysis/protocol/tcp/TCPSessionAdapter.cc b/src/packet_analysis/protocol/tcp/TCPSessionAdapter.cc index d0f4e6cb21..a8f28725cc 100644 --- a/src/packet_analysis/protocol/tcp/TCPSessionAdapter.cc +++ b/src/packet_analysis/protocol/tcp/TCPSessionAdapter.cc @@ -429,7 +429,7 @@ static zeek::RecordValPtr build_syn_packet_val(bool is_orig, const zeek::IP_Hdr* } static void init_window(analyzer::tcp::TCP_Endpoint* endpoint, analyzer::tcp::TCP_Endpoint* peer, - analyzer::tcp::TCP_Flags flags, bro_int_t scale, uint32_t base_seq, + analyzer::tcp::TCP_Flags flags, zeek_int_t scale, uint32_t base_seq, uint32_t ack_seq) { // ### In the following, we could be fooled by an diff --git a/src/packet_analysis/protocol/udp/UDPSessionAdapter.cc b/src/packet_analysis/protocol/udp/UDPSessionAdapter.cc index 99a798fe78..6f460c527e 100644 --- a/src/packet_analysis/protocol/udp/UDPSessionAdapter.cc +++ b/src/packet_analysis/protocol/udp/UDPSessionAdapter.cc @@ -38,7 +38,7 @@ void UDPSessionAdapter::UpdateConnVal(RecordVal* conn_val) void UDPSessionAdapter::UpdateEndpointVal(const ValPtr& endp_arg, bool is_orig) { - bro_int_t size = is_orig ? request_len : reply_len; + zeek_int_t size = is_orig ? request_len : reply_len; auto endp = endp_arg->AsRecordVal(); if ( size < 0 ) diff --git a/src/packet_analysis/protocol/udp/UDPSessionAdapter.h b/src/packet_analysis/protocol/udp/UDPSessionAdapter.h index a3cfcaa172..ed31d9ea4e 100644 --- a/src/packet_analysis/protocol/udp/UDPSessionAdapter.h +++ b/src/packet_analysis/protocol/udp/UDPSessionAdapter.h @@ -30,8 +30,8 @@ private: void UpdateEndpointVal(const ValPtr& endp_arg, bool is_orig); void ChecksumEvent(bool is_orig, uint32_t threshold); - bro_int_t request_len = -1; - bro_int_t reply_len = -1; + zeek_int_t request_len = -1; + zeek_int_t reply_len = -1; }; } // namespace zeek::packet_analysis::UDP diff --git a/src/scan.l b/src/scan.l index 6b4b10fde6..ad9350f768 100644 --- a/src/scan.l +++ b/src/scan.l @@ -467,7 +467,7 @@ F RET_CONST(zeek::val_mgr->False()->Ref()) } {D} { - RET_CONST(zeek::val_mgr->Count(static_cast(strtoull(yytext, (char**) NULL, 10))).release()) + RET_CONST(zeek::val_mgr->Count(static_cast(strtoull(yytext, (char**) NULL, 10))).release()) } {FLOAT} RET_CONST(new zeek::DoubleVal(atof(yytext))) @@ -515,7 +515,7 @@ F RET_CONST(zeek::val_mgr->False()->Ref()) {FLOAT}{OWS}msec(s?) RET_CONST(new zeek::IntervalVal(atof(yytext),Milliseconds)) {FLOAT}{OWS}usec(s?) RET_CONST(new zeek::IntervalVal(atof(yytext),Microseconds)) -"0x"{HEX}+ RET_CONST(zeek::val_mgr->Count(static_cast(strtoull(yytext, 0, 16))).release()) +"0x"{HEX}+ RET_CONST(zeek::val_mgr->Count(static_cast(strtoull(yytext, 0, 16))).release()) ({H}".")+{HTLD} RET_CONST(zeek::detail::dns_mgr->LookupHost(yytext).release()) diff --git a/src/script_opt/CPP/Compile.h b/src/script_opt/CPP/Compile.h index 01f5923bfd..2862bb0eff 100644 --- a/src/script_opt/CPP/Compile.h +++ b/src/script_opt/CPP/Compile.h @@ -32,7 +32,7 @@ // find optimization opportunities, including inlining. // // For some Zeek scripting types, we use their natural C++ counterparts, -// such as "bro_uint_t" for "count" values. In the source code these +// such as "zeek_uint_t" for "count" values. In the source code these // are referred to as "native" types. Other types, like tables, keep // their interpreter-equivalent type (e.g., TableVal). These are dealt // with almost entirely using IntrusivePtr's. The few exceptions (i.e., @@ -899,7 +899,7 @@ private: // // "Native" types are those Zeek scripting types that we support - // using low-level C++ types (like "bro_uint_t" for "count"). + // using low-level C++ types (like "zeek_uint_t" for "count"). // Types that we instead support using some form of ValPtr // representation are "non-native". bool IsNativeType(const TypePtr& t) const; diff --git a/src/script_opt/CPP/Driver.cc b/src/script_opt/CPP/Driver.cc index 9f70c84d66..9faceac98c 100644 --- a/src/script_opt/CPP/Driver.cc +++ b/src/script_opt/CPP/Driver.cc @@ -216,8 +216,8 @@ void CPPCompile::GenProlog() NL(); const_info[TYPE_BOOL] = CreateConstInitInfo("Bool", "ValPtr", "bool"); - const_info[TYPE_INT] = CreateConstInitInfo("Int", "ValPtr", "bro_int_t"); - const_info[TYPE_COUNT] = CreateConstInitInfo("Count", "ValPtr", "bro_uint_t"); + const_info[TYPE_INT] = CreateConstInitInfo("Int", "ValPtr", "zeek_int_t"); + const_info[TYPE_COUNT] = CreateConstInitInfo("Count", "ValPtr", "zeek_uint_t"); const_info[TYPE_DOUBLE] = CreateConstInitInfo("Double", "ValPtr", "double"); const_info[TYPE_TIME] = CreateConstInitInfo("Time", "ValPtr", "double"); const_info[TYPE_INTERVAL] = CreateConstInitInfo("Interval", "ValPtr", "double"); diff --git a/src/script_opt/CPP/Exprs.cc b/src/script_opt/CPP/Exprs.cc index 58120b7cd7..6c0912d2db 100644 --- a/src/script_opt/CPP/Exprs.cc +++ b/src/script_opt/CPP/Exprs.cc @@ -666,10 +666,10 @@ string CPPCompile::GenArithCoerceExpr(const Expr* e, GenType gt) switch ( t->InternalType() ) { case TYPE_INTERNAL_INT: - cast_name = "bro_int_t"; + cast_name = "zeek_int_t"; break; case TYPE_INTERNAL_UNSIGNED: - cast_name = "bro_uint_t"; + cast_name = "zeek_uint_t"; break; case TYPE_INTERNAL_DOUBLE: cast_name = "double"; diff --git a/src/script_opt/CPP/InitsInfo.h b/src/script_opt/CPP/InitsInfo.h index b8453b8135..56a4e2a902 100644 --- a/src/script_opt/CPP/InitsInfo.h +++ b/src/script_opt/CPP/InitsInfo.h @@ -392,7 +392,7 @@ public: } private: - bro_uint_t p; + zeek_uint_t p; }; // Abstract class for compound items (those defined in terms of other items). diff --git a/src/script_opt/CPP/RuntimeOps.h b/src/script_opt/CPP/RuntimeOps.h index d4d8ba2034..8c04e214bf 100644 --- a/src/script_opt/CPP/RuntimeOps.h +++ b/src/script_opt/CPP/RuntimeOps.h @@ -195,7 +195,7 @@ inline PatternValPtr re_append__CPP(const PatternValPtr& p1, const PatternValPtr extern ValPtr schedule__CPP(double dt, EventHandlerPtr event, std::vector args); // Simple helper functions for supporting absolute value. -inline bro_uint_t iabs__CPP(bro_int_t v) +inline zeek_uint_t iabs__CPP(zeek_int_t v) { return v < 0 ? -v : v; } @@ -207,28 +207,28 @@ inline double fabs__CPP(double v) // The following operations are provided using functions to support // error checking/reporting. -inline bro_int_t idiv__CPP(bro_int_t v1, bro_int_t v2) +inline zeek_int_t idiv__CPP(zeek_int_t v1, zeek_int_t v2) { if ( v2 == 0 ) reporter->CPPRuntimeError("division by zero"); return v1 / v2; } -inline bro_int_t imod__CPP(bro_int_t v1, bro_int_t v2) +inline zeek_int_t imod__CPP(zeek_int_t v1, zeek_int_t v2) { if ( v2 == 0 ) reporter->CPPRuntimeError("modulo by zero"); return v1 % v2; } -inline bro_uint_t udiv__CPP(bro_uint_t v1, bro_uint_t v2) +inline zeek_uint_t udiv__CPP(zeek_uint_t v1, zeek_uint_t v2) { if ( v2 == 0 ) reporter->CPPRuntimeError("division by zero"); return v1 / v2; } -inline bro_uint_t umod__CPP(bro_uint_t v1, bro_uint_t v2) +inline zeek_uint_t umod__CPP(zeek_uint_t v1, zeek_uint_t v2) { if ( v2 == 0 ) reporter->CPPRuntimeError("modulo by zero"); diff --git a/src/script_opt/CPP/RuntimeVec.h b/src/script_opt/CPP/RuntimeVec.h index 41be84c55f..78c809e535 100644 --- a/src/script_opt/CPP/RuntimeVec.h +++ b/src/script_opt/CPP/RuntimeVec.h @@ -83,8 +83,8 @@ extern VectorValPtr vector_select__CPP(const VectorValPtr& v1, VectorValPtr v2, extern VectorValPtr vector_coerce_to__CPP(const VectorValPtr& v, const TypePtr& targ); // Similar coercion, but works for v having perhaps not the correct type. -extern VectorValPtr vec_coerce_to_bro_int_t__CPP(const VectorValPtr& v, TypePtr targ); -extern VectorValPtr vec_coerce_to_bro_uint_t__CPP(const VectorValPtr& v, TypePtr targ); +extern VectorValPtr vec_coerce_to_zeek_int_t__CPP(const VectorValPtr& v, TypePtr targ); +extern VectorValPtr vec_coerce_to_zeek_uint_t__CPP(const VectorValPtr& v, TypePtr targ); extern VectorValPtr vec_coerce_to_double__CPP(const VectorValPtr& v, TypePtr targ); // A dummy function used during code generation for unsupported operations diff --git a/src/script_opt/CPP/Types.cc b/src/script_opt/CPP/Types.cc index 79d667e988..563c083a35 100644 --- a/src/script_opt/CPP/Types.cc +++ b/src/script_opt/CPP/Types.cc @@ -161,17 +161,17 @@ const char* CPPCompile::TypeName(const TypePtr& t) case TYPE_BOOL: return "bool"; case TYPE_COUNT: - return "bro_uint_t"; + return "zeek_uint_t"; case TYPE_DOUBLE: return "double"; case TYPE_ENUM: return "int"; case TYPE_INT: - return "bro_int_t"; + return "zeek_int_t"; case TYPE_INTERVAL: return "double"; case TYPE_PORT: - return "bro_uint_t"; + return "zeek_uint_t"; case TYPE_TIME: return "double"; case TYPE_VOID: diff --git a/src/script_opt/GenIDDefs.h b/src/script_opt/GenIDDefs.h index a18c01928e..29593e458c 100644 --- a/src/script_opt/GenIDDefs.h +++ b/src/script_opt/GenIDDefs.h @@ -99,7 +99,7 @@ private: // unseen confluence regions outer to those, and (2) they // can get quite deep due when inlining, so there are savings // to avoid having to track outer to them. - std::vector barrier_blocks; + std::vector barrier_blocks; // The following is parallel to confluence_blocks except // the front entry tracks identifiers at the outermost diff --git a/src/script_opt/IDOptInfo.cc b/src/script_opt/IDOptInfo.cc index 3ccbe4b483..69718683ab 100644 --- a/src/script_opt/IDOptInfo.cc +++ b/src/script_opt/IDOptInfo.cc @@ -70,7 +70,7 @@ void IDOptInfo::Clear() } void IDOptInfo::DefinedAfter(const Stmt* s, const ExprPtr& e, - const std::vector& conf_blocks, bro_uint_t conf_start) + const std::vector& conf_blocks, zeek_uint_t conf_start) { if ( tracing ) printf("ID %s defined at %d: %s\n", trace_ID, s ? s->GetOptInfo()->stmt_num : NO_DEF, @@ -174,7 +174,7 @@ void IDOptInfo::BranchBackTo(const Stmt* from, const Stmt* to, bool close_all) auto from_reg = ActiveRegion(); auto f_oi = from->GetOptInfo(); auto t_oi = to->GetOptInfo(); - bro_uint_t t_r_ind = FindRegionBeforeIndex(t_oi->stmt_num); + zeek_uint_t t_r_ind = FindRegionBeforeIndex(t_oi->stmt_num); auto& t_r = usage_regions[t_r_ind]; if ( from_reg && from_reg->DefinedAfter() != t_r.DefinedAfter() && diff --git a/src/script_opt/IDOptInfo.h b/src/script_opt/IDOptInfo.h index ada590e2bd..6bf8718a68 100644 --- a/src/script_opt/IDOptInfo.h +++ b/src/script_opt/IDOptInfo.h @@ -144,7 +144,7 @@ public: // It should be processed starting at conf_start (note that // conf_blocks may be empty). void DefinedAfter(const Stmt* s, const ExprPtr& e, const std::vector& conf_blocks, - bro_uint_t conf_start); + zeek_uint_t conf_start); // Called upon encountering a "return" statement. void ReturnAt(const Stmt* s); diff --git a/src/script_opt/ZAM/AM-Opt.cc b/src/script_opt/ZAM/AM-Opt.cc index 461c02f6fb..6b6131fd7d 100644 --- a/src/script_opt/ZAM/AM-Opt.cc +++ b/src/script_opt/ZAM/AM-Opt.cc @@ -478,7 +478,7 @@ void ZAMCompiler::ReMapFrame() frame1_to_frame2.resize(frame_layout1.size(), -1); managed_slotsI.clear(); - for ( bro_uint_t i = 0; i < insts1.size(); ++i ) + for ( zeek_uint_t i = 0; i < insts1.size(); ++i ) { auto inst = insts1[i]; @@ -655,7 +655,7 @@ void ZAMCompiler::ReMapInterpreterFrame() remapped_intrp_frame_sizes[func] = next_interp_slot; } -void ZAMCompiler::ReMapVar(const ID* id, int slot, bro_uint_t inst) +void ZAMCompiler::ReMapVar(const ID* id, int slot, zeek_uint_t inst) { // A greedy algorithm for this is to simply find the first suitable // frame slot. We do that with one twist: we also look for a @@ -731,7 +731,7 @@ void ZAMCompiler::ReMapVar(const ID* id, int slot, bro_uint_t inst) void ZAMCompiler::CheckSlotAssignment(int slot, const ZInstI* inst) { - ASSERT(slot >= 0 && static_cast(slot) < frame_denizens.size()); + ASSERT(slot >= 0 && static_cast(slot) < frame_denizens.size()); // We construct temporaries such that their values are never used // earlier than their definitions in loop bodies. For other @@ -770,7 +770,7 @@ void ZAMCompiler::CheckSlotUse(int slot, const ZInstI* inst) if ( slot < 0 ) return; - ASSERT(static_cast(slot) < frame_denizens.size()); + ASSERT(static_cast(slot) < frame_denizens.size()); if ( denizen_beginning.count(slot) == 0 ) { @@ -957,9 +957,9 @@ ZInstI* ZAMCompiler::FirstLiveInst(ZInstI* i, bool follow_gotos) return nullptr; } -bro_uint_t ZAMCompiler::FirstLiveInst(bro_uint_t i, bool follow_gotos) +zeek_uint_t ZAMCompiler::FirstLiveInst(zeek_uint_t i, bool follow_gotos) { - bro_uint_t num_inspected = 0; + zeek_uint_t num_inspected = 0; while ( i < insts1.size() ) { auto i0 = insts1[i]; @@ -987,7 +987,7 @@ bro_uint_t ZAMCompiler::FirstLiveInst(bro_uint_t i, bool follow_gotos) return i; } -void ZAMCompiler::KillInst(bro_uint_t i) +void ZAMCompiler::KillInst(zeek_uint_t i) { auto inst = insts1[i]; @@ -1042,7 +1042,7 @@ void ZAMCompiler::KillInst(bro_uint_t i) } } -void ZAMCompiler::KillInsts(bro_uint_t i) +void ZAMCompiler::KillInsts(zeek_uint_t i) { auto inst = insts1[i]; diff --git a/src/script_opt/ZAM/BuiltIn.cc b/src/script_opt/ZAM/BuiltIn.cc index ac129d1a60..9f78df21d7 100644 --- a/src/script_opt/ZAM/BuiltIn.cc +++ b/src/script_opt/ZAM/BuiltIn.cc @@ -416,11 +416,11 @@ bool ZAMCompiler::BuiltIn_to_lower(const NameExpr* n, const ExprPList& args) return true; } -bro_uint_t ZAMCompiler::ConstArgsMask(const ExprPList& args, int nargs) const +zeek_uint_t ZAMCompiler::ConstArgsMask(const ExprPList& args, int nargs) const { ASSERT(args.length() == nargs); - bro_uint_t mask = 0; + zeek_uint_t mask = 0; for ( int i = 0; i < nargs; ++i ) { diff --git a/src/script_opt/ZAM/Compile.h b/src/script_opt/ZAM/Compile.h index e1d06e128c..071521b6a7 100644 --- a/src/script_opt/ZAM/Compile.h +++ b/src/script_opt/ZAM/Compile.h @@ -76,9 +76,9 @@ public: template const CaseMaps& GetCases() const { - if constexpr ( std::is_same_v ) + if constexpr ( std::is_same_v ) return int_cases; - else if constexpr ( std::is_same_v ) + else if constexpr ( std::is_same_v ) return uint_cases; else if constexpr ( std::is_same_v ) return double_cases; @@ -256,7 +256,7 @@ private: // being the first argument (argument "0" in the list) and the // low-ordered bit being the last. Second parameter is the number // of arguments that should be present. - bro_uint_t ConstArgsMask(const ExprPList& args, int nargs) const; + zeek_uint_t ConstArgsMask(const ExprPList& args, int nargs) const; int ConvertToInt(const Expr* e) { @@ -419,7 +419,7 @@ private: // Computes the remapping for a variable currently in the given slot, // whose scope begins at the given instruction. - void ReMapVar(const ID* id, int slot, bro_uint_t inst); + void ReMapVar(const ID* id, int slot, zeek_uint_t inst); // Look to initialize the beginning of local lifetime based on slot // assignment at instruction inst. @@ -463,7 +463,7 @@ private: // First form returns nil if there's nothing live after i. // Second form returns insts1.size() in that case. ZInstI* FirstLiveInst(ZInstI* i, bool follow_gotos = false); - bro_uint_t FirstLiveInst(bro_uint_t i, bool follow_gotos = false); + zeek_uint_t FirstLiveInst(zeek_uint_t i, bool follow_gotos = false); // Same, but not including i. ZInstI* NextLiveInst(ZInstI* i, bool follow_gotos = false) @@ -482,12 +482,12 @@ private: // into insts1; any labels associated with it are transferred // to its next live successor, if any. void KillInst(ZInstI* i) { KillInst(i->inst_num); } - void KillInst(bro_uint_t i); + void KillInst(zeek_uint_t i); // The same, but kills any successor instructions until finding // one that's labeled. void KillInsts(ZInstI* i) { KillInsts(i->inst_num); } - void KillInsts(bro_uint_t i); + void KillInsts(zeek_uint_t i); // The first of these is used as we compile down to ZInstI's. // The second is the final intermediary code. They're separate @@ -569,8 +569,8 @@ private: // Intermediary switch tables (branching to ZInst's rather // than concrete instruction offsets). - CaseMapsI int_casesI; - CaseMapsI uint_casesI; + CaseMapsI int_casesI; + CaseMapsI uint_casesI; CaseMapsI double_casesI; // Note, we use this not only for strings but for addresses @@ -578,8 +578,8 @@ private: CaseMapsI str_casesI; // Same, but for the concretized versions. - CaseMaps int_cases; - CaseMaps uint_cases; + CaseMaps int_cases; + CaseMaps uint_cases; CaseMaps double_cases; CaseMaps str_cases; diff --git a/src/script_opt/ZAM/Driver.cc b/src/script_opt/ZAM/Driver.cc index b44e094af2..2cf6dd0461 100644 --- a/src/script_opt/ZAM/Driver.cc +++ b/src/script_opt/ZAM/Driver.cc @@ -442,7 +442,7 @@ template void ZAMCompiler::DumpCases(const T& cases, const char* ty std::string case_val; if constexpr ( std::is_same_v ) case_val = m.first; - else if constexpr ( std::is_same_v || std::is_same_v || + else if constexpr ( std::is_same_v || std::is_same_v || std::is_same_v ) case_val = std::to_string(m.first); diff --git a/src/script_opt/ZAM/Expr.cc b/src/script_opt/ZAM/Expr.cc index 5c42e67432..b1039ffcab 100644 --- a/src/script_opt/ZAM/Expr.cc +++ b/src/script_opt/ZAM/Expr.cc @@ -641,7 +641,7 @@ const ZAMStmt ZAMCompiler::CompileIndex(const NameExpr* n1, int n2_slot, const T auto var_ind = ind->Tag() == EXPR_NAME; auto n3 = var_ind ? ind->AsNameExpr() : nullptr; auto c3 = var_ind ? nullptr : ind->AsConstExpr(); - bro_uint_t c = 0; + zeek_uint_t c = 0; if ( ! var_ind ) { diff --git a/src/script_opt/ZAM/IterInfo.h b/src/script_opt/ZAM/IterInfo.h index 2fedf0a023..d94d1f4883 100644 --- a/src/script_opt/ZAM/IterInfo.h +++ b/src/script_opt/ZAM/IterInfo.h @@ -126,8 +126,8 @@ public: void IterFinished() { ++iter; } // Counter of where we are in the iteration. - bro_uint_t iter; // initialized to 0 at start of loop - bro_uint_t n; // we loop from 0 ... n-1 + zeek_uint_t iter; // initialized to 0 at start of loop + zeek_uint_t n; // we loop from 0 ... n-1 // The low-level value we're iterating over. const std::vector>* vv; diff --git a/src/script_opt/ZAM/Ops.in b/src/script_opt/ZAM/Ops.in index 5d4529883a..9e907362f4 100644 --- a/src/script_opt/ZAM/Ops.in +++ b/src/script_opt/ZAM/Ops.in @@ -8,7 +8,7 @@ # in either the nature of the instruction's operands (typically, whether # they are variables residing on the ZAM execution frame, or constants) # and/or the Zeek type of the operands (e.g., "count" or "double" or "addr"). -# +# # The Gen-ZAM utility processes this file to generate numerous C++ inclusion # files that are then compiled into Zeek. These files span the range of (1) # hooks that enable run-time generation of ZAM code to execute ASTs (which @@ -16,7 +16,7 @@ # properties of the different instructions, (3) code to evaluate (execute) # each instruction, and (4) macros (C++ #define's) to aid in writing that # code. See Gen-ZAM.h for a list of the different inclusion files. -# +# # Operation templates are declarative, other than the imperative C++ snippets # they include for instruction evaluation/execution. You specify a template # using lines of text for which, for the most part, the first word on the @@ -27,7 +27,7 @@ # last attribute. Comments begin with '#' at the start of the line (no # leading whitespace allowed), and can be intermingled with a template's # attributes. -# +# # Each ZAM instruction includes up to 4 integer values and one constant # (specified as a ZVal). Often, the integer values are interpreted as offsets # ("slots") into the ZAM execution "frame", though sometimes they have other @@ -39,53 +39,53 @@ # "operands". Thus, for example, an instruction with two operands used the # first 3 integer values, the first as the assignment slot and the other two # for computing the result to put in that slot. -# +# # The first attribute of each template states the type of operation specified # in the template, along with the name of the operation. The possible types # are: -# +# # op an operation that generally corresponds to a single ZAM # instruction, and is fully specified -# +# # expr-op an operation corresponding to an AST expression node # (some sort of Expr object). Gen-ZAM generates code for # automatically converting Expr objects to ZAM instructions. # The name of the operation must match that used in the AST # tag, so for example for "expr-op Foo" there must be a # corresponding "EXPR_FOO" tag. -# +# # unary-expr-op an expr-op for a unary Expr object # binary-expr-op an expr-op for a binary Expr object # rel-expr-op an expr-op for a (binary) Expr object that # represents a relational operation -# +# # assign-op directly assigning either a ZVal or a record field # to either a frame slot or a record field -# +# # unary-op an operation with one operand that requires special # treatment that doesn't fit with how unary-expr-op's # are expressed -# +# # direct-unary-op an operation with one operand that corresponds to # a specific ZAMCompiler method for generating its # instruction -# +# # internal-op similar to "op", but for ZAM instructions only used # internally, and thus not having any AST counterpart # internal-binary-op the same, for operations that take two operands # internal-assignment-op the same, for operations that assign ZVals # produced by loading interpreter variables # or calling functions -# +# # After specifying the type of operation, you list additional attributes to # fill out the template, ending by convention with the C++ evaluation snippet # (if appropriate). The most significant (and complex) of these are: -# +# # type specifies how to interpret the operation in terms of ZAM # instruction slots (and constant). The specification is # in terms of single-letter mnemonics for the different # possible types: -# +# # F special value designating a record field being # assigned to # H event handler @@ -96,7 +96,7 @@ # V variable (frame slot) # X used to indicate an empty specifier # i integer constant, often a record field offset -# +# # The full specification consists of concatenating mnemonics # with the order left-to-right corresponding to each of the # instruction's 4 integer values (stopping with the last one @@ -108,10 +108,10 @@ # also a frame variable, the second operand is the instruction's # constant, and the third operand is the instruction's third # integer value, with the fourth integer value not being used. -# +# # op-type for some form of expr-op, specifies to which Zeek scripting # types the expression applies: -# +# # A addr # D double # F file @@ -122,29 +122,29 @@ # T table # U count # V vector -# +# # along with two special types: 'X' indicates that Gen-ZAM # should not iterate over any possible values, and '*' # indicates that Gen-ZAM should additionally iterate over # all of possible values not explicitly listed (used in # conjunction with eval-type - see below) -# +# # eval specifies a block of C++ code used to evaluation the # execution of the instruction. The block begins with the # remainder of the "eval" line and continues until either a # blank line or a line that starts with non-whitespace. -# +# # Blocks can include special '$' parameters that Gen-ZAM # automatically expands. "$1" refers to an operation's first # operand, "$2" to its second, etc. "$$" refers to the # operation's assignment target. -# +# # For simple expr-op's you can express the block as simply # the C++ expression to compute. For example, for multiplication # (named "Times"), the "eval" block is simply "$1 * $2", # rather than "$$ = $1 * $2"; Gen-ZAM knows to expand it # accordingly. -# +# # Finally, to help with avoiding duplicate code, you can # define macros that expand to code snippets you want to use # in multiple places. You specify these using a "macro" @@ -154,95 +154,95 @@ # instead just indent the lines you want included, ending # (as with "eval" blocks) with an empty line or a line that # starts with non-whitespace. -# +# # We list the remaining types of attributes alphabetically. Note that some # only apply to certain types of operations. -# +# # assign-val for an assignment operation, the name of the # C++ variable that holds the value to assign -# +# # custom-method a ZAMCompiler method that Gen-ZAM should use for # this operation, rather than generating one -# +# # eval-mixed an expression "eval" block that applies to two # different op-type's -# +# # eval-pre code to add to the beginning of the "eval" block. # This can be required for operations where Gen-ZAM # generates elements of the C++ (such as for expr-op's). -# +# # eval-type evaluation code associated with one specific op-type -# +# # explicit-result-type the operation's evaluation yields a ZVal # rather than a low-level C++ type -# +# # field-op the operation is a direct assignment to a record field -# +# # includes-field-op the operation should include a version # that assigs to a record field as well as a # version for assigning to a frame variable -# +# # indirect-call the operation represents an indirect call (through # a variable, rather than directly). Only meaningful # if num-call-args is also specified. -# +# # method-post C++ code to add to the end of the method that # dynamically generates ZAM code -# +# # no-const do not generate a version of the unary-expr-op # where the operand is a constant -# +# # no-eval this operation does not have an "eval" block # (because it will be translated instead into internal # operations) -# +# # num-call-args indicates that the operation is a function call, # and specifies how many arguments the call takes. # A specification of 'n' means "build a ZAM instruction # for calling with an arbitrary number of arguments". -# +# # op-accessor tells Gen-ZAM what ZVal accessor to use to get to # the underlying values of the operand(s) -# +# # op1-accessor the same as op-accessor except only for the first # operand -# +# # op1-internal states that the operation's treatment of the # instruction's first integer value is for internal # purposes; the value does not correspond to a frame # variable -# +# # op1-read the operation treats the instruction's first integer # value as a frame variable, but only reads the value. # (The default is that the frame variable is written # to but not read.) -# +# # op1-read-write the operation treats the instruction's first integer # value as a frame variable, and both reads and # writes the value. -# +# # op2-accessor the same as op-accessor except only for the second # operand -# +# # set-type the instruction's primary type comes from either the # assignment target ("$$"), the first operand ("$1"), # or the second operand ("$2") -# +# # set-type2 the same as set-type but for the instruction's # secondary type -# +# # side-effects the operation has side-effects, so even if its # assignment target winds up being "dead" (the value is # no longer used), the operation should still occur. # Optionally, this attribute can include two arguments # specifying the ZAM opcode to use if the assignment # is dead, and the internal "type" of that opcode. -# +# # For example, "side-effects OP_CALL1_V OP_V" means # "this operation has side-effects; if eliminating # its assignment, change the ZAM op-code to OP_CALL1_V, # which has an internal type of OP_V". -# +# # vector generate a version of the operation that takes # vectors as operands @@ -297,14 +297,14 @@ op-type I U D A N S T V * explicit-result-type set-type $$ set-type2 $1 -eval-type I $$ = ZVal(bro_int_t($1 < 0 ? -$1 : $1)); +eval-type I $$ = ZVal(zeek_int_t($1 < 0 ? -$1 : $1)); eval-type U $$ = ZVal($1); eval-type D $$ = ZVal($1 < 0 ? -$1 : $1); -eval-type A $$ = ZVal(bro_uint_t($1->AsAddr().GetFamily() == IPv4 ? 32 : 128)); +eval-type A $$ = ZVal(zeek_uint_t($1->AsAddr().GetFamily() == IPv4 ? 32 : 128)); eval-type N $$ = ZVal(pow(2.0, double(128 - $1->AsSubNet().LengthIPv6()))); -eval-type S $$ = ZVal(bro_uint_t($1->Len())); -eval-type T $$ = ZVal(bro_uint_t($1->Size())); -eval-type V $$ = ZVal(bro_uint_t($1->Size())); +eval-type S $$ = ZVal(zeek_uint_t($1->Len())); +eval-type T $$ = ZVal(zeek_uint_t($1->Size())); +eval-type V $$ = ZVal(zeek_uint_t($1->Size())); eval auto v = frame[z.v2].ToVal(z.t2)->SizeVal(); $$ = BuildVal(v, z.t); @@ -510,12 +510,12 @@ eval $1 % $2 binary-expr-op And-And op-type I vector -eval bro_int_t($1 && $2) +eval zeek_int_t($1 && $2) binary-expr-op Or-Or op-type I vector -eval bro_int_t($1 || $2) +eval zeek_int_t($1 || $2) binary-expr-op And op-type U P T @@ -833,13 +833,13 @@ internal-op Val-Is-In-Vector type VVV eval auto& vec = frame[z.v3].vector_val; auto ind = frame[z.v2].int_val; - frame[z.v1].int_val = ind >= 0 && static_cast(ind) < vec->Size(); + frame[z.v1].int_val = ind >= 0 && static_cast(ind) < vec->Size(); internal-op Const-Is-In-Vector type VCV eval auto& vec = frame[z.v2].vector_val; auto ind = z.c.int_val; - frame[z.v1].int_val = ind >= 0 && static_cast(ind) < vec->Size(); + frame[z.v1].int_val = ind >= 0 && static_cast(ind) < vec->Size(); expr-op Cond type VVVV @@ -869,7 +869,7 @@ eval auto& vsel = *frame[z.v2].vector_val->RawVec(); (*res)[i] = vsel[i]->int_val ? v1[i] : v2[i]; auto& full_res = frame[z.v1].vector_val; Unref(full_res); - full_res = new VectorVal(cast_intrusive(z.t), res); + full_res = new VectorVal(cast_intrusive(z.t), res); # Our instruction format doesn't accommodate two constants, so for # the singular case of a V ? C1 : C2 conditional, we split it into @@ -944,7 +944,7 @@ eval EvalIndexVec(frame[z.v3].uint_val) macro EvalIndexVec(index) auto vv = frame[z.v2].vector_val->RawVec(); const auto& vec = *vv; - bro_uint_t ind = index; + zeek_uint_t ind = index; if ( ind >= vv->size() ) ZAM_run_time_error(z.loc, "no such index"); AssignV1(CopyVal(*vec[ind])) @@ -959,7 +959,7 @@ eval EvalIndexAnyVec(frame[z.v3].uint_val) macro EvalIndexAnyVec(index) auto vv = frame[z.v2].vector_val; - bro_uint_t ind = index; + zeek_uint_t ind = index; if ( ind >= vv->Size() ) ZAM_run_time_error(z.loc, "no such index"); AssignV1(ZVal(vv->ValAt(ind).release())) @@ -1141,7 +1141,7 @@ eval auto v = frame[z.v2].int_val; ZAM_run_time_error(z.loc, "underflow converting int to count"); break; } - frame[z.v1].uint_val = bro_uint_t(v); + frame[z.v1].uint_val = zeek_uint_t(v); internal-op Coerce-UD type VV @@ -1156,7 +1156,7 @@ eval auto v = frame[z.v2].double_val; ZAM_run_time_error(z.loc, "overflow converting double to count"); break; } - frame[z.v1].uint_val = bro_uint_t(v); + frame[z.v1].uint_val = zeek_uint_t(v); internal-op Coerce-IU type VV @@ -1166,7 +1166,7 @@ eval auto v = frame[z.v2].uint_val; ZAM_run_time_error(z.loc, "overflow converting count to int"); break; } - frame[z.v1].int_val = bro_int_t(v); + frame[z.v1].int_val = zeek_int_t(v); internal-op Coerce-ID type VV @@ -1181,7 +1181,7 @@ eval auto v = frame[z.v2].double_val; ZAM_run_time_error(z.loc, "overflow converting double to int"); break; } - frame[z.v1].int_val = bro_int_t(v); + frame[z.v1].int_val = zeek_int_t(v); internal-op Coerce-DI type VV @@ -1804,7 +1804,7 @@ op CheckAnyLen op1-read type Vi eval auto v = frame[z.v1].list_val; - if ( v->Vals().size() != static_cast(z.v2) ) + if ( v->Vals().size() != static_cast(z.v2) ) ZAM_run_time_error(z.loc, "mismatch in list lengths"); op Print @@ -2002,11 +2002,11 @@ eval EvalSubBytes(frame[z.v2], frame[z.v3].uint_val, z.v4) internal-op Sub-Bytes type VViV -eval EvalSubBytes(frame[z.v2], bro_uint_t(z.v4), frame[z.v3].int_val) +eval EvalSubBytes(frame[z.v2], zeek_uint_t(z.v4), frame[z.v3].int_val) internal-op Sub-Bytes type VVii -eval EvalSubBytes(frame[z.v2], bro_uint_t(z.v3), z.v4) +eval EvalSubBytes(frame[z.v2], zeek_uint_t(z.v3), z.v4) internal-op Sub-Bytes type VVVC @@ -2018,11 +2018,11 @@ eval EvalSubBytes(z.c, frame[z.v2].uint_val, z.v3) internal-op Sub-Bytes type ViVC -eval EvalSubBytes(z.c, bro_uint_t(z.v3), frame[z.v2].uint_val) +eval EvalSubBytes(z.c, zeek_uint_t(z.v3), frame[z.v2].uint_val) internal-op Sub-Bytes type ViiC -eval EvalSubBytes(z.c, bro_uint_t(z.v2), z.v3) +eval EvalSubBytes(z.c, zeek_uint_t(z.v2), z.v3) internal-op To-Lower @@ -2167,4 +2167,4 @@ internal-op Files--Set-Reassembly-Buffer op1-read type VC eval auto f = frame[z.v1].string_val->CheckString(); - file_mgr->SetReassemblyBuffer(f, bro_uint_t(z.v2)); + file_mgr->SetReassemblyBuffer(f, zeek_uint_t(z.v2)); diff --git a/src/script_opt/ZAM/Stmt.cc b/src/script_opt/ZAM/Stmt.cc index fc729e34eb..8538b9f3d0 100644 --- a/src/script_opt/ZAM/Stmt.cc +++ b/src/script_opt/ZAM/Stmt.cc @@ -502,8 +502,8 @@ const ZAMStmt ZAMCompiler::ValueSwitch(const SwitchStmt* sw, const NameExpr* v, // Now fill out the corresponding jump table. // // We will only use one of these. - CaseMapI new_int_cases; - CaseMapI new_uint_cases; + CaseMapI new_int_cases; + CaseMapI new_uint_cases; CaseMapI new_double_cases; CaseMapI new_str_cases; diff --git a/src/script_opt/ZAM/Support.cc b/src/script_opt/ZAM/Support.cc index 3ab61cba81..81aeaad340 100644 --- a/src/script_opt/ZAM/Support.cc +++ b/src/script_opt/ZAM/Support.cc @@ -62,7 +62,7 @@ StringVal* ZAM_to_lower(const StringVal* sv) return new StringVal(new String(1, lower_s, n)); } -StringVal* ZAM_sub_bytes(const StringVal* s, bro_uint_t start, bro_int_t n) +StringVal* ZAM_sub_bytes(const StringVal* s, zeek_uint_t start, zeek_int_t n) { if ( start > 0 ) --start; // make it 0-based diff --git a/src/script_opt/ZAM/Support.h b/src/script_opt/ZAM/Support.h index 8dbf31a865..1660ae6277 100644 --- a/src/script_opt/ZAM/Support.h +++ b/src/script_opt/ZAM/Support.h @@ -52,6 +52,6 @@ extern bool ZAM_error; extern void ZAM_run_time_warning(const Location* loc, const char* msg); extern StringVal* ZAM_to_lower(const StringVal* sv); -extern StringVal* ZAM_sub_bytes(const StringVal* s, bro_uint_t start, bro_int_t n); +extern StringVal* ZAM_sub_bytes(const StringVal* s, zeek_uint_t start, zeek_int_t n); } // namespace zeek::detail diff --git a/src/script_opt/ZAM/ZBody.cc b/src/script_opt/ZAM/ZBody.cc index d011736049..02858bac40 100644 --- a/src/script_opt/ZAM/ZBody.cc +++ b/src/script_opt/ZAM/ZBody.cc @@ -47,7 +47,7 @@ void report_ZOP_profile() // assigned value was missing (which we can only tell for managed types), // true otherwise. -static bool copy_vec_elem(VectorVal* vv, bro_uint_t ind, ZVal zv, const TypePtr& t) +static bool copy_vec_elem(VectorVal* vv, zeek_uint_t ind, ZVal zv, const TypePtr& t) { if ( vv->Size() <= ind ) vv->Resize(ind + 1); @@ -118,11 +118,11 @@ static void vec_exec(ZOp op, TypePtr t, VectorVal*& v1, const VectorVal* v2, con VEC_COERCE(DI, TYPE_DOUBLE, double, AsInt(), false_func, "") VEC_COERCE(DU, TYPE_DOUBLE, double, AsCount(), false_func, "") -VEC_COERCE(ID, TYPE_INT, bro_int_t, AsDouble(), double_to_int_would_overflow, "double to signed") -VEC_COERCE(IU, TYPE_INT, bro_int_t, AsCount(), count_to_int_would_overflow, "unsigned to signed") -VEC_COERCE(UD, TYPE_COUNT, bro_uint_t, AsDouble(), double_to_count_would_overflow, +VEC_COERCE(ID, TYPE_INT, zeek_int_t, AsDouble(), double_to_int_would_overflow, "double to signed") +VEC_COERCE(IU, TYPE_INT, zeek_int_t, AsCount(), count_to_int_would_overflow, "unsigned to signed") +VEC_COERCE(UD, TYPE_COUNT, zeek_uint_t, AsDouble(), double_to_count_would_overflow, "double to unsigned") -VEC_COERCE(UI, TYPE_COUNT, bro_int_t, AsInt(), int_to_count_would_overflow, "signed to unsigned") +VEC_COERCE(UI, TYPE_COUNT, zeek_int_t, AsInt(), int_to_count_would_overflow, "signed to unsigned") ZBody::ZBody(const char* _func_name, const ZAMCompiler* zc) : Stmt(STMT_ZAM) { @@ -141,8 +141,8 @@ ZBody::ZBody(const char* _func_name, const ZAMCompiler* zc) : Stmt(STMT_ZAM) globals = zc->Globals(); num_globals = globals.size(); - int_cases = zc->GetCases(); - uint_cases = zc->GetCases(); + int_cases = zc->GetCases(); + uint_cases = zc->GetCases(); double_cases = zc->GetCases(); str_cases = zc->GetCases(); diff --git a/src/script_opt/ZAM/ZBody.h b/src/script_opt/ZAM/ZBody.h index 11699a848b..0d3d594a8c 100644 --- a/src/script_opt/ZAM/ZBody.h +++ b/src/script_opt/ZAM/ZBody.h @@ -111,8 +111,8 @@ private: double* CPU_time = nullptr; // cumulative CPU time for the program std::vector* inst_CPU = nullptr; // per-instruction CPU time. - CaseMaps int_cases; - CaseMaps uint_cases; + CaseMaps int_cases; + CaseMaps uint_cases; CaseMaps double_cases; CaseMaps str_cases; }; diff --git a/src/script_opt/ZAM/ZInst.cc b/src/script_opt/ZAM/ZInst.cc index 7507700ec8..b5f907ffa3 100644 --- a/src/script_opt/ZAM/ZInst.cc +++ b/src/script_opt/ZAM/ZInst.cc @@ -11,7 +11,7 @@ using std::string; namespace zeek::detail { -void ZInst::Dump(bro_uint_t inst_num, const FrameReMap* mappings) const +void ZInst::Dump(zeek_uint_t inst_num, const FrameReMap* mappings) const { // printf("v%d ", n); @@ -212,7 +212,7 @@ int ZInst::NumSlots() const return -1; } -string ZInst::VName(int n, bro_uint_t inst_num, const FrameReMap* mappings) const +string ZInst::VName(int n, zeek_uint_t inst_num, const FrameReMap* mappings) const { if ( n > NumFrameSlots() ) return ""; @@ -223,7 +223,7 @@ string ZInst::VName(int n, bro_uint_t inst_num, const FrameReMap* mappings) cons return ""; // Find which identifier manifests at this instruction. - ASSERT(slot >= 0 && static_cast(slot) < mappings->size()); + ASSERT(slot >= 0 && static_cast(slot) < mappings->size()); auto& map = (*mappings)[slot]; @@ -323,12 +323,12 @@ string ZInstI::VName(int n, const FrameMap* frame_ids, const FrameReMap* remappi if ( remappings && live ) { // Find which identifier manifests at this instruction. - ASSERT(slot >= 0 && static_cast(slot) < remappings->size()); + ASSERT(slot >= 0 && static_cast(slot) < remappings->size()); auto& map = (*remappings)[slot]; unsigned int i; - auto inst_num_u = static_cast(inst_num); + auto inst_num_u = static_cast(inst_num); for ( i = 0; i < map.id_start.size(); ++i ) { // See discussion for ZInst::VName. diff --git a/src/script_opt/ZAM/ZInst.h b/src/script_opt/ZAM/ZInst.h index f9fc548804..a5796da663 100644 --- a/src/script_opt/ZAM/ZInst.h +++ b/src/script_opt/ZAM/ZInst.h @@ -37,7 +37,7 @@ public: // The ZAM instruction number where a given identifier starts its // scope, parallel to "ids". - std::vector id_start; + std::vector id_start; // The current end of the frame slot's scope. Gets updated as // new IDs are added to share the slot. @@ -69,7 +69,7 @@ public: virtual ~ZInst() = default; // Methods for printing out the instruction for debugging/maintenance. - void Dump(bro_uint_t inst_num, const FrameReMap* mappings) const; + void Dump(zeek_uint_t inst_num, const FrameReMap* mappings) const; void Dump(const std::string& id1, const std::string& id2, const std::string& id3, const std::string& id4) const; @@ -78,7 +78,7 @@ public: // by its number within a larger set. "mappings" provides the // mappings used to translate raw slots to the corresponding // script variable(s). - std::string VName(int n, bro_uint_t inst_num, const FrameReMap* mappings) const; + std::string VName(int n, zeek_uint_t inst_num, const FrameReMap* mappings) const; // Number of slots that refer to a frame element. These always // come first, if we use additional slots. diff --git a/src/threading/SerialTypes.cc b/src/threading/SerialTypes.cc index 2418f718ed..0c33f69e6a 100644 --- a/src/threading/SerialTypes.cc +++ b/src/threading/SerialTypes.cc @@ -103,7 +103,7 @@ Value::~Value() else if ( type == TYPE_TABLE ) { - for ( bro_int_t i = 0; i < val.set_val.size; i++ ) + for ( zeek_int_t i = 0; i < val.set_val.size; i++ ) delete val.set_val.vals[i]; delete[] val.set_val.vals; @@ -111,7 +111,7 @@ Value::~Value() else if ( type == TYPE_VECTOR ) { - for ( bro_int_t i = 0; i < val.vector_val.size; i++ ) + for ( zeek_int_t i = 0; i < val.vector_val.size; i++ ) delete val.vector_val.vals[i]; delete[] val.vector_val.vals; @@ -286,7 +286,7 @@ bool Value::Read(detail::SerializationFormat* fmt) val.set_val.vals = new Value*[val.set_val.size]; - for ( bro_int_t i = 0; i < val.set_val.size; ++i ) + for ( zeek_int_t i = 0; i < val.set_val.size; ++i ) { val.set_val.vals[i] = new Value; @@ -304,7 +304,7 @@ bool Value::Read(detail::SerializationFormat* fmt) val.vector_val.vals = new Value*[val.vector_val.size]; - for ( bro_int_t i = 0; i < val.vector_val.size; ++i ) + for ( zeek_int_t i = 0; i < val.vector_val.size; ++i ) { val.vector_val.vals[i] = new Value; diff --git a/src/threading/SerialTypes.h b/src/threading/SerialTypes.h index 8faed5314f..e432af565b 100644 --- a/src/threading/SerialTypes.h +++ b/src/threading/SerialTypes.h @@ -117,13 +117,13 @@ struct Value struct set_t { - bro_int_t size; + zeek_int_t size; Value** vals; }; using vec_t = set_t; struct port_t { - bro_uint_t port; + zeek_uint_t port; TransportProto proto; }; @@ -154,8 +154,8 @@ struct Value * including only the types we can log directly. See IsCompatibleType(). */ union _val { - bro_int_t int_val; - bro_uint_t uint_val; + zeek_int_t int_val; + zeek_uint_t uint_val; port_t port_val; double double_val; set_t set_val; diff --git a/src/threading/formatters/Ascii.cc b/src/threading/formatters/Ascii.cc index cb76083b5a..515f5dcfbe 100644 --- a/src/threading/formatters/Ascii.cc +++ b/src/threading/formatters/Ascii.cc @@ -153,7 +153,7 @@ bool Ascii::Describe(ODesc* desc, Value* val, const string& name) const desc->AddEscapeSequence(separators.set_separator); - for ( bro_int_t j = 0; j < val->val.set_val.size; j++ ) + for ( zeek_int_t j = 0; j < val->val.set_val.size; j++ ) { if ( j > 0 ) desc->AddRaw(separators.set_separator); @@ -180,7 +180,7 @@ bool Ascii::Describe(ODesc* desc, Value* val, const string& name) const desc->AddEscapeSequence(separators.set_separator); - for ( bro_int_t j = 0; j < val->val.vector_val.size; j++ ) + for ( zeek_int_t j = 0; j < val->val.vector_val.size; j++ ) { if ( j > 0 ) desc->AddRaw(separators.set_separator); diff --git a/src/threading/formatters/JSON.cc b/src/threading/formatters/JSON.cc index 2fe9e646fe..9c5825bdfd 100644 --- a/src/threading/formatters/JSON.cc +++ b/src/threading/formatters/JSON.cc @@ -184,7 +184,7 @@ void JSON::BuildJSON(NullDoubleWriter& writer, Value* val, const std::string& na { writer.StartArray(); - for ( bro_int_t idx = 0; idx < val->val.set_val.size; idx++ ) + for ( zeek_int_t idx = 0; idx < val->val.set_val.size; idx++ ) BuildJSON(writer, val->val.set_val.vals[idx]); writer.EndArray(); @@ -195,7 +195,7 @@ void JSON::BuildJSON(NullDoubleWriter& writer, Value* val, const std::string& na { writer.StartArray(); - for ( bro_int_t idx = 0; idx < val->val.vector_val.size; idx++ ) + for ( zeek_int_t idx = 0; idx < val->val.vector_val.size; idx++ ) BuildJSON(writer, val->val.vector_val.vals[idx]); writer.EndArray(); diff --git a/src/util.h b/src/util.h index 990a15a6db..f146b4e0fb 100644 --- a/src/util.h +++ b/src/util.h @@ -77,8 +77,10 @@ extern "C" #include "zeek/3rdparty/ghc/filesystem.hpp" -using bro_int_t = int64_t; -using bro_uint_t = uint64_t; +using zeek_int_t = int64_t; +using zeek_uint_t = uint64_t; +using bro_int_t [[deprecated("Remove in v6.1. Use zeek_int_t.")]] = zeek_int_t; +using bro_uint_t [[deprecated("Remove in v6.1. Use zeek_uint_t.")]] = zeek_uint_t; #ifndef HAVE_STRCASESTR extern char* strcasestr(const char* s, const char* find); @@ -509,7 +511,7 @@ inline char* safe_strncpy(char* dest, const char* src, size_t n) // Memory alignment helpers. -inline bool is_power_of_2(bro_uint_t x) +inline bool is_power_of_2(zeek_uint_t x) { return ((x - 1) & x) == 0; } diff --git a/src/zeek.bif b/src/zeek.bif index fb0c74ddd4..ba0e0d895e 100644 --- a/src/zeek.bif +++ b/src/zeek.bif @@ -36,9 +36,9 @@ zeek::TableType* var_sizes; static zeek::iosource::PktDumper* addl_pkt_dumper = nullptr; -bro_int_t parse_int(const char*& fmt) +zeek_int_t parse_int(const char*& fmt) { - bro_int_t k = 0; + zeek_int_t k = 0; while ( isdigit(*fmt) ) { k = k * 10 + (*fmt - '0'); @@ -201,7 +201,7 @@ static void do_fmt(const char*& fmt, zeek::Val* v, zeek::ODesc* d) else if ( it == zeek::TYPE_INTERNAL_UNSIGNED ) { - bro_uint_t u = v->CoerceToUnsigned(); + zeek_uint_t u = v->CoerceToUnsigned(); if ( v->GetType()->IsNetworkOrder() ) { @@ -949,7 +949,7 @@ function hrw_weight%(key_digest: count, site_id: count%): count ## provided by the OS. function rand%(max: count%): count %{ - auto result = bro_uint_t(double(max) * double(zeek::util::detail::random_number()) / (zeek::util::detail::max_random() + 1.0)); + auto result = zeek_uint_t(double(max) * double(zeek::util::detail::random_number()) / (zeek::util::detail::max_random() + 1.0)); return zeek::val_mgr->Count(result); %} @@ -2435,7 +2435,7 @@ function to_int%(str: string%): int const char* s = str->CheckString(); char* end_s; - bro_int_t i = strtoll(s, &end_s, 10); + zeek_int_t i = strtoll(s, &end_s, 10); #if 0 // Not clear we should complain. For example, is " 205 " @@ -2472,7 +2472,7 @@ function int_to_count%(n: int%): count ## by rint(). function double_to_int%(d: double%): int %{ - return zeek::val_mgr->Int(bro_int_t(rint(d))); + return zeek::val_mgr->Int(zeek_int_t(rint(d))); %} ## Converts a :zeek:type:`double` to a :zeek:type:`int`. @@ -2488,7 +2488,7 @@ function double_to_count%(d: double%): count if ( d < 0.0 ) zeek::emit_builtin_error("bad conversion to count", @ARG@[0]); - return zeek::val_mgr->Count(bro_uint_t(rint(d))); + return zeek::val_mgr->Count(zeek_uint_t(rint(d))); %} ## Converts a :zeek:type:`string` to a :zeek:type:`count`. @@ -3037,13 +3037,13 @@ function addr_to_ptr_name%(a: addr%): string ## .. zeek:see:: hexdump hexstr_to_bytestring function bytestring_to_hexstr%(bytestring: string%): string %{ - bro_uint_t len = bytestring->AsString()->Len(); + zeek_uint_t len = bytestring->AsString()->Len(); const u_char* bytes = bytestring->AsString()->Bytes(); auto hextr_buf = std::make_unique((2 * len) + 1); auto hexstr = hextr_buf.get(); hexstr[0] = 0; - for ( bro_uint_t i = 0; i < len; ++i ) + for ( zeek_uint_t i = 0; i < len; ++i ) snprintf(hexstr + (2 * i), 3, "%.2hhx", bytes[i]); return zeek::make_intrusive(hexstr); @@ -3062,7 +3062,7 @@ function bytestring_to_hexstr%(bytestring: string%): string ## .. zeek:see:: hexdump bytestring_to_hexstr function hexstr_to_bytestring%(hexstr: string%): string %{ - bro_uint_t len = hexstr->AsString()->Len(); + zeek_uint_t len = hexstr->AsString()->Len(); if ( len % 2 != 0 ) { zeek::reporter->Error("Hex string '%s' has invalid length (not divisible by 2)", hexstr->CheckString()); @@ -3075,7 +3075,7 @@ function hexstr_to_bytestring%(hexstr: string%): string auto bytestring = bytestring_buf.get(); memset(bytestring, 0, outlen); - for ( bro_uint_t i = 0; i < len/2; ++i ) + for ( zeek_uint_t i = 0; i < len/2; ++i ) { int res = sscanf(bytes + (2*i), "%2hhx", &bytestring[i]); diff --git a/testing/btest/spicy/spicyz-jit.test b/testing/btest/spicy/spicyz-jit.test index 93088f811d..514bec8990 100644 --- a/testing/btest/spicy/spicyz-jit.test +++ b/testing/btest/spicy/spicyz-jit.test @@ -1,8 +1,11 @@ # @TEST-DOC: Smoke test for a custom Spicy analyzer hooked into Zeek with JIT via Zeek itself. # # @TEST-REQUIRES: $SCRIPTS/have-spicy -# @TEST-EXEC: zeek -NN test.zeek test.spicy test.evt | grep -q ANALYZER_SPICY_TEST -# @TEST-EXEC: HILTI_DEBUG=compiler zeek -r ${TRACES}/http/post.trace test.spicy test.evt test.zeek "Spicy::enable_print = T;" >>output 2>&1 + +# Use a script here to prevent spicy from outputting warnings during compilation. If the build is +# failing, the script can be modified to not redirect the output. +# @TEST-EXEC: HILTI_CXX=$SCRIPTS/hilti-ignore-cxx-errors zeek -NN test.zeek test.spicy test.evt | grep -q ANALYZER_SPICY_TEST +# @TEST-EXEC: HILTI_CXX=$SCRIPTS/hilti-ignore-cxx-errors zeek -r ${TRACES}/http/post.trace test.spicy test.evt test.zeek "Spicy::enable_print = T;" >>output 2>&1 # @TEST-EXEC: btest-diff output # @TEST-START-FILE test.spicy diff --git a/testing/scripts/hilti-ignore-cxx-errors b/testing/scripts/hilti-ignore-cxx-errors new file mode 100755 index 0000000000..8440e0a2d7 --- /dev/null +++ b/testing/scripts/hilti-ignore-cxx-errors @@ -0,0 +1,4 @@ +#!/bin/sh + +COMPILER=$(awk -F= '/CMAKE_CXX_COMPILER:/ {print $2}' ${BUILD}/CMakeCache.txt) +${COMPILER} "$@" >/dev/null 2>&1