> Signed-off-by: Bill Fischofer <bill.fischo...@linaro.org>
> ---
>  .../linux-generic/include/odp/plat/time_types.h    |  5 +++-
>  platform/linux-generic/odp_time.c                  | 27 +++++++++++++----
> -----
>  2 files changed, 20 insertions(+), 12 deletions(-)
> 
> diff --git a/platform/linux-generic/include/odp/plat/time_types.h
> b/platform/linux-generic/include/odp/plat/time_types.h
> index e5765ec..05e2b59 100644
> --- a/platform/linux-generic/include/odp/plat/time_types.h
> +++ b/platform/linux-generic/include/odp/plat/time_types.h
> @@ -21,7 +21,10 @@ extern "C" {
>   *  @{
>   **/
> 
> -typedef struct timespec odp_time_t;
> +typedef struct {
> +     uint64_t tv_sec;
> +     int64_t  tv_nsec;
> +} odp_time_t;


This struct should match timespec exactly. If that’s not possible, union should 
not be used but copy data between timespec and odp_time_t.

POSIX: "The <time.h> header shall declare the structure timespec, which has at 
least the following members:"

time_t  tv_sec    Seconds. 
long    tv_nsec   Nanoseconds. 

int64_t is not long. I think we hit that previously this week. Long may be 32 
bits on a 32 bit system.

time_t is defined in C headers.

Also POSIX spec states that there can be more members than these. That hints 
that field order/offset and struct size may vary. At least the hack should be 
well documented and build/run time checked.

-Petri


> 
>  odp_time_t odp_time_null(void);
> 
> diff --git a/platform/linux-generic/odp_time.c b/platform/linux-
> generic/odp_time.c
> index 1c7c214..b5737f6 100644
> --- a/platform/linux-generic/odp_time.c
> +++ b/platform/linux-generic/odp_time.c
> @@ -11,7 +11,12 @@
>  #include <odp/hints.h>
>  #include <odp_debug_internal.h>
> 
> -static struct timespec start_time;
> +typedef union {
> +     odp_time_t      ex;
> +     struct timespec in;
> +} _odp_time_t;
> +
_______________________________________________
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to