summaryrefslogtreecommitdiffstats
path: root/apps/apps.c
diff options
context:
space:
mode:
authorAndy Polyakov <appro@openssl.org>2005-11-06 11:40:59 +0000
committerAndy Polyakov <appro@openssl.org>2005-11-06 11:40:59 +0000
commit0a39d8f2074aa96b48a76e01bd246f6beb778439 (patch)
treea2d2868dedfe9ec31eda665c17589f72d6a21b7a /apps/apps.c
parent6852d1d8c3dcc3b536ab779e4ab7ae82fa1fadbf (diff)
Collect timing procedures in apps/apps.c. It's a bit cruel patch, as it
temporarily[!] removes support for couple of esoteric platforms [well, Netware, vxWorks and VMS].
Diffstat (limited to 'apps/apps.c')
-rw-r--r--apps/apps.c96
1 files changed, 95 insertions, 1 deletions
diff --git a/apps/apps.c b/apps/apps.c
index 76dc61a142..60bd7ef343 100644
--- a/apps/apps.c
+++ b/apps/apps.c
@@ -2307,6 +2307,9 @@ void policies_print(BIO *out, X509_STORE_CTX *ctx)
BIO_free(out);
}
+/*
+ * Platform-specific sections
+ */
#if defined(_WIN32)
# ifdef fileno
# undef fileno
@@ -2363,7 +2366,98 @@ ok:
if (tfrom!=NULL && tfrom!=(TCHAR *)from) free(tfrom);
return ret;
}
+#endif
+
+/* app_tminterval section */
+#if defined(_WIN32)
+double app_tminterval(int stop,int usertime)
+ {
+ FILETIME now;
+ double ret=0;
+ static ULARGE_INTEGER tmstart;
+#ifdef _WIN32_WINNT
+ static HANDLE proc=NULL;
+
+ if (proc==NULL)
+ {
+ if (GetVersion() < 0x80000000)
+ proc = OpenProcess(PROCESS_QUERY_INFORMATION,FALSE,
+ GetCurrentProcessId());
+ if (proc==NULL) proc = (HANDLE)-1;
+ }
+
+ if (usertime && proc!=(HANDLE)-1)
+ {
+ FILETIME junk;
+ GetProcessTimes(proc,&junk,&junk,&junk,&now);
+ }
+ else
+#endif
+ {
+ SYSTEMTIME systime;
+ GetSystemTime(&systime);
+ SystemTimeToFileTime(&systime,&now);
+ }
+
+ if (stop==TM_START)
+ {
+ tmstart.u.LowPart = now.dwLowDateTime;
+ tmstart.u.HighPart = now.dwHighDateTime;
+ }
+ else {
+ ULARGE_INTEGER tmstop;
+
+ tmstop.u.LowPart = now.dwLowDateTime;
+ tmstop.u.HighPart = now.dwHighDateTime;
+
+ ret = (tmstop.QuadPart - tmstart.QuadPart)*1e-7;
+ }
+
+ return (ret);
+ }
+
+#elif defined(_SC_CLK_TCK) /* by means of unistd.h */
+#include <sys/times.h>
+
+double app_tminterval(int stop,int usertime)
+ {
+ double ret = 0;
+ struct tms rus;
+ clock_t now = times(&rus);
+ static clock_t tmstart;
+
+ if (usertime) now = rus.tms_utime;
+
+ if (stop==TMSTART) tmstart = now;
+ else ret = (now - tmstart)/(double)sysconf(_SC_CLK_TCK);
+
+ return (ret);
+ }
+
+#else
+#include <sys/time.h>
+#include <sys/resource.h>
+
+double app_tminterval(int stop,int usertime)
+ {
+ double ret = 0;
+ struct rusage rus;
+ struct timeval now;
+ static struct timeval tmstart;
+
+ if (usertime) getrusage(RUSAGE_SELF,&rus), now = rus.ru_time;
+ else gettimeofday(&now,NULL);
+
+ if (stop==TMSTART) tmstart = now;
+ else ret = ( (now.tv_sec+now.tv_usec*1e-6)
+ - (tmstart.tv_sec+tmstart.tv_usec*1e-6) );
+
+ return ret;
+ }
+#endif
+/* app_isdir section */
+#ifdef _WIN32
int app_isdir(const char *name)
{
HANDLE hList;
@@ -2411,6 +2505,7 @@ int app_isdir(const char *name)
}
#endif
+/* raw_read|write section */
#if defined(_WIN32) && defined(STD_INPUT_HANDLE)
int raw_read_stdin(void *buf,int siz)
{
@@ -2436,4 +2531,3 @@ int raw_write_stdout(void *buf,int siz)
int raw_write_stdout(const void *buf,int siz)
{ return write(fileno(stdout),buf,siz); }
#endif
-