Skip to content
Browse files

posix: struct timespec: Move definition to sys/_timespec.h

POSIX subsys defines struct timespec in <time.h> (as POSIX public
API requires), but newlib defines in in sys/_timespec.h, which
inevitably leads to inclusion order and redifinition conflicts.
Follow newlib way and define it in single place, sys/_timespec.h,
which belongs to libc namespace. Thus, we move current definition
to minimal libc, and will use either minlibc's or newlib's
definition, instead of trying to redefine it.

This is similar to the introduction of sys/_timeval.h done earlier.

Signed-off-by: Paul Sokolovsky <>
  • Loading branch information...
pfalcon authored and galak committed Jun 5, 2019
1 parent 3693f85 commit 3a4553913e8f7abc895a91b1503e95ec38634715
Showing with 18 additions and 8 deletions.
  1. +1 −8 include/posix/time.h
  2. +17 −0 lib/libc/minimal/include/sys/_timespec.h
@@ -10,14 +10,7 @@
extern "C" {

#ifndef __timespec_defined
#define __timespec_defined
struct timespec {
signed int tv_sec;
signed int tv_nsec;
#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,0 +1,17 @@
* Copyright (c) 2019 Linaro Limited
* SPDX-License-Identifier: Apache-2.0


#include <sys/types.h>

struct timespec {
time_t tv_sec;
long tv_nsec;


0 comments on commit 3a45539

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