summaryrefslogtreecommitdiff
path: root/src/lib/libssl/src/crypto/tmdiff.c
diff options
context:
space:
mode:
authorbeck <>1999-09-29 04:37:45 +0000
committerbeck <>1999-09-29 04:37:45 +0000
commitde8f24ea083384bb66b32ec105dc4743c5663cdf (patch)
tree1412176ae62a3cab2cf2b0b92150fcbceaac6092 /src/lib/libssl/src/crypto/tmdiff.c
parentcb929d29896bcb87c2a97417fbd03e50078fc178 (diff)
downloadopenbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.gz
openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.bz2
openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.zip
OpenSSL 0.9.4 merge
Diffstat (limited to 'src/lib/libssl/src/crypto/tmdiff.c')
-rw-r--r--src/lib/libssl/src/crypto/tmdiff.c106
1 files changed, 59 insertions, 47 deletions
diff --git a/src/lib/libssl/src/crypto/tmdiff.c b/src/lib/libssl/src/crypto/tmdiff.c
index b93799fc03..0ad8a9ed8d 100644
--- a/src/lib/libssl/src/crypto/tmdiff.c
+++ b/src/lib/libssl/src/crypto/tmdiff.c
@@ -57,32 +57,40 @@
57 */ 57 */
58#include <stdio.h> 58#include <stdio.h>
59#include <stdlib.h> 59#include <stdlib.h>
60#include "cryptlib.h"
61#include <openssl/tmdiff.h>
62
63#ifdef TIMEB
64#undef WIN32
65#undef TIMES
66#endif
60 67
61#ifndef MSDOS 68#ifndef MSDOS
62# ifndef WIN32 69# ifndef WIN32
63# define TIMES 70# if !defined(VMS) || defined(__DECC)
71# define TIMES
72# endif
64# endif 73# endif
65#endif 74#endif
66 75
67#ifndef VMS 76#ifndef _IRIX
68# ifndef _IRIX 77# include <time.h>
69# include <time.h> 78#endif
70# endif 79#ifdef TIMES
71# ifdef TIMES 80# include <sys/types.h>
72# include <sys/types.h> 81# include <sys/times.h>
73# include <sys/times.h> 82#endif
74# endif 83
75#else /* VMS */ 84/* Depending on the VMS version, the tms structure is perhaps defined.
76# include <types.h> 85 The __TMS macro will show if it was. If it wasn't defined, we should
77 struct tms { 86 undefine TIMES, since that tells the rest of the program how things
78 time_t tms_utime; 87 should be handled. -- Richard Levitte */
79 time_t tms_stime; 88#if defined(VMS) && defined(__DECC) && !defined(__TMS)
80 time_t tms_uchild; /* I dunno... */ 89#undef TIMES
81 time_t tms_uchildsys; /* so these names are a guess :-) */ 90#endif
82 } 91
83#endif /* VMS */ 92#if defined(sun) || defined(__ultrix)
84 93#define _POSIX_SOURCE
85#ifdef sun
86#include <limits.h> 94#include <limits.h>
87#include <sys/param.h> 95#include <sys/param.h>
88#endif 96#endif
@@ -99,11 +107,7 @@
99#ifndef HZ 107#ifndef HZ
100# ifndef CLK_TCK 108# ifndef CLK_TCK
101# ifndef _BSD_CLK_TCK_ /* FreeBSD hack */ 109# ifndef _BSD_CLK_TCK_ /* FreeBSD hack */
102# ifndef VMS 110# define HZ 100.0
103# define HZ 100.0
104# else /* VMS */
105# define HZ 100.0
106# endif
107# else /* _BSD_CLK_TCK_ */ 111# else /* _BSD_CLK_TCK_ */
108# define HZ ((double)_BSD_CLK_TCK_) 112# define HZ ((double)_BSD_CLK_TCK_)
109# endif 113# endif
@@ -126,11 +130,11 @@ typedef struct ms_tm
126#endif 130#endif
127 } MS_TM; 131 } MS_TM;
128 132
129char *ms_time_init() 133char *ms_time_new(void)
130 { 134 {
131 MS_TM *ret; 135 MS_TM *ret;
132 136
133 ret=malloc(sizeof(MS_TM)); 137 ret=(MS_TM *)Malloc(sizeof(MS_TM));
134 if (ret == NULL) 138 if (ret == NULL)
135 return(NULL); 139 return(NULL);
136 memset(ret,0,sizeof(MS_TM)); 140 memset(ret,0,sizeof(MS_TM));
@@ -140,34 +144,31 @@ char *ms_time_init()
140 return((char *)ret); 144 return((char *)ret);
141 } 145 }
142 146
143void ms_time_final(a) 147void ms_time_free(char *a)
144char *a;
145 { 148 {
146 if (a != NULL) 149 if (a != NULL)
147 free(a); 150 Free(a);
148 } 151 }
149 152
150void ms_time_get(a) 153void ms_time_get(char *a)
151char *a;
152 { 154 {
153 MS_TM *tm=(MS_TM *)a; 155 MS_TM *tm=(MS_TM *)a;
154 FILETIME tmpa,tmpb,tmpc; 156#ifdef WIN32
157 FILETIME tmpa,tmpb,tmpc;
158#endif
155 159
156#ifdef TIMES 160#ifdef TIMES
157 printf("AAA\n");
158 times(&tm->ms_tms); 161 times(&tm->ms_tms);
159#else 162#else
160# ifdef WIN32 163# ifdef WIN32
161 GetThreadTimes(tm->thread_id,&tmpa,&tmpb,&tmpc,&(tm->ms_win32)); 164 GetThreadTimes(tm->thread_id,&tmpa,&tmpb,&tmpc,&(tm->ms_win32));
162# else 165# else
163 printf("CCC\n"); 166 ftime(&tm->ms_timeb);
164 ftime(tm->ms_timeb);
165# endif 167# endif
166#endif 168#endif
167 } 169 }
168 170
169double ms_time_diff(ap,bp) 171double ms_time_diff(char *ap, char *bp)
170char *ap,*bp;
171 { 172 {
172 MS_TM *a=(MS_TM *)ap; 173 MS_TM *a=(MS_TM *)ap;
173 MS_TM *b=(MS_TM *)bp; 174 MS_TM *b=(MS_TM *)bp;
@@ -177,19 +178,30 @@ char *ap,*bp;
177 ret=(b->ms_tms.tms_utime-a->ms_tms.tms_utime)/HZ; 178 ret=(b->ms_tms.tms_utime-a->ms_tms.tms_utime)/HZ;
178#else 179#else
179# ifdef WIN32 180# ifdef WIN32
180 ret =(double)(b->ms_win32.dwHighDateTime&0x000fffff)*10+ 181 {
181 b->ms_win32.dwLowDateTime/1e7; 182#ifdef __GNUC__
182 ret-=(double)(a->ms_win32.dwHighDateTime&0x000fffff)*10+a->ms_win32.dwLowDateTime/1e7; 183 signed long long la,lb;
184#else
185 signed _int64 la,lb;
186#endif
187 la=a->ms_win32.dwHighDateTime;
188 lb=b->ms_win32.dwHighDateTime;
189 la<<=32;
190 lb<<=32;
191 la+=a->ms_win32.dwLowDateTime;
192 lb+=b->ms_win32.dwLowDateTime;
193 ret=((double)(lb-la))/1e7;
194 }
183# else 195# else
184 ret= (double)(b->time-a->time)+ 196 ret= (double)(b->ms_timeb.time-a->ms_timeb.time)+
185 ((double)((unsigned long)b->mullitm-(unsigned long)))/1000.0; 197 (((double)b->ms_timeb.millitm)-
198 ((double)a->ms_timeb.millitm))/1000.0;
186# endif 199# endif
187#endif 200#endif
188 return((ret < 0.0000001)?0.0000001:ret); 201 return((ret < 0.0000001)?0.0000001:ret);
189 } 202 }
190 203
191int ms_time_cmp(ap,bp) 204int ms_time_cmp(char *ap, char *bp)
192char *ap,*bp;
193 { 205 {
194 MS_TM *a=(MS_TM *)ap,*b=(MS_TM *)bp; 206 MS_TM *a=(MS_TM *)ap,*b=(MS_TM *)bp;
195 double d; 207 double d;
@@ -202,8 +214,8 @@ char *ap,*bp;
202 d =(b->ms_win32.dwHighDateTime&0x000fffff)*10+b->ms_win32.dwLowDateTime/1e7; 214 d =(b->ms_win32.dwHighDateTime&0x000fffff)*10+b->ms_win32.dwLowDateTime/1e7;
203 d-=(a->ms_win32.dwHighDateTime&0x000fffff)*10+a->ms_win32.dwLowDateTime/1e7; 215 d-=(a->ms_win32.dwHighDateTime&0x000fffff)*10+a->ms_win32.dwLowDateTime/1e7;
204# else 216# else
205 d= (double)(b->time-a->time)+ 217 d= (double)(b->ms_timeb.time-a->ms_timeb.time)+
206 ((double)((unsigned long)b->mullitm-(unsigned long)))/1000.0; 218 (((double)b->ms_timeb.millitm)-(double)a->ms_timeb.millitm)/1000.0;
207# endif 219# endif
208#endif 220#endif
209 if (d == 0.0) 221 if (d == 0.0)