Skip to content
  • Emanuele Giuseppe Esposito's avatar
    deb9c2ad
    util/qemu-thread-posix: use TSA_NO_TSA to suppress clang TSA warnings in FreeBSD · deb9c2ad
    Emanuele Giuseppe Esposito authored
    
    
    FreeBSD implements pthread headers using TSA (thread safety analysis)
    annotations, therefore when an application is compiled with
    -Wthread-safety there are some locking/annotation requirements that the
    user of the pthread API has to follow.
    
    This will also be the case in QEMU, since util/qemu-thread-posix.c uses
    the pthread API. Therefore when building it with -Wthread-safety, the
    compiler will throw warnings because the functions are not properly
    annotated. We need TSA to be enabled because it ensures that the
    critical sections of an annotated variable are properly locked.
    
    In order to make the compiler happy and avoid adding all the necessary
    macros to all callers (lock functions should use TSA_ACQUIRE, while
    unlock TSA_RELEASE, and this applies to all users of pthread_mutex_lock
    and pthread_mutex_unlock), simply use TSA_NO_TSA to supppress such
    warnings.
    
    Signed-off-by: default avatarEmanuele Giuseppe Esposito <eesposit@redhat.com>
    Message-Id: <20230117135203.3049709-2-eesposit@redhat.com>
    Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    deb9c2ad
    util/qemu-thread-posix: use TSA_NO_TSA to suppress clang TSA warnings in FreeBSD
    Emanuele Giuseppe Esposito authored
    
    
    FreeBSD implements pthread headers using TSA (thread safety analysis)
    annotations, therefore when an application is compiled with
    -Wthread-safety there are some locking/annotation requirements that the
    user of the pthread API has to follow.
    
    This will also be the case in QEMU, since util/qemu-thread-posix.c uses
    the pthread API. Therefore when building it with -Wthread-safety, the
    compiler will throw warnings because the functions are not properly
    annotated. We need TSA to be enabled because it ensures that the
    critical sections of an annotated variable are properly locked.
    
    In order to make the compiler happy and avoid adding all the necessary
    macros to all callers (lock functions should use TSA_ACQUIRE, while
    unlock TSA_RELEASE, and this applies to all users of pthread_mutex_lock
    and pthread_mutex_unlock), simply use TSA_NO_TSA to supppress such
    warnings.
    
    Signed-off-by: default avatarEmanuele Giuseppe Esposito <eesposit@redhat.com>
    Message-Id: <20230117135203.3049709-2-eesposit@redhat.com>
    Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
Loading