From 139b008fc985c6175e433017952407bb1793c7d8 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 14 Mar 2018 07:59:35 -0600 Subject: [PATCH] apps/system and wireless: Applications should use the standard clock() interface, not the internal NuttX clock_systimer() interface. --- interpreters/bas/bas_global.c | 6 ++---- system/ping/ping.c | 17 +++++++++-------- system/ping6/ping6.c | 17 +++++++++-------- wireless/ieee802154/i8shark/i8shark_main.c | 5 +++-- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/interpreters/bas/bas_global.c b/interpreters/bas/bas_global.c index 934bd5f69..a6e6373bc 100644 --- a/interpreters/bas/bas_global.c +++ b/interpreters/bas/bas_global.c @@ -24,7 +24,7 @@ * * Adapted to NuttX and re-released under a 3-clause BSD license: * - * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2014, 2018 Gregory Nutt. All rights reserved. * Authors: Alan Carvalho de Assis * Gregory Nutt * @@ -1922,9 +1922,7 @@ static struct Value *fn_tan(struct Value *v, struct Auto *stack) static struct Value *fn_timei(struct Value *v, struct Auto *stack) { - return Value_new_INTEGER(v, - (unsigned long)(clock_systimer() / - (CLK_TCK / 100.0))); + return Value_new_INTEGER(v, (unsigned long)(clock() / (CLK_TCK / 100.0))); } static struct Value *fn_times(struct Value *v, struct Auto *stack) diff --git a/system/ping/ping.c b/system/ping/ping.c index 2356e6fd9..b99c5af45 100644 --- a/system/ping/ping.c +++ b/system/ping/ping.c @@ -1,7 +1,7 @@ /**************************************************************************** * apps/system/ping/ping.c * - * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2017-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -183,7 +184,7 @@ static void icmp_ping(FAR struct ping_info_s *info) struct pollfd recvfd; FAR uint8_t *ptr; int32_t elapsed; - systime_t start; + clock_t start; socklen_t addrlen; ssize_t nsent; ssize_t nrecvd; @@ -231,7 +232,7 @@ static void icmp_ping(FAR struct ping_info_s *info) } } - start = clock_systimer(); + start = clock(); outsize = sizeof(struct icmp_hdr_s) + ICMP_PING_DATALEN; nsent = sendto(info->sockfd, info->iobuffer, outsize, 0, (FAR struct sockaddr*)&destaddr, @@ -296,7 +297,7 @@ static void icmp_ping(FAR struct ping_info_s *info) return; } - elapsed = (unsigned int)TICK2MSEC(clock_systimer() - start); + elapsed = (unsigned int)TICK2MSEC(clock() - start); inhdr = (FAR struct icmp_hdr_s *)info->iobuffer; if (inhdr->type == ICMP_ECHO_REPLY) @@ -388,7 +389,7 @@ static void icmp_ping(FAR struct ping_info_s *info) /* Wait if necessary to preserved the requested ping rate */ - elapsed = (unsigned int)TICK2MSEC(clock_systimer() - start); + elapsed = (unsigned int)TICK2MSEC(clock() - start); if (elapsed < info->delay) { struct timespec rqt; @@ -449,7 +450,7 @@ int ping_main(int argc, char **argv) { FAR struct ping_info_s *info; FAR char *endptr; - systime_t start; + clock_t start; int32_t elapsed; int exitcode; int option; @@ -537,12 +538,12 @@ int ping_main(int argc, char **argv) goto errout_with_info; } - start = clock_systimer(); + start = clock(); icmp_ping(info); /* Get the total elapsed time */ - elapsed = (int32_t)TICK2MSEC(clock_systimer() - start); + elapsed = (int32_t)TICK2MSEC(clock() - start); if (info->nrequests > 0) { diff --git a/system/ping6/ping6.c b/system/ping6/ping6.c index 941923978..ddf2a294b 100644 --- a/system/ping6/ping6.c +++ b/system/ping6/ping6.c @@ -1,7 +1,7 @@ /**************************************************************************** * apps/system/ping/ping.c * - * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2017-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -189,7 +190,7 @@ static void icmpv6_ping(FAR struct ping6_info_s *info) struct pollfd recvfd; FAR uint8_t *ptr; int32_t elapsed; - systime_t start; + clock_t start; socklen_t addrlen; ssize_t nsent; ssize_t nrecvd; @@ -235,7 +236,7 @@ static void icmpv6_ping(FAR struct ping6_info_s *info) } } - start = clock_systimer(); + start = clock(); outsize = SIZEOF_ICMPV6_ECHO_REPLY_S(0) + ICMPv6_PING6_DATALEN; nsent = sendto(info->sockfd, info->iobuffer, outsize, 0, (FAR struct sockaddr*)&destaddr, @@ -299,7 +300,7 @@ static void icmpv6_ping(FAR struct ping6_info_s *info) return; } - elapsed = (unsigned int)TICK2MSEC(clock_systimer() - start); + elapsed = (unsigned int)TICK2MSEC(clock() - start); inhdr = (FAR struct icmpv6_echo_reply_s *)info->iobuffer; if (inhdr->type == ICMPv6_ECHO_REPLY) @@ -389,7 +390,7 @@ static void icmpv6_ping(FAR struct ping6_info_s *info) /* Wait if necessary to preserved the requested ping rate */ - elapsed = (unsigned int)TICK2MSEC(clock_systimer() - start); + elapsed = (unsigned int)TICK2MSEC(clock() - start); if (elapsed < info->delay) { struct timespec rqt; @@ -450,7 +451,7 @@ int ping6_main(int argc, char **argv) { FAR struct ping6_info_s *info; FAR char *endptr; - systime_t start; + clock_t start; int32_t elapsed; int exitcode; int option; @@ -538,12 +539,12 @@ int ping6_main(int argc, char **argv) goto errout_with_info; } - start = clock_systimer(); + start = clock(); icmpv6_ping(info); /* Get the total elapsed time */ - elapsed = (int32_t)TICK2MSEC(clock_systimer() - start); + elapsed = (int32_t)TICK2MSEC(clock() - start); if (info->nrequests > 0) { diff --git a/wireless/ieee802154/i8shark/i8shark_main.c b/wireless/ieee802154/i8shark/i8shark_main.c index 9b2f2e683..9c868b439 100644 --- a/wireless/ieee802154/i8shark/i8shark_main.c +++ b/wireless/ieee802154/i8shark/i8shark_main.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -321,7 +322,7 @@ static int i8shark_daemon(int argc, FAR char *argv[]) struct mac802154dev_rxframe_s frame; enum ieee802154_frametype_e ftype; uint8_t zepframe[I8SHARK_MAX_ZEPFRAME]; - systime_t systime; + clock_t systime; int ind = 0; int nbytes; @@ -390,7 +391,7 @@ static int i8shark_daemon(int argc, FAR char *argv[]) /* Need to use NTP to get time, but for now, include the system time */ - systime = clock_systimer(); + systime = clock(); memcpy(&zepframe[ind], &systime, 8); ind += 8;