gawk-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] gawk branch, gawk-5.3-stable, updated. gawk-4.1.0-5446-ga9836189


From: Arnold Robbins
Subject: [SCM] gawk branch, gawk-5.3-stable, updated. gawk-4.1.0-5446-ga9836189
Date: Fri, 12 Jan 2024 04:56:06 -0500 (EST)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".

The branch, gawk-5.3-stable has been updated
       via  a983618996359fb30070203335529ba8bcd6e073 (commit)
      from  b853893f9335c64b89ac41d3e6741b69ebd6925a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=a983618996359fb30070203335529ba8bcd6e073

commit a983618996359fb30070203335529ba8bcd6e073
Author: Arnold D. Robbins <arnold@skeeve.com>
Date:   Fri Jan 12 11:55:36 2024 +0200

    Use same time system call in gawk and in time extension.

diff --git a/ChangeLog b/ChangeLog
index 156994ae..c3d878bb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-01-12         Arnold D. Robbins     <arnold@skeeve.com>
+
+       Use newer interfaces for getting the time if they're available.
+       Thanks to Andreas Schwab <schwab@suse.de> and Andrew Schorr.
+
+       * builtin.c (do_systime): Use clock_gettime() or gettimeofday() or
+       time(), in that order.
+       * configure.ac: Add checks for clock_gettime() and gettimeofday().
+
 2023-12-26         Arnold D. Robbins     <arnold@skeeve.com>
 
        * gawkapi.c (api_get_argument): Sync handling of AWK_UNDEFINED
diff --git a/builtin.c b/builtin.c
index 84a0dff5..cc13c7fa 100644
--- a/builtin.c
+++ b/builtin.c
@@ -2169,7 +2169,19 @@ do_systime(int nargs ATTRIBUTE_UNUSED)
 
        check_exact_args(nargs, "systime", 0);
 
+#ifdef HAVE_CLOCK_GETTIME
+       struct timespec the_time;
+
+       (void) clock_gettime(CLOCK_REALTIME, & the_time);
+       lclock = the_time.tv_sec;
+#elif defined(HAVE_GETTIMEOFDAY)
+       struct timeval the_time;
+
+       (void) gettimeofday(& the_time, NULL);
+       lclock = the_time.tv_sec;
+#else
        (void) time(& lclock);
+#endif
        return make_number((AWKNUM) lclock);
 }
 
diff --git a/configh.in b/configh.in
index db267cc4..dc574802 100644
--- a/configh.in
+++ b/configh.in
@@ -34,6 +34,9 @@
    the CoreFoundation framework. */
 #undef HAVE_CFPREFERENCESCOPYAPPVALUE
 
+/* Define to 1 if you have the `clock_gettime' function. */
+#undef HAVE_CLOCK_GETTIME
+
 /* Define to 1 if bool, true and false work as per C2023. */
 #undef HAVE_C_BOOL
 
@@ -72,6 +75,9 @@
 /* Define if the GNU gettext() function is already present or preinstalled. */
 #undef HAVE_GETTEXT
 
+/* Define to 1 if you have the `gettimeofday' function. */
+#undef HAVE_GETTIMEOFDAY
+
 /* Define to 1 if you have the `grantpt' function. */
 #undef HAVE_GRANTPT
 
diff --git a/configure b/configure
index 3391fed0..1325fdc9 100755
--- a/configure
+++ b/configure
@@ -11655,6 +11655,18 @@ if test "x$ac_cv_func_iswupper" = xyes
 then :
   printf "%s\n" "#define HAVE_ISWUPPER 1" >>confdefs.h
 
+fi
+ac_fn_c_check_func "$LINENO" "gettimeofday" "ac_cv_func_gettimeofday"
+if test "x$ac_cv_func_gettimeofday" = xyes
+then :
+  printf "%s\n" "#define HAVE_GETTIMEOFDAY 1" >>confdefs.h
+
+fi
+ac_fn_c_check_func "$LINENO" "clock_gettime" "ac_cv_func_clock_gettime"
+if test "x$ac_cv_func_clock_gettime" = xyes
+then :
+  printf "%s\n" "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h
+
 fi
 ac_fn_c_check_func "$LINENO" "lstat" "ac_cv_func_lstat"
 if test "x$ac_cv_func_lstat" = xyes
diff --git a/configure.ac b/configure.ac
index 8d6ff42a..b12555ef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -309,7 +309,7 @@ AC_SEARCH_LIBS(isnan, m)
 # Need the check for mkstemp and tmpfile for missing_d/snprintf.c.
 AC_CHECK_FUNCS(__etoa_l atexit btowc fmod fwrite_unlocked gai_strerror \
        getgrent getgroups grantpt isascii isblank iswctype iswlower iswupper \
-       lstat \
+       gettimeofday clock_gettime lstat \
        mbrlen memcmp memcpy memmove memset \
        mkstemp mtrace posix_openpt setenv setlocale setsid sigprocmask \
        snprintf strcasecmp strchr strcoll strerror strftime strncasecmp \
diff --git a/extension/ChangeLog b/extension/ChangeLog
index 40ed6dd0..65ee15cd 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,12 @@
+2024-01-12         Arnold D. Robbins     <arnold@skeeve.com>
+
+       Use newer interfaces for getting the time if they're available.
+       Thanks to Andreas Schwab <schwab@suse.de> and Andrew Schorr.
+
+       * time.c (do_gettimeofday): Use clock_gettime() or gettimeofday() or
+       time(), in that order.
+       * configure.ac: Add check for clock_gettime().
+
 2023-11-02         Arnold D. Robbins     <arnold@skeeve.com>
 
        * 5.3.0: Release tar ball made.
diff --git a/extension/configh.in b/extension/configh.in
index 77c8167b..bbb6fd47 100644
--- a/extension/configh.in
+++ b/extension/configh.in
@@ -22,6 +22,9 @@
    the CoreFoundation framework. */
 #undef HAVE_CFPREFERENCESCOPYAPPVALUE
 
+/* Define to 1 if you have the `clock_gettime' function. */
+#undef HAVE_CLOCK_GETTIME
+
 /* Define if the GNU dcgettext() function is already present or preinstalled.
    */
 #undef HAVE_DCGETTEXT
diff --git a/extension/configure b/extension/configure
index 7ec92ecc..65af57e6 100755
--- a/extension/configure
+++ b/extension/configure
@@ -17534,6 +17534,12 @@ if test "x$ac_cv_func_getdtablesize" = xyes
 then :
   printf "%s\n" "#define HAVE_GETDTABLESIZE 1" >>confdefs.h
 
+fi
+ac_fn_c_check_func "$LINENO" "clock_gettime" "ac_cv_func_clock_gettime"
+if test "x$ac_cv_func_clock_gettime" = xyes
+then :
+  printf "%s\n" "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h
+
 fi
 ac_fn_c_check_func "$LINENO" "gettimeofday" "ac_cv_func_gettimeofday"
 if test "x$ac_cv_func_gettimeofday" = xyes
diff --git a/extension/configure.ac b/extension/configure.ac
index 45c77a48..b40151cb 100644
--- a/extension/configure.ac
+++ b/extension/configure.ac
@@ -122,7 +122,8 @@ esac
 
 AC_SEARCH_LIBS(fmod, m)
 AC_CHECK_FUNCS(fdopendir fmod fnmatch getdtablesize \
-               gettimeofday nanosleep select statvfs \
+              clock_gettime gettimeofday \
+               nanosleep select statvfs \
                GetSystemTimeAsFileTime strptime)
 
 GAWK_FUNC_DIRFD
diff --git a/extension/time.c b/extension/time.c
index 8d93bda7..9dd98738 100644
--- a/extension/time.c
+++ b/extension/time.c
@@ -110,7 +110,14 @@ do_gettimeofday(int nargs, awk_value_t *result, struct 
awk_ext_func *unused)
 
        assert(result != NULL);
 
-#if defined(HAVE_GETTIMEOFDAY)
+#if defined(HAVE_CLOCK_GETTIME)
+       {
+               struct timespec tv;
+               clock_gettime(CLOCK_REALTIME, & tv);
+               curtime = tv.tv_sec + 0.0;
+               curtime = tv.tv_sec+(tv.tv_nsec/1000000000.0);
+       }
+#elif defined(HAVE_GETTIMEOFDAY)
        {
                struct timeval tv;
                gettimeofday(&tv,NULL);

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog              |  9 +++++++++
 builtin.c              | 12 ++++++++++++
 configh.in             |  6 ++++++
 configure              | 12 ++++++++++++
 configure.ac           |  2 +-
 extension/ChangeLog    |  9 +++++++++
 extension/configh.in   |  3 +++
 extension/configure    |  6 ++++++
 extension/configure.ac |  3 ++-
 extension/time.c       |  9 ++++++++-
 10 files changed, 68 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]