[PATCH] D60285: Make calls into the pthread library use weak symbols.

Sterling Augustine via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 5 13:51:21 PDT 2019


saugustine marked 2 inline comments as done.
saugustine added inline comments.


================
Comment at: libunwind/src/RWMutex.hpp:62
+extern "C" int __attribute__((weak))
+pthread_create(pthread_t *thread, const pthread_attr_t *attr,
+               void *(*start_routine)(void *), void *arg);
----------------
ldionne wrote:
> When you redeclare functions like this, are attributes stacked with the attributes of other (previous) declarations?
The gcc documentation says so.

6.33 Declaring Attributes of Functions
... Compatible attribute specifications on distinct declarations of the same function are merged....

The clang docs aren't specific on this point. But I know of enough uses of this style that I would consider it a bug if it didn't.


================
Comment at: libunwind/src/RWMutex.hpp:73
+// functions themselves, because the data structure should only be locked if
+// another thread has been created. This is what similar libraries do.
+
----------------
ldionne wrote:
> Just to make sure I understand: `pthread_create != nullptr` is only going to be satisfied if `pthread_create` was linked into the program, _and_ it was used at least once before? I thought it would be non-null whenever it was linked into the program, whether you used it or not.
It will be non-null only if it was linked. Whether or not it was used makes no difference.

This is more conservative than strictly necessary, but it saves the complexity of tracking whether or not multiple threads are actually active.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60285/new/

https://reviews.llvm.org/D60285





More information about the llvm-commits mailing list