On 2018/11/14 21:46, sisyphus wrote:
> On Wed, Nov 14, 2018 at 10:20 PM Tetsuo Handa 
> <penguin-ker...@i-love.sakura.ne.jp> wrote:
> 
>> Even on 32bit environments (at least for Linux), lstat() calls 64bit version
> 

Here is some test results on Linux.

32bits userspace on 32bits kernel:
# truncate -s 17592186044415 test
# perl -e 'use File::stat; my $sb = lstat("test"); printf("%s\n", $sb->size);'
17592186044415
# perl -e 'use File::stat; my $sb = lstat("test"); printf("%u\n", $sb->size);'
4294967295

32bits userspace on 64bits kernel:
# truncate -s 9223372036854775807 test
# perl -e 'use File::stat; my $sb = lstat("test"); printf("%s\n", $sb->size);'
9.22337203685478e+18
# perl -e 'use File::stat; my $sb = lstat("test"); printf("%u\n", $sb->size);'
4294967295

64bits userspace on 64bits kernel:
# truncate -s 9223372036854775807 test
# perl -e 'use File::stat; my $sb = lstat("test"); printf("%s\n", $sb->size);'
9223372036854775807
# perl -e 'use File::stat; my $sb = lstat("test"); printf("%u\n", $sb->size);'
9223372036854775807

> When I check on Windows, I find that the value is actually an NV (not an IV
> as I had expected).
> I expect it's the same for you, in which case it's a 53-bit double
> (unless $Config{nvsize} reports a value greater than 8).
> 
> You can test for this using Devel::Peek:
> 

64bits userspace on 64bits kernel:
NV is 8 bytes
SV = IV(0x1f98730) at 0x1f98740
  REFCNT = 1
  FLAGS = (IOK,pIOK)
  IV = 9223372036854775807

32bits userspace on 64bits kernel:
NV is 8 bytes
SV = NV(0x95d7608) at 0x95b45b8
  REFCNT = 1
  FLAGS = (NOK,pNOK)
  NV = 9.22337203685478e+18

Since accurate file size value is lost as soon as it is stored into $sb, doing

  my $x = $sb->size;
  $value = Math::BigInt->new("$x");

won't help. I will use "%s" without Math::BigInt.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to