Changeset 2
- Timestamp:
- Mar 13, 2007, 10:32:52 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/samba-3.0.25pre1/source/lib/os2ea.c
r1 r2 5 5 #define INCL_LONGLONG 6 6 #define INCL_DOS 7 #define INCL_DOSPROCESS 8 #define INCL_DOSPROFILE 9 #define INCL_DOSMISC 10 #define INCL_DOSMODULEMGR 7 11 #define INCL_DOSERRORS 8 12 //_SMB_H … … 14 18 #ifndef TESTING 15 19 #define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2))) 20 #define CMD_KI_RDCNT (0x63) 21 22 typedef struct _CPUUTIL { 23 ULONG ulTimeLow; /* Low 32 bits of time stamp */ 24 ULONG ulTimeHigh; /* High 32 bits of time stamp */ 25 ULONG ulIdleLow; /* Low 32 bits of idle time */ 26 ULONG ulIdleHigh; /* High 32 bits of idle time */ 27 ULONG ulBusyLow; /* Low 32 bits of busy time */ 28 ULONG ulBusyHigh; /* High 32 bits of busy time */ 29 ULONG ulIntrLow; /* Low 32 bits of interrupt time */ 30 ULONG ulIntrHigh; /* High 32 bits of interrupt time */ 31 } CPUUTIL; 32 16 33 #include "local.h" 17 34 #include "xfile.h" … … 41 58 return 0; 42 59 } 60 61 // very simple random data gatherer derived from openssl 62 void os2_randget(char * buffer, int length) 63 { 64 QWORD qwTime; 65 ULONG SysVars[QSV_FOREGROUND_PROCESS]; 66 int done = 0; 67 68 if (!buffer || length <= 0) 69 { 70 return; 71 } 72 73 DosTmrQueryTime(&qwTime); 74 memcpy(buffer, &qwTime, sizeof(qwTime) > length ? length : sizeof(qwTime)); 75 done += sizeof(qwTime); 76 if (done >= length) 77 { 78 return; 79 } 80 81 if (DosPerfSysCall) 82 { 83 CPUUTIL util; 84 if (DosPerfSysCall(CMD_KI_RDCNT, (ULONG)&util, 0, 0) == 0) 85 { 86 memcpy(buffer + done, &util, sizeof(util) > length - done ? length - done : sizeof(util)); 87 done += sizeof(util); 88 if (done >= length) 89 { 90 return; 91 } 92 } 93 } 94 95 DosQuerySysInfo(1, QSV_FOREGROUND_PROCESS, SysVars, sizeof(SysVars)); 96 memcpy(buffer + done, SysVars, sizeof(SysVars) > length - done ? length - done : sizeof(SysVars)); 97 } 98 43 99 44 100 void maperrno(int rc)
Note:
See TracChangeset
for help on using the changeset viewer.