/* For timeradd, timersub, timercmp, realpath. */
#define _BSD_SOURCE 1 /* for glibc < 2.19 */
#define _DEFAULT_SOURCE 1 /* for glibc >= 2.20 */
+/* For clock_gettime and associated types. */
+#define _POSIX_C_SOURCE 199309L
#endif
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <stdarg.h>
+#include <stdbool.h>
+#include <stdint.h>
#ifdef _WIN32
#include <windows.h>
#include <tchar.h>
#endif
#ifdef __linux__
#include <dirent.h>
-#ifndef __ANDROID__
-#include "linux/serial.h"
+/* Android only has linux/serial.h from platform 21 onwards. */
+#if !(defined(__ANDROID__) && (__ANDROID_API__ < 21))
+#include <linux/serial.h>
#endif
#include "linux_termios.h"