Topic : C Standard Library Date and Time Functions

Forum : ARM

Original Post
Post Information Post
July 13, 2012 - 11:23am

I am using Ride7 with STM32F2/4 processors and I'd like to implement the necessary syscalls so I can make use of the C Standard Library's data and time functions. However, I'm having a little trouble figuring out what this entails.

The Newlib docs say that to use the time() function, I need to implement a gettimeofday() system call. Well, I did that it didn't event get called. I did however implement a _gettimeofday_r() systemcall, and it did get called. But regardless of what values I set for the timeval structure, time(0) always returns the same value: all 0s.

If knows what might be required to implement this feature, please let me know.

Post Information Post
July 16, 2012 - 10:29am

I solved this problem by implementing

int _gettimeofday_r(struct _reent* r, struct timeval* tv, void* tz);

instead of

int _gettimeofday_r(struct timeval* tv, void* tz);

The Newlib source code here ( was very helpful:

I'm still not sure, though, if this is the correct approach.