Fix vvp segfault on Windows when vvp_net_ptr_t values exceed 4GB.
Under Windows unsigned long is 32 bits, so we must use unsigned long long values for 64-bit address masks.
This commit is contained in:
parent
48db632a03
commit
0d6a2f95a8
|
|
@ -135,6 +135,7 @@ CXXFLAGS="$iverilog_temp_cxxflags"
|
|||
AC_CHECK_SIZEOF(unsigned long long)
|
||||
AC_CHECK_SIZEOF(unsigned long)
|
||||
AC_CHECK_SIZEOF(unsigned)
|
||||
AC_CHECK_SIZEOF(void *)
|
||||
|
||||
# vvp uses these...
|
||||
AC_CHECK_LIB(termcap, tputs)
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
# define SIZEOF_UNSIGNED_LONG 0
|
||||
#endif
|
||||
# define SIZEOF_UNSIGNED 0
|
||||
# define SIZEOF_VOID_P 0
|
||||
|
||||
# undef NEED_LU
|
||||
# undef NEED_TU
|
||||
|
|
@ -127,6 +128,16 @@ typedef unsigned long vvp_time64_t;
|
|||
|
||||
#endif /* HAVE_INTTYPES_H */
|
||||
|
||||
# if SIZEOF_VOID_P == SIZEOF_UNSIGNED_LONG
|
||||
# define UINTPTR_C(n) n ## UL
|
||||
# else
|
||||
# if SIZEOF_VOID_P == SIZEOF_UNSIGNED_LONG_LONG
|
||||
# define UINTPTR_C(n) n ## ULL
|
||||
# else
|
||||
# error "Unexpected pointer size"
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# include <cmath>
|
||||
|
||||
/* getrusage, /proc/self/statm */
|
||||
|
|
|
|||
|
|
@ -1050,20 +1050,20 @@ template <class T> class vvp_sub_pointer_t {
|
|||
vvp_sub_pointer_t(T*ptr__, unsigned port__)
|
||||
{
|
||||
bits_ = reinterpret_cast<uintptr_t> (ptr__);
|
||||
assert( (bits_ & 3) == 0 );
|
||||
assert( (port__ & ~3) == 0 );
|
||||
assert( (bits_ & UINTPTR_C(3)) == 0 );
|
||||
assert( (port__ & ~UINTPTR_C(3)) == 0 );
|
||||
bits_ |= port__;
|
||||
}
|
||||
|
||||
~vvp_sub_pointer_t() { }
|
||||
|
||||
T* ptr()
|
||||
{ return reinterpret_cast<T*> (bits_ & ~3UL); }
|
||||
{ return reinterpret_cast<T*> (bits_ & ~UINTPTR_C(3)); }
|
||||
|
||||
const T* ptr() const
|
||||
{ return reinterpret_cast<const T*> (bits_ & ~3UL); }
|
||||
{ return reinterpret_cast<const T*> (bits_ & ~UINTPTR_C(3)); }
|
||||
|
||||
unsigned port() const { return bits_ & 3; }
|
||||
unsigned port() const { return bits_ & UINTPTR_C(3); }
|
||||
|
||||
bool nil() const { return bits_ == 0; }
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue