diff --git a/configure.in b/configure.in index 4248e7fad..83e0fe50e 100644 --- a/configure.in +++ b/configure.in @@ -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) diff --git a/vvp/config.h.in b/vvp/config.h.in index 20f56925b..ee5862707 100644 --- a/vvp/config.h.in +++ b/vvp/config.h.in @@ -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 /* getrusage, /proc/self/statm */ diff --git a/vvp/vvp_net.h b/vvp/vvp_net.h index b1ffd3cc7..75c7b3d2a 100644 --- a/vvp/vvp_net.h +++ b/vvp/vvp_net.h @@ -1050,20 +1050,20 @@ template class vvp_sub_pointer_t { vvp_sub_pointer_t(T*ptr__, unsigned port__) { bits_ = reinterpret_cast (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 (bits_ & ~3UL); } + { return reinterpret_cast (bits_ & ~UINTPTR_C(3)); } const T* ptr() const - { return reinterpret_cast (bits_ & ~3UL); } + { return reinterpret_cast (bits_ & ~UINTPTR_C(3)); } - unsigned port() const { return bits_ & 3; } + unsigned port() const { return bits_ & UINTPTR_C(3); } bool nil() const { return bits_ == 0; }