mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #5040 from kYc0o/rid_of_vtimer
sys/compat/vtimer: get rid of
This commit is contained in:
commit
30217f8a7b
@ -75,7 +75,7 @@ ifneq (,$(filter gnrc_zep,$(USEMODULE)))
|
||||
USEMODULE += ieee802154
|
||||
USEMODULE += gnrc_udp
|
||||
USEMODULE += random
|
||||
USEMODULE += vtimer
|
||||
USEMODULE += xtimer
|
||||
endif
|
||||
|
||||
ifneq (,$(filter gnrc_tftp,$(USEMODULE)))
|
||||
@ -354,10 +354,6 @@ ifneq (,$(filter sema,$(USEMODULE)))
|
||||
USEMODULE += xtimer
|
||||
endif
|
||||
|
||||
ifneq (,$(filter vtimer,$(USEMODULE)))
|
||||
USEMODULE += xtimer
|
||||
USEMODULE += timex
|
||||
endif
|
||||
|
||||
ifneq (,$(filter libfixmath-unittests,$(USEMODULE)))
|
||||
USEPKG += libfixmath
|
||||
@ -429,7 +425,6 @@ endif
|
||||
|
||||
ifneq (,$(filter pthread,$(USEMODULE)))
|
||||
USEMODULE += xtimer
|
||||
USEMODULE += vtimer
|
||||
USEMODULE += timex
|
||||
endif
|
||||
|
||||
|
@ -402,7 +402,7 @@ int getpid(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef MODULE_VTIMER
|
||||
#ifdef MODULE_XTIMER
|
||||
int _gettimeofday(struct timeval *tp, void *restrict tzp)
|
||||
{
|
||||
(void) tzp;
|
||||
|
@ -23,7 +23,7 @@
|
||||
* Application developers are free to use this module.
|
||||
* Be aware of portability issues.
|
||||
*
|
||||
* You most likely want to use the vtimer interface instead.
|
||||
* You most likely want to use the xtimer interface instead.
|
||||
*
|
||||
* @ingroup x86-irq
|
||||
* @{
|
||||
|
2
dist/Makefile
vendored
2
dist/Makefile
vendored
@ -34,7 +34,7 @@ QUIET ?= 1
|
||||
|
||||
#USEMODULE += shell
|
||||
#USEMODULE += posix
|
||||
#USEMODULE += vtimer
|
||||
#USEMODULE += xtimer
|
||||
|
||||
#export INCLUDES += -Iapplication_include
|
||||
|
||||
|
@ -61,8 +61,8 @@ endif
|
||||
ifneq (,$(filter log_%,$(USEMODULE)))
|
||||
DIRS += log
|
||||
endif
|
||||
ifneq (,$(filter vtimer,$(USEMODULE)))
|
||||
DIRS += compat/vtimer
|
||||
ifneq (,$(filter xtimer,$(USEMODULE)))
|
||||
DIRS += xtimer
|
||||
endif
|
||||
ifneq (,$(filter cpp11-compat,$(USEMODULE)))
|
||||
DIRS += cpp11-compat
|
||||
|
@ -1 +0,0 @@
|
||||
include $(RIOTBASE)/Makefile.base
|
@ -1 +0,0 @@
|
||||
include $(RIOTBASE)/Makefile.base
|
@ -1,94 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup sys_compat
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Implementation of the vtimer interface over xtimers
|
||||
*
|
||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include "xtimer.h"
|
||||
#include "timex.h"
|
||||
#include "vtimer.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <string.h>
|
||||
|
||||
int vtimer_sleep(timex_t time)
|
||||
{
|
||||
xtimer_usleep64(timex_uint64(time));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vtimer_msg_receive_timeout(msg_t *m, timex_t timeout)
|
||||
{
|
||||
uint64_t _timeout = timex_uint64(timeout);
|
||||
return xtimer_msg_receive_timeout64(m, _timeout);
|
||||
}
|
||||
|
||||
void vtimer_now(timex_t *out)
|
||||
{
|
||||
*out = timex_from_uint64(xtimer_now64());
|
||||
}
|
||||
|
||||
void vtimer_get_localtime(struct tm *localt)
|
||||
{
|
||||
timex_t now;
|
||||
vtimer_now(&now);
|
||||
|
||||
memset(localt, 0, sizeof(struct tm));
|
||||
localt->tm_sec = now.seconds % 60;
|
||||
localt->tm_min = (now.seconds / 60) % 60;
|
||||
localt->tm_hour = (now.seconds / 60 / 60) % 24;
|
||||
}
|
||||
|
||||
void vtimer_set_msg(vtimer_t *t, timex_t interval, kernel_pid_t pid, uint16_t type, void *ptr)
|
||||
{
|
||||
t->msg.type = type;
|
||||
t->msg.content.ptr = ptr;
|
||||
|
||||
xtimer_set_msg64(&t->timer, timex_uint64(interval), &t->msg, pid);
|
||||
}
|
||||
|
||||
int vtimer_set_wakeup(vtimer_t *t, timex_t interval, kernel_pid_t pid)
|
||||
{
|
||||
xtimer_set_wakeup64(&t->timer, timex_uint64(interval), pid);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vtimer_remove(vtimer_t *t)
|
||||
{
|
||||
xtimer_remove(&t->timer);
|
||||
}
|
||||
|
||||
/*
|
||||
* This is a workaround for missing support in clang on OSX,
|
||||
* the alias is not needed in native.
|
||||
* Compare https://github.com/RIOT-OS/RIOT/issues/2336
|
||||
*/
|
||||
#ifndef BOARD_NATIVE
|
||||
void _gettimeofday(void) __attribute__ ((weak, alias("vtimer_gettimeofday")));
|
||||
#endif
|
||||
|
||||
void vtimer_gettimeofday(struct timeval *tp)
|
||||
{
|
||||
timex_t now;
|
||||
vtimer_now(&now);
|
||||
|
||||
tp->tv_sec = now.seconds;
|
||||
tp->tv_usec = now.microseconds;
|
||||
}
|
@ -12,7 +12,7 @@
|
||||
*
|
||||
* @file
|
||||
* @brief C++11 chrono drop in replacement that adds the function now based on
|
||||
* vtimer/timex
|
||||
* xtimer/timex
|
||||
* @see <a href="http://en.cppreference.com/w/cpp/thread/thread">
|
||||
* std::thread, defined in header <thread>
|
||||
* </a>
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include "mutex.h"
|
||||
#include "net/ipv6.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "vtimer.h"
|
||||
#include "xtimer.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -76,7 +76,7 @@
|
||||
#include "net/gnrc/rpl/dodag.h"
|
||||
#include "net/gnrc/rpl/of_manager.h"
|
||||
#include "net/fib.h"
|
||||
#include "vtimer.h"
|
||||
#include "xtimer.h"
|
||||
#include "trickle.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1,138 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2009, 2014, 2015 Kaspar Schleiser <kaspar@schleiser.de>
|
||||
* Copyright (C) 2013, 2014 Freie Universität Berlin
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup sys_vtimer Virtual Timer
|
||||
* @ingroup sys
|
||||
* @brief Provides a high level abstraction timer module to register
|
||||
* timers, get current system time, and let a thread sleep for a certain amount
|
||||
* of time. It does not give any timing guarantees.
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @{
|
||||
* @file
|
||||
* @brief vtimer interface definitions
|
||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||
*/
|
||||
|
||||
#ifndef VTIMER_H
|
||||
#define VTIMER_H
|
||||
|
||||
#include "msg.h"
|
||||
#include "timex.h"
|
||||
#include "xtimer.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief IPC message type for vtimer msg callback
|
||||
*/
|
||||
#define MSG_TIMER 12345
|
||||
|
||||
/**
|
||||
* @brief A vtimer object.
|
||||
*
|
||||
* This structure is used for declaring a vtimer. This should not be used by
|
||||
* programmers, use the vtimer_set_*-functions instead.
|
||||
*
|
||||
* \hideinitializer
|
||||
* @deprecated
|
||||
*/
|
||||
typedef struct vtimer {
|
||||
xtimer_t timer;
|
||||
msg_t msg;
|
||||
} vtimer_t;
|
||||
|
||||
/**
|
||||
* @brief Current system time
|
||||
* @return Time as timex_t since system boot
|
||||
* @deprecated
|
||||
*/
|
||||
void vtimer_now(timex_t *out);
|
||||
|
||||
/**
|
||||
* @brief will cause the calling thread to be suspended from excecution until the time specified by time has elapsed
|
||||
* @param[in] time timex_t with time to suspend execution
|
||||
* @return 0 on success, < 0 on error
|
||||
* @deprecated
|
||||
*/
|
||||
int vtimer_sleep(timex_t time);
|
||||
|
||||
/**
|
||||
* @brief receive a message but return in case of timeout time is passed by without a new message
|
||||
* @param[out] m pointer to a msg_t which will be filled in case of no timeout
|
||||
* @param[in] timeout timex_t containing the relative time to fire the timeout
|
||||
* @return < 0 on error, other value otherwise
|
||||
* @deprecated
|
||||
*/
|
||||
int vtimer_msg_receive_timeout(msg_t *m, timex_t timeout);
|
||||
|
||||
/**
|
||||
* @brief Returns the current time in broken down format
|
||||
* @param[out] localt Pointer to structure to receive time
|
||||
* @deprecated
|
||||
*/
|
||||
void vtimer_get_localtime(struct tm *localt);
|
||||
|
||||
/**
|
||||
* @brief set a vtimer with msg event handler of the specified type
|
||||
* @param[in] t pointer to preinitialised vtimer_t
|
||||
* @param[in] interval vtimer timex_t interval
|
||||
* @param[in] pid process id
|
||||
* @param[in] type value for the msg_t type
|
||||
* @param[in] ptr message value
|
||||
* @deprecated
|
||||
*/
|
||||
void vtimer_set_msg(vtimer_t *t, timex_t interval, kernel_pid_t pid, uint16_t type, void *ptr);
|
||||
|
||||
/**
|
||||
* @brief set a vtimer with wakeup event
|
||||
* @param[in] t pointer to preinitialised vtimer_t
|
||||
* @param[in] interval the interval after which the timer shall fire
|
||||
* @param[in] pid process id
|
||||
* @return 0 on success, < 0 on error
|
||||
*/
|
||||
int vtimer_set_wakeup(vtimer_t *t, timex_t interval, kernel_pid_t pid);
|
||||
|
||||
/**
|
||||
* @brief Get the current time in seconds and microseconds since system start
|
||||
* @param[in] tp Uptime will be stored in the timeval structure pointed to by tp
|
||||
*/
|
||||
void vtimer_gettimeofday(struct timeval *tp);
|
||||
|
||||
/**
|
||||
* @brief remove a vtimer
|
||||
* @param[in] t pointer to preinitialised vtimer_t
|
||||
* @deprecated
|
||||
*/
|
||||
void vtimer_remove(vtimer_t *t);
|
||||
|
||||
/**
|
||||
* @brief will cause the calling thread to be suspended from excecution until the number of microseconds has elapsed
|
||||
* @param[in] us number of microseconds
|
||||
* @return 0 on success, < 0 on error
|
||||
*/
|
||||
static inline int vtimer_usleep(uint32_t us)
|
||||
{
|
||||
xtimer_usleep(us);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif /* VTIMER_H */
|
@ -264,7 +264,7 @@ gnrc_ipv6_nc_t *gnrc_ipv6_nc_still_reachable(const ipv6_addr_t *ipv6_addr)
|
||||
|
||||
if ((gnrc_ipv6_nc_get_state(entry) != GNRC_IPV6_NC_STATE_INCOMPLETE) &&
|
||||
(gnrc_ipv6_nc_get_state(entry) != GNRC_IPV6_NC_STATE_UNMANAGED)) {
|
||||
#if defined(MODULE_GNRC_IPV6_NETIF) && defined(MODULE_VTIMER) && defined(MODULE_GNRC_IPV6)
|
||||
#if defined(MODULE_GNRC_IPV6_NETIF) && defined(MODULE_XTIMER) && defined(MODULE_GNRC_IPV6)
|
||||
gnrc_ipv6_netif_t *iface = gnrc_ipv6_netif_get(entry->iface);
|
||||
|
||||
gnrc_ndp_internal_reset_nbr_sol_timer(entry, iface->reach_time,
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include "pthread_cond.h"
|
||||
#include "thread.h"
|
||||
#include "vtimer.h"
|
||||
#include "xtimer.h"
|
||||
#include "sched.h"
|
||||
#include "irq.h"
|
||||
#include "debug.h"
|
||||
@ -122,15 +122,15 @@ int pthread_cond_timedwait(struct pthread_cond_t *cond, struct mutex_t *mutex, c
|
||||
{
|
||||
timex_t now, then, reltime;
|
||||
|
||||
vtimer_now(&now);
|
||||
xtimer_now_timex(&now);
|
||||
then.seconds = abstime->tv_sec;
|
||||
then.microseconds = abstime->tv_nsec / 1000u;
|
||||
reltime = timex_sub(then, now);
|
||||
|
||||
vtimer_t timer;
|
||||
vtimer_set_wakeup(&timer, reltime, sched_active_pid);
|
||||
xtimer_t timer;
|
||||
xtimer_set_wakeup64(&timer, timex_uint64(reltime) , sched_active_pid);
|
||||
int result = pthread_cond_wait(cond, mutex);
|
||||
vtimer_remove(&timer);
|
||||
xtimer_remove(&timer);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
#include "pthread.h"
|
||||
#include "sched.h"
|
||||
#include "vtimer.h"
|
||||
#include "xtimer.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
@ -191,7 +191,7 @@ static int pthread_rwlock_timedlock(pthread_rwlock_t *rwlock,
|
||||
then.microseconds = abstime->tv_nsec / 1000u;
|
||||
timex_normalize(&then);
|
||||
|
||||
vtimer_now(&now);
|
||||
xtimer_now_timex(&now);
|
||||
|
||||
if (timex_cmp(then, now) <= 0) {
|
||||
return ETIMEDOUT;
|
||||
@ -199,11 +199,11 @@ static int pthread_rwlock_timedlock(pthread_rwlock_t *rwlock,
|
||||
else {
|
||||
timex_t reltime = timex_sub(then, now);
|
||||
|
||||
vtimer_t timer;
|
||||
vtimer_set_wakeup(&timer, reltime, sched_active_pid);
|
||||
xtimer_t timer;
|
||||
xtimer_set_wakeup64(&timer, timex_uint64(reltime) , sched_active_pid);
|
||||
int result = pthread_rwlock_lock(rwlock, is_blocked, is_writer, incr_when_held, true);
|
||||
if (result != ETIMEDOUT) {
|
||||
vtimer_remove(&timer);
|
||||
xtimer_remove(&timer);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -8,7 +8,7 @@ BOARD_INSUFFICIENT_MEMORY := stm32f0discovery
|
||||
|
||||
USEMODULE += posix
|
||||
USEMODULE += pthread
|
||||
USEMODULE += vtimer
|
||||
USEMODULE += xtimer
|
||||
|
||||
CFLAGS += -DNATIVE_AUTO_EXIT
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user