-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[libc][sched] Implement proxy headers for cpu_set_t, struct sched_param and sched_macros.
#126303
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
Changes from 11 commits
1a2fe13
ba8c535
c6a14a1
822bdb0
00b5943
8c990d2
926702c
02b5e6c
99ee89d
5a91cde
ece948f
c2ccccf
fd0ec52
32f9a0a
88fd93f
b34baef
de1eead
55849ca
7b48a0c
9a42b90
8baed07
9228a3b
0811fb1
23f30e9
cbcaf85
3f67c42
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| //===-- Definition of macros from sched.h ---------------------------------===// | ||
| // | ||
| // 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_HDR_SCHED_MACROS_H | ||
| #define LLVM_LIBC_HDR_SCHED_MACROS_H | ||
|
|
||
| #ifdef LIBC_FULL_BUILD | ||
|
|
||
| #include "include/llvm-libc-macros/sched-macros.h" | ||
|
|
||
| #else // Overlay mode | ||
|
|
||
| #include <sched.h> | ||
|
|
||
| #endif // LLVM_LIBC_FULL_BUILD | ||
|
|
||
| #endif // LLVM_LIBC_HDR_SCHED_MACROS_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| //===-- Proxy for cpu_set_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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLVM_LIBC_HDR_TYPES_CPU_SET_T_H | ||
| #define LLVM_LIBC_HDR_TYPES_CPU_SET_T_H | ||
|
|
||
| #ifdef LIBC_FULL_BUILD | ||
|
|
||
| #include "include/llvm-libc-types/cpu_set_t.h" | ||
|
|
||
| #else // Overlay mode | ||
|
|
||
| #include <sched.h> | ||
|
|
||
| #endif // LLVM_LIBC_FULL_BUILD | ||
|
|
||
| #endif // LLVM_LIBC_HDR_TYPES_CPU_SET_T_H | ||
nickdesaulniers marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| //===-- Proxy for struct sched_param --------------------------------------===// | ||
| // | ||
| // 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_HDR_TYPES_STRUCT_SCHED_PARAM_H | ||
| #define LLVM_LIBC_HDR_TYPES_STRUCT_SCHED_PARAM_H | ||
|
|
||
| #ifdef LIBC_FULL_BUILD | ||
|
|
||
| #include "include/llvm-libc-types/struct_sched_param.h" | ||
|
|
||
| #else // Overlay mode | ||
|
|
||
| #include <sched.h> | ||
|
|
||
| #endif // LLVM_LIBC_FULL_BUILD | ||
|
|
||
| #endif // LLVM_LIBC_HDR_TYPES_STRUCT_SCHED_PARAM_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ | |
| typedef struct { | ||
| // If a processor with more than 1024 CPUs is to be supported in future, | ||
| // we need to adjust the size of this array. | ||
| unsigned long __mask[128 / sizeof(unsigned long)]; | ||
| unsigned long __bits[128 / sizeof(unsigned long)]; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's up with this change?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so the glibc implementation of ref: https://elixir.bootlin.com/glibc/glibc-2.41/source/posix/bits/cpu-set.h#L38-L43
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Right, and libc/include/llvm-libc-types/cpu_set_t.h should only be included in fullbuild mode, not overlay mode. |
||
| } cpu_set_t; | ||
|
|
||
| #endif // LLVM_LIBC_TYPES_CPU_SET_T_H | ||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -6,6 +6,9 @@ add_entrypoint_object( | |||
| ../sched_getaffinity.h | ||||
| DEPENDS | ||||
| libc.include.sched | ||||
|
||||
| libc.include.sched |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| libc.include.sched |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| libc.include.sched |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| libc.include.sched |
(all of these include are wrong)
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| libc.include.sched |
(all of these include are wrong)
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| libc.include.sched |
(all of these include are wrong)
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| libc.include.sched |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| libc.include.sys_syscall |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| libc.include.sys_syscall |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| libc.include.sched |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,19 +8,19 @@ | |
|
|
||
| #include "src/sched/sched_getcpucount.h" | ||
|
|
||
| #include "src/__support/common.h" | ||
| #include "src/__support/macros/config.h" | ||
| #include "src/__support/common.h" // LLVM_LIBC_FUNCTION | ||
| #include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL | ||
|
|
||
| #include <sched.h> | ||
| #include <stddef.h> | ||
| #include "hdr/types/cpu_set_t.h" | ||
| #include "hdr/types/size_t.h" | ||
|
|
||
| namespace LIBC_NAMESPACE_DECL { | ||
|
|
||
| LLVM_LIBC_FUNCTION(int, __sched_getcpucount, | ||
| (size_t cpuset_size, const cpu_set_t *mask)) { | ||
| int result = 0; | ||
| for (size_t i = 0; i < cpuset_size / sizeof(long); ++i) { | ||
| result += __builtin_popcountl(mask->__mask[i]); | ||
| result += __builtin_popcountl(mask->__bits[i]); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this change? Also, while you're here, mind removing the |
||
| } | ||
| return result; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you test adding a line here:
It's ultimately not correct, but @michaelrj-google and I have a hypothesis that anchoring a dependency in libc/config/{OS}/{ARCH}/entrypoints.txt has a race for fullbuild when using scudo.
Please just add a commit on top with that one line change; if it doesn't pass presubmit, we can drop it+force push.
If it does, we can merge this PR and file a bug/todo about looking into that race.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and.. it's still failing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got the following errors when trying this PR locally:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, so changing from
LIBC_NAMESPACE::CPU_COUNTto justCPU_COUNTis causing problems in full build mode.. i'll just keep it as it was