[uClibc]ftruncate64 on arm

Miles Bader miles at lsi.nec.co.jp
Mon Apr 1 03:35:01 UTC 2002


libc/sysdeps/linux/arm/ftruncate64.c, says:

   /* Unlike some architectures, arm can pass an off64_t directly 
    * into a syscall so we don't need to do anything special */
   extern _syscall2 (int, _ftruncate64, int, fd, __off64_t, length);

Are you sure about this?

This is the arm code for _syscall2 (from asm/unistd.h):

   #define _syscall2(type,name,type1,arg1,type2,arg2)			\
   type name(type1 arg1,type2 arg2) {					\
     long __res;							\
     __asm__ __volatile__ (						\
     "mov\tr0,%1\n\t"							\
     "mov\tr1,%2\n\t"							\
     __syscall(name)							\
     "mov\t%0,r0"							\
           : "=r" (__res)						\
           : "r" ((long)(arg1)),"r" ((long)(arg2))			\
           : "r0","r1","lr");						\
     __syscall_return(type,__res);					\
   }

Notice the casts to (long) -- it seems as if it will truncate all
arguments to long, i.e., 32 bits, so even though you don't get a compile
error, the code generated for ftruncate64 will be wrong.

[Perhaps there's magic of which I'm not aware though.]

-Miles
-- 
Come now, if we were really planning to harm you, would we be waiting here, 
 beside the path, in the very darkest part of the forest?



More information about the uClibc mailing list