public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin/main] Cygwin: timespec_get: implement C11 function
Date: Fri, 16 Feb 2024 19:44:48 +0000 (GMT)	[thread overview]
Message-ID: <20240216194448.E0C0B3857B8B@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=a7bf7c7dd524ab724913da0019f8b4a5425b5927

commit a7bf7c7dd524ab724913da0019f8b4a5425b5927
Author:     Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Fri Feb 16 20:44:31 2024 +0100
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Fri Feb 16 20:44:31 2024 +0100

    Cygwin: timespec_get: implement C11 function
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/cygwin.din            | 1 +
 winsup/cygwin/include/cygwin/time.h | 6 ++++++
 winsup/cygwin/release/3.6.0         | 2 ++
 winsup/cygwin/times.cc              | 9 +++++++++
 4 files changed, 18 insertions(+)

diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din
index be9efdc00f44..37ec00896232 100644
--- a/winsup/cygwin/cygwin.din
+++ b/winsup/cygwin/cygwin.din
@@ -1559,6 +1559,7 @@ timerfd_create SIGFE
 timerfd_gettime SIGFE
 timerfd_settime SIGFE
 times SIGFE
+timespec_get SIGFE
 timezone SIGFE
 timingsafe_bcmp NOSIGFE
 timingsafe_memcmp NOSIGFE
diff --git a/winsup/cygwin/include/cygwin/time.h b/winsup/cygwin/include/cygwin/time.h
index d7f9d3f75b15..9b63e9aeb6ce 100644
--- a/winsup/cygwin/include/cygwin/time.h
+++ b/winsup/cygwin/include/cygwin/time.h
@@ -35,6 +35,12 @@ extern long timezone __asm__ (_SYMSTR (_timezone));
 
 #endif /* __SVID_VISIBLE || __XSI_VISIBLE */
 
+#if __ISO_C_VISIBLE >= 2011
+#define TIME_UTC 1
+
+extern int timespec_get (struct timespec *, int);
+#endif
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/winsup/cygwin/release/3.6.0 b/winsup/cygwin/release/3.6.0
index 561637c397e6..e190aa2927d6 100644
--- a/winsup/cygwin/release/3.6.0
+++ b/winsup/cygwin/release/3.6.0
@@ -7,6 +7,8 @@ What's new:
 
 - New API call: setproctitle.
 
+- New API call: timespec_get.
+
 
 What changed:
 -------------
diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc
index ddea061b8920..87773934bfd7 100644
--- a/winsup/cygwin/times.cc
+++ b/winsup/cygwin/times.cc
@@ -559,3 +559,12 @@ clock_getcpuclockid (pid_t pid, clockid_t *clk_id)
   *clk_id = (clockid_t) PID_TO_CLOCKID (pid);
   return 0;
 }
+
+extern "C" int
+timespec_get (struct timespec *ts, int base)
+{
+  if (base != TIME_UTC)
+    return 0;
+  clock_gettime (CLOCK_REALTIME, ts);
+  return base;
+}

                 reply	other threads:[~2024-02-16 19:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240216194448.E0C0B3857B8B@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).