in reply to Re^7: SvUV vs SvIV for pointers in SVs, typemap
in thread SvUV vs SvIV for pointers in SVs, typemap
#!/usr/bin/perl -w use Devel::Peek; $ptrUV = unpack('J',pack('P[12]',"Hello World")); $ptrIV = unpack('j',pack('P[12]',"Hello World")); print Dump($ptrUV); print Dump($ptrIV); $ptrUV += 2**31; print Dump($ptrUV);
Perl keeps all unsigneds as IVs until they are greater than IV_MAX (~ +2 billion), then it uses the UV flag/UV mode. [sv.c#l1620 in perl.git] But, if the pointer is larger than 2 billion, and the user manipulates the pointer, for struct offsets for example, before passing it to unpack, or passes the scalar with the pointer inside it to an XSUB that takes a pointer (bad XSUB design right?)SV = IV(0x182a260) at 0x182a264 REFCNT = 1 FLAGS = (IOK,pIOK) IV = 28545556 SV = IV(0x182a3e0) at 0x182a3e4 REFCNT = 1 FLAGS = (IOK,pIOK) IV = 26107564 SV = IV(0x182a260) at 0x182a264 REFCNT = 1 FLAGS = (IOK,pIOK,IsUV) UV = 2176029204
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^9: SvUV vs SvIV for pointers in SVs, typemap
by BrowserUk (Patriarch) on Feb 21, 2011 at 18:05 UTC | |
Re^9: SvUV vs SvIV for pointers in SVs, typemap
by ikegami (Patriarch) on Feb 21, 2011 at 19:36 UTC |
In Section
Seekers of Perl Wisdom