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

2009年2月4日 星期三

Porting from windows to windows mobile

很多open source的software都有embedded visual c++的版本以及Windows XP上的版本. 但是要把這些software porting到windows mobile 6.0上,經常要把專案檔改成vs2005的格式.

eVC++ 到 VS2005專案檔的轉換, 微軟有一個網頁在說明.
Migrating Microsoft eMbedded Visual C++ Projects to Visual Studio 2005
http://msdn.microsoft.com/en-us/library/ms838254.aspx

Step by Step: Migrating an eMbedded Visual C++ Application to Visual Studio 2005
http://msdn.microsoft.com/en-us/library/aa454893.aspx


另外還有一個問題就是open source software使用到很多GNU的C程式庫(套一句行話, GNU Platform SDK), 很多標頭檔(header file), APIs有可能在Windows CE/Mobile上面並沒有實作.
所以要想辦法去補齊這些缺漏的部分.

例如, time.h, struct tm資料結構以及gmtime()在CE上就沒有支援.