[libc-commits] [libc] [libc][POSIX][pthreads] implement pthread_rwlockattr_t functions (PR #89322)

Schrodinger ZHU Yifan via libc-commits libc-commits at lists.llvm.org
Mon Apr 22 08:16:15 PDT 2024


================
@@ -0,0 +1,64 @@
+//===-- Unittests for pthread_rwlockattr_t --------------------------------===//
+//
+// 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 "include/llvm-libc-macros/generic-error-number-macros.h" // EINVAL
+#include "src/pthread/pthread_rwlockattr_destroy.h"
+#include "src/pthread/pthread_rwlockattr_getpshared.h"
+#include "src/pthread/pthread_rwlockattr_init.h"
+#include "src/pthread/pthread_rwlockattr_setpshared.h"
+#include "test/UnitTest/Test.h"
+
+// TODO: https://github.com/llvm/llvm-project/issues/88997
+#include <pthread.h> // PTHREAD_PROCESS_PRIVATE, PTHREAD_PROCESS_SHARED
+
+TEST(LlvmLibcPThreadRWLockAttrTest, InitAndDestroy) {
+  pthread_rwlockattr_t attr;
+  ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlockattr_init(&attr), 0);
+  ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlockattr_destroy(&attr), 0);
+}
+
+TEST(LlvmLibcPThreadRWLockAttrTest, GetDefaultValues) {
+  pthread_rwlockattr_t attr;
+
+  // Invalid value.
+  int pshared = 42;
----------------
SchrodingerZhu wrote:

How come the answer to "the Ultimate Question of Life, the Universe, and Everything" is invalid 😄 

https://github.com/llvm/llvm-project/pull/89322


More information about the libc-commits mailing list