Return to time.c CVS log | Up to [OMI] / omi / base |
File: [OMI] / omi / base / Attic / time.c
(download)
Revision: 1.1.1.1 (vendor branch), Wed May 30 21:47:49 2012 UTC (12 years, 1 month ago) by mike Branch: TOG CVS Tags: OMI_1_0_2_Branch, OMI_1_0_2, OMI_1_0_1_PRE, OMI_1_0_1, OMI_1_0_0 Changes since 1.1: +0 -0 lines Initial Import |
/* **============================================================================== ** ** 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 |