Skip to content

Commit

Permalink
posix: Move gettimeofday declaration to <sys/time.h>
Browse files Browse the repository at this point in the history
According to POSIX, that's the header which defines this function.
Similarly, nothing in POSIX indicates that <time.h> should have
access to struct timeval, so it's removed (it's made accessible
to <sys/time.h> via <sys/_timeval.h> introduced earlier).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
  • Loading branch information
pfalcon authored and nashif committed May 8, 2019
1 parent c896f87 commit 81fa697
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
22 changes: 22 additions & 0 deletions include/posix/sys/time.h
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2019 Linaro Limited
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef ZEPHYR_INCLUDE_POSIX_SYS_TIME_H_
#define ZEPHYR_INCLUDE_POSIX_SYS_TIME_H_

#include <sys/_timeval.h>

#ifdef __cplusplus
extern "C" {
#endif

int gettimeofday(struct timeval *tv, const void *tz);

#ifdef __cplusplus
}
#endif

#endif /* ZEPHYR_INCLUDE_POSIX_SYS_TIME_H_ */
7 changes: 0 additions & 7 deletions include/posix/time.h
Expand Up @@ -34,11 +34,6 @@ struct itimerspec {
};
#endif

struct timeval {
signed int tv_sec;
signed int tv_usec;
};

#include <kernel.h>
#include <errno.h>
#include "posix_types.h"
Expand Down Expand Up @@ -72,8 +67,6 @@ int timer_gettime(timer_t timerid, struct itimerspec *its);
int timer_settime(timer_t timerid, int flags, const struct itimerspec *value,
struct itimerspec *ovalue);

int gettimeofday(struct timeval *tv, const void *tz);

#ifdef __cplusplus
}
#endif
Expand Down
1 change: 1 addition & 0 deletions lib/posix/clock.c
Expand Up @@ -6,6 +6,7 @@
#include <kernel.h>
#include <errno.h>
#include <posix/time.h>
#include <posix/sys/time.h>

/*
* `k_uptime_get` returns a timestamp based on an always increasing
Expand Down
1 change: 1 addition & 0 deletions tests/posix/common/src/clock.c
Expand Up @@ -5,6 +5,7 @@
*/
#include <ztest.h>
#include <posix/time.h>
#include <posix/sys/time.h>
#include <posix/unistd.h>

#define SLEEP_SECONDS 1
Expand Down

0 comments on commit 81fa697

Please sign in to comment.