Re: [PATCH] Add timegm POSIX call
Andreas Köpke <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <3413982.AioNPDlp2W@andreas> |
> On Aug 13 18:17, Andrew Russell via newlib wrote: > > >From e182faa79c35984b667029ef7b6e4a8ce7329897 Mon Sep 17 00:00:00 2001 > > > > From: Andrew Russell <[email protected]> > > Date: Fri, 10 Aug 2018 12:14:18 -0700 > > Subject: [PATCH 1/4] Start of mktime.c copy to timegm.c > > > > I am proposing to add the timegm POSIX call to > > Newlib. Part of this refactors some of the code in libc/time/local.h and > > libc/time/mktime.c, per this discussion: > > > > https://sourceware.org/ml/newlib/2018/msg00186.html > > I'm looking for comments from other (non-Cygwin) devs here. > > > Thanks, > Corinna I did not test it yet but we need this function. cygwin has it, but uses a completely different codebase (localtime.cc). It is always needed if your default timezone is not GMT and you need to exchange time information with e.g. sync mechanisms like NTP or GPS. You usually get broken down time information referenced to GMT and need to re- assemble using GMT as reference. Using setenv/getenv to temporarily change the timezone does not work: there is a memory leak in the implementation. Well, at least it looks like one. Parsing the TZ information takes time (at least on 12MHz MCUs) and stack space (~ 600 bytes) which is not always available. So having a working implementation would be great. Best regards, Andreas