Make threading helpers tests thread safe
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
diff --git a/include/mbedtls/threading.h b/include/mbedtls/threading.h
index c136ea0..cdfa7d6 100644
--- a/include/mbedtls/threading.h
+++ b/include/mbedtls/threading.h
@@ -29,10 +29,11 @@
typedef struct mbedtls_threading_mutex_t {
pthread_mutex_t MBEDTLS_PRIVATE(mutex);
- /* is_valid is controlled by code in tests/src/threading_helpers - it will
- * be 0 after a failed init or a free, and nonzero after a successful init.
- * This field is for testing only and thus not considered part of the
- * public API of Mbed TLS and may change without notice. */
+ /* WARNING - is_valid should only be accessed when holding the mutex lock in
+ * tests/src/threading_helpers.c, otherwise corruption can occur.
+ * is_valid will be 0 after a failed init or a free, and nonzero after a
+ * successful init. This field is for testing only and thus not considered
+ * part of the public API of Mbed TLS and may change without notice.*/
char MBEDTLS_PRIVATE(is_valid);
} mbedtls_threading_mutex_t;