]> git.ipfire.org Git - thirdparty/libvirt.git/commit
Add internal APIs for dealing with time
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 29 Nov 2011 12:11:01 +0000 (12:11 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 30 Nov 2011 11:43:49 +0000 (11:43 +0000)
commit3ec128989606278635a7c5dfbeee959692d12e15
tree608434707c2586983f80827b44931f432fb5b79e
parent380110cf082b397e573da7e044b74728f6ff7556
Add internal APIs for dealing with time

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
configure.ac
po/POTFILES.in
src/Makefile.am
src/libvirt_private.syms
src/util/virtime.c [new file with mode: 0644]
src/util/virtime.h [new file with mode: 0644]
tests/.gitignore
tests/Makefile.am
tests/virtimetest.c [new file with mode: 0644]