[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: notation for documenting multithread-safety
From: |
Ben Pfaff |
Subject: |
Re: notation for documenting multithread-safety |
Date: |
Tue, 26 Nov 2019 10:17:26 -0800 |
On Tue, Nov 26, 2019 at 9:59 AM Bruno Haible <address@hidden> wrote:
> Is anyone aware of a notation that allows to specify, unambiguously, under
> which calls to a C function are multithread-safe?
>
> I would like to start documenting the multithread-safety of the functions in
> gnulib and other libraries (libunistring, libgettextpo, ...).
The only thing I know of that is close to this is the thread-safety annotations
that Clang supports, in which one can mark a function as requiring a particular
mutex to be taken, or that a particular mutex must not be taken, or that the
function acquires the mutex and then returns holding it, and various other
helpful things. The compiler analyzes the code and reports violations of the
annotations where possible.
Details:
https://clang.llvm.org/docs/ThreadSafetyAnalysis.html
The Clang docs mostly talk about C++ but it also supports C.
The "sparse" code analyzer has something a little like this but it is weaker.
This only covers one of your cases, however.