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

Steve Lhomme robux4 at ycbcr.xyz
Fri Aug 7 07:06:35 CEST 2020


On 2020-08-07 6:55, Steve Lhomme wrote:
> 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

Or maybe a comment in this case, the function is small enough. For the 
cache patch [2/2] a static assert may be useful.

> 
> 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


More information about the vlc-devel mailing list