2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

more renaming

This commit is contained in:
Bob Halley
1998-10-22 01:33:20 +00:00
parent de9282a1ea
commit bf6d2e3912
14 changed files with 333 additions and 256 deletions

View File

@@ -10,19 +10,19 @@
* to represent intervals.
*/
typedef struct os_time_t {
typedef struct isc_time {
time_t seconds;
long nanoseconds;
} os_time_t;
} *isc_time_t;
isc_result
os_time_get(os_time_t *timep);
isc_result_t
isc_time_get(isc_time_t t);
/*
* Set *timep to the current absolute time (secs + nsec since January 1, 1970).
* Set 't' to the current absolute time (secs + nsec since January 1, 1970).
*
* Requires:
*
* 'timep' is a valid pointer.
* 't' is a valid pointer.
*
* Returns:
*
@@ -31,41 +31,41 @@ os_time_get(os_time_t *timep);
*/
int
os_time_compare(os_time_t *t1p, os_time_t *t2p);
isc_time_compare(isc_time_t t1, isc_time_t t2);
/*
* Compare the times referenced by 't1p' and 't2p'
* Compare the times referenced by 't1' and 't2'
*
* Requires:
*
* 't1p' and 't2p' are a valid.
* 't1' and 't2' are a valid.
*
* Returns:
*
* -1 *tp1 < *t2p
* 0 *tp1 = *t2p
* 1 *tp1 > *t2p
* -1 t1 < t2 (comparing times, not pointers)
* 0 t1 = t2
* 1 t1 > t2
*/
void
os_time_add(os_time_t *t1p, os_time_t *t2p, os_time_t *t3p);
isc_time_add(isc_time_t t1, isc_time_t t2, isc_time_t t3);
/*
* Add 't1p' to 't2p', storing the result in 't3p'.
* Add 't1' to 't2', storing the result in 't3'.
*
* Requires:
*
* 't1p', 't2p', and 't3p' are valid.
* 't1', 't2', and 't3' are valid.
*/
void
os_time_subtract(os_time_t *t1p, os_time_t *t2p, os_time_t *t3p);
isc_time_subtract(isc_time_t t1, isc_time_t t2, isc_time_t t3);
/*
* Subtract 't2p' from 't1p', storing the result in 't3p'.
* Subtract 't2' from 't1', storing the result in 't3'.
*
* Requires:
*
* 't1p', 't2p', and 't3p' are valid.
* 't1', 't2', and 't3' are valid.
*
* *tp1 >= *t2p
* t1 >= t2 (comparing times, not pointers)
*/
#endif /* ISC_TIME_H */

View File

@@ -5,13 +5,12 @@
#include <time.h>
#include <errno.h>
#include <isc/assertions.h>
#include <isc/assertions.h>
#include <isc/unexpect.h>
#include <isc/time.h>
isc_result
os_time_get(os_time_t *timep) {
isc_time_get(isc_time_t timep) {
struct timeval tv;
/*
@@ -33,56 +32,56 @@ os_time_get(os_time_t *timep) {
}
int
os_time_compare(os_time_t *t1p, os_time_t *t2p) {
isc_time_compare(isc_time_t t1, isc_time_t t2) {
/*
* Compare the times referenced by 't1p' and 't2p'
* Compare the times referenced by 't1' and 't2'
*/
REQUIRE(t1p != NULL && t2p != NULL);
REQUIRE(t1 != NULL && t2 != NULL);
if (t1p->seconds < t2p->seconds)
if (t1->seconds < t2->seconds)
return (-1);
if (t1p->seconds > t2p->seconds)
if (t1->seconds > t2->seconds)
return (1);
if (t1p->nanoseconds < t2p->nanoseconds)
if (t1->nanoseconds < t2->nanoseconds)
return (-1);
if (t1p->nanoseconds > t2p->nanoseconds)
if (t1->nanoseconds > t2->nanoseconds)
return (1);
return (0);
}
void
os_time_add(os_time_t *t1p, os_time_t *t2p, os_time_t *t3p)
isc_time_add(isc_time_t t1, isc_time_t t2, isc_time_t t3)
{
/*
* Add 't1p' to 't2p', storing the result in 't3p'.
* Add 't1' to 't2', storing the result in 't3'.
*/
REQUIRE(t1p != NULL && t2p != NULL && t3p != NULL);
REQUIRE(t1 != NULL && t2 != NULL && t3 != NULL);
t3p->seconds = t1p->seconds + t2p->seconds;
t3p->nanoseconds = t1p->nanoseconds + t2p->nanoseconds;
if (t3p->nanoseconds > 1000000000) {
t3p->seconds++;
t3p->nanoseconds -= 1000000000;
t3->seconds = t1->seconds + t2->seconds;
t3->nanoseconds = t1->nanoseconds + t2->nanoseconds;
if (t3->nanoseconds > 1000000000) {
t3->seconds++;
t3->nanoseconds -= 1000000000;
}
}
void
os_time_subtract(os_time_t *t1p, os_time_t *t2p, os_time_t *t3p) {
isc_time_subtract(isc_time_t t1, isc_time_t t2, isc_time_t t3) {
/*
* Subtract 't2p' from 't1p', storing the result in 't1p'.
* Subtract 't2' from 't1', storing the result in 't1'.
*/
REQUIRE(t1p != NULL && t2p != NULL && t3p != NULL);
REQUIRE(os_time_compare(t1p, t2p) >= 0);
REQUIRE(t1 != NULL && t2 != NULL && t3 != NULL);
REQUIRE(isc_time_compare(t1, t2) >= 0);
t3p->seconds = t1p->seconds - t2p->seconds;
if (t1p->nanoseconds >= t2p->nanoseconds)
t3p->nanoseconds = t1p->nanoseconds - t2p->nanoseconds;
t3->seconds = t1->seconds - t2->seconds;
if (t1->nanoseconds >= t2->nanoseconds)
t3->nanoseconds = t1->nanoseconds - t2->nanoseconds;
else {
t3p->nanoseconds = 1000000000 - t2p->nanoseconds +
t1p->nanoseconds;
t3p->seconds--;
t3->nanoseconds = 1000000000 - t2->nanoseconds +
t1->nanoseconds;
t3->seconds--;
}
}