Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1a2fe13
feat: add proxy header for `cpu_set_t`
krishna2803 Feb 7, 2025
ba8c535
fix: replace <sched.h> with proxy headers
krishna2803 Feb 7, 2025
c6a14a1
fix: rename `__mask` to `__bits` for compatibility with glibc cpu_set_t
krishna2803 Feb 11, 2025
822bdb0
fix: change to proxy headers for `cpu_set_t`, `size_t` and `pid_t` types
krishna2803 Feb 11, 2025
00b5943
fix: update CMakeLists for proxy header dependencies
krishna2803 Feb 11, 2025
8c990d2
style: clang-format
krishna2803 Feb 11, 2025
926702c
fix: add proxy headers for unittests
krishna2803 Feb 11, 2025
02b5e6c
fix: add proxy header for `struct_sched_param`
krishna2803 Feb 11, 2025
99ee89d
fix: add proxy header for `sched_macros`
krishna2803 Feb 11, 2025
5a91cde
fix: tests for sched functions
krishna2803 Feb 11, 2025
ece948f
style: clang-format
krishna2803 Feb 11, 2025
c2ccccf
fix: remove unused dependencies from CMakeLists
krishna2803 Feb 12, 2025
fd0ec52
fix: remove unused header and comply llvm coding standard
krishna2803 Feb 12, 2025
32f9a0a
fix: add missing header for struct_timespec
krishna2803 Feb 12, 2025
88fd93f
Merge branch 'main' into fix-cpuset-includes
krishna2803 Feb 13, 2025
b34baef
fix: add `libc.include.llvm-libc-macros.sched_macros` for full build …
krishna2803 Feb 14, 2025
de1eead
fix: attempt fix for `struct_timespec`
krishna2803 Feb 15, 2025
55849ca
fix: attempt fix for `sched`
krishna2803 Feb 15, 2025
7b48a0c
add: sched.h in scudo CMakeListsts
krishna2803 Feb 16, 2025
9a42b90
revert: "add: sched.h in scudo CMakeListsts"
krishna2803 Feb 16, 2025
8baed07
merge: branch 'main' into fix-cpuset-includes
krishna2803 Feb 23, 2025
9228a3b
revert: "fix: attempt fix for `struct_timespec`"
krishna2803 Feb 23, 2025
0811fb1
revert: "fix: attempt fix for `sched`"
krishna2803 Feb 23, 2025
23f30e9
merge: branch 'main' into fix-cpuset-includes
krishna2803 Feb 27, 2025
cbcaf85
merge: branch 'main' into fix-cpuset-includes
krishna2803 Mar 5, 2025
3f67c42
fix: attempt removing sched.h
krishna2803 Mar 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions libc/hdr/types/cpu_set_t.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
2 changes: 1 addition & 1 deletion libc/src/sched/linux/sched_getaffinity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "src/__support/macros/config.h"
#include "src/errno/libc_errno.h"

#include <sched.h>
#include "hdr/types/cpu_set_t.h"
#include <stdint.h>
#include <sys/syscall.h> // For syscall numbers.

Expand Down
2 changes: 1 addition & 1 deletion libc/src/sched/linux/sched_getcpucount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "src/__support/common.h"
#include "src/__support/macros/config.h"

#include <sched.h>
#include "hdr/types/cpu_set_t.h"
#include <stddef.h>
Copy link
Member

Choose a reason for hiding this comment

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

What does this file use from stddef.h?

Please explicitly include libc/hdr/types/size_t.h for size_t.


namespace LIBC_NAMESPACE_DECL {
Expand Down
2 changes: 1 addition & 1 deletion libc/src/sched/linux/sched_setaffinity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "src/__support/macros/config.h"
#include "src/errno/libc_errno.h"

#include <sched.h>
#include "hdr/types/cpu_set_t.h"
#include <sys/syscall.h> // For syscall numbers.

namespace LIBC_NAMESPACE_DECL {
Expand Down
2 changes: 1 addition & 1 deletion libc/src/sched/sched_getaffinity.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define LLVM_LIBC_SRC_SCHED_SCHED_GETAFFINITY_H

#include "src/__support/macros/config.h"
#include <sched.h>
#include "hdr/types/cpu_set_t.h"

namespace LIBC_NAMESPACE_DECL {

Expand Down
2 changes: 1 addition & 1 deletion libc/src/sched/sched_getcpucount.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define LLVM_LIBC_SRC_SCHED_SCHED_GETCPUCOUNT_H

#include "src/__support/macros/config.h"
#include <sched.h>
#include "hdr/types/cpu_set_t.h"
#include <stddef.h>

namespace LIBC_NAMESPACE_DECL {
Expand Down
2 changes: 1 addition & 1 deletion libc/src/sched/sched_getparam.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define LLVM_LIBC_SRC_SCHED_SCHED_GETPARAM_H

#include "src/__support/macros/config.h"
#include <sched.h>
#include "hdr/types/cpu_set_t.h"
Copy link
Member

Choose a reason for hiding this comment

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

Add libc/hdr/types/pid_t.h and ...oh look, we need a proxy header for struct sched_param, too! Want to put down this PR and get that resolved in a distinct PR, too?

This function signature isn't even using cpu_set_t, so it's spurious to include it!

Copy link
Contributor Author

@krishna2803 krishna2803 Feb 11, 2025

Choose a reason for hiding this comment

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

we need a proxy header for struct sched_param, too!

aah.. this is weird, i have a feeling that this could be the case for some other stuff too! but i think we should cpuset includes done first and then maybe we can work on struct sched_param (and the other types if there are any).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

aah.. this is weird, i have a feeling that this could be the case for some other stuff too! but i think we should cpuset includes done first and then maybe we can work on struct sched_param (and the other types if there are any).

and... this caused me a lot of trouble with the tests :(
i guess i will just do the fix in this PR only as it is messing with the tests

Copy link
Contributor Author

@krishna2803 krishna2803 Feb 11, 2025

Choose a reason for hiding this comment

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

/home/krishna/OpenSource/llvm-project/build/./bin/clang++ --target=x86_64-unknown-linux-gnu -DLIBC_NAMESPACE=__llvm_libc_21_0_0_git -D_DEBUG -I/home/krishna/OpenSource/llvm-project/libc -isystem /home/krishna/OpenSource/llvm-project/build/runtimes/runtimes-bins/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 -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 -ffixed-point -Wextra-semi -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -std=gnu++17 -MD -MT libc/test/src/sched/CMakeFiles/libc.test.src.sched.get_priority_test.__build__.dir/get_priority_test.cpp.o -MF libc/test/src/sched/CMakeFiles/libc.test.src.sched.get_priority_test.__build__.dir/get_priority_test.cpp.o.d -o libc/test/src/sched/CMakeFiles/libc.test.src.sched.get_priority_test.__build__.dir/get_priority_test.cpp.o -c /home/krishna/OpenSource/llvm-project/libc/test/src/sched/get_priority_test.cpp
/home/krishna/OpenSource/llvm-project/libc/test/src/sched/get_priority_test.cpp:66:18: error: use of undeclared identifier 'SCHED_OTHER'
   66 |     int policy = SCHED_OTHER;
      |                  ^
/home/krishna/OpenSource/llvm-project/libc/test/src/sched/get_priority_test.cpp:80:18: error: use of undeclared identifier 'SCHED_FIFO'
   80 |     int policy = SCHED_FIFO;
      |                  ^
/home/krishna/OpenSource/llvm-project/libc/test/src/sched/get_priority_test.cpp:94:18: error: use of undeclared identifier 'SCHED_RR'
   94 |     int policy = SCHED_RR;
      |                  ^
3 errors generated.

and.. i guess we need to create proxy headers for sched-macros.h as well..

Copy link
Member

Choose a reason for hiding this comment

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

yep! heh, sorry, sometimes when there's more than 1 bug, we don't have visibility beyond the first. It looked like cpuset includes were the only issue, but fixing it uncovers other issues that need to be addressed first. Thanks for digging into them.


namespace LIBC_NAMESPACE_DECL {

Expand Down
2 changes: 1 addition & 1 deletion libc/src/sched/sched_getscheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define LLVM_LIBC_SRC_SCHED_SCHED_GETSCHEDULER_H

#include "src/__support/macros/config.h"
#include <sched.h>
#include "hdr/types/cpu_set_t.h"
Copy link
Member

Choose a reason for hiding this comment

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

Not used, needs pid_t.h

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the patch! I'm stopping my review here, because this issue pertains to the rest of the PR below I assume.


namespace LIBC_NAMESPACE_DECL {

Expand Down
2 changes: 1 addition & 1 deletion libc/src/sched/sched_rr_get_interval.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define LLVM_LIBC_SRC_SCHED_SCHED_RR_GET_INTERVAL_H

#include "src/__support/macros/config.h"
#include <sched.h>
#include "hdr/types/cpu_set_t.h"

namespace LIBC_NAMESPACE_DECL {

Expand Down
2 changes: 1 addition & 1 deletion libc/src/sched/sched_setaffinity.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define LLVM_LIBC_SRC_SCHED_SCHED_SETAFFINITY_H

#include "src/__support/macros/config.h"
#include <sched.h>
#include "hdr/types/cpu_set_t.h"

namespace LIBC_NAMESPACE_DECL {

Expand Down
2 changes: 1 addition & 1 deletion libc/src/sched/sched_setparam.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define LLVM_LIBC_SRC_SCHED_SCHED_SETPARAM_H

#include "src/__support/macros/config.h"
#include <sched.h>
#include "hdr/types/cpu_set_t.h"
Copy link
Member

Choose a reason for hiding this comment

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

unused


namespace LIBC_NAMESPACE_DECL {

Expand Down
2 changes: 1 addition & 1 deletion libc/src/sched/sched_setscheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define LLVM_LIBC_SRC_SCHED_SCHED_SETSCHEDULER_H

#include "src/__support/macros/config.h"
#include <sched.h>
#include "hdr/types/cpu_set_t.h"

namespace LIBC_NAMESPACE_DECL {

Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/sched/affinity_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "src/sched/sched_setaffinity.h"
#include "test/UnitTest/ErrnoSetterMatcher.h"

#include <sched.h>
#include "hdr/types/cpu_set_t.h"
#include <sys/syscall.h>

TEST(LlvmLibcSchedAffinityTest, SmokeTest) {
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/sched/cpu_count_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "src/sched/sched_getcpucount.h"
#include "test/UnitTest/ErrnoSetterMatcher.h"

#include <sched.h>
#include "hdr/types/cpu_set_t.h"
#include <sys/syscall.h>

TEST(LlvmLibcSchedCpuCountTest, SmokeTest) {
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/sched/get_priority_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "src/sched/sched_get_priority_min.h"
#include "test/UnitTest/Test.h"

#include <sched.h>
#include "hdr/types/cpu_set_t.h"

TEST(LlvmLibcSchedGetPriorityTest, HandleBadPolicyTest) {

Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/sched/param_and_scheduler_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "src/unistd/getuid.h"
#include "test/UnitTest/Test.h"

#include <sched.h>
#include "hdr/types/cpu_set_t.h"

// We Test:
// SCHED_OTHER, SCHED_FIFO, SCHED_RR
Expand Down
2 changes: 1 addition & 1 deletion libc/test/src/sched/sched_rr_get_interval_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "src/unistd/getuid.h"
#include "test/UnitTest/Test.h"

#include <sched.h>
#include "hdr/types/cpu_set_t.h"

TEST(LlvmLibcSchedRRGetIntervalTest, SmokeTest) {
LIBC_NAMESPACE::libc_errno = 0;
Expand Down
Loading