VirtualBox

source: vbox/trunk/src/libs/openssl-3.3.2/crypto/time.c@ 108358

最後變更 在這個檔案從108358是 108206,由 vboxsync 提交於 5 週 前

openssl-3.3.2: Exported all files to OSE and removed .scm-settings ​bugref:10757

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 1.3 KB
 
1/*
2 * Copyright 2022-2023 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10#include <errno.h>
11#include <openssl/err.h>
12#include "internal/time.h"
13
14OSSL_TIME ossl_time_now(void)
15{
16 OSSL_TIME r;
17
18#if defined(_WIN32) && !defined(OPENSSL_SYS_UEFI)
19 SYSTEMTIME st;
20 union {
21 unsigned __int64 ul;
22 FILETIME ft;
23 } now;
24
25 GetSystemTime(&st);
26 SystemTimeToFileTime(&st, &now.ft);
27 /* re-bias to 1/1/1970 */
28# ifdef __MINGW32__
29 now.ul -= 116444736000000000ULL;
30# else
31 now.ul -= 116444736000000000UI64;
32# endif
33 r.t = ((uint64_t)now.ul) * (OSSL_TIME_SECOND / 10000000);
34#else /* defined(_WIN32) */
35 struct timeval t;
36
37 if (gettimeofday(&t, NULL) < 0) {
38 ERR_raise_data(ERR_LIB_SYS, get_last_sys_error(),
39 "calling gettimeofday()");
40 return ossl_time_zero();
41 }
42 if (t.tv_sec <= 0)
43 r.t = t.tv_usec <= 0 ? 0 : t.tv_usec * OSSL_TIME_US;
44 else
45 r.t = ((uint64_t)t.tv_sec * 1000000 + t.tv_usec) * OSSL_TIME_US;
46#endif /* defined(_WIN32) */
47 return r;
48}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette