[vlc-devel] [PATCH 1/3] vlc_common: add vlc_align helper

Marvin Scholz epirat07 at gmail.com
Wed Feb 12 18:54:25 CET 2020


On 12 Feb 2020, at 17:41, Rémi Denis-Courmont wrote:

> Le keskiviikkona 12. helmikuuta 2020, 15.50.12 EET Marvin Scholz a 
> écrit :
>> ---
>>  include/vlc_common.h | 11 +++++++++++
>>  1 file changed, 11 insertions(+)
>>
>> diff --git a/include/vlc_common.h b/include/vlc_common.h
>> index e4c5cd85c9..9d9d0375c9 100644
>> --- a/include/vlc_common.h
>> +++ b/include/vlc_common.h
>> @@ -548,6 +548,17 @@ typedef int ( * vlc_list_callback_t ) ( 
>> vlc_object_t *,
>>      /* variable's objec /* clip v in [min, max] */
>>  #define VLC_CLIP(v, min, max)    __MIN(__MAX((v), (min)), (max))
>>
>> +/**
>> + * Make integer v a multiple of align
>> + *
>> + * \note align must be a power of 2
>> + */
>> +VLC_USED
>> +static inline size_t vlc_align(size_t v, size_t align)
>> +{
>> +    return ((v) + ((align) - 1)) & ~((align) - 1);
>
> Useless parenthesis.
>

Thanks, fixed locally.

>> +}
>> +
>
> This is an intrinsically questionable case because it should be a 
> function for
> expansion safety, but a macro to expand as a constant (e.g., as an 
> array
> sizes) - which are contradictory requirements.
>

Yeah I agree it’s not ideal, although currently there is no case where 
it is
used as a constant. I have no strong opinions here at all, it just made
sense to me to have it in common seeing how many modules use it.

>>  /** Greatest common divisor */
>>  VLC_USED
>>  static inline int64_t GCD ( int64_t a, int64_t b )
>
> -- 
> レミ・デニ-クールモン
> http://www.remlab.net/
>
>
>
> _______________________________________________
> 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