summaryrefslogtreecommitdiffstats
path: root/crypto/tmdiff.c
diff options
context:
space:
mode:
authorGeoff Thorpe <geoff@openssl.org>2003-10-29 04:40:13 +0000
committerGeoff Thorpe <geoff@openssl.org>2003-10-29 04:40:13 +0000
commit0991f0703478fd0fc704b6c59ffbb675b92899c1 (patch)
tree9f01246c6a7cd7283019165a35e09c4318dd6564 /crypto/tmdiff.c
parent2aaec9cced89edfdc8375b38a130fa1c35a98025 (diff)
For whatever reason (compiler or header bugs), at least one commonly-used
linux system (namely mine) chokes on our definitions and uses of the "HZ" symbol in crypto/tmdiff.[ch] and apps/speed.c as a "bad function cast" (when in fact there is no function casting involved at all). In both cases, it is easily worked around by not defining a cast into the macro and jiggling the expressions slightly. In addition - this highlights some cruft in openssl that needs sorting out. The tmdiff.h header is exported as part of the openssl API despite the fact that it is ugly as the driven sludge and not used anywhere in the library, applications, or utilities. More weird still, almost identical code exists in apps/speed.c though it looks to be slightly tweaked - so either tmdiff should be updated and used by speed.c, or it should be dumped because it's obviously not useful enough. Rather than removing it for now, I've changed the API for tmdiff to at least make sense. This involves taking the object type (MS_TM) from the implementation and using it in the header rather than using "char *" in the API and casting mercilessly in the code (ugh). If someone doesn't like "MS_TM" and the "ms_time_***" naming, by all means change it. This should be a harmless improvement, because the existing API is clearly not very useful (eg. we reimplement it rather than using it in our own utils). However, someone still needs to take a hack at consolidating speed.c and tmdiff.[ch] somehow.
Diffstat (limited to 'crypto/tmdiff.c')
-rw-r--r--crypto/tmdiff.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/crypto/tmdiff.c b/crypto/tmdiff.c
index 307523ebba..cbec38e178 100644
--- a/crypto/tmdiff.c
+++ b/crypto/tmdiff.c
@@ -106,7 +106,8 @@
#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 */
@@ -120,7 +121,7 @@
# 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;