diff options
author | roberto <roberto@FreeBSD.org> | 2001-08-29 14:35:15 +0000 |
---|---|---|
committer | roberto <roberto@FreeBSD.org> | 2001-08-29 14:35:15 +0000 |
commit | 40b8e415eb0f835a9dd7a473ddf134ec67877fd7 (patch) | |
tree | 3cfb63f1a112ee17469b17fc1593a88d004ddda6 /contrib/ntp/libntp/buftvtots.c | |
parent | a5a8dc6136fcee95f261a31609a25669038c3861 (diff) | |
download | FreeBSD-src-40b8e415eb0f835a9dd7a473ddf134ec67877fd7.zip FreeBSD-src-40b8e415eb0f835a9dd7a473ddf134ec67877fd7.tar.gz |
Virgin import of ntpd 4.1.0
Diffstat (limited to 'contrib/ntp/libntp/buftvtots.c')
-rw-r--r-- | contrib/ntp/libntp/buftvtots.c | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/contrib/ntp/libntp/buftvtots.c b/contrib/ntp/libntp/buftvtots.c index 96338bc..1944233 100644 --- a/contrib/ntp/libntp/buftvtots.c +++ b/contrib/ntp/libntp/buftvtots.c @@ -19,6 +19,7 @@ buftvtots( register const u_char *bp; register u_long sec; register u_long usec; + struct timeval tv; #ifdef WORDS_BIGENDIAN bp = (const u_char *)bufp; @@ -31,13 +32,33 @@ buftvtots( sec <<= 8; sec += (u_long)*bp++ & 0xff; + if (sizeof(tv.tv_sec) == 8) { + sec += (u_long)*bp++ & 0xff; + sec <<= 8; + sec += (u_long)*bp++ & 0xff; + sec <<= 8; + sec += (u_long)*bp++ & 0xff; + sec <<= 8; + sec += (u_long)*bp++ & 0xff; + } + usec = (u_long)*bp++ & 0xff; usec <<= 8; usec += (u_long)*bp++ & 0xff; usec <<= 8; usec += (u_long)*bp++ & 0xff; usec <<= 8; - usec += (u_long)*bp & 0xff; + usec += (u_long)*bp++ & 0xff; + + if (sizeof(tv.tv_usec) == 8) { + usec += (u_long)*bp++ & 0xff; + usec <<= 8; + usec += (u_long)*bp++ & 0xff; + usec <<= 8; + usec += (u_long)*bp++ & 0xff; + usec <<= 8; + usec += (u_long)*bp & 0xff; + } #else bp = (const u_char *)bufp + 7; @@ -49,13 +70,33 @@ buftvtots( usec <<= 8; usec += (u_long)*bp-- & 0xff; + if (sizeof(tv.tv_usec) == 8) { + usec += (u_long)*bp-- & 0xff; + usec <<= 8; + usec += (u_long)*bp-- & 0xff; + usec <<= 8; + usec += (u_long)*bp-- & 0xff; + usec <<= 8; + usec += (u_long)*bp-- & 0xff; + } + sec = (u_long)*bp-- & 0xff; sec <<= 8; sec += (u_long)*bp-- & 0xff; sec <<= 8; sec += (u_long)*bp-- & 0xff; sec <<= 8; - sec += (u_long)*bp & 0xff; + sec += (u_long)*bp-- & 0xff; + + if (sizeof (tv.tv_sec) == 8) { + sec += (u_long)*bp-- & 0xff; + sec <<= 8; + sec += (u_long)*bp-- & 0xff; + sec <<= 8; + sec += (u_long)*bp-- & 0xff; + sec <<= 8; + sec += (u_long)*bp & 0xff; + } #endif ts->l_ui = sec + (u_long)JAN_1970; if (usec > 999999) |