[vlc-devel] [PATCH 1/2] posix/wait: do not use alignof on expression

Rémi Denis-Courmont remi at remlab.net
Fri Aug 7 14:42:40 CEST 2020


Hi,

You can use _Generic() if you want to match types. No need for compiler-dependent ifdef'ery.

Might be overkill here though.

Le 7 août 2020 07:55:35 GMT+03:00, Steve Lhomme <robux4 at ycbcr.xyz> a écrit :
>OK for both. Although it would be nice to have a safety check in case 
>the underlying type changes and the alignof is not valid anymore.
>
>May a static_assert when compiling with GCC, like
>#if defined(__GNUC__) && !defined(__llvm__) &&
>!defined(__INTEL_COMPILER)
>static_assert(alignof(*addr) == alignof(atomic_uint), "type mismatch");
>#endif
>
>
>On 2020-08-07 6:44, Marvin Scholz wrote:
>> Using alignof not on a type but an expression is a GNU extension and
>> causes the following warning:
>> 
>>     warning: '_Alignof' applied to an expression is a GNU extension
>> ---
>>   src/posix/wait.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/src/posix/wait.c b/src/posix/wait.c
>> index 584cc493b1a..3fa6890193a 100644
>> --- a/src/posix/wait.c
>> +++ b/src/posix/wait.c
>> @@ -52,7 +52,7 @@ static struct wait_bucket
>>   static struct wait_bucket *wait_bucket_get(atomic_uint *addr)
>>   {
>>       uintptr_t u = (uintptr_t)addr;
>> -    size_t idx = (u / alignof (*addr)) % ARRAY_SIZE(wait_buckets);
>> +    size_t idx = (u / alignof (atomic_uint)) %
>ARRAY_SIZE(wait_buckets);
>>   
>>       return &wait_buckets[idx];
>>   }
>> -- 
>> 2.24.3 (Apple Git-128)
>> 
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
>> 
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel

-- 
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20200807/7bcfcb73/attachment.html>


More information about the vlc-devel mailing list