Skip to content

get_time: fix time_t parsing on musl libc

Danh Doan requested to merge sgn/giggle:time_t-detection into master

strptime(3) is specified by POSIX, but "%s" and "%z" is not POSIX specifier in strptime(3). Let's not blindly use it when it's available. Guarded it inside GLIBC instead, since it's a glibcism.

From musl 1.2.0, sizeof(time_t) is always 8 (64 bit) regardless of platform it run on.

On some 32-bit architect, let's say armv6 (maybe armv7 also), sizeof(long) and sizeof(int) is 4 (32 bit).

Let's not try to detect sizeof time_t and guess its underlying type in configure script, since it won't report correct signedness of underlying type, thus running into Undefined Behaviour.

Let's just use the biggest available integer from GLib and cast it to time_t instead.

Merge request reports