diff --git a/src/CCL.cc b/src/CCL.cc index 6f36c100c6..2ca3f5b4fc 100644 --- a/src/CCL.cc +++ b/src/CCL.cc @@ -31,7 +31,7 @@ void CCL::Negate() void CCL::Add(int sym) { - ptr_compat_int sym_p = ptr_compat_int(sym); + auto sym_p = static_cast(sym); // Check to see if the character is already in the ccl. for ( auto sym : *syms ) diff --git a/src/CCL.h b/src/CCL.h index 4407cef767..9e5cc30bb0 100644 --- a/src/CCL.h +++ b/src/CCL.h @@ -2,12 +2,12 @@ #pragma once +#include #include -#include "util.h" // for ptr_compat_int namespace zeek::detail { -using int_list = std::vector; +using int_list = std::vector; class CCL { public: diff --git a/src/EquivClass.cc b/src/EquivClass.cc index 7e0658ab54..c5272daccb 100644 --- a/src/EquivClass.cc +++ b/src/EquivClass.cc @@ -4,6 +4,7 @@ #include "EquivClass.h" #include "CCL.h" +#include "util.h" namespace zeek::detail { diff --git a/src/scan.l b/src/scan.l index fc44d6baf3..521928aeab 100644 --- a/src/scan.l +++ b/src/scan.l @@ -46,7 +46,7 @@ extern YYLTYPE yylloc; // holds start line and column of token extern zeek::EnumType* cur_enum_type; // Track the @if... depth. -ptr_compat_int current_depth = 0; +std::intptr_t current_depth = 0; zeek::detail::int_list if_stack; diff --git a/src/util.cc b/src/util.cc index d370bdd213..91ed616e4b 100644 --- a/src/util.cc +++ b/src/util.cc @@ -1253,8 +1253,8 @@ uint64_t rand64bit() int int_list_cmp(const void* v1, const void* v2) { - ptr_compat_int i1 = *(ptr_compat_int*) v1; - ptr_compat_int i2 = *(ptr_compat_int*) v2; + std::intptr_t i1 = *(std::intptr_t*) v1; + std::intptr_t i2 = *(std::intptr_t*) v2; if ( i1 < i2 ) return -1; diff --git a/src/util.h b/src/util.h index 8191e98cba..2c91bb9742 100644 --- a/src/util.h +++ b/src/util.h @@ -86,16 +86,14 @@ typedef uint64_t bro_uint_t; // pointer size. They can be cast safely to a pointer, e.g. in Lists, // which represent their entities as void* pointers. // +#define PRI_PTR_COMPAT_INT PRIdPTR // Format to use with printf. +#define PRI_PTR_COMPAT_UINT PRIuPTR #if SIZEOF_VOID_P == 8 -typedef uint64_t ptr_compat_uint; -typedef int64_t ptr_compat_int; -#define PRI_PTR_COMPAT_INT PRId64 // Format to use with printf. -#define PRI_PTR_COMPAT_UINT PRIu64 +typedef uint64_t ptr_compat_uint [[deprecated("Remove in v4.1. Use std::uintptr_t.")]]; +typedef int64_t ptr_compat_int [[deprecated("Remove in v4.1. Use std::intptr_t.")]]; #elif SIZEOF_VOID_P == 4 -typedef uint32_t ptr_compat_uint; -typedef int32_t ptr_compat_int; -#define PRI_PTR_COMPAT_INT PRId32 -#define PRI_PTR_COMPAT_UINT PRIu32 +typedef uint32_t ptr_compat_uint [[deprecated("Remove in v4.1. Use std::uintptr_t")]]; +typedef int32_t ptr_compat_int [[deprecated("Remove in v4.1. Use std::iintptr_t")]]; #else # error "Unsupported pointer size." #endif @@ -243,7 +241,7 @@ extern uint64_t rand64bit(); // Unfortunately, it introduces circular dependencies when defined in one of // the obvious places (like Event.h or RemoteSerializer.h) -typedef ptr_compat_uint SourceID; +using SourceID = std::uintptr_t; #define PRI_SOURCE_ID PRI_PTR_COMPAT_UINT static const SourceID SOURCE_LOCAL = 0;