From c9aad1ae6227c434d480d1d3aa8eae3c3c910c18 Mon Sep 17 00:00:00 2001 From: marha Date: Sun, 22 Feb 2015 14:43:31 +0100 Subject: Upgraded to openssl-1.0.2 --- openssl/crypto/rand/rand_os2.c | 86 ++++++++++++++++++++++++------------------ 1 file changed, 50 insertions(+), 36 deletions(-) (limited to 'openssl/crypto/rand/rand_os2.c') diff --git a/openssl/crypto/rand/rand_os2.c b/openssl/crypto/rand/rand_os2.c index fc1e78b17..9c4a137bb 100644 --- a/openssl/crypto/rand/rand_os2.c +++ b/openssl/crypto/rand/rand_os2.c @@ -7,7 +7,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -59,29 +59,32 @@ #ifdef OPENSSL_SYS_OS2 -#define INCL_DOSPROCESS -#define INCL_DOSPROFILE -#define INCL_DOSMISC -#define INCL_DOSMODULEMGR -#include +# define INCL_DOSPROCESS +# define INCL_DOSPROFILE +# define INCL_DOSMISC +# define INCL_DOSMODULEMGR +# include -#define CMD_KI_RDCNT (0x63) +# define CMD_KI_RDCNT (0x63) typedef struct _CPUUTIL { - ULONG ulTimeLow; /* Low 32 bits of time stamp */ - ULONG ulTimeHigh; /* High 32 bits of time stamp */ - ULONG ulIdleLow; /* Low 32 bits of idle time */ - ULONG ulIdleHigh; /* High 32 bits of idle time */ - ULONG ulBusyLow; /* Low 32 bits of busy time */ - ULONG ulBusyHigh; /* High 32 bits of busy time */ - ULONG ulIntrLow; /* Low 32 bits of interrupt time */ + ULONG ulTimeLow; /* Low 32 bits of time stamp */ + ULONG ulTimeHigh; /* High 32 bits of time stamp */ + ULONG ulIdleLow; /* Low 32 bits of idle time */ + ULONG ulIdleHigh; /* High 32 bits of idle time */ + ULONG ulBusyLow; /* Low 32 bits of busy time */ + ULONG ulBusyHigh; /* High 32 bits of busy time */ + ULONG ulIntrLow; /* Low 32 bits of interrupt time */ ULONG ulIntrHigh; /* High 32 bits of interrupt time */ } CPUUTIL; -#ifndef __KLIBC__ -APIRET APIENTRY(*DosPerfSysCall) (ULONG ulCommand, ULONG ulParm1, ULONG ulParm2, ULONG ulParm3) = NULL; -APIRET APIENTRY(*DosQuerySysState) (ULONG func, ULONG arg1, ULONG pid, ULONG _res_, PVOID buf, ULONG bufsz) = NULL; -#endif +# ifndef __KLIBC__ +APIRET APIENTRY(*DosPerfSysCall) (ULONG ulCommand, ULONG ulParm1, + ULONG ulParm2, ULONG ulParm3) = NULL; +APIRET APIENTRY(*DosQuerySysState) (ULONG func, ULONG arg1, ULONG pid, + ULONG _res_, PVOID buf, ULONG bufsz) = + NULL; +# endif HMODULE hDoscalls = 0; int RAND_poll(void) @@ -91,56 +94,67 @@ int RAND_poll(void) ULONG SysVars[QSV_FOREGROUND_PROCESS]; if (hDoscalls == 0) { - ULONG rc = DosLoadModule(failed_module, sizeof(failed_module), "DOSCALLS", &hDoscalls); + ULONG rc = + DosLoadModule(failed_module, sizeof(failed_module), "DOSCALLS", + &hDoscalls); -#ifndef __KLIBC__ +# ifndef __KLIBC__ if (rc == 0) { - rc = DosQueryProcAddr(hDoscalls, 976, NULL, (PFN *)&DosPerfSysCall); + rc = DosQueryProcAddr(hDoscalls, 976, NULL, + (PFN *) & DosPerfSysCall); if (rc) DosPerfSysCall = NULL; - rc = DosQueryProcAddr(hDoscalls, 368, NULL, (PFN *)&DosQuerySysState); + rc = DosQueryProcAddr(hDoscalls, 368, NULL, + (PFN *) & DosQuerySysState); if (rc) DosQuerySysState = NULL; } -#endif +# endif } /* Sample the hi-res timer, runs at around 1.1 MHz */ DosTmrQueryTime(&qwTime); RAND_add(&qwTime, sizeof(qwTime), 2); - /* Sample a bunch of system variables, includes various process & memory statistics */ + /* + * Sample a bunch of system variables, includes various process & memory + * statistics + */ DosQuerySysInfo(1, QSV_FOREGROUND_PROCESS, SysVars, sizeof(SysVars)); RAND_add(SysVars, sizeof(SysVars), 4); - /* If available, sample CPU registers that count at CPU MHz - * Only fairly new CPUs (PPro & K6 onwards) & OS/2 versions support this + /* + * If available, sample CPU registers that count at CPU MHz Only fairly + * new CPUs (PPro & K6 onwards) & OS/2 versions support this */ if (DosPerfSysCall) { CPUUTIL util; - if (DosPerfSysCall(CMD_KI_RDCNT, (ULONG)&util, 0, 0) == 0) { + if (DosPerfSysCall(CMD_KI_RDCNT, (ULONG) & util, 0, 0) == 0) { RAND_add(&util, sizeof(util), 10); - } - else { -#ifndef __KLIBC__ + } else { +# ifndef __KLIBC__ DosPerfSysCall = NULL; -#endif +# endif } } - /* DosQuerySysState() gives us a huge quantity of process, thread, memory & handle stats */ + /* + * DosQuerySysState() gives us a huge quantity of process, thread, memory + * & handle stats + */ if (DosQuerySysState) { char *buffer = OPENSSL_malloc(256 * 1024); if (DosQuerySysState(0x1F, 0, 0, 0, buffer, 256 * 1024) == 0) { - /* First 4 bytes in buffer is a pointer to the thread count - * there should be at least 1 byte of entropy per thread + /* + * First 4 bytes in buffer is a pointer to the thread count there + * should be at least 1 byte of entropy per thread */ - RAND_add(buffer, 256 * 1024, **(ULONG **)buffer); + RAND_add(buffer, 256 * 1024, **(ULONG **) buffer); } OPENSSL_free(buffer); @@ -150,4 +164,4 @@ int RAND_poll(void) return 0; } -#endif /* OPENSSL_SYS_OS2 */ +#endif /* OPENSSL_SYS_OS2 */ -- cgit v1.2.3