• D
    Add internal APIs for dealing with time · 3ec12898
    Daniel P. Berrange 提交于
    The logging APIs need to be able to generate formatted timestamps
    using only async signal safe functions. This rules out using
    gmtime/localtime/malloc/gettimeday(!) and much more.
    
    Introduce a new internal API which is async signal safe.
    
      virTimeMillisNowRaw replacement for gettimeofday. Uses clock_gettime
                          where available, otherwise falls back to the unsafe
                          gettimeofday
    
      virTimeFieldsNowRaw  replacements for gmtime(), convert a timestamp
      virTimeFieldsThenRaw into a broken out set of fields. No localtime()
                           replacement is provided, because converting to
                           local time is not practical with only async signal
                           safe APIs.
    
      virTimeStringNowRaw  replacements for strftime() which print a timestamp
      virTimeStringThenRaw into a string, using a pre-determined format, with
                           a fixed size buffer (VIR_TIME_STRING_BUFLEN)
    
    For each of these there is also a version without the Raw postfix
    which raises a full libvirt error. These versions are not async
    signal safe
    
    * src/Makefile.am, src/util/virtime.c, src/util/virtime.h: New files
    * src/libvirt_private.syms: New APis
    * configure.ac: Check for clock_gettime in -lrt
    * tests/virtimetest.c, tests/Makefile.am: Test new APIs
    3ec12898
configure.ac 87.8 KB