virhostuptime: Introduce virHostBootTimeInit()

The idea is to offer callers an init function that they can call
independently to ensure that the global variables get
initialized.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Michal Privoznik 2019-12-19 10:11:04 +01:00
parent 40a65ab4a9
commit 9d69bc19b9
3 changed files with 15 additions and 1 deletions

View File

@ -2199,6 +2199,7 @@ virHostMemSetParameters;
# util/virhostuptime.h
virHostBootTimeInit;
virHostGetBootTime;

View File

@ -126,7 +126,7 @@ virHostGetBootTimeOnceInit(void)
int
virHostGetBootTime(unsigned long long *when)
{
if (virOnce(&virHostGetBootTimeOnce, virHostGetBootTimeOnceInit) < 0)
if (virHostBootTimeInit() < 0)
return -1;
if (bootTimeErrno) {
@ -137,3 +137,13 @@ virHostGetBootTime(unsigned long long *when)
*when = bootTime;
return 0;
}
int
virHostBootTimeInit(void)
{
if (virOnce(&virHostGetBootTimeOnce, virHostGetBootTimeOnceInit) < 0)
return -1;
return 0;
}

View File

@ -25,3 +25,6 @@
int
virHostGetBootTime(unsigned long long *when)
G_GNUC_NO_INLINE;
int
virHostBootTimeInit(void);