mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
random_timespec_usec_resolution: new func.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5987 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
c85157c599
commit
393ff20342
@ -98,17 +98,38 @@ random_timespec_zero_nsec (gboolean zero_nsec_in)
|
||||
zero_nsec = zero_nsec_in;
|
||||
}
|
||||
|
||||
static gboolean usec_resolution = FALSE;
|
||||
|
||||
void
|
||||
random_timespec_usec_resolution (gboolean usec_resolution_in)
|
||||
{
|
||||
usec_resolution = usec_resolution_in;
|
||||
}
|
||||
|
||||
Timespec*
|
||||
get_random_timespec(void)
|
||||
{
|
||||
Timespec *ret;
|
||||
Timespec *ret;
|
||||
|
||||
ret = g_new(Timespec, 1);
|
||||
ret = g_new(Timespec, 1);
|
||||
|
||||
ret->tv_sec = rand();
|
||||
ret->tv_nsec = zero_nsec ? 0 : rand();
|
||||
ret->tv_sec = rand();
|
||||
|
||||
return ret;
|
||||
if (zero_nsec)
|
||||
ret->tv_nsec = 0;
|
||||
else
|
||||
{
|
||||
ret->tv_nsec = rand();
|
||||
|
||||
if (usec_resolution)
|
||||
{
|
||||
ret->tv_nsec = MIN (ret->tv_nsec, 999999999);
|
||||
ret->tv_nsec /= 1000;
|
||||
ret->tv_nsec *= 1000;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
gnc_numeric
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
Timespec* get_random_timespec(void);
|
||||
void random_timespec_zero_nsec (gboolean zero_nsec);
|
||||
void random_timespec_usec_resolution (gboolean usec_resolution);
|
||||
|
||||
kvp_value* get_random_kvp_value(int type);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user