V3 [PATCH] Add a C wrapper for prctl [BZ #25896]

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Thu Nov 10 12:25:45 GMT 2022



On 10/11/22 09:03, Florian Weimer wrote:
> * Adhemerval Zanella Netto:
> 
>> The previous syscalls.list entry marked the function as 5 argument one
>> instead of variadic, so I think it would be better to add a way each
>> ABI to use this instead of the variadic one. Something like:
>>
>>   #if PRCTL_VARIADIC_OK
>>   int
>>   __prctl (int option, ...)
>>   {
>>     va_list arg;
>>     va_start (arg, option);
>>     unsigned long int arg2 = va_arg (arg, unsigned long int);
>>     unsigned long int arg3 = va_arg (arg, unsigned long int);
>>     unsigned long int arg4 = va_arg (arg, unsigned long int);
>>     unsigned long int arg5 = va_arg (arg, unsigned long int);
>>     va_end (arg);
>>     return INLINE_SYSCALL_CALL (prctl, option, arg2, arg3, arg4, arg5);
>>   }
>>   #else
>>   int
>>   __prctl (int option, int arg1, int arg2, int arg3, int arg4, int arg5)
>>   {
>>     return INLINE_SYSCALL_CALL (prctl, option, arg2, arg3, arg4, arg5);
>>   }
>>   #endif
> 
> (The arguments need to be unsigned long int.)
> 
> This is not easy to do in C because the GCC aliasing machinery performs
> type checking (as it should).
> 
> We can probably use
> 
> #define prctl prctl_XXX
> #define __prctl __prctl_XXX

Yes, I did not include it but we already do it for non-LFS to LFS alias.

> 
> before including <sys/prctl.h>, but that's quite ugly.  Do you still
> want me to proceed with the C version?

I would, although it is not the simplest solution.


More information about the Libc-alpha mailing list