summaryrefslogtreecommitdiff
path: root/src/lib/libssl/src/crypto/tmdiff.c
diff options
context:
space:
mode:
authorbeck <>2002-05-15 02:29:21 +0000
committerbeck <>2002-05-15 02:29:21 +0000
commitb64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9 (patch)
treefa27cf82a1250b64ed3bf5f4a18c7354d470bbcc /src/lib/libssl/src/crypto/tmdiff.c
parente471e1ea98d673597b182ea85f29e30c97cd08b5 (diff)
downloadopenbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.gz
openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.bz2
openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.zip
OpenSSL 0.9.7 stable 2002 05 08 merge
Diffstat (limited to 'src/lib/libssl/src/crypto/tmdiff.c')
-rw-r--r--src/lib/libssl/src/crypto/tmdiff.c44
1 files changed, 28 insertions, 16 deletions
diff --git a/src/lib/libssl/src/crypto/tmdiff.c b/src/lib/libssl/src/crypto/tmdiff.c
index 7773928666..7ebf2b202a 100644
--- a/src/lib/libssl/src/crypto/tmdiff.c
+++ b/src/lib/libssl/src/crypto/tmdiff.c
@@ -61,16 +61,12 @@
61#include <openssl/tmdiff.h> 61#include <openssl/tmdiff.h>
62 62
63#ifdef TIMEB 63#ifdef TIMEB
64#undef WIN32 64#undef OPENSSL_SYS_WIN32
65#undef TIMES 65#undef TIMES
66#endif 66#endif
67 67
68#ifndef MSDOS 68#if !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_SYS_VMS) || defined(__DECC) && !defined(OPENSSL_SYS_MACOSX) && !defined(OPENSSL_SYS_VXWORKS)
69# ifndef WIN32 69# define TIMES
70# if !defined(VMS) || defined(__DECC)
71# define TIMES
72# endif
73# endif
74#endif 70#endif
75 71
76#ifndef _IRIX 72#ifndef _IRIX
@@ -85,7 +81,7 @@
85 The __TMS macro will show if it was. If it wasn't defined, we should 81 The __TMS macro will show if it was. If it wasn't defined, we should
86 undefine TIMES, since that tells the rest of the program how things 82 undefine TIMES, since that tells the rest of the program how things
87 should be handled. -- Richard Levitte */ 83 should be handled. -- Richard Levitte */
88#if defined(VMS) && defined(__DECC) && !defined(__TMS) 84#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
89#undef TIMES 85#undef TIMES
90#endif 86#endif
91 87
@@ -95,11 +91,11 @@
95#include <sys/param.h> 91#include <sys/param.h>
96#endif 92#endif
97 93
98#ifndef TIMES 94#if !defined(TIMES) && !defined(OPENSSL_SYS_VXWORKS)
99#include <sys/timeb.h> 95#include <sys/timeb.h>
100#endif 96#endif
101 97
102#ifdef WIN32 98#ifdef OPENSSL_SYS_WIN32
103#include <windows.h> 99#include <windows.h>
104#endif 100#endif
105 101
@@ -121,11 +117,15 @@ typedef struct ms_tm
121#ifdef TIMES 117#ifdef TIMES
122 struct tms ms_tms; 118 struct tms ms_tms;
123#else 119#else
124# ifdef WIN32 120# ifdef OPENSSL_SYS_WIN32
125 HANDLE thread_id; 121 HANDLE thread_id;
126 FILETIME ms_win32; 122 FILETIME ms_win32;
127# else 123# else
124# ifdef OPENSSL_SYS_VSWORKS
125 unsigned long ticks;
126# else
128 struct timeb ms_timeb; 127 struct timeb ms_timeb;
128# endif
129# endif 129# endif
130#endif 130#endif
131 } MS_TM; 131 } MS_TM;
@@ -138,7 +138,7 @@ char *ms_time_new(void)
138 if (ret == NULL) 138 if (ret == NULL)
139 return(NULL); 139 return(NULL);
140 memset(ret,0,sizeof(MS_TM)); 140 memset(ret,0,sizeof(MS_TM));
141#ifdef WIN32 141#ifdef OPENSSL_SYS_WIN32
142 ret->thread_id=GetCurrentThread(); 142 ret->thread_id=GetCurrentThread();
143#endif 143#endif
144 return((char *)ret); 144 return((char *)ret);
@@ -153,17 +153,21 @@ void ms_time_free(char *a)
153void ms_time_get(char *a) 153void ms_time_get(char *a)
154 { 154 {
155 MS_TM *tm=(MS_TM *)a; 155 MS_TM *tm=(MS_TM *)a;
156#ifdef WIN32 156#ifdef OPENSSL_SYS_WIN32
157 FILETIME tmpa,tmpb,tmpc; 157 FILETIME tmpa,tmpb,tmpc;
158#endif 158#endif
159 159
160#ifdef TIMES 160#ifdef TIMES
161 times(&tm->ms_tms); 161 times(&tm->ms_tms);
162#else 162#else
163# ifdef WIN32 163# ifdef OPENSSL_SYS_WIN32
164 GetThreadTimes(tm->thread_id,&tmpa,&tmpb,&tmpc,&(tm->ms_win32)); 164 GetThreadTimes(tm->thread_id,&tmpa,&tmpb,&tmpc,&(tm->ms_win32));
165# else 165# else
166# ifdef OPENSSL_SYS_VSWORKS
167 tm->ticks = tickGet();
168# else
166 ftime(&tm->ms_timeb); 169 ftime(&tm->ms_timeb);
170# endif
167# endif 171# endif
168#endif 172#endif
169 } 173 }
@@ -177,7 +181,7 @@ double ms_time_diff(char *ap, char *bp)
177#ifdef TIMES 181#ifdef TIMES
178 ret=(b->ms_tms.tms_utime-a->ms_tms.tms_utime)/HZ; 182 ret=(b->ms_tms.tms_utime-a->ms_tms.tms_utime)/HZ;
179#else 183#else
180# ifdef WIN32 184# ifdef OPENSSL_SYS_WIN32
181 { 185 {
182#ifdef __GNUC__ 186#ifdef __GNUC__
183 signed long long la,lb; 187 signed long long la,lb;
@@ -193,10 +197,14 @@ double ms_time_diff(char *ap, char *bp)
193 ret=((double)(lb-la))/1e7; 197 ret=((double)(lb-la))/1e7;
194 } 198 }
195# else 199# else
200# ifdef OPENSSL_SYS_VSWORKS
201 ret = (double)(b->ticks - a->ticks) / (double)sysClkRateGet();
202# else
196 ret= (double)(b->ms_timeb.time-a->ms_timeb.time)+ 203 ret= (double)(b->ms_timeb.time-a->ms_timeb.time)+
197 (((double)b->ms_timeb.millitm)- 204 (((double)b->ms_timeb.millitm)-
198 ((double)a->ms_timeb.millitm))/1000.0; 205 ((double)a->ms_timeb.millitm))/1000.0;
199# endif 206# endif
207# endif
200#endif 208#endif
201 return((ret < 0.0000001)?0.0000001:ret); 209 return((ret < 0.0000001)?0.0000001:ret);
202 } 210 }
@@ -210,13 +218,17 @@ int ms_time_cmp(char *ap, char *bp)
210#ifdef TIMES 218#ifdef TIMES
211 d=(b->ms_tms.tms_utime-a->ms_tms.tms_utime)/HZ; 219 d=(b->ms_tms.tms_utime-a->ms_tms.tms_utime)/HZ;
212#else 220#else
213# ifdef WIN32 221# ifdef OPENSSL_SYS_WIN32
214 d =(b->ms_win32.dwHighDateTime&0x000fffff)*10+b->ms_win32.dwLowDateTime/1e7; 222 d =(b->ms_win32.dwHighDateTime&0x000fffff)*10+b->ms_win32.dwLowDateTime/1e7;
215 d-=(a->ms_win32.dwHighDateTime&0x000fffff)*10+a->ms_win32.dwLowDateTime/1e7; 223 d-=(a->ms_win32.dwHighDateTime&0x000fffff)*10+a->ms_win32.dwLowDateTime/1e7;
216# else 224# else
225# ifdef OPENSSL_SYS_VSWORKS
226 d = (b->ticks - a->ticks);
227# else
217 d= (double)(b->ms_timeb.time-a->ms_timeb.time)+ 228 d= (double)(b->ms_timeb.time-a->ms_timeb.time)+
218 (((double)b->ms_timeb.millitm)-(double)a->ms_timeb.millitm)/1000.0; 229 (((double)b->ms_timeb.millitm)-(double)a->ms_timeb.millitm)/1000.0;
219# endif 230# endif
231# endif
220#endif 232#endif
221 if (d == 0.0) 233 if (d == 0.0)
222 ret=0; 234 ret=0;