[uClibc] about struct tm

Manuel Novoa III mjn3 at codepoet.org
Tue Aug 19 03:01:39 UTC 2003


On Mon, Aug 18, 2003 at 07:40:48PM -0700, Wen Yang wrote:
> In uClibc-0.9.20, the include/time.h struct tm has
>  
>   __const char tm_zone[8];    /* Timezone abbreviation.  */
> 
> 
> The default /usr/include/time.h on my machine has "__const char *
> tm_zone;"
>  
> What was the reason to change it to char[8];

glibc dynamicly allocates space for the timezone name.  But since the
amount of data is small, I decided to simply store it in the struct tm.

Unfortunately, the const qualifier caused problems with g++, so it
has changed again.  There is now an additional array field in struct tm
and the tm_zone ptr is initialized to it in the time code.

> Currently, in order for my program to compile with the uClibc toolchain,
> I manually modified the time.h as
>  
>   __const char * tm_zone;
>   char * tm_reserved;
>  
> Would it cause any problem at run-time on i386 and arm?

Yes, since the time code will then write data to whatever random memory
tm_zone happens to be pointing to.

For a better fix, you can either upgrade to the latest cvs version or
try to extract the appropriate change from the include/time.h and
libc/misc/time/time.c files.

Alternately, if you are experiencing the same g++ problem as someone
else reported, you could simply remove the const qualifier and use
char tm_zone[8] in struct tm.  That worked for them.

Manuel



More information about the uClibc mailing list