commit: 257c43c58feb7b0b4e7f166b2c264346a5d032b1
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 29 20:16:04 2025 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Nov 29 20:16:04 2025 +0000
URL: https://gitweb.gentoo.org/proj/steve.git/commit/?id=257c43c5
Add missing headers
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
steve.h | 31 +++++++++++++++++++++++++++++++
util.hxx | 29 +++++++++++++++++++++++++++++
2 files changed, 60 insertions(+)
diff --git a/steve.h b/steve.h
new file mode 100644
index 0000000..8d47850
--- /dev/null
+++ b/steve.h
@@ -0,0 +1,31 @@
+/* Steve, the jobserver
+ * (c) 2025 Michał Górny
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#pragma once
+
+#ifndef STEVE_H
+#define STEVE_H 1
+
+#include <sys/ioctl.h>
+
+/* get number of currently available tokens */
+#define STEVE_IOC_GET_TOKENS _IOR(0x53, 0x00, int64_t)
+/* get/set total job count (may lower min-jobs) */
+#define STEVE_IOC_GET_JOBS _IOR(0x53, 0x01, int64_t)
+#define STEVE_IOC_SET_JOBS _IOW(0x53, 0x01, int64_t)
+/* get/set min-jobs (must be no higher than jobs) */
+#define STEVE_IOC_GET_MIN_JOBS _IOR(0x53, 0x02, int64_t)
+#define STEVE_IOC_SET_MIN_JOBS _IOW(0x53, 0x02, int64_t)
+/* get/set load-average */
+#define STEVE_IOC_GET_LOAD_AVG _IOR(0x53, 0x03, double)
+#define STEVE_IOC_SET_LOAD_AVG _IOW(0x53, 0x03, double)
+
+#define STEVE_IOC_MASK_GET _IOR(0x53, 0, int64_t)
+#define STEVE_IOC_MASK_SET _IOW(0x53, 0, int64_t)
+
+#define STEVE_IOC_IS_GET(num) ((num & STEVE_IOC_MASK_GET) ==
STEVE_IOC_MASK_GET)
+#define STEVE_IOC_IS_SET(num) ((num & STEVE_IOC_MASK_SET) ==
STEVE_IOC_MASK_SET)
+
+#endif /*STEVE_H*/
diff --git a/util.hxx b/util.hxx
new file mode 100644
index 0000000..fab35c7
--- /dev/null
+++ b/util.hxx
@@ -0,0 +1,29 @@
+/* Steve, the jobserver
+ * (c) 2025 Michał Górny
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include <climits>
+
+struct fd_guard {
+ int fd;
+ ~fd_guard() { close(fd); }
+};
+
+bool arg_to_long(const char *optarg, long *out) {
+ char *endptr;
+ errno = 0;
+ *out = strtol(optarg, &endptr, 10);
+ return (
+ !*endptr && errno == 0 && *out >= 0 && *out < INT_MAX
+ );
+}
+
+bool arg_to_load_avg(const char *optarg, double *out) {
+ char *endptr;
+ errno = 0;
+ *out = strtod(optarg, &endptr);
+ return (
+ !*endptr && errno == 0 && *out >= 1
+ );
+}