I just discovered that the inline version too works the wrong way. The
strange behaviour I found (ftello64 working inline but not when the
result was stored in a var) was due to the fact that the file size was
in the interval (2^31, 2^32). If the file size is more than 2^32 bytes
the two results for ftello64 are equal (and wrong).

/* output */
Size of file hugefile2.hf retrieved in different ways
fgetpos64 var(64b) 4311081472
ftello64  var(64b) 16114176
ftello64  inline   16114176
/* end output */

I also attach the asm code without -O3 so that it is easier to
understand.

/* asm */
.L7:
        movq    -16(%rbp), %rdi # filein, filein
        movl    $0, %eax        #,
        call    ftello64        #
        cltq
        movq    %rax, -8(%rbp)  # D.2124, size_tl
        movq    -16(%rbp), %rdi # filein, filein
        movl    $0, %eax        #,
        call    ftello64        #
        movl    %eax, %edx      #, D.2125                          <---------
        movq    -32(%rbp), %rsi # size_gp, size_gp.3
        movq    -8(%rbp), %rax  # size_tl, size_tl
        movl    %edx, %r9d      # D.2125, D.2125               <----------
        movq    %rax, %r8       # size_tl, size_tl
        movl    $64, %ecx       #,
        movq    %rsi, %rdx      # size_gp.3, size_gp.3
        movl    $64, %esi       #,
        movl    $.LC5, %edi     #,
        movl    $0, %eax        #,
        call    printf  #
        movq    -16(%rbp), %rdi # filein, filein
        call    fclose  #
        movl    $0, -52(%rbp)   #, D.2119
/* end asm */

The arguments to the functions are passed as registers in this order: RDI RSI 
RDX RCX R8 R9, and the return value is stored in RAX.
It seems like the return value of ftello64 is considered 32 bits because in the 
lines marked with the arrow just the 32bit part of the return value of ftello64 
is moved to R9 (namely R9d), i.e. to the 6th argument of printf.

Cheers,
Luca

-- 
ftello64 not working with large files
https://bugs.launchpad.net/bugs/113791
You received this bug notification because you are a member of Ubuntu
Bugs, which is the bug contact for Ubuntu.

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to