On Tue, Nov 26, 2019 at 9:59 AM Bruno Haible <[email protected]> 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.
