From 6063ffead95bc3710cf9b3786583fd09f37c8657 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sat, 7 Feb 2026 20:34:49 +0100 Subject: [PATCH] libutil: remove unused functions Change-Id: I2b1c42460de50aff1f742856654c59fc4ce88e04 --- lix/libutil/file-descriptor.cc | 8 --- lix/libutil/file-descriptor.hh | 5 -- lix/libutil/signals.cc | 19 ------- lix/libutil/signals.hh | 7 --- lix/libutil/thread-pool.hh | 100 --------------------------------- 5 files changed, 139 deletions(-) diff --git a/lix/libutil/file-descriptor.cc b/lix/libutil/file-descriptor.cc index 1875a3473..c7047121e 100644 --- a/lix/libutil/file-descriptor.cc +++ b/lix/libutil/file-descriptor.cc @@ -65,14 +65,6 @@ std::string readLine(int fd) } } - -void writeLine(int fd, std::string s) -{ - s += '\n'; - writeFull(fd, s); -} - - void readFull(int fd, char * buf, size_t count) { while (count) { diff --git a/lix/libutil/file-descriptor.hh b/lix/libutil/file-descriptor.hh index d899d23f8..577cba8f3 100644 --- a/lix/libutil/file-descriptor.hh +++ b/lix/libutil/file-descriptor.hh @@ -20,11 +20,6 @@ rlimit getOpenFilesLimit(); */ std::string readLine(int fd); -/** - * Write a line to a file descriptor. - */ -void writeLine(int fd, std::string s); - /** * Read the contents of a file into a string. */ diff --git a/lix/libutil/signals.cc b/lix/libutil/signals.cc index 86757dfe3..0227b5f81 100644 --- a/lix/libutil/signals.cc +++ b/lix/libutil/signals.cc @@ -155,25 +155,6 @@ void triggerInterrupt() static sigset_t savedSignalMask; static bool savedSignalMaskIsSet = false; -void setChildSignalMask(sigset_t * sigs) -{ - assert(sigs); // C style function, but think of sigs as a reference - -#if _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE - sigemptyset(&savedSignalMask); - // There's no "assign" or "copy" function, so we rely on (math) idempotence - // of the or operator: a or a = a. - sigorset(&savedSignalMask, sigs, sigs); -#else - // Without sigorset, our best bet is to assume that sigset_t is a type that - // can be assigned directly, such as is the case for a sigset_t defined as - // an integer type. - savedSignalMask = *sigs; -#endif - - savedSignalMaskIsSet = true; -} - void saveSignalMask() { if (sigprocmask(SIG_BLOCK, nullptr, &savedSignalMask)) throw SysError("querying signal mask"); diff --git a/lix/libutil/signals.hh b/lix/libutil/signals.hh index 11e96bd24..2f33fd61e 100644 --- a/lix/libutil/signals.hh +++ b/lix/libutil/signals.hh @@ -97,13 +97,6 @@ void startSignalHandlerThread(); */ void saveSignalMask(); -/** - * Sets the signal mask. Like saveSignalMask() but for a signal set that doesn't - * necessarily match the current thread's mask. - * See saveSignalMask() to set the saved mask to the current mask. - */ -void setChildSignalMask(sigset_t *sigs); - struct InterruptCallback { virtual ~InterruptCallback() { }; diff --git a/lix/libutil/thread-pool.hh b/lix/libutil/thread-pool.hh index 748173bf7..71ab4440b 100644 --- a/lix/libutil/thread-pool.hh +++ b/lix/libutil/thread-pool.hh @@ -91,106 +91,6 @@ private: void shutdown(); }; -/** - * Process in parallel a set of items of type T that have a partial - * ordering between them. Thus, any item is only processed after all - * its dependencies have been processed. - */ -template -void processGraph( - const char *poolName, - const std::set & nodes, - std::function(AsyncIoRoot &, const T &)> getEdges, - std::function processNode) -{ - struct Graph { - std::set left; - std::map> refs, rrefs; - }; - - Sync graph_(Graph{nodes, {}, {}}); - - std::function worker; - - /* Create pool last to ensure threads are stopped before other destructors - * run */ - ThreadPool pool{poolName}; - - - worker = [&](AsyncIoRoot & aio, const T & node) { - - { - auto graph(graph_.lock()); - auto i = graph->refs.find(node); - if (i == graph->refs.end()) - goto getRefs; - goto doWork; - } - - getRefs: - { - auto refs = getEdges(aio, node); - refs.erase(node); - - { - auto graph(graph_.lock()); - for (auto & ref : refs) - if (graph->left.count(ref)) { - graph->refs[node].insert(ref); - graph->rrefs[ref].insert(node); - } - if (graph->refs[node].empty()) - goto doWork; - } - } - - return; - - doWork: - processNode(aio, node); - - /* Enqueue work for all nodes that were waiting on this one - and have no unprocessed dependencies. */ - { - auto graph(graph_.lock()); - for (auto & rref : graph->rrefs[node]) { - auto & refs(graph->refs[rref]); - auto i = refs.find(node); - assert(i != refs.end()); - refs.erase(i); - if (refs.empty()) - pool.enqueueWithAio(std::bind(worker, std::placeholders::_1, rref)); - } - graph->left.erase(node); - graph->refs.erase(node); - graph->rrefs.erase(node); - } - }; - - for (auto & node : nodes) - pool.enqueueWithAio(std::bind(worker, std::placeholders::_1, std::ref(node))); - - pool.process(); - - if (!graph_.lock()->left.empty()) - throw Error("graph processing incomplete (cyclic reference?)"); -} - -template -void processGraph( - const char *poolName, - const std::set & nodes, - std::function(const T &)> getEdges, - std::function processNode) -{ - processGraph( - poolName, - nodes, - [&](AsyncIoRoot &, const T & node) { return getEdges(node); }, - [&](AsyncIoRoot &, const T & node) { processNode(node); } - ); -} - template kj::Promise> processGraphAsync( const std::set & nodes,