2009年2月5日 星期四

time.h on windows ce

在Porting libpng 1.2.34到wince時,發現time.h並沒有在wince被實作!

後來找到Windows CE Networking Team Blog, 微軟的人(應該是吧)說沒有time.h以及time相關的functions是因為rom的大小限制的關係. 有人就寫了一個簡單的wince版的time(), 如下.

Fredrik said:This is a very annoying shortcoming of WindowsCE, here's my eMbedded Visual C++ solution:

time_t time( time_t *inTT )
{
SYSTEMTIME sysTimeStruct;
FILETIME fTime;
ULARGE_INTEGER int64time;
time_t locTT = 0;
if ( inTT == NULL ) {
inTT = &locTT;
}
GetSystemTime( &sysTimeStruct );
if ( SystemTimeToFileTime( &sysTimeStruct, &fTime ) ) {
memcpy( &int64time, &fTime, sizeof( FILETIME ) );
/* Subtract the value for 1970-01-01 00:00 (UTC) */
int64time.QuadPart -= 0x19db1ded53e8000;
/* Convert to seconds. */
int64time.QuadPart /= 10000000;
*inTT = int64time.QuadPart;
}
return *inTT;
}

Would a small function like this really break the ROM limits form WinCE?
/Fredrik
September 4, 2006 5:19 AM

全文的網址下:
time.h on Windows CE
http://blogs.msdn.com/cenet/archive/2006/04/29/time-h-on-windows-ce.aspx

另外該網誌建議了另外一個連結,有time.h及相關函數的實作

OpenTimeCE from OpenNETCF Consulting
http://www.opennetcf.com/SharedSource/OpenTimeCE/tabid/247/Default.aspx

最後來一個猛一點的, portin openssl會用到
wcecompat (v1.2) - plugs the holes in the eMbedded Visual C++ C Runtime Library, making it more compatible with ANSI C.Licensed under the GNU LGPL
Happy porting

沒有留言:

張貼留言