--- a/libpurple/protocols/zephyr/ZWait4Not.c Sat Nov 21 22:54:04 2020 -0600
+++ b/libpurple/protocols/zephyr/ZWait4Not.c Sun Nov 22 01:44:50 2020 -0600
@@ -11,21 +11,6 @@
-#ifndef ZEPHYR_USES_KERBEROS
-static int gettimeofday(struct timeval* tv, struct timezone* tz){
- long long ns100; /*time since 1 Jan 1601 in 100ns units */
- GetSystemTimeAsFileTime( &(_now.ft) );
- tv->tv_usec=(long)((_now.ns100 / 10LL) % 1000000LL );
- tv->tv_sec= (long)((_now.ns100-(116444736000000000LL))/10000000LL);
@@ -35,7 +20,8 @@
@@ -50,8 +36,7 @@
- gettimeofday (&t0, (struct timezone *)NULL);
+ t0 = g_get_monotonic_time() + timeout * G_USEC_PER_SEC; i = select (fd + 1, &fdmask, (fd_set *) 0, (fd_set *) 0, &tv);
@@ -65,14 +50,9 @@
if (retval != ZERR_NONOTICE) /* includes ZERR_NONE */
- gettimeofday (&tv, (struct timezone *) NULL);
- tv.tv_usec = t0.tv_usec - tv.tv_usec;
- tv.tv_sec = t0.tv_sec - tv.tv_sec - 1;
- tv.tv_sec = t0.tv_sec - tv.tv_sec;
+ tdiff = t0 - g_get_monotonic_time(); + tv.tv_sec = tdiff / G_USEC_PER_SEC; + tv.tv_usec = tdiff - tv.tv_sec * G_USEC_PER_SEC; --- a/libpurple/protocols/zephyr/Zinternal.c Sat Nov 21 22:54:04 2020 -0600
+++ b/libpurple/protocols/zephyr/Zinternal.c Sun Nov 22 01:44:50 2020 -0600
@@ -12,21 +12,6 @@
-#ifndef ZEPHYR_USES_KERBEROS
- int gettimeofday(struct timeval* p, struct timezone* tz ){
- long long ns100; /*time since 1 Jan 1601 in 100ns units */
- GetSystemTimeAsFileTime( &(_now.ft) );
- p->tv_usec=(long)((_now.ns100 / 10LL) % 1000000LL );
- p->tv_sec= (long)((_now.ns100-(116444736000000000LL))/10000000LL);
@@ -192,23 +177,25 @@
static struct _Z_InputQ *Z_SearchQueue(ZUnique_Id_t *uid, ZNotice_Kind_t kind)
- register struct _Z_InputQ *qptr;
- struct _Z_InputQ *next;
+ register struct _Z_InputQ *qptr; + struct _Z_InputQ *next; - (void) gettimeofday(&tv, (struct timezone *)0);
+ now = g_get_monotonic_time();
- if (ZCompareUID(uid, &qptr->uid) && qptr->kind == kind)
- if (qptr->timep && ((time_t)qptr->timep+Z_NOTICETIMELIMIT < tv.tv_sec))
+ if (ZCompareUID(uid, &qptr->uid) && qptr->kind == kind) { + if (qptr->time && qptr->time + Z_NOTICETIMELIMIT < now) { @@ -474,16 +461,15 @@
int last, oldfirst, oldlast;
struct _Z_Hole *hole, *lasthole;
- /* Incorporate this notice's checked authentication. */
- if (notice->z_checked_auth == ZAUTH_FAILED)
- qptr->auth = ZAUTH_FAILED;
- else if (notice->z_checked_auth == ZAUTH_NO && qptr->auth != ZAUTH_FAILED)
+ /* Incorporate this notice's checked authentication. */ + if (notice->z_checked_auth == ZAUTH_FAILED) { + qptr->auth = ZAUTH_FAILED; + } else if (notice->z_checked_auth == ZAUTH_NO && qptr->auth != ZAUTH_FAILED) { - (void) gettimeofday(&tv, (struct timezone *)0);
- qptr->timep = tv.tv_sec;
+ qptr->time = g_get_monotonic_time(); last = part+notice->z_message_len-1;
@@ -572,7 +558,7 @@
- qptr->timep = 0; /* don't time out anymore */
+ qptr->time = 0; /* don't time out anymore */ qptr->packet_len = qptr->header_len+qptr->msg_len;
if (!(qptr->packet = (char *) malloc((unsigned) qptr->packet_len)))
@@ -590,6 +576,7 @@
static char version[BUFSIZ]; /* default init should be all \0 */
socklen_t namelen = sizeof(name);
@@ -610,9 +597,12 @@
notice->z_multinotice = "";
- (void) gettimeofday(¬ice->z_uid.tv, (struct timezone *)0);
- notice->z_uid.tv.tv_sec = htonl((unsigned long) notice->z_uid.tv.tv_sec);
- notice->z_uid.tv.tv_usec = htonl((unsigned long) notice->z_uid.tv.tv_usec);
+ realtime = g_get_real_time(); + notice->z_uid.tv.tv_sec = realtime / G_USEC_PER_SEC; + notice->z_uid.tv.tv_usec = + realtime - notice->z_uid.tv.tv_sec * G_USEC_PER_SEC; + notice->z_uid.tv.tv_sec = htonl((unsigned long)notice->z_uid.tv.tv_sec); + notice->z_uid.tv.tv_usec = htonl((unsigned long)notice->z_uid.tv.tv_usec); (void) memcpy(¬ice->z_uid.zuid_addr, &__My_addr, sizeof(__My_addr));
@@ -867,12 +857,14 @@
(void) sprintf(multi, "%d/%d", offset, notice->z_message_len);
partnotice.z_multinotice = multi;
- (void) gettimeofday(&partnotice.z_uid.tv,
- partnotice.z_uid.tv.tv_sec =
- htonl((unsigned long) partnotice.z_uid.tv.tv_sec);
- partnotice.z_uid.tv.tv_usec =
- htonl((unsigned long) partnotice.z_uid.tv.tv_usec);
+ gint64 realtime = g_get_real_time(); + partnotice.z_uid.tv.tv_sec = realtime / G_USEC_PER_SEC; + partnotice.z_uid.tv.tv_usec = + realtime - partnotice.z_uid.tv.tv_sec * G_USEC_PER_SEC; + partnotice.z_uid.tv.tv_sec = + htonl((unsigned long)partnotice.z_uid.tv.tv_sec); + partnotice.z_uid.tv.tv_usec = + htonl((unsigned long)partnotice.z_uid.tv.tv_usec); (void) memcpy((char *)&partnotice.z_uid.zuid_addr, &__My_addr,
--- a/libpurple/protocols/zephyr/internal.h Sat Nov 21 22:54:04 2020 -0600
+++ b/libpurple/protocols/zephyr/internal.h Sun Nov 22 01:44:50 2020 -0600
@@ -65,7 +65,7 @@
- unsigned ZEPHYR_INT32 timep;