On 19.11.20 г. 0:17 ч., Steven Rostedt wrote:
On Wed, 18 Nov 2020 16:49:49 +0200 "Yordan Karadzhov (VMware)" <y.karadz@xxxxxxxxx> wrote:+/** + * Bit mask (16-63) used when converting indexes to pointers and vise-versa. + */ +#define INVALID_STREAM_MASK (~((uint64_t) INDEX_MASK))This wont work on a 32 bit machine, as pointers are 32 bits not 64.
You are right. I will change this to #define INVALID_STREAM_MASK (~((unsigned long) INDEX_MASK))
+ +static int index_from_ptr(void *ptr) +{ + unsigned long index = (unsigned long) ptr; + + return (int) (index & INDEX_MASK); +} + +static void *index_to_ptr(unsigned int index) +{ + unsigned long p; + + p = INVALID_STREAM_MASK | index; + + return (void *) p; +} + +static bool kshark_is_valid_stream(void *ptr) +{ + unsigned long p = (unsigned long) ptr; + bool v = !((p & ~INDEX_MASK) == INVALID_STREAM_MASK);On 32 bit, the above will always fail, because unsigned long is 32 bits (as is void *), but INVALID_STREAM_MASK is 64 bits. And the two could never equal each other.
Thanks a lot! Yordan
-- Steve+ + return p && v; +} +