bitwiseworks / libc

LIBC Next (kLIBC fork)
9 stars 3 forks source link

Add tm_gmtoff and tm_zone to struct tm #78

Open dmik opened 4 years ago

dmik commented 4 years ago

Currently, tm_gmtoff and tm_zone are commented out in time.h saying they are not implemented. From what I see, it should be as easy as remove the ifdef and set these fields to the corresponding values of the internal EMX _tzi variable (or to the values of standard POSIX timezone and tzname external variables) in the respective functions.

The main problem here is binary compatibility. Old code might crash the LIBC DLL which has it enabled by supplying an old, shorter version of struct tm to the respective functions. I don't see an easy solution here.

dmik commented 4 years ago

Encountered when porting chromium v8 code (https://github.com/bitwiseworks/qtwebengine-chromium-os2/issues/3).

ydario commented 4 years ago

LIBC exports are ordinal only right? so assume old structure is used by ordinal 888: in new libc you export my_old_libc_wrapper() as ordinal 888 using old structure; my_old_libc_wrapper copies data to new structure, calls the standard function, copies fields back and returns. Newer code will use new ordinals, this new code compiled will use new ordinals.

All this is failing if libc exports by name, but if I remember correctly this is not the case.

dmik commented 4 years ago

LIBC exports both by ordinal and by name IIRC. And the old structure is used by a dozen of exports, not just one (search for struct tm in public headers). However, even in case of exports by name there is a solution: change the library major number to change the DLL name (currently it's libcn0, can be changed to e.g. libcn1) and provide a forwarder under the old name with both old ordinals and names. However, this is not an easy solution :)

Too much work for now so definitely postponed.

PS. Ordinal 888 is __std_popen, struct tm is not used by that one...

dmik commented 4 years ago

BTW, #76 is definitely related here. Once this is done, that should be easily doable too.