summaryrefslogtreecommitdiff
path: root/Libraries/LibC
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2020-09-06 09:59:19 -0400
committerAndreas Kling <kling@serenityos.org>2020-09-06 21:50:55 +0200
commit0fff4e11a68127c45c34f1d5e6fa64e6196d28b5 (patch)
tree035e264f78323a9c848424e9fbac9e3258bea7cd /Libraries/LibC
parent0736ae4116845a63429bb481e6b2f3dc97f3adcb (diff)
downloadserenity-0fff4e11a68127c45c34f1d5e6fa64e6196d28b5.zip
LibC: Add settimeofday
Diffstat (limited to 'Libraries/LibC')
-rw-r--r--Libraries/LibC/sys/time.h1
-rw-r--r--Libraries/LibC/time.cpp7
2 files changed, 8 insertions, 0 deletions
diff --git a/Libraries/LibC/sys/time.h b/Libraries/LibC/sys/time.h
index f660c2b24a..ac3013747e 100644
--- a/Libraries/LibC/sys/time.h
+++ b/Libraries/LibC/sys/time.h
@@ -43,6 +43,7 @@ struct timezone {
};
int gettimeofday(struct timeval* __restrict__, void* __restrict__) __attribute__((nonnull(1)));
+int settimeofday(struct timeval* __restrict__, void* __restrict__) __attribute__((nonnull(1)));
static inline void timeradd(const struct timeval* a, const struct timeval* b, struct timeval* out)
{
diff --git a/Libraries/LibC/time.cpp b/Libraries/LibC/time.cpp
index 5f1c8eeabe..c35cdf84c6 100644
--- a/Libraries/LibC/time.cpp
+++ b/Libraries/LibC/time.cpp
@@ -55,6 +55,13 @@ int gettimeofday(struct timeval* __restrict__ tv, void* __restrict__)
__RETURN_WITH_ERRNO(rc, rc, -1);
}
+int settimeofday(struct timeval* __restrict__ tv, void* __restrict__)
+{
+ timespec ts;
+ TIMEVAL_TO_TIMESPEC(tv, &ts);
+ return clock_settime(CLOCK_REALTIME, &ts);
+}
+
char* ctime(const time_t* t)
{
return asctime(localtime(t));