Skip to content
Browse files

posix: time.h: Add workaround for outdated newlib used by Xtensa

Unfortunately, Zephyr SDK 0.10.0 ships with outdated Newlib 2.0.0
(from 2015 or earlier) which lacks sys/_timespec.h header, requiring
ugly workaround of defining struct timespec inline (the whole idea
was to standardize on sys/_timespec.h header for different libc's).

This is similar to earlier workaround for struct timeval definition
introduced in a6aee9b. Zephyr SDK ticket for this issue
is zephyrproject-rtos/sdk-ng#64, and it
will ve possible to remove both workarounds when Xtensa toolchain
will be upgraded to newlib version consistent with other

Signed-off-by: Paul Sokolovsky <>
  • Loading branch information...
pfalcon authored and galak committed Jun 5, 2019
1 parent 3a45539 commit 15a9709186f59bdc8c5925bd906416ed0a60b2eb
Showing with 23 additions and 0 deletions.
  1. +23 −0 include/posix/time.h
@@ -10,7 +10,30 @@
extern "C" {

/* Kludge to support outdated newlib version as used in SDK 0.10 for Xtensa */
#include <newlib.h>

#ifdef __NEWLIB__
/* Newever Newlib 3.x+ */
#include <sys/_timespec.h>
/* Workaround for older Newlib 2.x, as used by Xtensa. It lacks sys/_timeval.h,
* so mimic it here.
#include <sys/types.h>
#ifndef __timespec_defined
struct timespec {
time_t tv_sec;
long tv_nsec;

/* Not Newlib */
#include <sys/_timespec.h>

/* Older newlib's like 2.{0-2}.0 don't define any newlib version defines, only
* __NEWLIB_H__ so we use that to decide if itimerspec was defined in

0 comments on commit 15a9709

Please sign in to comment.
You can’t perform that action at this time.