port_rt_get_counter_value defined in os/common/ports/SIMIA32/chcore.c uses gettimeofday() to create a counter value.
The result is returned as rtncnt_t. However, since the type of time_t is fixed to int64_t or equivalent types in most recent
libraries because of Y2038 problem, port_rt_get_counter_value will return an invalid counter value since the value might
overflow when returned as rtncnt_t.
I think the return value should be uint64_t, which means that either rtncnt_t should be uint64_t, or a different type should
be defined to be used.
rtncnt_t should be defined as uint64_t in order to prevent integer overflows Topic is solved
- Giovanni
- Site Admin
- Posts: 14455
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: rtncnt_t should be defined as uint64_t in order to prevent integer overflows
Hi,
The purpose of rtcnt_t is to perform execution time measurements, it is not a time-of-day service and it is meant to overflow.
The only thing affected by the counter size is the number of cycles that can be measured. It is 32 bits because the simulator is compiled in 32 bits mode sand 32 bits operation add less overhead to measurements.
Giovanni
The purpose of rtcnt_t is to perform execution time measurements, it is not a time-of-day service and it is meant to overflow.
The only thing affected by the counter size is the number of cycles that can be measured. It is 32 bits because the simulator is compiled in 32 bits mode sand 32 bits operation add less overhead to measurements.
Giovanni
Who is online
Users browsing this forum: No registered users and 10 guests