oksh-noxz

[fork] Portable OpenBSD ksh, based on the Public Domain Korn Shell (pdksh).
git clone https://noxz.tech/git/oksh-noxz.git
oksh-noxz

commit: 596abbf6df68657e9ea70074e3d1598416a861b7
parent: 72c07a61de54ce0226855f1f60f1099e8365f1db
author: Alison Winters <alisonatwork@outlook.com>
date:   Sun, 14 Mar 2021 07:49:48 +0000
add check for timerclear and implementation
Mconfigure26++++++++++++++++++++
Mportable.h4+++
2 files changed, 30 insertions(+)
diff --git a/configure b/configure
@@ -690,6 +690,22 @@ EOF
   fi
 }
 
+timerclearcheck() {
+  cat << EOF > conftest.c
+#include <sys/time.h>
+int main(void){struct timeval a;timerclear(&a);return 0;}
+EOF
+  $cc $cflags -o conftest.o -c conftest.c > /dev/null 2>&1
+  $cc $ldflags -o conftest conftest.o > /dev/null 2>&1
+  if [ $? -eq 0 ] ; then
+    rm -f conftest conftest.o conftest.c
+    return 0
+  else
+    rm -f conftest conftest.o conftest.c
+    return 1
+  fi
+}
+
 timersubcheck() {
   cat << EOF > conftest.c
 #include <sys/time.h>
@@ -898,6 +914,7 @@ if [ $doconfigure -eq 0 ] ; then
 /* #define HAVE_SIGLIST */
 /* #define HAVE_SIGNAME */
 /* #define HAVE_TIMERADD */
+/* #define HAVE_TIMERCLEAR */
 /* #define HAVE_TIMERSUB */
 EOF
   Makefile
@@ -1264,6 +1281,15 @@ else
   echo "no"
 fi
 
+printf "checking for timerclear... "
+timerclearcheck
+if [ $? -eq 0 ] ; then
+  echo "#define HAVE_TIMERCLEAR" >> pconfig.h
+  echo "yes"
+else
+  echo "no"
+fi
+
 printf "checking for timersub... "
 timersubcheck
 if [ $? -eq 0 ] ; then
diff --git a/portable.h b/portable.h
@@ -140,6 +140,10 @@
         } while (0)
 #endif /* !HAVE_TIMERADD */
 
+#ifndef HAVE_TIMERCLEAR
+#define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
+#endif /* !HAVE_TIMERCLEAR */
+
 #ifndef HAVE_TIMERSUB
 #define timersub(tvp, uvp, vvp)                                         \
         do {                                                            \