Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: XS: returning a 64-bit unsigned int?

by Anonymous Monk
on Sep 27, 2011 at 06:49 UTC ( #928021=note: print w/replies, xml ) Need Help??


in reply to XS: returning a 64-bit unsigned int?

Petition p5p?

It seems you can't get an IV no matter what you do

SV* bob() PREINIT: SV* temp; //~ unsigned int uncle = 42; unsigned long long uncle = 42; CODE: //~ temp = newSVuv( 42 ); temp = newSVuv( uncle ); SvIOK_only_UV( temp ); warn("we got em %p SvIOK_UV(%b)SvUVX(%u)", temp, SvIOK_UV(temp +), SvUVX(temp) ); RETVAL = temp; OUTPUT: RETVAL

Always gives

we got em 3f8d14 SvIOK_UV(0)SvUVX(42) at -e line 1. SV = IV(0x3f8d10) at 0x3f8d14 REFCNT = 1 FLAGS = (TEMP,IOK,pIOK) IV = 42

Replies are listed 'Best First'.
Re^2: XS: returning a 64-bit unsigned int?
by BrowserUk (Pope) on Sep 27, 2011 at 06:57 UTC

    Seems you can, provided you look in the wrong part of the manual for the api. :(


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Right, but shouldn't newSVuv make a UV and not an IV? Talk about false advertising :)
        shouldn't newSVuv make a UV and not an IV? Talk about false advertising :)

        I concur completely. But you think that ones bad, what d'ya think newSVrv( rv ) does?


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        Perl claims the right to convert among equivalent representations. It's an optimisation that an UV isn't used unless needed since UVs require extra handling.

        >perl -MDevel::Peek -e"Dump(0x7FFFFFFF)" SV = IV(0x1de9d00) at 0x1de9d04 REFCNT = 1 FLAGS = (PADTMP,IOK,READONLY,pIOK) IV = 2147483647 >perl -MDevel::Peek -e"Dump(0x80000000)" SV = IV(0x4a9d00) at 0x4a9d04 REFCNT = 1 FLAGS = (PADTMP,IOK,READONLY,pIOK,IsUV) UV = 2147483648

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://928021]
help
Chatterbox?
[Lotus1]: belg4mit are you on a Linix server?
[belg4mit]: yes. the regular expression is generated in code from a text file. that s the regular expression that Perl blows up when it reaches it, but if I use it from the comman line it's fine
[belg4mit]: oh, wait, damn, different lne number
[choroba]: same Perl version?
[choroba]: oh, ok
[belg4mit]: I had \Q'd in one RE but not a subsequent one, doh
[talexb]: Programs writing programs. Neat stuff.

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (13)
As of 2017-04-25 16:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (460 votes). Check out past polls.