diff --git a/Makefile.dep b/Makefile.dep index 553b16894cd096884f779df20b992e23f4af7b70..1a1634768f379c16a714a045fdc956586963e6e8 100644 --- a/Makefile.dep +++ b/Makefile.dep @@ -49,7 +49,7 @@ ifneq (,$(filter gnrc_zep,$(USEMODULE))) USEMODULE += ieee802154 USEMODULE += gnrc_udp USEMODULE += random - USEMODULE += vtimer + USEMODULE += xtimer endif ifneq (,$(filter gnrc_tftp,$(USEMODULE))) @@ -328,10 +328,6 @@ ifneq (,$(filter sema,$(USEMODULE))) USEMODULE += xtimer endif -ifneq (,$(filter vtimer,$(USEMODULE))) - USEMODULE += xtimer - USEMODULE += timex -endif ifneq (,$(filter libfixmath-unittests,$(USEMODULE))) USEPKG += libfixmath @@ -403,7 +399,6 @@ endif ifneq (,$(filter pthread,$(USEMODULE))) USEMODULE += xtimer - USEMODULE += vtimer USEMODULE += timex endif diff --git a/cpu/native/syscalls.c b/cpu/native/syscalls.c index 20115a5590a89d52ab84d970fa78facfeeffad88..a7df2b4a342351bdff8f3216df9622f343d89cd5 100644 --- a/cpu/native/syscalls.c +++ b/cpu/native/syscalls.c @@ -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; diff --git a/cpu/x86/include/x86_pit.h b/cpu/x86/include/x86_pit.h index 44d441a7c7a9a7d4f47eadb583fcaa890fa9a4ed..3eab35d5c9336ab89297cdb8578f04adbcec6cdb 100644 --- a/cpu/x86/include/x86_pit.h +++ b/cpu/x86/include/x86_pit.h @@ -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 * @{ diff --git a/dist/Makefile b/dist/Makefile index c330667b81e58159f696abd559078bfb62cc25c4..3c35bff32d1d58db42a2bc707484908a3fd42b16 100644 --- a/dist/Makefile +++ b/dist/Makefile @@ -34,7 +34,7 @@ QUIET ?= 1 #USEMODULE += shell #USEMODULE += posix -#USEMODULE += vtimer +#USEMODULE += xtimer #export INCLUDES += -Iapplication_include diff --git a/sys/Makefile b/sys/Makefile index 01986396d39c2c57afd1ca742808961a090741b4..f5aada5d07d475cc7d93b2c6ff0ff057c0f39b1d 100644 --- a/sys/Makefile +++ b/sys/Makefile @@ -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 diff --git a/sys/compat/Makefile b/sys/compat/Makefile deleted file mode 100644 index 48422e909a47d7cd428d10fa73825060ccc8d8c2..0000000000000000000000000000000000000000 --- a/sys/compat/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(RIOTBASE)/Makefile.base diff --git a/sys/compat/vtimer/Makefile b/sys/compat/vtimer/Makefile deleted file mode 100644 index 48422e909a47d7cd428d10fa73825060ccc8d8c2..0000000000000000000000000000000000000000 --- a/sys/compat/vtimer/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(RIOTBASE)/Makefile.base diff --git a/sys/compat/vtimer/vtimer_compat.c b/sys/compat/vtimer/vtimer_compat.c deleted file mode 100644 index 0a35908a75f0211e726f3696d759b6e4a9e6c6f3..0000000000000000000000000000000000000000 --- a/sys/compat/vtimer/vtimer_compat.c +++ /dev/null @@ -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; -} diff --git a/sys/cpp11-compat/include/riot/chrono.hpp b/sys/cpp11-compat/include/riot/chrono.hpp index 6d1b97239c05c249152da43ef7383ba1c8e221cc..4f94738714d4c722c65d419d8fee33d7226aec67 100644 --- a/sys/cpp11-compat/include/riot/chrono.hpp +++ b/sys/cpp11-compat/include/riot/chrono.hpp @@ -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> diff --git a/sys/include/net/gnrc/ipv6/netif.h b/sys/include/net/gnrc/ipv6/netif.h index c7047fb1a7ff10b1af8e308ad179e5a17716a369..a1bcfa571b96fd34a44f9eabc4ef94afc48d12b1 100644 --- a/sys/include/net/gnrc/ipv6/netif.h +++ b/sys/include/net/gnrc/ipv6/netif.h @@ -30,7 +30,6 @@ #include "mutex.h" #include "net/ipv6.h" #include "net/ipv6/addr.h" -#include "vtimer.h" #include "xtimer.h" #ifdef __cplusplus diff --git a/sys/include/net/gnrc/rpl.h b/sys/include/net/gnrc/rpl.h index 7ca26b7e1e4faf1305d3f91d1bff85c10b3cdecd..ba668e713e55044945ea54435048c0d902135f76 100644 --- a/sys/include/net/gnrc/rpl.h +++ b/sys/include/net/gnrc/rpl.h @@ -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 diff --git a/sys/include/vtimer.h b/sys/include/vtimer.h deleted file mode 100644 index 3c5563677177c1bae91d2705fdf2e2ff41bc6bb0..0000000000000000000000000000000000000000 --- a/sys/include/vtimer.h +++ /dev/null @@ -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 */ diff --git a/sys/net/gnrc/network_layer/ipv6/nc/gnrc_ipv6_nc.c b/sys/net/gnrc/network_layer/ipv6/nc/gnrc_ipv6_nc.c index 7dfb7379584ad0797029bea87c946d020192b42f..a32b176764942c57d2bbeb6240c9d6309638a475 100644 --- a/sys/net/gnrc/network_layer/ipv6/nc/gnrc_ipv6_nc.c +++ b/sys/net/gnrc/network_layer/ipv6/nc/gnrc_ipv6_nc.c @@ -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, diff --git a/sys/posix/pthread/pthread_cond.c b/sys/posix/pthread/pthread_cond.c index b7a7ae5b13bb24971221210e88704afd259923b4..51fd0fbf9a5ff3caded40868f7ccdc8a68af5c5b 100644 --- a/sys/posix/pthread/pthread_cond.c +++ b/sys/posix/pthread/pthread_cond.c @@ -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; } diff --git a/sys/posix/pthread/pthread_rwlock.c b/sys/posix/pthread/pthread_rwlock.c index ee401b0c0f9f0a08ca5cba3f77f93667ce4df0ca..dde72eb6ef40e13ef80d447c4899542f419f3912 100644 --- a/sys/posix/pthread/pthread_rwlock.c +++ b/sys/posix/pthread/pthread_rwlock.c @@ -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; diff --git a/tests/pthread_condition_variable/Makefile b/tests/pthread_condition_variable/Makefile index c9066db1893200112f0961113bb8236d68c651ec..3f4e7923c5f6cccb8f545dd6e4cde7bde09d56a1 100644 --- a/tests/pthread_condition_variable/Makefile +++ b/tests/pthread_condition_variable/Makefile @@ -8,7 +8,7 @@ BOARD_INSUFFICIENT_MEMORY := stm32f0discovery USEMODULE += posix USEMODULE += pthread -USEMODULE += vtimer +USEMODULE += xtimer CFLAGS += -DNATIVE_AUTO_EXIT