From 04bc408931583d29899b938a5d830f5254c92f60 Mon Sep 17 00:00:00 2001
From: Kaspar Schleiser <kaspar@schleiser.de>
Date: Thu, 19 Nov 2015 13:04:29 +0100
Subject: [PATCH] cpu: msp430: add write() + needed libc header fixes

---
 cpu/msp430-common/include/sys/types.h | 22 ++++++++++++++++++++++
 cpu/msp430fxyz/msp430_stdio.c         | 19 +++++++++++++++++--
 2 files changed, 39 insertions(+), 2 deletions(-)
 create mode 100644 cpu/msp430-common/include/sys/types.h

diff --git a/cpu/msp430-common/include/sys/types.h b/cpu/msp430-common/include/sys/types.h
new file mode 100644
index 0000000000..d50105720c
--- /dev/null
+++ b/cpu/msp430-common/include/sys/types.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2014 INRIA
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser
+ * General Public License v2.1. See the file LICENSE in the top level
+ * directory for more details.
+ */
+
+#ifndef SYS_TYPES_H_
+#define SYS_TYPES_H_
+
+#include "msp430_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* SYS_TYPES_H_ */
diff --git a/cpu/msp430fxyz/msp430_stdio.c b/cpu/msp430fxyz/msp430_stdio.c
index 17619dd1d5..31f783a669 100644
--- a/cpu/msp430fxyz/msp430_stdio.c
+++ b/cpu/msp430fxyz/msp430_stdio.c
@@ -18,6 +18,9 @@
  * @}
  */
 
+#include <sys/types.h>
+#include <unistd.h>
+
 #include "uart_stdio.h"
 
 /**
@@ -37,6 +40,18 @@ int getchar(void)
 int putchar(int c)
 {
     char _c = c;
-    uart_stdio_write(&_c, 1);
-    return 1;
+    return uart_stdio_write(&_c, 1);
+}
+
+/**
+ * @brief   Write nbyte characters to the STDIO UART interface
+ */
+ssize_t write(int fildes, const void *buf, size_t nbyte)
+{
+    if (fildes == STDOUT_FILENO) {
+        return uart_stdio_write(buf, nbyte);
+    }
+    else {
+        return -1;
+    }
 }
-- 
GitLab