-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: add clang thread safety annotations #1419
base: master
Are you sure you want to change the base?
Conversation
libusb/libusbi.h
Outdated
@@ -44,6 +44,17 @@ | |||
#define static_assert(cond, msg) _Static_assert(cond, msg) | |||
#endif | |||
|
|||
/* https://clang.llvm.org/docs/ThreadSafetyAnalysis.html */ | |||
#ifdef __clang |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is how it is suggested by ThreadSafetyAnalysis.html
#ifdef __clang | |
#if defined(__clang__) && (!defined(SWIG)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we explicitly add -Wthread-safety
for this to kick in?
should be great to have those checks on CI if we're to add them on code level
generally looks good, don't see any code changes, only extra annotations
Yes. I haven't even tried that yet, because also required is that the threading functions be annotated too. pthread.h on my OS is not. It might be possible to annotate the wrappers in threads_posix.h though, which I will try...
Correct. The annotations also require that the mutex is declared before variables it protects, which is why I moved some things around. |
@mcuee not sure the macOS tag is appropriate, there's nothing macOS specific here. |
a1ef646
to
a9fee51
Compare
a9fee51
to
0a47f0c
Compare
0a47f0c
to
02d6423
Compare
02d6423
to
0aabba9
Compare
0aabba9
to
d0874d9
Compare
d0874d9
to
2095e55
Compare
… (for C++ compat)
2095e55
to
94bf9ba
Compare
See:
https://clang.llvm.org/docs/ThreadSafetyAnalysis.html