On 19/07/11 19:45, Paul Eggert wrote:
> On 07/19/11 04:00, Pádraig Brady wrote:
> 
>> +  if (timer_create (CLOCK_REALTIME, NULL, &timerid) == -1)
>> +    error (EXIT_FAILURE, errno, _("error in timer_create"));
>> +  if (timer_settime (timerid, 0, &its, NULL) == -1)
>> +    error (EXIT_FAILURE, errno, _("error in timer_settime"));
> 
> A minor point: the usual (more-conservative, and often-faster) style
> in coreutils is to write "foo (...) != 0" rather than "foo (...) ==
> -1" for system calls that return 0 or -1.
> 
>> We could remove the setitimer stuff altogether and
>> just support 1 second resolution on darwin et. al.
>> That's by far the most common use case anyway.
> 

OK I'll do that, encompassing your fallback suggestion.

> 
>> The gnulib check could be lumped into clock_time, like:
> 
> Yes, that would work, but the clock-time module probably should stay
> decoupled from timer_settime.  How about the following (untested)
> patch instead?  The idea is to append "timeout_LDADD +=
> $(LIB_TIMER_SETTIME)" to src/Makefile.am.
> 
> diff --git a/m4/jm-macros.m4 b/m4/jm-macros.m4

I'd rather not add this into jm-macros.
How about just adding a module to gnulib
where others might find it useful too?
Proposed module attached.

cheers,
Pádraig.
>From 40c196b627ab6b5343cabd7fd4befc0733142ba5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <p...@draigbrady.com>
Date: Tue, 19 Jul 2011 21:51:49 +0100
Subject: [PATCH] timer-time: A new module to check for timer_settime()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* m4/timer_time.m4: Check for the POSIX function.
* modules/timer-time: Add the new module.
* MODULES.html.sh (Compat checks for POSIX:2008 functions):
Mention it.

Signed-off-by: Pádraig Brady <p...@draigbrady.com>
---
 ChangeLog          |    8 ++++++++
 MODULES.html.sh    |    1 +
 m4/timer_time.m4   |   26 ++++++++++++++++++++++++++
 modules/timer-time |   26 ++++++++++++++++++++++++++
 4 files changed, 61 insertions(+), 0 deletions(-)
 create mode 100644 m4/timer_time.m4
 create mode 100644 modules/timer-time

diff --git a/ChangeLog b/ChangeLog
index e72af4c..fa135a2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2011-07-19  Pádraig Brady  <p...@draigbrady.com>
 
+	timer-time: A new module to check for timer_settime()
+	* m4/timer_time.m4: Check for the posix function.
+	* modules/timer-time: Add the new module.
+	* MODULES.html.sh (Compat checks for POSIX:2008 functions):
+	Mention it.
+
+2011-07-19  Pádraig Brady  <p...@draigbrady.com>
+
 	getopt-gnu: suppress core dumps from detection code
 	* m4/getopt.m4 (gl_GETOPT_CHECK_HEADERS): Use the nocrash module
 	to suppress core dumps that may well occur on glibc systems.
diff --git a/MODULES.html.sh b/MODULES.html.sh
index 99de344..bcd8aac 100755
--- a/MODULES.html.sh
+++ b/MODULES.html.sh
@@ -2522,6 +2522,7 @@ func_all_modules ()
   func_module link-follow
   func_module rename-dest-slash
   func_module rmdir-errno
+  func_module timer-time
   func_module unlink-busy
   func_module winsz-ioctl
   func_module winsz-termios
diff --git a/m4/timer_time.m4 b/m4/timer_time.m4
new file mode 100644
index 0000000..29e5a3d
--- /dev/null
+++ b/m4/timer_time.m4
@@ -0,0 +1,26 @@
+# timer_time.m4 serial 1
+dnl Copyright (C) 2011 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+# Check for timer_settime, and set LIB_TIMER_TIME.
+# For a program named, say foo, you should add a line like the following
+# in the corresponding Makefile.am file:
+# foo_LDADD = $(LDADD) $(LIB_TIMER_TIME)
+
+AC_DEFUN([gl_TIMER_TIME],
+[
+  dnl Based on clock_time.m4. See details there.
+
+  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+
+  LIB_TIMER_TIME=
+  AC_SUBST([LIB_TIMER_TIME])
+  gl_saved_libs=$LIBS
+    AC_SEARCH_LIBS([timer_settime], [rt posix4],
+                   [test "$ac_cv_search_timer_settime" = "none required" ||
+                    LIB_TIMER_TIME=$ac_cv_search_timer_settime])
+    AC_CHECK_FUNCS([timer_settime])
+  LIBS=$gl_saved_libs
+])
diff --git a/modules/timer-time b/modules/timer-time
new file mode 100644
index 0000000..1adcf2c
--- /dev/null
+++ b/modules/timer-time
@@ -0,0 +1,26 @@
+Description:
+Check for timer_settime.  Within HAVE_TIMER_SETTIME one can
+assume timer_create is available too, as that is a
+prerequisite to use timer_settime.
+
+Files:
+m4/timer_time.m4
+
+Depends-on:
+extensions
+
+configure.ac:
+gl_TIMER_TIME
+
+Makefile.am:
+
+Include:
+
+Link:
+$(LIB_TIMER_TIME)
+
+License:
+LGPLv2+
+
+Maintainer:
+Pádraig Brady
-- 
1.7.5.2

Reply via email to