From dce566553cffef61d49ad135f2b5a9e1d96fe34f Mon Sep 17 00:00:00 2001 From: =?utf8?q?P=C3=A1draig=20Brady?=
Date: Sat, 5 Apr 2025 21:48:05 +0100
Subject: [PATCH] timeout: remove dependence on libm
This was seen to add about 100,000 ns to the startup time,
on a 2.6 GHz i7-5600U with glibc 2.40.
* .gitignore: Remove /lib/fenv.h.
* bootstrap.conf: Remove fenv-rounding and signbit deps.
* src/local.mk: Remove fenv lib dependency.
* src/timeout.c (is_negative): A new helper function to
be equivalent of signbit in the underflow case.
(parse_duration): Remove the rounding up logic,
as a nanosecond here or there has no significance.
---
.gitignore | 1 -
bootstrap.conf | 2 --
src/local.mk | 3 ---
src/timeout.c | 36 +++++++++++-------------------------
4 files changed, 11 insertions(+), 31 deletions(-)
diff --git a/.gitignore b/.gitignore
index 4dc39ae551..f4a17ad044 100644
--- a/.gitignore
+++ b/.gitignore
@@ -67,7 +67,6 @@
/lib/errno.h
/lib/error.h
/lib/fcntl.h
-/lib/fenv.h
/lib/float.h
/lib/fnmatch.h
/lib/getopt-cdefs.h
diff --git a/bootstrap.conf b/bootstrap.conf
index 3c133ef714..c99838e95a 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -99,7 +99,6 @@ gnulib_modules="
fdatasync
fdopen
fdutimensat
- fenv-rounding
file-has-acl
file-type
fileblocks
@@ -243,7 +242,6 @@ gnulib_modules="
settime
sig2str
sigaction
- signbit
skipchars
smack
ssize_t
diff --git a/src/local.mk b/src/local.mk
index 0a4e3af432..fd9dc81c27 100644
--- a/src/local.mk
+++ b/src/local.mk
@@ -257,9 +257,6 @@ src_stat_LDADD += $(LIB_SELINUX)
# for nvlist_lookup_uint64_array
src_stat_LDADD += $(LIB_NVPAIR)
-# for fegetround, fesetround
-src_timeout_LDADD += $(FENV_ROUNDING_LIBM)
-
# for gettime, settime, tempname, utimecmp, utimens
copy_ldadd += $(CLOCK_TIME_LIB)
src_date_LDADD += $(CLOCK_TIME_LIB)
diff --git a/src/timeout.c b/src/timeout.c
index 5947c19421..fe8eb45596 100644
--- a/src/timeout.c
+++ b/src/timeout.c
@@ -45,9 +45,8 @@
Written by Pádraig Brady. */
#include