diff options
Diffstat (limited to 'src/lib/krb5/os/c_ustime.c')
-rw-r--r-- | src/lib/krb5/os/c_ustime.c | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/src/lib/krb5/os/c_ustime.c b/src/lib/krb5/os/c_ustime.c index fbb6d61281..1bfdac4af3 100644 --- a/src/lib/krb5/os/c_ustime.c +++ b/src/lib/krb5/os/c_ustime.c @@ -1,3 +1,4 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * lib/crypto/os/c_ustime.c * @@ -8,7 +9,7 @@ * require a specific license from the United States Government. * It is the responsibility of any person or organization contemplating * export to obtain such a license before exporting. - * + * * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and * distribute this software and its documentation for any purpose and * without fee is hereby granted, provided that the above copyright @@ -22,11 +23,11 @@ * M.I.T. makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. - * + * * * krb5_mstimeofday for BSD 4.3 */ - + #include "k5-int.h" #include "k5-thread.h" @@ -36,8 +37,8 @@ struct time_now { krb5_int32 sec, usec; }; #if defined(_WIN32) - /* Microsoft Windows NT and 95 (32bit) */ - /* This one works for WOW (Windows on Windows, ntvdm on Win-NT) */ +/* Microsoft Windows NT and 95 (32bit) */ +/* This one works for WOW (Windows on Windows, ntvdm on Win-NT) */ #include <time.h> #include <sys/timeb.h> @@ -64,7 +65,7 @@ get_time_now(struct time_now *n) struct timeval tv; if (gettimeofday(&tv, (struct timezone *)0) == -1) - return errno; + return errno; n->sec = tv.tv_sec; n->usec = tv.tv_usec; @@ -84,11 +85,11 @@ krb5_crypto_us_timeofday(krb5_int32 *seconds, krb5_int32 *microseconds) now.sec = now.usec = 0; err = get_time_now(&now); if (err) - return err; + return err; err = k5_mutex_lock(&krb5int_us_time_mutex); if (err) - return err; + return err; /* Just guessing: If the number of seconds hasn't changed, yet the microseconds are moving backwards, we probably just got a third instance of returning the same clock value from the system, so @@ -98,17 +99,17 @@ krb5_crypto_us_timeofday(krb5_int32 *seconds, krb5_int32 *microseconds) quite likely. On UNIX, it appears that we always get new microsecond values, so this case should never trigger. */ if ((now.sec == last_time.sec) && (now.usec <= last_time.usec)) { - /* Same as last time??? */ - now.usec = ++last_time.usec; - if (now.usec >= 1000000) { - ++now.sec; - now.usec = 0; - } - /* For now, we're not worrying about the case of enough - returns of the same value that we roll over now.sec, and - the next call still gets the previous now.sec value. */ + /* Same as last time??? */ + now.usec = ++last_time.usec; + if (now.usec >= 1000000) { + ++now.sec; + now.usec = 0; + } + /* For now, we're not worrying about the case of enough + returns of the same value that we roll over now.sec, and + the next call still gets the previous now.sec value. */ } - last_time.sec = now.sec; /* Remember for next time */ + last_time.sec = now.sec; /* Remember for next time */ last_time.usec = now.usec; k5_mutex_unlock(&krb5int_us_time_mutex); |