-
Notifications
You must be signed in to change notification settings - Fork 15.6k
[libc] Add stub pthread_attr_getschedparam / pthread_attr_setschedparam #173440
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] Add stub pthread_attr_getschedparam / pthread_attr_setschedparam #173440
Conversation
Add the boilerplate for declaring these POSIX functions and providing implementations. So far the only implementations are just stubs that fail with ENOTSUP, and they are neither tested nor included in any CMake entrypoints lists. More work is still required to add the actual fields to the pthread_attr_t and implement the support in the Linux pthread_create et al, but that is not done here. It's not an especially large amount of work, but more than just trivial. The scaffolding here paves the way for that later work, but is also immediately useful for filling out the subset of POSIX pthread_attr_* functions that Fuchsia's libc already supports.
|
@llvm/pr-subscribers-libc Author: Roland McGrath (frobtech) ChangesAdd the boilerplate for declaring these POSIX functions and The scaffolding here paves the way for that later work, but is Full diff: https://github.com/llvm/llvm-project/pull/173440.diff 6 Files Affected:
diff --git a/libc/include/pthread.yaml b/libc/include/pthread.yaml
index 8afce2098adde..df4c31c1eca39 100644
--- a/libc/include/pthread.yaml
+++ b/libc/include/pthread.yaml
@@ -48,6 +48,13 @@ functions:
arguments:
- type: const pthread_attr_t *__restrict
- type: size_t *__restrict
+ - name: pthread_attr_getschedparam
+ standards:
+ - POSIX
+ return_type: int
+ arguments:
+ - type: const pthread_attr_t *__restrict
+ - type: struct sched_param *__restrict
- name: pthread_attr_getstack
standards:
- POSIX
@@ -83,6 +90,13 @@ functions:
arguments:
- type: pthread_attr_t *
- type: size_t
+ - name: pthread_attr_setschedparam
+ standards:
+ - POSIX
+ return_type: int
+ arguments:
+ - type: pthread_attr_t *__restrict
+ - type: const struct sched_param *__restrict
- name: pthread_attr_setstack
standards:
- POSIX
diff --git a/libc/src/pthread/CMakeLists.txt b/libc/src/pthread/CMakeLists.txt
index fe31e6a915e7b..d7f03c8f18d23 100644
--- a/libc/src/pthread/CMakeLists.txt
+++ b/libc/src/pthread/CMakeLists.txt
@@ -60,6 +60,26 @@ add_entrypoint_object(
libc.src.errno.errno
)
+add_entrypoint_object(
+ pthread_attr_getschedparam
+ SRCS
+ pthread_attr_getschedparam.cpp
+ HDRS
+ pthread_attr_getschedparam.h
+ DEPENDS
+ libc.include.pthread
+)
+
+add_entrypoint_object(
+ pthread_attr_setschedparam
+ SRCS
+ pthread_attr_setschedparam.cpp
+ HDRS
+ pthread_attr_setschedparam.h
+ DEPENDS
+ libc.include.pthread
+)
+
add_entrypoint_object(
pthread_attr_getstacksize
SRCS
diff --git a/libc/src/pthread/pthread_attr_getschedparam.cpp b/libc/src/pthread/pthread_attr_getschedparam.cpp
new file mode 100644
index 0000000000000..5219c4a75c862
--- /dev/null
+++ b/libc/src/pthread/pthread_attr_getschedparam.cpp
@@ -0,0 +1,24 @@
+//===-- Implementation of the pthread_attr_getschedparam -----------------===//
+//
+// 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_attr_getschedparam.h"
+
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+#include <pthread.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(int, pthread_attr_getschedparam,
+ (const pthread_attr_t *attr,
+ struct sched_param *schedparam)) {
+ return ENOTSUP;
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/pthread/pthread_attr_getschedparam.h b/libc/src/pthread/pthread_attr_getschedparam.h
new file mode 100644
index 0000000000000..ee118d77c1c02
--- /dev/null
+++ b/libc/src/pthread/pthread_attr_getschedparam.h
@@ -0,0 +1,22 @@
+//===-- Implementation header for pthread_attr_getschedparam -*- 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_ATTR_GETSCHEDPARAM_H
+#define LLVM_LIBC_SRC_PTHREAD_PTHREAD_ATTR_GETSCHEDPARAM_H
+
+#include "src/__support/macros/config.h"
+#include <pthread.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+int pthread_attr_getschedparam(const pthread_attr_t *__restrict attr,
+ struct sched_param *__restrict schedparam);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_PTHREAD_PTHREAD_ATTR_GETSCHEDPARAM_H
diff --git a/libc/src/pthread/pthread_attr_setschedparam.cpp b/libc/src/pthread/pthread_attr_setschedparam.cpp
new file mode 100644
index 0000000000000..1a80f0bd48d24
--- /dev/null
+++ b/libc/src/pthread/pthread_attr_setschedparam.cpp
@@ -0,0 +1,24 @@
+//===-- Implementation of the pthread_attr_setschedparam -----------------===//
+//
+// 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_attr_setschedparam.h"
+
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+#include <pthread.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(int, pthread_attr_setschedparam,
+ (pthread_attr_t * attr,
+ const struct sched_param *schedparam)) {
+ return ENOTSUP;
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/pthread/pthread_attr_setschedparam.h b/libc/src/pthread/pthread_attr_setschedparam.h
new file mode 100644
index 0000000000000..cd8787f591a52
--- /dev/null
+++ b/libc/src/pthread/pthread_attr_setschedparam.h
@@ -0,0 +1,22 @@
+//===-- Implementation header for pthread_attr_setschedparam -*- 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_ATTR_SETSCHEDPARAM_H
+#define LLVM_LIBC_SRC_PTHREAD_PTHREAD_ATTR_SETSCHEDPARAM_H
+
+#include "src/__support/macros/config.h"
+#include <pthread.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+int pthread_attr_setschedparam(pthread_attr_t *__restrict attr,
+ const struct sched_param *__restrict schedparam);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_PTHREAD_PTHREAD_ATTR_SETSCHEDPARAM_H
|
Add the boilerplate for declaring these POSIX functions and
providing implementations. So far the only implementations are
just stubs that fail with ENOTSUP, and they are neither tested
nor included in any CMake entrypoints lists. More work is still
required to add the actual fields to the pthread_attr_t and
implement the support in the Linux pthread_create et al, but that
is not done here. It's not an especially large amount of work,
but more than just trivial.
The scaffolding here paves the way for that later work, but is
also immediately useful for filling out the subset of POSIX
pthread_attr_* functions that Fuchsia's libc already supports.