mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-03-29 22:57:06 +00:00
timegm() is not provided everywhere and the documentation on how to replace it is bogus as it proposes an inefficient and non-thread safe alternative. Here we reimplement everything needed to compute the number of seconds since Epoch based on the broken down fields in struct tm. It is only guaranteed to return correct values for correct inputs. It was successfully tested with all possible 32-bit values of time_t converted to struct tm using gmtime() and back to time_t using the legacy timegm() and this function, and both functions always produced the same result. Thanks to Benoît Garnier for an instructive discussion and detailed explanations of the various time functions, leading to this solution. |
||
---|---|---|
.. | ||
common | ||
import | ||
proto | ||
types |