Return to time.c CVS log | Up to [OMI] / omi / base |
File: [OMI] / omi / base / Attic / time.c
(download)
Revision: 1.2, Mon Apr 20 17:10:10 2015 UTC (9 years, 1 month ago) by krisbash Branch: MAIN CVS Tags: HEAD Changes since 1.1: +0 -0 lines FILE REMOVED Remove 1.0.2 |
/* **============================================================================== ** ** Open Management Infrastructure (OMI) ** ** Copyright (c) Microsoft Corporation ** ** Licensed under the Apache License, Version 2.0 (the "License"); you may not ** use this file except in compliance with the License. You may obtain a copy ** of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ** KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED ** WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, ** MERCHANTABLITY OR NON-INFRINGEMENT. ** ** See the Apache 2 License for the specific language governing permissions ** and limitations under the License. ** **============================================================================== */ #include "time.h" #if defined(CONFIG_OS_WINDOWS) # include <windows.h> # include <time.h> #elif defined(CONFIG_POSIX) # include <unistd.h> # include <time.h> # include <sys/time.h> # include <sys/types.h> #endif void Time_Sleep(MI_Uint64 msec) { #if defined(CONFIG_OS_WINDOWS) Sleep((DWORD)msec); #else struct timespec ts; ts.tv_sec = (long)(msec/1000); ts.tv_nsec = (long)((msec%1000)*1000*1000); nanosleep(&ts, NULL); #endif } MI_Result Time_Now( MI_Uint64* self) { #if defined(CONFIG_OS_WINDOWS) FILETIME ft; ULARGE_INTEGER tmp; GetSystemTimeAsFileTime(&ft); tmp.u.LowPart = ft.dwLowDateTime; tmp.u.HighPart = ft.dwHighDateTime; tmp.QuadPart -= 0X19DB1DED53E8000; *self = tmp.QuadPart / (UINT64)10; return MI_RESULT_OK; #else struct timeval tv; struct timezone tz; memset(&tv, 0, sizeof(tv)); memset(&tz, 0, sizeof(tz)); if (gettimeofday(&tv, &tz) != 0) return MI_RESULT_FAILED; *self = (MI_Uint64)tv.tv_sec * (MI_Uint64)1000000 + (MI_Uint64)tv.tv_usec; return MI_RESULT_OK; #endif }
ViewCVS 0.9.2 |