[libc] Add mtx_destroy which does nothing.

There is not cleanup to be done for the mutex type so mtx_destroy does
nothing.

GitOrigin-RevId: 7a2a765745973ebeb041276d2d9489a000ba9371
diff --git a/config/linux/x86_64/entrypoints.txt b/config/linux/x86_64/entrypoints.txt
index 3a15068..a4b8383 100644
--- a/config/linux/x86_64/entrypoints.txt
+++ b/config/linux/x86_64/entrypoints.txt
@@ -189,6 +189,7 @@
 
     # threads.h entrypoints
     libc.src.threads.call_once
+    libc.src.threads.mtx_destroy
     libc.src.threads.mtx_init
     libc.src.threads.mtx_lock
     libc.src.threads.mtx_unlock
diff --git a/spec/stdc.td b/spec/stdc.td
index da169a5..08ceea7 100644
--- a/spec/stdc.td
+++ b/spec/stdc.td
@@ -581,6 +581,13 @@
               ]
           >,
           FunctionSpec<
+              "mtx_destroy",
+              RetValSpec<IntType>,
+              [
+                  ArgSpec<VoidType>,
+              ]
+          >,
+          FunctionSpec<
               "mtx_lock",
               RetValSpec<IntType>,
               [
diff --git a/src/threads/CMakeLists.txt b/src/threads/CMakeLists.txt
index 276aa51..a5d9589 100644
--- a/src/threads/CMakeLists.txt
+++ b/src/threads/CMakeLists.txt
@@ -31,6 +31,13 @@
 )
 
 add_entrypoint_object(
+  mtx_destroy
+  ALIAS
+  DEPENDS
+    .${LIBC_TARGET_OS}.mtx_destroy
+)
+
+add_entrypoint_object(
   mtx_lock
   ALIAS
   DEPENDS
diff --git a/src/threads/linux/CMakeLists.txt b/src/threads/linux/CMakeLists.txt
index 730314c..b28850b 100644
--- a/src/threads/linux/CMakeLists.txt
+++ b/src/threads/linux/CMakeLists.txt
@@ -82,6 +82,17 @@
 )
 
 add_entrypoint_object(
+  mtx_destroy
+  SRCS
+    mtx_destroy.cpp
+  HDRS
+    ../mtx_destroy.h
+  DEPENDS
+    .threads_utils
+    libc.include.threads
+)
+
+add_entrypoint_object(
   mtx_lock
   SRCS
     mtx_lock.cpp
diff --git a/src/threads/linux/mtx_destroy.cpp b/src/threads/linux/mtx_destroy.cpp
new file mode 100644
index 0000000..a64cfde
--- /dev/null
+++ b/src/threads/linux/mtx_destroy.cpp
@@ -0,0 +1,18 @@
+//===-- Linux implementation of the mtx_destroy function ------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/threads/mtx_destroy.h"
+#include "include/threads.h" // For mtx_t definition.
+#include "src/__support/common.h"
+#include "src/threads/linux/Mutex.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(void, mtx_destroy, (mtx_t * mutex)) {}
+
+} // namespace __llvm_libc
diff --git a/src/threads/mtx_destroy.h b/src/threads/mtx_destroy.h
new file mode 100644
index 0000000..c123b81
--- /dev/null
+++ b/src/threads/mtx_destroy.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for mtx_destroy function ----------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_THREADS_MTX_DESTROY_H
+#define LLVM_LIBC_SRC_THREADS_MTX_DESTROY_H
+
+#include "include/threads.h"
+
+namespace __llvm_libc {
+
+void mtx_destroy(mtx_t *mutex);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_THREADS_MTX_DESTROY_H
diff --git a/test/src/threads/CMakeLists.txt b/test/src/threads/CMakeLists.txt
index 246401d..52d0e0d 100644
--- a/test/src/threads/CMakeLists.txt
+++ b/test/src/threads/CMakeLists.txt
@@ -9,6 +9,7 @@
   DEPENDS
     libc.include.threads
     libc.src.threads.call_once
+    libc.src.threads.mtx_destroy
     libc.src.threads.mtx_init
     libc.src.threads.mtx_lock
     libc.src.threads.mtx_unlock
@@ -39,6 +40,7 @@
   DEPENDS
     libc.include.threads
     libc.src.errno.__errno_location
+    libc.src.threads.mtx_destroy
     libc.src.threads.mtx_init
     libc.src.threads.mtx_lock
     libc.src.threads.mtx_unlock
diff --git a/test/src/threads/call_once_test.cpp b/test/src/threads/call_once_test.cpp
index 569c912..18ed710 100644
--- a/test/src/threads/call_once_test.cpp
+++ b/test/src/threads/call_once_test.cpp
@@ -8,6 +8,7 @@
 
 #include "include/threads.h"
 #include "src/threads/call_once.h"
+#include "src/threads/mtx_destroy.h"
 #include "src/threads/mtx_init.h"
 #include "src/threads/mtx_lock.h"
 #include "src/threads/mtx_unlock.h"
@@ -108,4 +109,6 @@
   ASSERT_EQ(retval, 0);
 
   ASSERT_EQ(static_cast<unsigned int>(done_count), 2U);
+
+  __llvm_libc::mtx_destroy(&once_func_blocker);
 }
diff --git a/test/src/threads/mtx_test.cpp b/test/src/threads/mtx_test.cpp
index 536ff52..8ee8cf5 100644
--- a/test/src/threads/mtx_test.cpp
+++ b/test/src/threads/mtx_test.cpp
@@ -7,6 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "include/threads.h"
+#include "src/threads/mtx_destroy.h"
 #include "src/threads/mtx_init.h"
 #include "src/threads/mtx_lock.h"
 #include "src/threads/mtx_unlock.h"
@@ -63,6 +64,8 @@
   int retval = 123;
   __llvm_libc::thrd_join(&thread, &retval);
   ASSERT_EQ(retval, 0);
+
+  __llvm_libc::mtx_destroy(&mutex);
 }
 
 mtx_t start_lock, step_lock;
@@ -126,6 +129,9 @@
   int retval = 123;
   __llvm_libc::thrd_join(&thread, &retval);
   ASSERT_EQ(retval, 0);
+
+  __llvm_libc::mtx_destroy(&start_lock);
+  __llvm_libc::mtx_destroy(&step_lock);
 }
 
 static constexpr int THREAD_COUNT = 10;
@@ -179,4 +185,7 @@
   }
 
   ASSERT_EQ(wait_count, 0);
+
+  __llvm_libc::mtx_destroy(&multiple_waiter_lock);
+  __llvm_libc::mtx_destroy(&counter_lock);
 }