From cce83b44430d6067c596cdb9979da5287e9e76cc Mon Sep 17 00:00:00 2001
From: Juan Carrano <j.carrano@fu-berlin.de>
Date: Mon, 7 May 2018 10:48:51 +0200
Subject: [PATCH] sys/newlib: Add missing syscalls (stubs).

Add small stubs for _times_r and _link_r so that code using times()
or link() can still compile. The functions are marked as not implemented
and return invalid codes.
---
 sys/newlib_syscalls_default/syscalls.c | 34 ++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/sys/newlib_syscalls_default/syscalls.c b/sys/newlib_syscalls_default/syscalls.c
index 91543fcd18..af4ed45e04 100644
--- a/sys/newlib_syscalls_default/syscalls.c
+++ b/sys/newlib_syscalls_default/syscalls.c
@@ -45,6 +45,8 @@
 
 #include "uart_stdio.h"
 
+#include <sys/times.h>
+
 #ifdef MODULE_XTIMER
 #include <sys/time.h>
 #include "div.h"
@@ -461,6 +463,23 @@ int _unlink_r(struct _reent *r, const char *path)
 }
 #endif /* MODULE_VFS */
 
+/**
+ * Create a hard link (not implemented).
+ *
+ * @todo    Not implemented.
+ *
+ * @return  -1. Sets errno to ENOSYS.
+ */
+int _link_r(struct _reent *ptr, const char *old_name, const char *new_name)
+{
+    (void)old_name;
+    (void)new_name;
+
+    ptr->_errno = ENOSYS;
+
+    return -1;
+}
+
 /**
  * @brief Query whether output stream is a terminal
  *
@@ -516,3 +535,18 @@ int _gettimeofday_r(struct _reent *r, struct timeval *restrict tp, void *restric
     return -1;
 }
 #endif
+
+/**
+ * Current process times (not implemented).
+ *
+ * @param[out]  ptms    Not modified.
+ *
+ * @return  -1, this function always fails. errno is set to ENOSYS.
+ */
+clock_t _times_r(struct _reent *ptr, struct tms *ptms)
+{
+    (void)ptms;
+    ptr->_errno = ENOSYS;
+
+    return (-1);
+}
-- 
GitLab