Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc][POSIX][pthreads] implemented missing pthread_rwlockattr functions #90249

Merged
merged 2 commits into from
May 13, 2024

Conversation

HendrikHuebner
Copy link
Contributor

Closes #89443

I added the two missing functions and respective test cases. Let me know if anything needs changing.

Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added the libc label Apr 26, 2024
@llvmbot
Copy link

llvmbot commented Apr 26, 2024

@llvm/pr-subscribers-libc

Author: Hendrik Hübner (HendrikHuebner)

Changes

Closes #89443

I added the two missing functions and respective test cases. Let me know if anything needs changing.


Full diff: https://github.com/llvm/llvm-project/pull/90249.diff

11 Files Affected:

  • (modified) libc/config/linux/x86_64/entrypoints.txt (+2)
  • (modified) libc/include/pthread.h.def (+5)
  • (modified) libc/spec/posix.td (+10)
  • (modified) libc/src/pthread/CMakeLists.txt (+21)
  • (added) libc/src/pthread/pthread_rwlockattr_getkind_np.cpp (+23)
  • (added) libc/src/pthread/pthread_rwlockattr_getkind_np.h (+20)
  • (modified) libc/src/pthread/pthread_rwlockattr_init.cpp (+1)
  • (added) libc/src/pthread/pthread_rwlockattr_setkind_np.cpp (+30)
  • (added) libc/src/pthread/pthread_rwlockattr_setkind_np.h (+20)
  • (modified) libc/test/src/pthread/CMakeLists.txt (+2)
  • (modified) libc/test/src/pthread/pthread_rwlockattr_test.cpp (+26-3)
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index a8e28992766712..4a6d9659380321 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -670,8 +670,10 @@ if(LLVM_LIBC_FULL_BUILD)
     libc.src.pthread.pthread_mutexattr_settype
     libc.src.pthread.pthread_once
     libc.src.pthread.pthread_rwlockattr_destroy
+    libc.src.pthread.pthread_rwlockattr_getkind_np
     libc.src.pthread.pthread_rwlockattr_getpshared
     libc.src.pthread.pthread_rwlockattr_init
+    libc.src.pthread.pthread_rwlockattr_setkind_np
     libc.src.pthread.pthread_rwlockattr_setpshared
     libc.src.pthread.pthread_setspecific
 
diff --git a/libc/include/pthread.h.def b/libc/include/pthread.h.def
index a94d770657e100..d41273b5590eaa 100644
--- a/libc/include/pthread.h.def
+++ b/libc/include/pthread.h.def
@@ -38,6 +38,11 @@ enum {
 #define PTHREAD_PROCESS_PRIVATE 0
 #define PTHREAD_PROCESS_SHARED 1
 
+#define PTHREAD_RWLOCK_PREFER_READER_NP 0
+#define PTHREAD_RWLOCK_PREFER_WRITER_NP 1
+#define PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP 2
+
+
 %%public_api()
 
 #endif // LLVM_LIBC_PTHREAD_H
diff --git a/libc/spec/posix.td b/libc/spec/posix.td
index d428d54e32a331..e8a6dff25d7300 100644
--- a/libc/spec/posix.td
+++ b/libc/spec/posix.td
@@ -1229,6 +1229,11 @@ def POSIX : StandardSpec<"POSIX"> {
           RetValSpec<IntType>,
           [ArgSpec<PThreadRWLockAttrTPtr>]
       >,
+      FunctionSpec<
+          "pthread_rwlockattr_getkind_np",
+          RetValSpec<IntType>,
+          [ArgSpec<PThreadRWLockAttrTPtr>, ArgSpec<IntPtr>]
+      >,
       FunctionSpec<
           "pthread_rwlockattr_getpshared",
           RetValSpec<IntType>,
@@ -1239,6 +1244,11 @@ def POSIX : StandardSpec<"POSIX"> {
           RetValSpec<IntType>,
           [ArgSpec<PThreadRWLockAttrTPtr>]
       >,
+      FunctionSpec<
+          "pthread_rwlockattr_setkind_np",
+          RetValSpec<IntType>,
+          [ArgSpec<PThreadRWLockAttrTPtr>, ArgSpec<IntType>]
+      >,
       FunctionSpec<
           "pthread_rwlockattr_setpshared",
           RetValSpec<IntType>,
diff --git a/libc/src/pthread/CMakeLists.txt b/libc/src/pthread/CMakeLists.txt
index c57475c9114fa6..e5bebb63c64013 100644
--- a/libc/src/pthread/CMakeLists.txt
+++ b/libc/src/pthread/CMakeLists.txt
@@ -470,6 +470,16 @@ add_entrypoint_object(
     libc.include.pthread
 )
 
+add_entrypoint_object(
+  pthread_rwlockattr_getkind_np
+  SRCS
+    pthread_rwlockattr_getkind_np.cpp
+  HDRS
+    pthread_rwlockattr_getkind_np.h
+  DEPENDS
+    libc.include.pthread
+)
+
 add_entrypoint_object(
   pthread_rwlockattr_getpshared
   SRCS
@@ -490,6 +500,17 @@ add_entrypoint_object(
     libc.include.pthread
 )
 
+add_entrypoint_object(
+  pthread_rwlockattr_setkind_np
+  SRCS
+    pthread_rwlockattr_setkind_np.cpp
+  HDRS
+    pthread_rwlockattr_setkind_np.h
+  DEPENDS
+    libc.include.pthread
+    libc.include.errno
+)
+
 add_entrypoint_object(
   pthread_rwlockattr_setpshared
   SRCS
diff --git a/libc/src/pthread/pthread_rwlockattr_getkind_np.cpp b/libc/src/pthread/pthread_rwlockattr_getkind_np.cpp
new file mode 100644
index 00000000000000..a80ef41fb28efb
--- /dev/null
+++ b/libc/src/pthread/pthread_rwlockattr_getkind_np.cpp
@@ -0,0 +1,23 @@
+//===-- Implementation of the pthread_rwlockattr_getkind_np ---------------===//
+//
+// 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 "pthread_rwlockattr_getkind_np.h"
+
+#include "src/__support/common.h"
+
+#include <pthread.h> // pthread_rwlockattr_t
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(int, pthread_rwlockattr_getkind_np,
+                   (const pthread_rwlockattr_t *__restrict attr, int *__restrict pref)) {
+  *pref = attr->pref;
+  return 0;
+}
+
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/pthread/pthread_rwlockattr_getkind_np.h b/libc/src/pthread/pthread_rwlockattr_getkind_np.h
new file mode 100644
index 00000000000000..827506d955d203
--- /dev/null
+++ b/libc/src/pthread/pthread_rwlockattr_getkind_np.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for pthread_rwlockattr_getkind_np -*- 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_PTHREAD_PTHREAD_RWLOCKATTR_GETKIND_NP_H
+#define LLVM_LIBC_SRC_PTHREAD_PTHREAD_RWLOCKATTR_GETKIND_NP_H
+
+#include <pthread.h>
+
+namespace LIBC_NAMESPACE {
+
+int pthread_rwlockattr_getkind_np(const pthread_rwlockattr_t *__restrict attr, int *__restrict pref);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_PTHREAD_PTHREAD_RWLOCKATTR_GETKIND_NP_H
diff --git a/libc/src/pthread/pthread_rwlockattr_init.cpp b/libc/src/pthread/pthread_rwlockattr_init.cpp
index 7971f1714db484..bbc89555c6c1cd 100644
--- a/libc/src/pthread/pthread_rwlockattr_init.cpp
+++ b/libc/src/pthread/pthread_rwlockattr_init.cpp
@@ -17,6 +17,7 @@ namespace LIBC_NAMESPACE {
 LLVM_LIBC_FUNCTION(int, pthread_rwlockattr_init,
                    (pthread_rwlockattr_t * attr)) {
   attr->pshared = PTHREAD_PROCESS_PRIVATE;
+  attr->pref = PTHREAD_RWLOCK_PREFER_READER_NP;
   return 0;
 }
 
diff --git a/libc/src/pthread/pthread_rwlockattr_setkind_np.cpp b/libc/src/pthread/pthread_rwlockattr_setkind_np.cpp
new file mode 100644
index 00000000000000..ca3ab7d4a9a6ae
--- /dev/null
+++ b/libc/src/pthread/pthread_rwlockattr_setkind_np.cpp
@@ -0,0 +1,30 @@
+//===-- Implementation of the pthread_rwlockattr_setkind_np ---------------===//
+//
+// 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 "pthread_rwlockattr_setkind_np.h"
+
+#include "src/__support/common.h"
+
+#include <errno.h>
+#include <pthread.h> // pthread_rwlockattr_t
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(int, pthread_rwlockattr_setkind_np,
+                   (pthread_rwlockattr_t *attr, int pref)) {
+
+  if (pref != PTHREAD_RWLOCK_PREFER_READER_NP &&
+      pref != PTHREAD_RWLOCK_PREFER_WRITER_NP &&
+      pref != PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP)
+    return EINVAL;
+
+  attr->pref = pref;
+  return 0;
+}
+
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/pthread/pthread_rwlockattr_setkind_np.h b/libc/src/pthread/pthread_rwlockattr_setkind_np.h
new file mode 100644
index 00000000000000..00ef8e1bbe0090
--- /dev/null
+++ b/libc/src/pthread/pthread_rwlockattr_setkind_np.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for pthread_rwlockattr_setkind_np -*- 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_PTHREAD_PTHREAD_RWLOCKATTR_SETKIND_NP_H
+#define LLVM_LIBC_SRC_PTHREAD_PTHREAD_RWLOCKATTR_SETKIND_NP_H
+
+#include <pthread.h>
+
+namespace LIBC_NAMESPACE {
+
+int pthread_rwlockattr_setkind_np(pthread_rwlockattr_t *attr, int pref);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_PTHREAD_PTHREAD_RWLOCKATTR_SETKIND_NP_H
diff --git a/libc/test/src/pthread/CMakeLists.txt b/libc/test/src/pthread/CMakeLists.txt
index ea75e65f57c9eb..0eeec445d5f49c 100644
--- a/libc/test/src/pthread/CMakeLists.txt
+++ b/libc/test/src/pthread/CMakeLists.txt
@@ -68,7 +68,9 @@ add_libc_unittest(
     libc.include.errno
     libc.include.pthread
     libc.src.pthread.pthread_rwlockattr_destroy
+    libc.src.pthread.pthread_rwlockattr_getkind_np
     libc.src.pthread.pthread_rwlockattr_getpshared
     libc.src.pthread.pthread_rwlockattr_init
+    libc.src.pthread.pthread_rwlockattr_setkind_np
     libc.src.pthread.pthread_rwlockattr_setpshared
 )
diff --git a/libc/test/src/pthread/pthread_rwlockattr_test.cpp b/libc/test/src/pthread/pthread_rwlockattr_test.cpp
index 6e5ae70df7343f..3791f568e2228d 100644
--- a/libc/test/src/pthread/pthread_rwlockattr_test.cpp
+++ b/libc/test/src/pthread/pthread_rwlockattr_test.cpp
@@ -8,8 +8,10 @@
 
 #include "include/llvm-libc-macros/generic-error-number-macros.h" // EINVAL
 #include "src/pthread/pthread_rwlockattr_destroy.h"
+#include "src/pthread/pthread_rwlockattr_getkind_np.h"
 #include "src/pthread/pthread_rwlockattr_getpshared.h"
 #include "src/pthread/pthread_rwlockattr_init.h"
+#include "src/pthread/pthread_rwlockattr_setkind_np.h"
 #include "src/pthread/pthread_rwlockattr_setpshared.h"
 #include "test/UnitTest/Test.h"
 
@@ -25,40 +27,61 @@ TEST(LlvmLibcPThreadRWLockAttrTest, InitAndDestroy) {
 TEST(LlvmLibcPThreadRWLockAttrTest, GetDefaultValues) {
   pthread_rwlockattr_t attr;
 
-  // Invalid value.
+  // Invalid values.
   int pshared = 42;
+  int pref = 1337;
 
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlockattr_init(&attr), 0);
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlockattr_getpshared(&attr, &pshared), 0);
+  ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlockattr_getkind_np(&attr, &pref), 0);
+
   ASSERT_EQ(pshared, PTHREAD_PROCESS_PRIVATE);
+  ASSERT_EQ(pref, PTHREAD_RWLOCK_PREFER_READER_NP);
+
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlockattr_destroy(&attr), 0);
 }
 
 TEST(LlvmLibcPThreadRWLockAttrTest, SetGoodValues) {
   pthread_rwlockattr_t attr;
 
-  // Invalid value.
+  // Invalid values.
   int pshared = 42;
+  int pref = 1337;
 
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlockattr_init(&attr), 0);
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlockattr_setpshared(
                 &attr, PTHREAD_PROCESS_SHARED),
             0);
+  ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlockattr_setkind_np(
+                &attr, PTHREAD_RWLOCK_PREFER_WRITER_NP),
+            0);
+
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlockattr_getpshared(&attr, &pshared), 0);
+  ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlockattr_getkind_np(&attr, &pref), 0);
+
   ASSERT_EQ(pshared, PTHREAD_PROCESS_SHARED);
+  ASSERT_EQ(pref, PTHREAD_RWLOCK_PREFER_WRITER_NP);
+
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlockattr_destroy(&attr), 0);
 }
 
 TEST(LlvmLibcPThreadRWLockAttrTest, SetBadValues) {
   pthread_rwlockattr_t attr;
 
-  // Invalid value.
+  // Invalid values.
   int pshared = 42;
+  int pref = 1337;
 
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlockattr_init(&attr), 0);
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlockattr_setpshared(&attr, pshared),
             EINVAL);
+  ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlockattr_setkind_np(&attr, pref), EINVAL);
+
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlockattr_getpshared(&attr, &pshared), 0);
+  ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlockattr_getkind_np(&attr, &pref), 0);
+
   ASSERT_EQ(pshared, PTHREAD_PROCESS_PRIVATE);
+  ASSERT_EQ(pref, PTHREAD_RWLOCK_PREFER_READER_NP);
+
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlockattr_destroy(&attr), 0);
 }

Copy link
Contributor

@michaelrj-google michaelrj-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch looks good to me, thanks for submitting it! Feel free to ping me if you need me to merge it for you.

Copy link

github-actions bot commented Apr 26, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@michaelrj-google
Copy link
Contributor

ah, the formatter found some issues. You should address those before landing

@nickdesaulniers
Copy link
Member

thanks for the patch!

@HendrikHuebner
Copy link
Contributor Author

@nickdesaulniers can this get merged?

@SchrodingerZhu
Copy link
Contributor

SchrodingerZhu commented May 13, 2024

@nickdesaulniers seems to be traveling. I will merge this according to previous approval. BTW, I am working on an rwlock implementation which will support these nonportable features.

@SchrodingerZhu SchrodingerZhu merged commit d2676a7 into llvm:main May 13, 2024
4 checks passed
Copy link

@HendrikHuebner Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested
by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as
the builds can include changes from many authors. It is not uncommon for your
change to be included in a build that fails due to someone else's changes, or
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself.
This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

@SchrodingerZhu
Copy link
Contributor

Unfortunately, fullbuild is broken with this patch. I have reverted the PR in #91966.

Looking forward to your fixed version! Thank you again for working on this.

@nickdesaulniers
Copy link
Member

The errors from the bot are:

/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg/llvm-project/libc/src/pthread/pthread_rwlockattr_getkind_np.cpp:20:17: error: no member named 'pref' in 'pthread_rwlockattr_t'
  *pref = attr->pref;
          ~~~~  ^
1 error generated.
[298/496] Building CXX object projects/libc/src/stdlib/CMakeFiles/libc.src.stdlib.strfroml.dir/strfroml.cpp.o
[299/496] Building CXX object projects/libc/src/pthread/CMakeFiles/libc.src.pthread.pthread_rwlockattr_destroy.dir/pthread_rwlockattr_destroy.cpp.o
[300/496] Building CXX object projects/libc/src/pthread/CMakeFiles/libc.src.pthread.pthread_rwlockattr_setkind_np.dir/pthread_rwlockattr_setkind_np.cpp.o
FAILED: projects/libc/src/pthread/CMakeFiles/libc.src.pthread.pthread_rwlockattr_setkind_np.dir/pthread_rwlockattr_setkind_np.cpp.o 
/usr/bin/clang++ -DLIBC_NAMESPACE=__llvm_libc_19_0_0_git -D_DEBUG -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg/build/projects/libc/src/pthread -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg/llvm-project/libc/src/pthread -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg/llvm-project/libc -isystem /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg/build/projects/libc/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g -fpie -DLIBC_FULL_BUILD -ffreestanding -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wstrict-prototypes -Wthread-safety -Wglobal-constructors -DLIBC_COPT_PUBLIC_PACKAGING -std=c++17 -MD -MT projects/libc/src/pthread/CMakeFiles/libc.src.pthread.pthread_rwlockattr_setkind_np.dir/pthread_rwlockattr_setkind_np.cpp.o -MF projects/libc/src/pthread/CMakeFiles/libc.src.pthread.pthread_rwlockattr_setkind_np.dir/pthread_rwlockattr_setkind_np.cpp.o.d -o projects/libc/src/pthread/CMakeFiles/libc.src.pthread.pthread_rwlockattr_setkind_np.dir/pthread_rwlockattr_setkind_np.cpp.o -c /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg/llvm-project/libc/src/pthread/pthread_rwlockattr_setkind_np.cpp
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg/llvm-project/libc/src/pthread/pthread_rwlockattr_setkind_np.cpp:26:9: error: no member named 'pref' in 'pthread_rwlockattr_t'
  attr->pref = pref;
  ~~~~  ^
1 error generated.
[301/496] Building CXX object projects/libc/src/pthread/CMakeFiles/libc.src.pthread.pthread_mutex_lock.dir/pthread_mutex_lock.cpp.o
[302/496] Building CXX object projects/libc/src/string/CMakeFiles/libc.src.string.memset_explicit.dir/memset_explicit.cpp.o
[303/496] Building CXX object projects/libc/src/pthread/CMakeFiles/libc.src.pthread.pthread_mutex_unlock.dir/pthread_mutex_unlock.cpp.o
[304/496] Building CXX object projects/libc/src/pthread/CMakeFiles/libc.src.pthread.pthread_rwlockattr_init.dir/pthread_rwlockattr_init.cpp.o
FAILED: projects/libc/src/pthread/CMakeFiles/libc.src.pthread.pthread_rwlockattr_init.dir/pthread_rwlockattr_init.cpp.o 
/usr/bin/clang++ -DLIBC_NAMESPACE=__llvm_libc_19_0_0_git -D_DEBUG -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg/build/projects/libc/src/pthread -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg/llvm-project/libc/src/pthread -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg/llvm-project/libc -isystem /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg/build/projects/libc/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g -fpie -DLIBC_FULL_BUILD -ffreestanding -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wstrict-prototypes -Wthread-safety -Wglobal-constructors -DLIBC_COPT_PUBLIC_PACKAGING -std=c++17 -MD -MT projects/libc/src/pthread/CMakeFiles/libc.src.pthread.pthread_rwlockattr_init.dir/pthread_rwlockattr_init.cpp.o -MF projects/libc/src/pthread/CMakeFiles/libc.src.pthread.pthread_rwlockattr_init.dir/pthread_rwlockattr_init.cpp.o.d -o projects/libc/src/pthread/CMakeFiles/libc.src.pthread.pthread_rwlockattr_init.dir/pthread_rwlockattr_init.cpp.o -c /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg/llvm-project/libc/src/pthread/pthread_rwlockattr_init.cpp
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-fullbuild-dbg/llvm-project/libc/src/pthread/pthread_rwlockattr_init.cpp:20:9: error: no member named 'pref' in 'pthread_rwlockattr_t'
  attr->pref = PTHREAD_RWLOCK_PREFER_READER_NP;
  ~~~~  ^

So it looks like you missed adding the new member to the struct definition for the getter/setters you added.

@nickdesaulniers
Copy link
Member

specifically, libc/include/llvm-libc-types/pthread_rwlockattr_t.h needs the addition of the new field.

@nickdesaulniers
Copy link
Member

sorry I missed that in the original code review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[libc][gnu ext] implement pthread_rwlockattr_{get|set}kind_np
5 participants