fix wall time calculations

The time measurements provided by the clock() function on Linux are
grossly inaccurate, which results in unexpected simulator behavior.

This patch provides an alternative to be used when compiled on Linux.

BUG=chrome-os-partner:43025
TEST=fixes test(s) listed in https://goo.gl/OXiTRX, the rest of the
     tests still pass

Change-Id: I0dd617fd1e2f76d2c81ebfe89fe770a8d695c84f
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/307881
Reviewed-by: Utkarsh Sanghi <usanghi@chromium.org>
1 file changed
tree: 2a7101a6091c783363a2f227aabefb63438d0689
  1. generator/
  2. .gitignore
  3. _TPM_Hash_Data.c
  4. _TPM_Hash_Data_fp.h
  5. _TPM_Hash_End.c
  6. _TPM_Hash_End_fp.h
  7. _TPM_Hash_Start.c
  8. _TPM_Hash_Start_fp.h
  9. _TPM_Init.c
  10. _TPM_Init_fp.h
  11. ActivateCredential.c
  12. ActivateCredential_fp.h
  13. AlgorithmCap.c
  14. AlgorithmCap_fp.h
  15. Attest_spt.c
  16. Attest_spt_fp.h
  17. BaseTypes.h
  18. Bits.c
  19. bits.h
  20. Bits_fp.h
  21. bool.h
  22. Cancel.c
  23. Capabilities.h
  24. Certify.c
  25. Certify_fp.h
  26. CertifyCreation.c
  27. CertifyCreation_fp.h
  28. ChangeEPS.c
  29. ChangeEPS_fp.h
  30. ChangePPS.c
  31. ChangePPS_fp.h
  32. Clear.c
  33. Clear_fp.h
  34. ClearControl.c
  35. ClearControl_fp.h
  36. Clock.c
  37. ClockRateAdjust.c
  38. ClockRateAdjust_fp.h
  39. ClockSet.c
  40. ClockSet_fp.h
  41. CommandAttributeData.c
  42. CommandAudit.c
  43. CommandAudit_fp.h
  44. CommandCodeAttributes.c
  45. CommandCodeAttributes_fp.h
  46. CommandDispatcher.c
  47. CommandDispatcher_fp.h
  48. Commands_fp.h
  49. COMMIT-QUEUE.ini
  50. Commit.c
  51. Commit_fp.h
  52. Context_spt.c
  53. Context_spt_fp.h
  54. ContextLoad.c
  55. ContextLoad_fp.h
  56. ContextSave.c
  57. ContextSave_fp.h
  58. CpriCryptPri.c
  59. CpriCryptPri_fp.h
  60. CpriDataEcc.c
  61. CpriDataEcc.h
  62. CpriECC.c
  63. CpriECC_fp.h
  64. CpriHash.c
  65. CpriHash_fp.h
  66. CpriHashData.c
  67. CpriMisc.c
  68. CpriMisc_fp.h
  69. CpriRNG.c
  70. CpriRNG_fp.h
  71. CpriRSA.c
  72. CpriRSA_fp.h
  73. CpriSym.c
  74. CpriSym_fp.h
  75. Create.c
  76. Create_fp.h
  77. CreatePrimary.c
  78. CreatePrimary_fp.h
  79. CryptoEngine.h
  80. CryptSelfTest.c
  81. CryptSelfTest_fp.h
  82. CryptUtil.c
  83. CryptUtil_fp.h
  84. DA.c
  85. DA_fp.h
  86. DictionaryAttackLockReset.c
  87. DictionaryAttackLockReset_fp.h
  88. DictionaryAttackParameters.c
  89. DictionaryAttackParameters_fp.h
  90. DRTM.c
  91. Duplicate.c
  92. Duplicate_fp.h
  93. EC_Ephemeral.c
  94. EC_Ephemeral_fp.h
  95. ECC_Parameters.c
  96. ECC_Parameters_fp.h
  97. ECDH_KeyGen.c
  98. ECDH_KeyGen_fp.h
  99. ECDH_ZGen.c
  100. ECDH_ZGen_fp.h
  101. EncryptDecrypt.c
  102. EncryptDecrypt_fp.h
  103. Entity.c
  104. Entity_fp.h
  105. Entropy.c
  106. EventSequenceComplete.c
  107. EventSequenceComplete_fp.h
  108. EvictControl.c
  109. EvictControl_fp.h
  110. ExecCommand.c
  111. ExecCommand_fp.h
  112. FieldUpgradeData.c
  113. FieldUpgradeData_fp.h
  114. FieldUpgradeStart.c
  115. FieldUpgradeStart_fp.h
  116. FirmwareRead.c
  117. FirmwareRead_fp.h
  118. FlushContext.c
  119. FlushContext_fp.h
  120. GetCapability.c
  121. GetCapability_fp.h
  122. GetCommandAuditDigest.c
  123. GetCommandAuditDigest_fp.h
  124. GetCommandCodeString.c
  125. GetCommandCodeString_fp.h
  126. GetRandom.c
  127. GetRandom_fp.h
  128. GetSessionAuditDigest.c
  129. GetSessionAuditDigest_fp.h
  130. GetTestResult.c
  131. GetTestResult_fp.h
  132. GetTime.c
  133. GetTime_fp.h
  134. Global.c
  135. Global.h
  136. Handle.c
  137. Handle_fp.h
  138. HandleProcess.c
  139. HandleProcess_fp.h
  140. Hash.c
  141. Hash_fp.h
  142. HashSequenceStart.c
  143. HashSequenceStart_fp.h
  144. Hierarchy.c
  145. Hierarchy_fp.h
  146. HierarchyChangeAuth.c
  147. HierarchyChangeAuth_fp.h
  148. HierarchyControl.c
  149. HierarchyControl_fp.h
  150. HMAC.c
  151. HMAC_fp.h
  152. HMAC_Start.c
  153. HMAC_Start_fp.h
  154. Implementation.h
  155. Import.c
  156. Import_fp.h
  157. IncrementalSelfTest.c
  158. IncrementalSelfTest_fp.h
  159. InternalRoutines.h
  160. LICENSE
  161. Load.c
  162. Load_fp.h
  163. LoadExternal.c
  164. LoadExternal_fp.h
  165. Locality.c
  166. Locality_fp.h
  167. LocalityPlat.c
  168. MakeCredential.c
  169. MakeCredential_fp.h
  170. Makefile
  171. Manufacture.c
  172. Manufacture_fp.h
  173. Marshal_ActivateCredential.c
  174. Marshal_Certify.c
  175. Marshal_CertifyCreation.c
  176. Marshal_ChangeEPS.c
  177. Marshal_ChangePPS.c
  178. Marshal_Clear.c
  179. Marshal_ClearControl.c
  180. Marshal_ClockRateAdjust.c
  181. Marshal_ClockSet.c
  182. Marshal_Commit.c
  183. Marshal_ContextLoad.c
  184. Marshal_ContextSave.c
  185. Marshal_Create.c
  186. Marshal_CreatePrimary.c
  187. Marshal_DictionaryAttackLockReset.c
  188. Marshal_DictionaryAttackParameters.c
  189. Marshal_Duplicate.c
  190. Marshal_EC_Ephemeral.c
  191. Marshal_ECC_Parameters.c
  192. Marshal_ECDH_KeyGen.c
  193. Marshal_ECDH_ZGen.c
  194. Marshal_EncryptDecrypt.c
  195. Marshal_EventSequenceComplete.c
  196. Marshal_EvictControl.c
  197. Marshal_FieldUpgradeData.c
  198. Marshal_FieldUpgradeStart.c
  199. Marshal_FirmwareRead.c
  200. Marshal_FlushContext.c
  201. marshal_fp.h
  202. Marshal_GetCapability.c
  203. Marshal_GetCommandAuditDigest.c
  204. Marshal_GetRandom.c
  205. Marshal_GetSessionAuditDigest.c
  206. Marshal_GetTestResult.c
  207. Marshal_GetTime.c
  208. Marshal_Hash.c
  209. Marshal_HashSequenceStart.c
  210. Marshal_HierarchyChangeAuth.c
  211. Marshal_HierarchyControl.c
  212. Marshal_HMAC.c
  213. Marshal_HMAC_Start.c
  214. Marshal_Import.c
  215. Marshal_IncrementalSelfTest.c
  216. Marshal_Load.c
  217. Marshal_LoadExternal.c
  218. Marshal_MakeCredential.c
  219. Marshal_NV_Certify.c
  220. Marshal_NV_ChangeAuth.c
  221. Marshal_NV_DefineSpace.c
  222. Marshal_NV_Extend.c
  223. Marshal_NV_GlobalWriteLock.c
  224. Marshal_NV_Increment.c
  225. Marshal_NV_Read.c
  226. Marshal_NV_ReadLock.c
  227. Marshal_NV_ReadPublic.c
  228. Marshal_NV_SetBits.c
  229. Marshal_NV_UndefineSpace.c
  230. Marshal_NV_UndefineSpaceSpecial.c
  231. Marshal_NV_Write.c
  232. Marshal_NV_WriteLock.c
  233. Marshal_ObjectChangeAuth.c
  234. Marshal_PCR_Allocate.c
  235. Marshal_PCR_Event.c
  236. Marshal_PCR_Extend.c
  237. Marshal_PCR_Read.c
  238. Marshal_PCR_Reset.c
  239. Marshal_PCR_SetAuthPolicy.c
  240. Marshal_PCR_SetAuthValue.c
  241. Marshal_PolicyAuthorize.c
  242. Marshal_PolicyAuthValue.c
  243. Marshal_PolicyCommandCode.c
  244. Marshal_PolicyCounterTimer.c
  245. Marshal_PolicyCpHash.c
  246. Marshal_PolicyDuplicationSelect.c
  247. Marshal_PolicyGetDigest.c
  248. Marshal_PolicyLocality.c
  249. Marshal_PolicyNameHash.c
  250. Marshal_PolicyNV.c
  251. Marshal_PolicyNvWritten.c
  252. Marshal_PolicyOR.c
  253. Marshal_PolicyPassword.c
  254. Marshal_PolicyPCR.c
  255. Marshal_PolicyPhysicalPresence.c
  256. Marshal_PolicyRestart.c
  257. Marshal_PolicySecret.c
  258. Marshal_PolicySigned.c
  259. Marshal_PolicyTicket.c
  260. Marshal_PP_Commands.c
  261. Marshal_Quote.c
  262. Marshal_ReadClock.c
  263. Marshal_ReadPublic.c
  264. Marshal_Rewrap.c
  265. Marshal_RSA_Decrypt.c
  266. Marshal_RSA_Encrypt.c
  267. Marshal_SelfTest.c
  268. Marshal_SequenceComplete.c
  269. Marshal_SequenceUpdate.c
  270. Marshal_SetAlgorithmSet.c
  271. Marshal_SetCommandCodeAuditStatus.c
  272. Marshal_SetPrimaryPolicy.c
  273. Marshal_Shutdown.c
  274. Marshal_Sign.c
  275. Marshal_StartAuthSession.c
  276. Marshal_Startup.c
  277. Marshal_StirRandom.c
  278. marshal_test.c
  279. Marshal_TestParms.c
  280. Marshal_Unseal.c
  281. Marshal_VerifySignature.c
  282. Marshal_ZGen_2Phase.c
  283. MathFunctions.c
  284. MathFunctions_fp.h
  285. MemoryLib.c
  286. MemoryLib_fp.h
  287. NV.c
  288. NV_Certify.c
  289. NV_Certify_fp.h
  290. NV_ChangeAuth.c
  291. NV_ChangeAuth_fp.h
  292. NV_DefineSpace.c
  293. NV_DefineSpace_fp.h
  294. NV_Extend.c
  295. NV_Extend_fp.h
  296. NV_fp.h
  297. NV_GlobalWriteLock.c
  298. NV_GlobalWriteLock_fp.h
  299. NV_Increment.c
  300. NV_Increment_fp.h
  301. NV_Read.c
  302. NV_Read_fp.h
  303. NV_ReadLock.c
  304. NV_ReadLock_fp.h
  305. NV_ReadPublic.c
  306. NV_ReadPublic_fp.h
  307. NV_SetBits.c
  308. NV_SetBits_fp.h
  309. NV_spt.c
  310. NV_spt_fp.h
  311. NV_UndefineSpace.c
  312. NV_UndefineSpace_fp.h
  313. NV_UndefineSpaceSpecial.c
  314. NV_UndefineSpaceSpecial_fp.h
  315. NV_Write.c
  316. NV_Write_fp.h
  317. NV_WriteLock.c
  318. NV_WriteLock_fp.h
  319. NVMem.c
  320. Object.c
  321. Object_fp.h
  322. Object_spt.c
  323. Object_spt_fp.h
  324. ObjectChangeAuth.c
  325. ObjectChangeAuth_fp.h
  326. OsslCryptoEngine.h
  327. parsep3
  328. parsep4
  329. part3.txt
  330. part4.txt
  331. PCR.c
  332. PCR_Allocate.c
  333. PCR_Allocate_fp.h
  334. PCR_Event.c
  335. PCR_Event_fp.h
  336. PCR_Extend.c
  337. PCR_Extend_fp.h
  338. PCR_fp.h
  339. PCR_Read.c
  340. PCR_Read_fp.h
  341. PCR_Reset.c
  342. PCR_Reset_fp.h
  343. PCR_SetAuthPolicy.c
  344. PCR_SetAuthPolicy_fp.h
  345. PCR_SetAuthValue.c
  346. PCR_SetAuthValue_fp.h
  347. Platform.h
  348. PlatformData.c
  349. PlatformData.h
  350. Policy_spt.c
  351. Policy_spt_fp.h
  352. PolicyAuthorize.c
  353. PolicyAuthorize_fp.h
  354. PolicyAuthValue.c
  355. PolicyAuthValue_fp.h
  356. PolicyCommandCode.c
  357. PolicyCommandCode_fp.h
  358. PolicyCounterTimer.c
  359. PolicyCounterTimer_fp.h
  360. PolicyCpHash.c
  361. PolicyCpHash_fp.h
  362. PolicyDuplicationSelect.c
  363. PolicyDuplicationSelect_fp.h
  364. PolicyGetDigest.c
  365. PolicyGetDigest_fp.h
  366. PolicyLocality.c
  367. PolicyLocality_fp.h
  368. PolicyNameHash.c
  369. PolicyNameHash_fp.h
  370. PolicyNV.c
  371. PolicyNV_fp.h
  372. PolicyNvWritten.c
  373. PolicyNvWritten_fp.h
  374. PolicyOR.c
  375. PolicyOR_fp.h
  376. PolicyPassword.c
  377. PolicyPassword_fp.h
  378. PolicyPCR.c
  379. PolicyPCR_fp.h
  380. PolicyPhysicalPresence.c
  381. PolicyPhysicalPresence_fp.h
  382. PolicyRestart.c
  383. PolicyRestart_fp.h
  384. PolicySecret.c
  385. PolicySecret_fp.h
  386. PolicySigned.c
  387. PolicySigned_fp.h
  388. PolicyTicket.c
  389. PolicyTicket_fp.h
  390. Power.c
  391. Power_fp.h
  392. PowerPlat.c
  393. PP.c
  394. PP_Commands.c
  395. PP_Commands_fp.h
  396. PP_fp.h
  397. PPPlat.c
  398. PRESUBMIT.cfg
  399. PropertyCap.c
  400. PropertyCap_fp.h
  401. Quote.c
  402. Quote_fp.h
  403. ReadClock.c
  404. ReadClock_fp.h
  405. README
  406. ReadPublic.c
  407. ReadPublic_fp.h
  408. Rewrap.c
  409. Rewrap_fp.h
  410. RSA_Decrypt.c
  411. RSA_Decrypt_fp.h
  412. RSA_Encrypt.c
  413. RSA_Encrypt_fp.h
  414. RSAData.c
  415. RSAKeySieve.c
  416. RSAKeySieve.h
  417. RSAKeySieve_fp.h
  418. SelfTest.c
  419. SelfTest_fp.h
  420. SequenceComplete.c
  421. SequenceComplete_fp.h
  422. SequenceUpdate.c
  423. SequenceUpdate_fp.h
  424. Session.c
  425. Session_fp.h
  426. SessionProcess.c
  427. SessionProcess_fp.h
  428. SetAlgorithmSet.c
  429. SetAlgorithmSet_fp.h
  430. SetCommandCodeAuditStatus.c
  431. SetCommandCodeAuditStatus_fp.h
  432. SetPrimaryPolicy.c
  433. SetPrimaryPolicy_fp.h
  434. Shutdown.c
  435. Shutdown_fp.h
  436. Sign.c
  437. Sign_fp.h
  438. StartAuthSession.c
  439. StartAuthSession_fp.h
  440. Startup.c
  441. Startup_fp.h
  442. StirRandom.c
  443. StirRandom_fp.h
  444. swap.h
  445. TcpServer.c
  446. TestParms.c
  447. TestParms_fp.h
  448. Ticket.c
  449. Ticket_fp.h
  450. Time.c
  451. Time_fp.h
  452. Tpm.h
  453. tpm_generated.c
  454. tpm_generated.h
  455. TPM_Types.h
  456. tpm_types.h
  457. TPMB.h
  458. TpmBuildSwitches.h
  459. TPMCmdp.c
  460. TPMCmds.c
  461. TpmError.h
  462. TpmFail.c
  463. TpmFail_fp.h
  464. TpmTcpProtocol.h
  465. Unique.c
  466. Unique_fp.h
  467. Unseal.c
  468. Unseal_fp.h
  469. VendorString.h
  470. VerifySignature.c
  471. VerifySignature_fp.h
  472. ZGen_2Phase.c
  473. ZGen_2Phase_fp.h