[En-Nut-Discussion] Thread-safe version of asctime

Nathan Moore nategoose at gmail.com
Wed May 7 16:25:40 CEST 2014


Sorry about the previous e-mail.  It was sent before I was done with it.

Like I said, the formatting string accounts for the apparent length problem
of the days of the week and months of the year, which saves a byte for each
entry.
#define ASCTIME_FMT "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %4d\n"

I personally think that there should be a comment alerting other developers
that this is what is being done.

This same byte saving technique is used in the man page here
http://pubs.opengroup.org/onlinepubs/009604499/functions/asctime.html which
has code demonstrating what asctime does.

If I may offer a suggestion, I think that it would be a good idea to move
the asctime_r and asctime functions into different source files so that if
users wish to avoid using the asctime function and would like to save space
they would avoid the extra code and static buffer space.  This might be an
issue on AVR, and if all of the old static buffer functions were not linked
in when only the _r versions were used the space savings could add up to
something noticable.


Thanks,
Nathan


More information about the En-Nut-Discussion mailing list