On Sep 3, 2014, at 2:07 AM, Savolainen, Petri (NSN - FI/Espoo) <[email protected]> wrote:
> > >> -----Original Message----- >> From: ext Anders Roxell [mailto:[email protected]] >> Sent: Tuesday, September 02, 2014 10:07 PM >> To: Petri Savolainen >> Cc: [email protected] >> Subject: Re: [lng-odp] [PATCH v2 1/2] Use timer resolution >> >> On 2014-09-02 15:47, Petri Savolainen wrote: >>> Use resolution and min/max tmo values from timer create call. >>> Use common nanosec time defines. >>> >>> Signed-off-by: Petri Savolainen <[email protected]> >>> --- >>> platform/linux-generic/include/api/odp_time.h | 5 ++ >>> platform/linux-generic/odp_timer.c | 67 >> ++++++++++++++++++++------- >>> 2 files changed, 55 insertions(+), 17 deletions(-) >>> >>> diff --git a/platform/linux-generic/include/api/odp_time.h >> b/platform/linux-generic/include/api/odp_time.h >>> index 188d1fe..1770223 100644 >>> --- a/platform/linux-generic/include/api/odp_time.h >>> +++ b/platform/linux-generic/include/api/odp_time.h >>> @@ -21,6 +21,11 @@ extern "C" { >>> >>> #include <odp_std_types.h> >>> >>> +/* Time in nanoseconds */ >>> +#define ODP_TIME_USEC 1000UL /*< Microsecond in nsec */ >>> +#define ODP_TIME_MSEC 1000000UL /*< Millisecond in nsec */ >>> +#define ODP_TIME_SEC 1000000000UL /*< Second in nsec */ >> >> you need to add "/**<" and not "/*<" > > OK. > >> >>> + >>> >>> /** >>> * Current time in CPU cycles >>> diff --git a/platform/linux-generic/odp_timer.c b/platform/linux- >> generic/odp_timer.c >>> index 1bf37f9..6e89f5c 100644 >>> --- a/platform/linux-generic/odp_timer.c >>> +++ b/platform/linux-generic/odp_timer.c >>> @@ -6,6 +6,7 @@ >>> >>> #include <odp_timer.h> >>> #include <odp_timer_internal.h> >>> +#include <odp_time.h> >>> #include <odp_buffer_pool_internal.h> >>> #include <odp_internal.h> >>> #include <odp_atomic.h> >>> @@ -18,9 +19,14 @@ >>> >>> #include <string.h> >>> >>> +#define USEC ODP_TIME_USEC >>> +#define MSEC ODP_TIME_MSEC >>> +#define SEC ODP_TIME_SEC >> >> no, why duplicate it? > > What's the problem? The only problem I see with using the shorting names is possible name space collision with pre-existing code. As much as I like the shorter names the ODP_TIME_XXX prefix is safer and the one I would have picked. If we already have ODP_TIME_XXX defines then using them instead of creating new defines just to save a few keystrokes is not worth it IMO. As for readability they both are readable and when I see ODP_TIME_XXX I know for a fact it is an ODP define. > > For example this is shorter and more readable... > sec = res / SEC; > nsec = res - sec*SEC; > > than this. > sec = res / ODP_TIME_SEC; > nsec = res - sec*ODP_TIME_SEC; > > > SEC is too generic definition for ODP API, so ODP_TIME_SEC was used (for > nanoseconds, time bases could be added also but nanoseconds is the current > default). > > -Petri > > > _______________________________________________ > lng-odp mailing list > [email protected] > http://lists.linaro.org/mailman/listinfo/lng-odp Keith Wiles, Principal Technologist with CTO office, Wind River mobile 972-213-5533 _______________________________________________ lng-odp mailing list [email protected] http://lists.linaro.org/mailman/listinfo/lng-odp
