win_time.c 507 B

1234567891011121314151617181920
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #include "platform_api_vmcore.h"
  6. uint64
  7. os_time_get_boot_microsecond()
  8. {
  9. struct timespec ts;
  10. #if defined(__MINGW32__)
  11. // https://www.mail-archive.com/mingw-w64-public@lists.sourceforge.net/msg18361.html
  12. clock_gettime(CLOCK_REALTIME, &ts);
  13. #else
  14. timespec_get(&ts, TIME_UTC);
  15. #endif
  16. return ((uint64)ts.tv_sec) * 1000 * 1000 + ((uint64)ts.tv_nsec) / 1000;
  17. }