[vlc-devel] [PATCH 3/4] cpu: deduplicate one-time initialization

Rémi Denis-Courmont remi at remlab.net
Mon Mar 30 10:13:50 CEST 2020


It's a mistake. It should move the existing weak qualifier, not add a new one.

Le 30 mars 2020 10:35:38 GMT+03:00, Alexandre Janniaux <ajanni at videolabs.io> a écrit :
>Hi,
>
>Can you add the reason for putting an additional VLC_WEAK
>on vlc_CPU_raw in the commit message? It would probably help
>in the future.
>
>Regards,
>--
>Alexandre Janniaux
>Videolabs
>
>On Sun, Mar 29, 2020 at 11:43:54PM +0300, Rémi Denis-Courmont wrote:
>> ---
>>  include/vlc_cpu.h |  8 ++++++++
>>  src/linux/cpu.c   | 22 +---------------------
>>  src/misc/cpu.c    |  2 +-
>>  3 files changed, 10 insertions(+), 22 deletions(-)
>>
>> diff --git a/include/vlc_cpu.h b/include/vlc_cpu.h
>> index 6fe098f78a..80dfd9656d 100644
>> --- a/include/vlc_cpu.h
>> +++ b/include/vlc_cpu.h
>> @@ -31,6 +31,14 @@
>>   */
>>  VLC_API unsigned vlc_CPU(void);
>>
>> +/**
>> + * Computes CPU capability flags.
>> + *
>> + * Do not call this function directly.
>> + * Call vlc_CPU() instead, which caches the correct value.
>> + */
>> +unsigned vlc_CPU_raw(void);
>> +
>>  # if defined (__i386__) || defined (__x86_64__)
>>  #  define HAVE_FPU 1
>>  #  define VLC_CPU_MMX    0x00000008
>> diff --git a/src/linux/cpu.c b/src/linux/cpu.c
>> index f9a82bb51e..6ba11512ef 100644
>> --- a/src/linux/cpu.c
>> +++ b/src/linux/cpu.c
>> @@ -40,7 +40,7 @@
>>  #endif
>>
>>  #ifdef CPU_FLAGS
>> -static unsigned vlc_CPU_raw(void)
>> +unsigned vlc_CPU_raw(void)
>>  {
>>      FILE *info = fopen ("/proc/cpuinfo", "rte");
>>      if (info == NULL)
>> @@ -120,24 +120,4 @@ static unsigned vlc_CPU_raw(void)
>>
>>      return all_caps;
>>  }
>> -
>> -static uint32_t cpu_flags = 0;
>> -
>> -static void vlc_CPU_init(void)
>> -{
>> -    cpu_flags = vlc_CPU_raw();
>> -}
>> -
>> -unsigned vlc_CPU (void)
>> -{
>> -    static pthread_once_t once = PTHREAD_ONCE_INIT;
>> -
>> -    pthread_once (&once, vlc_CPU_init);
>> -    return cpu_flags;
>> -}
>> -#else /* CPU_FLAGS */
>> -unsigned vlc_CPU (void)
>> -{
>> -    return 0;
>> -}
>>  #endif
>> diff --git a/src/misc/cpu.c b/src/misc/cpu.c
>> index 8a8835b79b..7f3a89a3cb 100644
>> --- a/src/misc/cpu.c
>> +++ b/src/misc/cpu.c
>> @@ -113,7 +113,7 @@ static void Altivec_test (void)
>>  /**
>>   * Determines the CPU capabilities.
>>   */
>> -static unsigned vlc_CPU_raw(void)
>> +VLC_WEAK unsigned vlc_CPU_raw(void)
>>  {
>>      uint32_t i_capabilities = 0;
>>
>> --
>> 2.26.0
>>
>> _______________________________________________
>> 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/20200330/81dbcfe7/attachment.html>


More information about the vlc-devel mailing list