Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Non ix86 internals

by diotalevi (Canon)
on Jan 06, 2003 at 06:02 UTC ( [id://224558]=perlquestion: print w/replies, xml ) Need Help??

diotalevi has asked for the wisdom of the Perl Monks concerning the following question:

I'm interested in what some of B's output looks like on different archtectures. I wrote a simple script that dumps some information on the FLAGS portion of a few scalars (global/pad/int/str). I also printed some config information on the off chance it's interesting though I don't know that in advance. So please, if you have something that isn't ix86 based then I'm interested to see what this outputs for you. So post your output and you'll earn my gratitude and a ++. Thanks.

require B; sub flags { my ($name, $test_ref) = @_; my $test_obj = B::svref_2object( $test_ref ); my $bits = sprintf "%o", $test_obj -> FLAGS; # my $bits = unpack 'B*', pack 'N', $test_obj -> FLAGS; print "$name: $bits\n"; } my $pad_str = "str"; my $pad_int = 1; $str = "str"; $int = 1; flags( "pad str", \ $pad_str ); flags( "pad int", \ $pad_int ); flags( "gbl str", \ $str ); flags( "gbl int", \ $int ); print "\n"; # Print some values I'm interested in seeing. use Config qw(config_vars); config_vars(qw(archname intsize longsize ptrsize doublesize byteorder d_longlong longlongsize d_longdbl longdblsize ivtype ivsize nvtype nvsize lseeksize alignbytes)); __DATA__ pad str: 401002404 pad int: 100202401 gbl str: 401000004 gbl int: 100200001 archname='MSWin32-x86-multi-thread'; intsize='4'; longsize='4'; ptrsize='4'; doublesize='8'; byteorder='1234'; d_longlong='undef'; longlongsize='8'; d_longdbl='define'; longdblsize='10'; ivtype='long'; ivsize='4'; nvtype='double'; nvsize='8'; lseeksize='4'; alignbytes='8';

Replies are listed 'Best First'.
Re: Non ix86 internals
by gjb (Vicar) on Jan 06, 2003 at 06:23 UTC

    A DEC, er... Compaq, er... HP Alpha (perl, version 5.005_03) ;-)

    pad str: 401002404 pad int: 100202401 gbl str: 401000004 gbl int: 100200001 archname='alpha-dec_osf'; intsize='4'; longsize='8'; ptrsize='8'; doublesize='8'; byteorder='12345678'; d_longlong='define'; longlongsize='8'; d_longdbl='define'; longdblsize='8'; ivtype='UNKNOWN'; ivsize='UNKNOWN'; nvtype='UNKNOWN'; nvsize='UNKNOWN'; lseeksize='UNKNOWN'; alignbytes='8';
    Hope this helps, -gjb-

    PS: of course I only do it for the XPs ;-)

Re: Non ix86 internals
by submersible_toaster (Chaplain) on Jan 06, 2003 at 06:33 UTC
    In anticipation of ++ : )
    Here's what my desktop SGI indy thinks (the first bit is the hinv header in case it's any use).
    CPU: MIPS R5000 Processor Chip Revision: 1.0 FPU: MIPS R5000 Floating Point Coprocessor Revision: 1.0 1 180 MHZ IP22 Processor Main memory size: 256 Mbytes Secondary unified instruction/data cache size: 512 Kbytes on Processor + 0 Instruction cache size: 32 Kbytes Data cache size: 32 Kbytes pad str: 401002404 pad int: 100202401 gbl str: 401000004 gbl int: 100200001 archname='irix-n32'; intsize='4'; longsize='4'; ptrsize='4'; doublesize='8'; byteorder='87654321'; d_longlong='define'; longlongsize='8'; d_longdbl='define'; longdblsize='16'; ivtype='long long'; ivsize='8'; nvtype='double'; nvsize='8'; lseeksize='8'; alignbytes='8';


    I can't believe it's not psellchecked
Re: Non ix86 internals
by shotgunefx (Parson) on Jan 06, 2003 at 06:29 UTC
    Sparc Ultra 10 running linux... perl 5.6.1
    pad str: 401002404 pad int: 100202401 gbl str: 401000004 gbl int: 100200001 archname='sparc64-linux'; intsize='4'; longsize='4'; ptrsize='4'; doublesize='8'; byteorder='4321'; d_longlong='define'; longlongsize='8'; d_longdbl='define'; longdblsize='8'; ivtype='long'; ivsize='4'; nvtype='long double'; nvsize='8'; lseeksize='8'; alignbytes='8';


    -Lee

    "To be civilized is to deny one's nature."

      Another Sun, similar (but not identical) results (using 5.6.1)

      % perl diol pad str: 401002404 pad int: 100202401 gbl str: 401000004 gbl int: 100200001 archname='sun4-solaris'; intsize='4'; longsize='4'; ptrsize='4'; doublesize='8'; byteorder='4321'; d_longlong='define'; longlongsize='8'; d_longdbl='define'; longdblsize='16'; ivtype='long'; ivsize='4'; nvtype='double'; nvsize='8'; lseeksize='8'; alignbytes='8'; % uname -a SunOS ouessant 5.6 Generic_105181-31 sun4u sparc SUNW,Ultra-4


      print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'
Re: Non ix86 internals
by davis (Vicar) on Jan 06, 2003 at 09:13 UTC
    perl 5.6.1 on a HPPA 2.0 cpu. (HP C360 running HP-UX 11.00):
    pad str: 401002404 pad int: 100202401 gbl str: 401000004 gbl int: 100200001 archname='PA-RISC2.0'; intsize='4'; longsize='4'; ptrsize='4'; doublesize='8'; byteorder='4321'; d_longlong='define'; longlongsize='8'; d_longdbl='define'; longdblsize='8'; ivtype='long'; ivsize='4'; nvtype='double'; nvsize='8'; lseeksize='4'; alignbytes='8';

    davis
    Is this going out live?
    No, Homer, very few cartoons are broadcast live - it's a terrible strain on the animator's wrist
Re: Non ix86 internals
by pg (Canon) on Jan 06, 2003 at 06:47 UTC
    AIX:
    pad str: 401002404
    pad int: 100202401
    gbl str: 401000004
    gbl int: 100200001
    
    archname='ppc-aix';
    intsize='4';
    longsize='4';
    ptrsize='4';
    doublesize='8';
    byteorder='4321';
    d_longlong='define';
    longlongsize='8';
    d_longdbl='define';
    longdblsize='8';
    ivtype='long';
    ivsize='4';
    nvtype='double';
    nvsize='8';
    lseeksize='8';
    alignbytes='8';
    
    Update:

    You can also see most of those values without even running any script. They are stored in a file called uconfig.sh.

    For activestate perl on win32, those values are stored in a file called uconfig.h under lib/CORE.
Re: Non ix86 internals
by diotalevi (Canon) on Jan 06, 2003 at 06:55 UTC

    Well that's cool then. It looks like the output of B::SV->FLAGS works the same regardless of which endian things are. So I learned something today.

    Update: [I just moved a whole block of added content to this node's response. It's still around, just more visible and not exactly here. ]


    Fun Fun Fun in the Fluffy Chair

      This response was originally tacked onto the end of another node but I decided to promote it to a new response just so it'd be more visible.


      I should note - the whole point of this exercise was to find out whether things like the following code fragment would produce similar results on differing endian machines. I didn't know whether reading from B's FLAGS attribute was like using unpack 'L', unpack 'P4', pack 'L', 12+\$pad_str to read directly from memory. I'd expect the direct memory read to non-portable for a couple of reasons. I just didn't know what would happen if I read the value properly. It appears to come out alright which is just great.

      As for why I'm doing something so obscure - just for obfus. It'd be no fun to write more poetry and have it fail or not work because of differing endian-ness. Thanks for playing all!

      require B; my $pad_int = 1; $o = B::svref_2object( \ $pad_int ); $flags = $o -> FLAGS; $type = $flags & 0xff; $flags = $flags & ~ 0xff; $, = " "; print "\$pad_int == $pad_int (",type($type),flags($flags),")"; # Prints "$pad_int == 1 ( IV PADBUSY PADMY IOK pIOK OK )" sub type { ('NULL', 'IV' , 'NV' , 'RV' , 'PV' , 'PVIV', 'PVNV', 'PVMG', 'PVBM', 'PVLV', 'PVAV', 'PVHV', 'PVCV', 'PVGV', 'PVFM', 'PVIO')[ $_[0] ] } # I included these routines just for fun - I already had it written d +own # and just transcribed it. So this is at least a sniff at the fun thi +ngs # you can check if you can actually do this reliably - which it appea +rs # you can. sub flags { my @flags = (); my $flags = shift; # Mask off the TYPE portion $flags &= ~ 0xff; push @flags, 'PADBUSY' if $flags & 0x100; # reserved for tmp or my already push @flags, 'PADTMP' if $flags & 0x200; # in use as tmp push @flags, 'PADMY' if $flags & 0x400; # in use as "my" variable push @flags, 'TEMP' if $flags & 0x800; # string is stealable? push @flags, 'OBJECT' if $flags & 0x1000; # is "blessed" push @flags, 'GMG' if $flags & 0x2000; # has magical get method push @flags, 'SMG' if $flags & 0x4000; # has magical set method push @flags, 'RMG' if $flags & 0x8000; # has random magical methods push @flags, 'IOK' if $flags & 0x10000; # has valid public integer value push @flags, 'NOK' if $flags & 0x20000; # has valid public numeric value push @flags, 'POK' if $flags & 0x40000; # has valid pointer value push @flags, 'ROK' if $flags & 0x80000; # has a valid reference pointer push @flags, 'FAKE' if $flags & 0x100000; # glob or lexical is just a copy push @flags, 'OOK' if $flags & 0x200000; # has valid offset value push @flags, 'BREAK' if $flags & 0x400000; # refcnt is artificially low push @flags, 'READONLY' if $flags & 0x800000; # may not be modified push @flags, 'pIOK' if $flags & 0x1000000; # has valid non-public integer value push @flags, 'pNOK' if $flags & 0x2000000; # has valid non-public numeric value push @flags, 'pPOK' if $flags & 0x4000000; # has valid non-public pointer value push @flags, 'SCREAM' if $flags & 0x8000000; # has been studied? push @flags, 'UTF8' if $flags & 0x20000000; # SvPVX is UTF-8 encoded push @flags, 'THINKFIRST' if $flags & (0x00800000 | 0x00080000 | 0x00100000 | 0x20000000); # READONLY, ROK, FAKE or UTF-8 push @flags, 'OK' if $flags & (0x0010000 | 0x0020000 | 0x0040000 | 0x0080000 | 0x1000000 | 0x2000000 | 0x4000000); # IOK, NOK, POK, ROK, pIOK, pNOK or pPOK push @flags, 'AMAGIC' if $flags & 0x10000000; # has magical overloaded methods # Some private flags # SVpad_OUR may be set on SVt_PV{NV,MG,GV} types push @flags, 'OUR' if $flags & 0x80000000; # pad name is "our" instead of "my" push @flags, 'IVisUV' if $flags & 0x80000000; # use XPVUV instead of XPVIV push @flags, 'COMPILED' if $flags & 0x80000000; # FORMLINE is compiled push @flags, 'VALID' if $flags & 0x80000000; push @flags, 'TAIL' if $flags & 0x40000000; push @flags, 'EVAL' if $flags & 0x40000000; # Replacemenet part of S///e push @flags, 'SHAREKEYS' if $flags & 0x20000000; # keys live on shared string table push @flags, 'LAZYDEL' if $flags & 0x40000000; # entry in xhv_eiter must be deleted push @flags, 'WEAKREF' if $flags & 0x80000000; # Weak reference return @flags }

      Fun Fun Fun in the Fluffy Chair

Re: Non ix86 internals
by staunch (Pilgrim) on Jan 06, 2003 at 13:45 UTC
    Here ya go!
    $ perl -v This is perl, v5.6.1 built for sun4-solaris-64int $ uname -a SunOS good 5.9 Generic sun4u sparc SUNW,Ultra-60 pad str: 401002404 pad int: 100202401 gbl str: 401000004 gbl int: 100200001 archname='sun4-solaris-64int'; intsize='4'; longsize='4'; ptrsize='4'; doublesize='8'; byteorder='87654321'; d_longlong='define'; longlongsize='8'; d_longdbl='define'; longdblsize='16'; ivtype='long long'; ivsize='8'; nvtype='double'; nvsize='8'; lseeksize='8'; alignbytes='8';


    Staunch

Re: Non ix86 internals
by Beatnik (Parson) on Jan 06, 2003 at 07:43 UTC
    Since no one posted the obvious...
    pad str: 401002404 pad int: 100202401 gbl str: 401000004 gbl int: 100200001 archname='i686-linux'; intsize='4'; longsize='4'; ptrsize='4'; doublesize='8'; byteorder='1234'; d_longlong='define'; longlongsize='8'; d_longdbl='define'; longdblsize='12'; ivtype='long'; ivsize='4'; nvtype='double'; nvsize='8'; lseeksize='8'; alignbytes='4';
    Update:Well, maybe I should get more coffee before posting ;-)

    Greetz
    Beatnik
    ... Quidquid perl dictum sit, altum viditur.

      Your i686 isn't ix86? ;^)

        I donno I don't know :-) is your windows box?

        Greetz
        Beatnik
        ... Quidquid perl dictum sit, altum viditur.
Re: Non ix86 internals
by krujos (Curate) on Jan 06, 2003 at 22:45 UTC
    Here are some intresting results when I ran this on a big sun box at work. If anyone can offer an explination as to why they came out this way I would be intrested to find out why.
    jkruck:<greytea> % uname -a SunOS greytea 5.8 Generic_108528-13 sun4u sparc SUNW,Ultra-Enterprise- +10000 jkruck:<greytea> % perl tmp.pl pad str: 401002404 pad int: 100202401 gbl str: 401000004 gbl int: 100200001 archname='sun4-solaris'; intsize='4'; longsize='4'; ptrsize='4'; doublesize='8'; byteorder='4321'; d_longlong='define'; longlongsize='8'; d_longdbl='define'; longdblsize='16'; ivtype='UNKNOWN'; ivsize='UNKNOWN'; nvtype='UNKNOWN'; nvsize='UNKNOWN'; lseeksize='UNKNOWN'; alignbytes='8'; jkruck:<greytea> %
    also a new ppc based AIX box just for kicks
    jkruck:<snow> % uname -a AIX snow 1 5 0000BC3A4C00 jkruck:<snow> % perl tmp.pl pad str: 401002404 pad int: 20100202401 gbl str: 401000004 gbl int: 20100200001 archname='aix'; intsize='4'; longsize='4'; ptrsize='4'; doublesize='8'; byteorder='4321'; d_longlong='define'; longlongsize='8'; d_longdbl='define'; longdblsize='8'; ivtype='long'; ivsize='4'; nvtype='double'; nvsize='8'; lseeksize='8'; alignbytes='8'; jkruck:<snow> %
    Thanks Josh

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://224558]
Approved by rob_au
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-24 00:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found