X-Git-Url: https://git.openssl.org/gitweb/?a=blobdiff_plain;f=apps%2Fapps.c;h=29a60a980f9dc284c4aeff9804a1012a779834f8;hb=a950f28762fbfa8dbb1c1c0f6234afd9fe6abe6d;hp=76dc61a142e3bcb226899994e8ecef2b7ca3d088;hpb=a1ad253f172fa70809e489320fa118247ab3a02c;p=openssl.git diff --git a/apps/apps.c b/apps/apps.c index 76dc61a142..29a60a980f 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,138 @@ 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; + static int warning=1; +#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; + + if (usertime && warning) + { + BIO_printf(bio_err,"To get meaningful results, run " + "this program on idle system.\n"); + warning=1; + } + 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(OPENSSL_SYSTEM_VMS) +#include +#include + +double app_tminterval(int stop,int usertime) + { + static clock_t tmstart; + double ret = 0; + clock_t now; +#ifdef __TMS + struct tms rus; + + now = times(&rus); + if (usertime) now = rus.tms_utime; +#else + if (usertime) + now = clock(); /* sum of user and kernel times */ + else { + struct timeval tv; + gettimeofday(&tv,NULL); + now = (clock_t)( + (unsigned long long)tv.tv_sec*CLK_TCK + + (unsigned long long)tv.tv_usec*(1000000/CLK_TCK) + ); + } +#endif + if (stop==TM_START) tmstart = now; + else ret = (now - tmstart)/(double)(CLK_TCK); + + return (ret); + } + +#elif defined(_SC_CLK_TCK) /* by means of unistd.h */ +#include + +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==TM_START) tmstart = now; + else ret = (now - tmstart)/(double)sysconf(_SC_CLK_TCK); + + return (ret); + } + +#else +#include +#include + +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==TM_START) 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 +2545,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 +2571,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 -