versioner: Fix C11 threads.h

This commit annotates C11 Thread APIs so that bionic versioner won't
report errors.

This commit also adds a guard before `mtx_timedlock` because
`pthread_mutex_timedlock` was introduced in Android L.

Test: PATH=$(pwd)/prebuilts/clang-tools/linux-x86/bin:$PATH \
      bionic/tools/versioner/run_tests.py
Bug: 140110040

Change-Id: I3c6ce0831f613ffd3a7bf1c1972fd3548195cc56
diff --git a/libc/include/bits/threads_inlines.h b/libc/include/bits/threads_inlines.h
index 1130b3a..8f2beb0 100644
--- a/libc/include/bits/threads_inlines.h
+++ b/libc/include/bits/threads_inlines.h
@@ -34,9 +34,7 @@
 #include <sched.h>
 #include <stdlib.h>
 
-#if !defined(__BIONIC_THREADS_INLINE)
-#define __BIONIC_THREADS_INLINE static __inline
-#endif
+#if defined(__BIONIC_THREADS_INLINE)
 
 __BEGIN_DECLS
 
@@ -105,10 +103,12 @@
   return __bionic_thrd_error(pthread_mutex_lock(__mtx));
 }
 
+#if __ANDROID_API__ >= __ANDROID_API_L__
 __BIONIC_THREADS_INLINE int mtx_timedlock(mtx_t* __mtx,
                                           const struct timespec* __timeout) {
   return __bionic_thrd_error(pthread_mutex_timedlock(__mtx, __timeout));
 }
+#endif
 
 __BIONIC_THREADS_INLINE int mtx_trylock(mtx_t* __mtx) {
   return __bionic_thrd_error(pthread_mutex_trylock(__mtx));
@@ -205,3 +205,5 @@
 }
 
 __END_DECLS
+
+#endif  // __BIONIC_THREADS_INLINE
diff --git a/libc/include/threads.h b/libc/include/threads.h
index 2c43b0b..752761d 100644
--- a/libc/include/threads.h
+++ b/libc/include/threads.h
@@ -82,71 +82,72 @@
 // This file is implemented as static inlines before API level 30.
 
 /** Uses `__flag` to ensure that `__function` is called exactly once. */
-void call_once(once_flag* __flag, void (*__function)(void));
+void call_once(once_flag* __flag, void (*__function)(void)) __INTRODUCED_IN(30);
 
 
 
 /**
  * Unblocks all threads blocked on `__cond`.
  */
-int cnd_broadcast(cnd_t* __cond);
+int cnd_broadcast(cnd_t* __cond) __INTRODUCED_IN(30);
 
 /**
  * Destroys a condition variable.
  */
-void cnd_destroy(cnd_t* __cond);
+void cnd_destroy(cnd_t* __cond) __INTRODUCED_IN(30);
 
 /**
  * Creates a condition variable.
  */
-int cnd_init(cnd_t* __cond);
+int cnd_init(cnd_t* __cond) __INTRODUCED_IN(30);
 
 /**
  * Unblocks one thread blocked on `__cond`.
  */
-int cnd_signal(cnd_t* __cond);
+int cnd_signal(cnd_t* __cond) __INTRODUCED_IN(30);
 
 /**
  * Unlocks `__mutex` and blocks until `__cond` is signaled or `__timeout` occurs.
  */
-int cnd_timedwait(cnd_t* __cond, mtx_t* __mutex, const struct timespec* __timeout);
+int cnd_timedwait(cnd_t* __cond, mtx_t* __mutex, const struct timespec* __timeout)
+    __INTRODUCED_IN(30);
 
 /**
  * Unlocks `__mutex` and blocks until `__cond` is signaled.
  */
-int cnd_wait(cnd_t* __cond, mtx_t* __mutex);
+int cnd_wait(cnd_t* __cond, mtx_t* __mutex) __INTRODUCED_IN(30);
 
 
 
 /**
  * Destroys a mutex.
  */
-void mtx_destroy(mtx_t* __mutex);
+void mtx_destroy(mtx_t* __mutex) __INTRODUCED_IN(30);
 
 /**
  * Creates a mutex.
  */
-int mtx_init(mtx_t* __mutex, int __type);
+int mtx_init(mtx_t* __mutex, int __type) __INTRODUCED_IN(30);
 
 /**
  * Blocks until `__mutex` is acquired.
  */
-int mtx_lock(mtx_t* __mutex);
+int mtx_lock(mtx_t* __mutex) __INTRODUCED_IN(30);
 
 /**
  * Blocks until `__mutex` is acquired or `__timeout` expires.
  */
-int mtx_timedlock(mtx_t* __mutex, const struct timespec* __timeout);
+int mtx_timedlock(mtx_t* __mutex, const struct timespec* __timeout) __INTRODUCED_IN(30);
 
 /**
  * Acquires `__mutex` or returns `thrd_busy`.
  */
-int mtx_trylock(mtx_t* __mutex);
+int mtx_trylock(mtx_t* __mutex) __INTRODUCED_IN(30);
 
 /**
  * Unlocks `__mutex`.
  */
-int mtx_unlock(mtx_t* __mutex);
+int mtx_unlock(mtx_t* __mutex) __INTRODUCED_IN(30);
 
 
 
@@ -154,33 +155,33 @@
  * Creates a new thread running `__function(__arg)`, and sets `*__thrd` to
  * the new thread.
  */
-int thrd_create(thrd_t* __thrd, thrd_start_t __function, void* __arg);
+int thrd_create(thrd_t* __thrd, thrd_start_t __function, void* __arg) __INTRODUCED_IN(30);
 
 /**
  * Returns the `thrd_t` corresponding to the caller.
  */
-thrd_t thrd_current(void);
+thrd_t thrd_current(void) __INTRODUCED_IN(30);
 
 /**
  * Tells the OS to automatically dispose of `__thrd` when it exits.
  */
-int thrd_detach(thrd_t __thrd);
+int thrd_detach(thrd_t __thrd) __INTRODUCED_IN(30);
 
 /**
  * Tests whether two threads are the same thread.
  */
-int thrd_equal(thrd_t __lhs, thrd_t __rhs);
+int thrd_equal(thrd_t __lhs, thrd_t __rhs) __INTRODUCED_IN(30);
 
 /**
  * Terminates the calling thread, setting its result to `__result`.
  */
-void thrd_exit(int __result) __noreturn;
+void thrd_exit(int __result) __noreturn __INTRODUCED_IN(30);
 
 /**
  * Blocks until `__thrd` terminates. If `__result` is not null, `*__result`
  * is set to the exiting thread's result.
  */
-int thrd_join(thrd_t __thrd, int* __result);
+int thrd_join(thrd_t __thrd, int* __result) __INTRODUCED_IN(30);
 
 /**
  * Blocks the caller for at least `__duration` unless a signal is delivered.
@@ -189,12 +190,12 @@
  *
  * Returns 0 on success, or -1 if a signal was delivered.
  */
-int thrd_sleep(const struct timespec* __duration, struct timespec* __remaining);
+int thrd_sleep(const struct timespec* __duration, struct timespec* __remaining) __INTRODUCED_IN(30);
 
 /**
  * Request that other threads should be scheduled.
  */
-void thrd_yield(void);
+void thrd_yield(void) __INTRODUCED_IN(30);
 
 
 
@@ -202,24 +203,24 @@
  * Creates a thread-specific storage key with the associated destructor (which
  * may be null).
  */
-int tss_create(tss_t* __key, tss_dtor_t __dtor);
+int tss_create(tss_t* __key, tss_dtor_t __dtor) __INTRODUCED_IN(30);
 
 /**
  * Destroys a thread-specific storage key.
  */
-void tss_delete(tss_t __key);
+void tss_delete(tss_t __key) __INTRODUCED_IN(30);
 
 /**
  * Returns the value for the current thread held in the thread-specific storage
  * identified by `__key`.
  */
-void* tss_get(tss_t __key);
+void* tss_get(tss_t __key) __INTRODUCED_IN(30);
 
 /**
  * Sets the current thread's value for the thread-specific storage identified
  * by `__key` to `__value`.
  */
-int tss_set(tss_t __key, void* __value);
+int tss_set(tss_t __key, void* __value) __INTRODUCED_IN(30);
 
 #endif