This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/CC2640R2F: How to use 64-bits time (time_t)

Part Number: CC2640R2F

Tool/software: TI-RTOS

Hi,all

I want to use 64-bits time in cc2640r2f with TI-RTOS .

The purpose is that I need to deal with the time after 2038-12-31 23:59:59.

I have simply added the "_DLIB_TIME_USES_64" and "_DLIB_TIME_ALLOW_64" definition to pre-processor in IDE (IAR for arm 8.22.2).

Then I built the project,it generated one error when doing post building action .

The xdc clock module is used.

I know the size of the seconds of "Seconds_set(UInt32 seconds);" is 32-bits.So I couldn't do any any changes to the xdc clock module.

So I use the clock module just as a timer-tick.,and add time offset (not from 1970) outside of seconds module.

Here is what I want to do:

Seconds_set(0);

t=time(NULL);

t+=(1514736000);// time start from 2018/1/1 0:0:0

ctime(&t);....

.....

If the time_t is 64-bits, it can work fine.

If the time_t is 32-bits, it will overflow after 2038.

  • Hi,

    time_t is 32-bits. Does that mean you cannot do what you need?

    I did not quite understand what you were doing in the code above.

    Judah
  • Hi,

    I want to deal with the time after 2038 (which will overflow in 32-bits time_t).

    I  have tried the code below to test.

    /***********************************************/

    time_t t;

    Seconds_set(2208960000); //0x83AA0E00,  2040-1-1 0:0:0:

    t=time(NULL);

    printf(ctime(&t)); //it is 1902-1-1 

    /***********************************************/

    So I want to use 64-bits time_t.

    I know the param passed to Seconds_set is uint32_t .So I will pass a time value (<0x7FFFFFFF) to Seconds_set as start time point, and add the time offset  to the value returned from  time(NULL).

    If the time_t is 64-bits,  I can represent the time value (>0x7FFFFFFF)  via standard C time functions correctly.

    Now the problem is that I cannot use 64-bits time_t.It generated an error when doing post building command as I mentioned before.

    So I want to know how to use 64-bits time_t. 

    Regards,

  • I want to deal with the time after 2038 (which will overflow in 32-bits time_t).
    See the reply below.
  • Kaifeng,

    This is not a TIRTOS question.  Its a question for the tools/compiler team.  Are you using TI tools or GCC?
    As far as I can tell the TI compiler represents time_t as 32-bits for this device and you cannot change time_t to 64bits.
    But I'm not an expert on compilers so I'll try to have this post move to compiler team and maybe someone there can better answer your question.

    Judah

  • I apologize for overlooking this thread until now.

    Kaifeng.He said:
    IDE (IAR for arm 8.22.2).

    Unfortunately, we do not support the IAR ARM compiler in this forum.  We only support compilers released by TI.  Please contact IAR with your question.

    Thanks and regards,

    -George