aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessio Balsini <balsini@google.com>2024-03-04 14:18:02 +0000
committerAlessio Balsini <balsini@google.com>2024-03-04 16:42:55 +0000
commit7b4e122027eac90ba76da2eb6a4703a3f76813c4 (patch)
treeb2b7a6d3c01c484248ce1856ebda23afd222d940
parent40b07b8734e1c472db5e9ea7a43c9f0fb05bb814 (diff)
downloaddittosuite-7b4e122027eac90ba76da2eb6a4703a3f76813c4.tar.gz
Move SchedAttr__ to syscall
As part of a refactoring required to implement functions not yet available in the libraries provided by Kleaf's sysroot, move the data structure that mimicks sched_attr in sched/types.h into the syscall-related code. Test: build Bug: 322744630 Change-Id: I05ca8ffb2ef36b29708dfc0340635fb2c2162037 Signed-off-by: Alessio Balsini <balsini@google.com>
-rw-r--r--include/ditto/multithreading_utils.h18
-rw-r--r--include/ditto/syscall.h17
-rw-r--r--src/multithreading_utils.cpp15
-rw-r--r--src/syscall.cpp11
4 files changed, 29 insertions, 32 deletions
diff --git a/include/ditto/multithreading_utils.h b/include/ditto/multithreading_utils.h
index b1ca472..b8295be 100644
--- a/include/ditto/multithreading_utils.h
+++ b/include/ditto/multithreading_utils.h
@@ -21,6 +21,7 @@
#endif
#include <ditto/logger.h>
+#include <ditto/syscall.h>
#include <sys/syscall.h>
#include <unistd.h>
@@ -37,23 +38,6 @@ enum SchedPolicy {
SchedDeadline = 6,
};
-struct SchedAttr__ {
- uint32_t size; /* Size of this structure */
- uint32_t sched_policy; /* Policy (SCHED_*) */
- uint64_t sched_flags; /* Flags */
-
- int32_t sched_nice; /* Nice value (SCHED_OTHER,
- SCHED_BATCH) */
- uint32_t sched_priority; /* Static priority (SCHED_FIFO,
- SCHED_RR) */
- /* Remaining fields are for SCHED_DEADLINE */
- uint64_t sched_runtime;
- uint64_t sched_deadline;
- uint64_t sched_period;
-};
-
-std::string to_string(const SchedAttr__& attr);
-
class SchedAttr {
bool initialized_ = false;
SchedAttr__ sched_attr_;
diff --git a/include/ditto/syscall.h b/include/ditto/syscall.h
index c7e3af8..e51cc95 100644
--- a/include/ditto/syscall.h
+++ b/include/ditto/syscall.h
@@ -25,6 +25,23 @@
namespace dittosuite {
+struct SchedAttr__ {
+ uint32_t size; /* Size of this structure */
+ uint32_t sched_policy; /* Policy (SCHED_*) */
+ uint64_t sched_flags; /* Flags */
+
+ int32_t sched_nice; /* Nice value (SCHED_OTHER,
+ SCHED_BATCH) */
+ uint32_t sched_priority; /* Static priority (SCHED_FIFO,
+ SCHED_RR) */
+ /* Remaining fields are for SCHED_DEADLINE */
+ uint64_t sched_runtime;
+ uint64_t sched_deadline;
+ uint64_t sched_period;
+};
+
+std::string to_string(const SchedAttr__& attr);
+
class SyscallInterface {
public:
virtual ~SyscallInterface() {}
diff --git a/src/multithreading_utils.cpp b/src/multithreading_utils.cpp
index 9b9716f..b3355d6 100644
--- a/src/multithreading_utils.cpp
+++ b/src/multithreading_utils.cpp
@@ -19,21 +19,6 @@
namespace dittosuite {
-std::string to_string(const SchedAttr__& attr) {
- std::string ret;
-
- ret += "size: " + std::to_string(attr.size);
- ret += ", policy: " + std::to_string(attr.sched_policy);
- ret += ", flags: " + std::to_string(attr.sched_flags);
- ret += ", nice: " + std::to_string(attr.sched_nice);
- ret += ", priority: " + std::to_string(attr.sched_priority);
- ret += ", runtime: " + std::to_string(attr.sched_runtime);
- ret += ", deadline: " + std::to_string(attr.sched_deadline);
- ret += ", period: " + std::to_string(attr.sched_period);
-
- return ret;
-}
-
bool SchedAttr::IsSet() const { return initialized_; }
void SchedAttr::Set() const {
diff --git a/src/syscall.cpp b/src/syscall.cpp
index 83e6cee..13d81e0 100644
--- a/src/syscall.cpp
+++ b/src/syscall.cpp
@@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+#include <sstream>
+
#include <ditto/syscall.h>
namespace dittosuite {
@@ -85,4 +87,13 @@ int64_t Syscall::Write(int fd, char* buf, int64_t count, int64_t offset) {
return pwrite64(fd, buf, count, offset);
}
+std::string to_string(const SchedAttr__& attr) {
+ std::stringstream ss;
+ ss << "size: " << attr.size << ", policy: " << attr.sched_policy
+ << ", flags: " << attr.sched_flags << ", nice: " << attr.sched_nice
+ << ", priority: " << attr.sched_priority << ", runtime: " << attr.sched_runtime
+ << ", deadline: " << attr.sched_deadline << ", period: " << attr.sched_period;
+ return ss.str();
+}
+
} // namespace dittosuite