For whatever reason (compiler or header bugs), at least one commonly-used
[openssl.git] / crypto / tmdiff.c
index 307523e..cbec38e 100644 (file)
 #ifndef HZ
 # if defined(_SC_CLK_TCK) \
      && (!defined(OPENSSL_SYS_VMS) || __CTRL_VER >= 70000000)
-#  define HZ ((double)sysconf(_SC_CLK_TCK))
+/* #  define HZ ((double)sysconf(_SC_CLK_TCK)) */
+#  define HZ sysconf(_SC_CLK_TCK)
 # else
 #  ifndef CLK_TCK
 #   ifndef _BSD_CLK_TCK_ /* FreeBSD hack */
 # endif
 #endif
 
-typedef struct ms_tm
+struct ms_tm
        {
 #ifdef TIMES
        struct tms ms_tms;
@@ -136,9 +137,9 @@ typedef struct ms_tm
 #    endif
 #  endif
 #endif
-       } MS_TM;
+       };
 
-char *ms_time_new(void)
+MS_TM *ms_time_new(void)
        {
        MS_TM *ret;
 
@@ -149,18 +150,17 @@ char *ms_time_new(void)
 #ifdef OPENSSL_SYS_WIN32
        ret->thread_id=GetCurrentThread();
 #endif
-       return((char *)ret);
+       return ret;
        }
 
-void ms_time_free(char *a)
+void ms_time_free(MS_TM *a)
        {
        if (a != NULL)
                OPENSSL_free(a);
        }
 
-void ms_time_get(char *a)
+void ms_time_get(MS_TM *tm)
        {
-       MS_TM *tm=(MS_TM *)a;
 #ifdef OPENSSL_SYS_WIN32
        FILETIME tmpa,tmpb,tmpc;
 #endif
@@ -180,14 +180,13 @@ void ms_time_get(char *a)
 #endif
        }
 
-double ms_time_diff(char *ap, char *bp)
+double ms_time_diff(MS_TM *a, MS_TM *b)
        {
-       MS_TM *a=(MS_TM *)ap;
-       MS_TM *b=(MS_TM *)bp;
        double ret;
 
 #ifdef TIMES
-       ret=(b->ms_tms.tms_utime-a->ms_tms.tms_utime)/HZ;
+       ret = HZ;
+       ret = (b->ms_tms.tms_utime-a->ms_tms.tms_utime) / ret;
 #else
 # ifdef OPENSSL_SYS_WIN32
        {
@@ -217,14 +216,14 @@ double ms_time_diff(char *ap, char *bp)
        return((ret < 0.0000001)?0.0000001:ret);
        }
 
-int ms_time_cmp(char *ap, char *bp)
+int ms_time_cmp(const MS_TM *a, const MS_TM *b)
        {
-       MS_TM *a=(MS_TM *)ap,*b=(MS_TM *)bp;
        double d;
        int ret;
 
 #ifdef TIMES
-       d=(b->ms_tms.tms_utime-a->ms_tms.tms_utime)/HZ;
+       d = HZ;
+       d = (b->ms_tms.tms_utime-a->ms_tms.tms_utime) / d;
 #else
 # ifdef OPENSSL_SYS_WIN32
        d =(b->ms_win32.dwHighDateTime&0x000fffff)*10+b->ms_win32.dwLowDateTime/1e7;