Add lock annotations to <sys/cdefs.h>.

Clang has support for annotating mutexes and code that uses mutexes to
validate certain aspects of thread safety:

- Whether acquiring/releasing locks is done properly (e.g., whether you
  unlock a mutex before leaving a function).
- Whether a lock is held while reading/writing data from/to memory.

Analysis is performed at the function level. Functions can be annotated
to indicate they:

- (try to) pick up a lock,
- release a lock,
- can only be called when (not) holding a lock,
- assert that a lock is held.

Variables and structure members can be annotated to indicate that they
are guarded by a certain lock. In C++, these annotations can refer
to both global variables, but also other class/structure members. In C,
it is only possible to refer to global variables.

This change adds wrappers for the annotations used by Clang to
<sys/cdefs.h>. They currently have no effect, but this is on purpose.
This change will be merged back to FreeBSD 9 and 10, which means we can
safely experiment with these annotations on HEAD without making it
harder to port changes back.

Reviewed by:	announced on arch@ and toolchain@
MFC after:	3 weeks


git-svn-id: svn+ssh://svn.freebsd.org/base/head@270941 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Enable lock annotations on HEAD when using Clang.

MFC after:	never


git-svn-id: svn+ssh://svn.freebsd.org/base/head@270942 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Add lock annotations to the header files of our threading libraries.

This change extends all of the functions present in the <pthread.h> and
<threads.h> headers to have lock annotations. This will allow Clang to
warn about the following:

- Locking a function twice,
- Unlocking a function without a mutex being locked,
- Forgetting to unlock a mutex before returning,
- Destroying or reinitializing a mutex that is currenty locked,
- Using an unlocked mutex in combination with a condition variable.

Enabling these annotations already allowed me to catch a bug in one of
our userspace tools (r270749).


git-svn-id: svn+ssh://svn.freebsd.org/base/head@270943 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Add lock annotations to the threading API used by hastd.

Approved by:	pjd@


git-svn-id: svn+ssh://svn.freebsd.org/base/head@270944 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f