diff mbox

[4/4] Consolidate Linux truncate implementations

Message ID 20160922155131.GA20294@yury-N73SV
State New
Headers show

Commit Message

Yury Norov Sept. 22, 2016, 3:51 p.m. UTC
On Thu, Sep 22, 2016 at 11:42:11AM -0300, Adhemerval Zanella wrote:
> 
> 
> On 22/09/2016 11:24, Yury Norov wrote:
> >> +/* Truncate PATH to LENGTH bytes.  */
> >>  int
> >> -truncate64 (const char *path, off64_t length)
> >> +__truncate64 (const char *path, off64_t length)
> >>  {
> >> -  unsigned int low = length & 0xffffffff;
> >> -  unsigned int high = length >> 32;
> >> -  int result = INLINE_SYSCALL (truncate64, 3, path,
> >> -			       __LONG_LONG_PAIR (high, low));
> >> -  return result;
> >> +  return INLINE_SYSCALL_CALL (truncate64, path,
> >> +			      __ALIGNMENT_ARG SYSCALL_LL64 (length));
> >>  }
> >> +weak_alias (__truncate64, truncate64)
> >> +
> >> +#ifdef __OFF_T_MATCHES_OFF64_T
> >> +weak_alias (__truncate64, truncate);
> >> +#endif
> > 
> > It seems you forgot weak_alias (__truncate64, __truncate);
> > 
> 
> I do not think it requires to add __truncate alias since glibc currently
> does have internal calls to truncate.

Sorry, I was meaning __ftruncate: 
/home/yury/work/toolchain/build-glibc-aarch64-thunderx-linux-gnu-mabi-ilp32/libc_pic.os:
In function `internal_fallocate':
/home/yury/work/toolchain/gits/glibc/io/../sysdeps/posix/posix_fallocate.c:64:
undefined reference to `__ftruncate'

Truncate looks correct.
The fix is like this to me:

--

Comments

Adhemerval Zanella Netto Sept. 22, 2016, 7:04 p.m. UTC | #1
On 22/09/2016 12:51, Yury Norov wrote:
> On Thu, Sep 22, 2016 at 11:42:11AM -0300, Adhemerval Zanella wrote:
>>
>>
>> On 22/09/2016 11:24, Yury Norov wrote:
>>>> +/* Truncate PATH to LENGTH bytes.  */
>>>>  int
>>>> -truncate64 (const char *path, off64_t length)
>>>> +__truncate64 (const char *path, off64_t length)
>>>>  {
>>>> -  unsigned int low = length & 0xffffffff;
>>>> -  unsigned int high = length >> 32;
>>>> -  int result = INLINE_SYSCALL (truncate64, 3, path,
>>>> -			       __LONG_LONG_PAIR (high, low));
>>>> -  return result;
>>>> +  return INLINE_SYSCALL_CALL (truncate64, path,
>>>> +			      __ALIGNMENT_ARG SYSCALL_LL64 (length));
>>>>  }
>>>> +weak_alias (__truncate64, truncate64)
>>>> +
>>>> +#ifdef __OFF_T_MATCHES_OFF64_T
>>>> +weak_alias (__truncate64, truncate);
>>>> +#endif
>>>
>>> It seems you forgot weak_alias (__truncate64, __truncate);
>>>
>>
>> I do not think it requires to add __truncate alias since glibc currently
>> does have internal calls to truncate.
> 
> Sorry, I was meaning __ftruncate: 
> /home/yury/work/toolchain/build-glibc-aarch64-thunderx-linux-gnu-mabi-ilp32/libc_pic.os:
> In function `internal_fallocate':
> /home/yury/work/toolchain/gits/glibc/io/../sysdeps/posix/posix_fallocate.c:64:
> undefined reference to `__ftruncate'
> 
> Truncate looks correct.
> The fix is like this to me:
> 
> --
> diff --git a/sysdeps/unix/sysv/linux/ftruncate64.c b/sysdeps/unix/sysv/linux/ftruncate64.c
> index 914ce67..4a00db5 100644
> --- a/sysdeps/unix/sysv/linux/ftruncate64.c
> +++ b/sysdeps/unix/sysv/linux/ftruncate64.c
> @@ -33,5 +33,6 @@ __ftruncate64 (int fd, off64_t length)
>  weak_alias (__ftruncate64, ftruncate64)
> 
>  #ifdef __OFF_T_MATCHES_OFF64_T
> +weak_alias (__ftruncate64, __ftruncate)
>  weak_alias (__ftruncate64, ftruncate);
>  #endif
> 

Ah right, the fallback posix_fallocate implementation. I will add this to
the patch, thanks.
Adhemerval Zanella Netto Oct. 25, 2016, 5:54 p.m. UTC | #2
Ping.

On 22/09/2016 16:04, Adhemerval Zanella wrote:
> 
> 
> On 22/09/2016 12:51, Yury Norov wrote:
>> On Thu, Sep 22, 2016 at 11:42:11AM -0300, Adhemerval Zanella wrote:
>>>
>>>
>>> On 22/09/2016 11:24, Yury Norov wrote:
>>>>> +/* Truncate PATH to LENGTH bytes.  */
>>>>>  int
>>>>> -truncate64 (const char *path, off64_t length)
>>>>> +__truncate64 (const char *path, off64_t length)
>>>>>  {
>>>>> -  unsigned int low = length & 0xffffffff;
>>>>> -  unsigned int high = length >> 32;
>>>>> -  int result = INLINE_SYSCALL (truncate64, 3, path,
>>>>> -			       __LONG_LONG_PAIR (high, low));
>>>>> -  return result;
>>>>> +  return INLINE_SYSCALL_CALL (truncate64, path,
>>>>> +			      __ALIGNMENT_ARG SYSCALL_LL64 (length));
>>>>>  }
>>>>> +weak_alias (__truncate64, truncate64)
>>>>> +
>>>>> +#ifdef __OFF_T_MATCHES_OFF64_T
>>>>> +weak_alias (__truncate64, truncate);
>>>>> +#endif
>>>>
>>>> It seems you forgot weak_alias (__truncate64, __truncate);
>>>>
>>>
>>> I do not think it requires to add __truncate alias since glibc currently
>>> does have internal calls to truncate.
>>
>> Sorry, I was meaning __ftruncate: 
>> /home/yury/work/toolchain/build-glibc-aarch64-thunderx-linux-gnu-mabi-ilp32/libc_pic.os:
>> In function `internal_fallocate':
>> /home/yury/work/toolchain/gits/glibc/io/../sysdeps/posix/posix_fallocate.c:64:
>> undefined reference to `__ftruncate'
>>
>> Truncate looks correct.
>> The fix is like this to me:
>>
>> --
>> diff --git a/sysdeps/unix/sysv/linux/ftruncate64.c b/sysdeps/unix/sysv/linux/ftruncate64.c
>> index 914ce67..4a00db5 100644
>> --- a/sysdeps/unix/sysv/linux/ftruncate64.c
>> +++ b/sysdeps/unix/sysv/linux/ftruncate64.c
>> @@ -33,5 +33,6 @@ __ftruncate64 (int fd, off64_t length)
>>  weak_alias (__ftruncate64, ftruncate64)
>>
>>  #ifdef __OFF_T_MATCHES_OFF64_T
>> +weak_alias (__ftruncate64, __ftruncate)
>>  weak_alias (__ftruncate64, ftruncate);
>>  #endif
>>
> 
> Ah right, the fallback posix_fallocate implementation. I will add this to
> the patch, thanks.
>
Adhemerval Zanella Netto Nov. 9, 2016, 1:44 p.m. UTC | #3
Does anyone have any objection with this patch? If no one opposes I 
would like to push it to avoid get in late near freeze.

On 25/10/2016 15:54, Adhemerval Zanella wrote:
> Ping.
> 
> On 22/09/2016 16:04, Adhemerval Zanella wrote:
>>
>>
>> On 22/09/2016 12:51, Yury Norov wrote:
>>> On Thu, Sep 22, 2016 at 11:42:11AM -0300, Adhemerval Zanella wrote:
>>>>
>>>>
>>>> On 22/09/2016 11:24, Yury Norov wrote:
>>>>>> +/* Truncate PATH to LENGTH bytes.  */
>>>>>>  int
>>>>>> -truncate64 (const char *path, off64_t length)
>>>>>> +__truncate64 (const char *path, off64_t length)
>>>>>>  {
>>>>>> -  unsigned int low = length & 0xffffffff;
>>>>>> -  unsigned int high = length >> 32;
>>>>>> -  int result = INLINE_SYSCALL (truncate64, 3, path,
>>>>>> -			       __LONG_LONG_PAIR (high, low));
>>>>>> -  return result;
>>>>>> +  return INLINE_SYSCALL_CALL (truncate64, path,
>>>>>> +			      __ALIGNMENT_ARG SYSCALL_LL64 (length));
>>>>>>  }
>>>>>> +weak_alias (__truncate64, truncate64)
>>>>>> +
>>>>>> +#ifdef __OFF_T_MATCHES_OFF64_T
>>>>>> +weak_alias (__truncate64, truncate);
>>>>>> +#endif
>>>>>
>>>>> It seems you forgot weak_alias (__truncate64, __truncate);
>>>>>
>>>>
>>>> I do not think it requires to add __truncate alias since glibc currently
>>>> does have internal calls to truncate.
>>>
>>> Sorry, I was meaning __ftruncate: 
>>> /home/yury/work/toolchain/build-glibc-aarch64-thunderx-linux-gnu-mabi-ilp32/libc_pic.os:
>>> In function `internal_fallocate':
>>> /home/yury/work/toolchain/gits/glibc/io/../sysdeps/posix/posix_fallocate.c:64:
>>> undefined reference to `__ftruncate'
>>>
>>> Truncate looks correct.
>>> The fix is like this to me:
>>>
>>> --
>>> diff --git a/sysdeps/unix/sysv/linux/ftruncate64.c b/sysdeps/unix/sysv/linux/ftruncate64.c
>>> index 914ce67..4a00db5 100644
>>> --- a/sysdeps/unix/sysv/linux/ftruncate64.c
>>> +++ b/sysdeps/unix/sysv/linux/ftruncate64.c
>>> @@ -33,5 +33,6 @@ __ftruncate64 (int fd, off64_t length)
>>>  weak_alias (__ftruncate64, ftruncate64)
>>>
>>>  #ifdef __OFF_T_MATCHES_OFF64_T
>>> +weak_alias (__ftruncate64, __ftruncate)
>>>  weak_alias (__ftruncate64, ftruncate);
>>>  #endif
>>>
>>
>> Ah right, the fallback posix_fallocate implementation. I will add this to
>> the patch, thanks.
>>
diff mbox

Patch

diff --git a/sysdeps/unix/sysv/linux/ftruncate64.c b/sysdeps/unix/sysv/linux/ftruncate64.c
index 914ce67..4a00db5 100644
--- a/sysdeps/unix/sysv/linux/ftruncate64.c
+++ b/sysdeps/unix/sysv/linux/ftruncate64.c
@@ -33,5 +33,6 @@  __ftruncate64 (int fd, off64_t length)
 weak_alias (__ftruncate64, ftruncate64)

 #ifdef __OFF_T_MATCHES_OFF64_T
+weak_alias (__ftruncate64, __ftruncate)
 weak_alias (__ftruncate64, ftruncate);
 #endif