Closed GoogleCodeExporter closed 9 years ago
Great, thank you. Working on patch. Any reason why you made mg_write static?
Original comment by valenok
on 21 May 2009 at 9:28
Another question - does MS gives wince compiler for free? Can I setup WinCE
build
environment without paying them?
Original comment by valenok
on 21 May 2009 at 9:49
Download Link for Microsoft eMbedded Visual C++:
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=1dacdb3d
-50d1-41b2-a107-fa75ae960856
Original comment by matthewj...@googlemail.com
on 21 May 2009 at 1:20
Oops, mg_write should not be static. Sorry, it was meant for mgce_write.
Also, in mgce_open() there should be some code added to open files with
FILE_SHARE_READ when O_RDONLY is specified.
static int
mgce_open(const wchar_t *filename, int oflag, int pmode)
{
HANDLE hFile;
DWORD dwAccess = 0;
DWORD dwCreate = OPEN_EXISTING;
DWORD dwShare = 0;
pmode = 0; // unused
if(oflag & O_RDONLY) {
dwAccess |= GENERIC_READ;
dwShare = FILE_SHARE_READ;
}
if(oflag & O_WRONLY)
dwAccess |= GENERIC_WRITE;
if(oflag & O_CREAT)
dwCreate = OPEN_ALWAYS;
if(oflag & O_TRUNC)
dwCreate = CREATE_ALWAYS;
hFile = CreateFile(filename, dwAccess, dwShare, NULL, dwCreate,
FILE_ATTRIBUTE_NORMAL, NULL);
if(hFile == INVALID_HANDLE_VALUE)
return -1;
return (int)hFile;
}
Original comment by gilbert....@gmail.com
on 21 May 2009 at 4:11
May I request to fix couple of things and re-send the path, please? Things to
fix:
1. Identation - please follow the style like the rest of the code
2. Remove compiler warnings when building under Win32, like DeleteFile warning.
Thank you!
Original comment by valenok
on 22 May 2009 at 11:57
OK, here is the well-formatted patch.
I still have some concerns about the following:
* The date_to_epoch() function does not account for timezone. I'm not sure
that this
causes any problems.
* Windows CE has no equivalent to SignalObjectAndWait that I could find. I
replaced
the call with a SetEvent call for Windows CE, but I am not sure that it is
enough.
Original comment by gilbert....@gmail.com
on 23 May 2009 at 7:33
Attachments:
Brilliant, thank you.
I am trying to set up WinCE environment on my WinXP box.
If I do not manage to do it fast, I may take an iterative approach - I will
roll out
your patch with my changes (I will try to minimize the use of conditionals,
etc).
Then, if it accidentally breaks WinCE functionality, I request another patch
from you
- which will be considerably smaller.
Original comment by valenok
on 23 May 2009 at 5:43
I have installed Microsoft eMbedded Visual C++ 4.0
It smells very much like good old Visual Studio 6, and it seems to lack C99
features.
Am I using the right thing?
Original comment by valenok
on 23 May 2009 at 8:20
I use Microsoft Visual Studio 2005 Standard Edition and compile for the Pocket
PC
2003 platform. It has a better emulator than EVC4 and unlike VS2008 does not
require
the Professional version to build for smart devices.
The eMbedded Visual C++ 4.0 (EVC4) will also work; it is older, but it is free.
It
is best to install the latest Service Pack (SP4) when using EVC4, and you should
install the Pocket PC 2003 SDK.
Original comment by gilbert....@gmail.com
on 24 May 2009 at 2:17
Going iterative path.
Submitted change http://code.google.com/p/mongoose/source/detail?r=381
o renamed all mgce_* functions to appropriate mg_* function, to avoid unnecessary
conditionals
o in some functions (start_thread(), pthread_mutex_wait()) adopted Win32 and WinCE
code to be WinCE friendly
o removed mgce_gmtime(), changed to localtime .. wonder if it was correct.
I think we should get rid of other WinCE conditionals around "struct tm" by
switching
the rest of the code to using WinCE way for printing time. Maybe print_time()
function must be introduced that does that.
Please sync and send another patch if I broke something (I am sure I did).
Original comment by valenok
on 24 May 2009 at 7:54
Here are changes to make it compile and run again.
The challenges faced to compile in CE vs Windows:
- The only available Windows APIs are Unicode versions. There are a few exceptions,
like GetProcAddressA().
- Parts of the standard C runtime library are not implemented. Like these functions:
_open, _close, _write, _read, _lseek, time, mktime, strerror, _rename, _access,
strftime. Also there is no errno variable.
- There is no current directory, access to all data files is absolute.
The changes made in this patch:
- Functions that are replacements for missing C runtime functions are renamed ce_*
instead of mg_*. This is mostly due to a name conflict between mg_write and the
now
ce_write.
- There is now a bunch of fix-up defines for CE that map the standard C runtime
functions to the ce_* version.
- The ce_localtime function has a different signature the the standard localtime
function--this change allows the ce_localtime to be thread-safe without using
thread-local variables. The code using localtime is now ifdef'ed to allow for
the
difference.
- The function ce_gmtime was reintroduced. The strftime function does not exist in
CE. To simplify its replacement sprintf is used. Time zone information is not
in the
tm struct, so instead the timezone is hard coded to GMT and ce_gmtime is used.
- A missing semi-colon was fixed.
A print_time() function would be a good idea. I did not implement it here. The
buffer that is used for print_time should not be a 'static' buffer to improve
thread-safety. The buffer should either be passed in, or thread-local storage
would
be needed.
Original comment by gilbert....@gmail.com
on 10 Jun 2009 at 5:39
Attachments:
Thanks! I have very little time these days to work on Mongoose; I will get back
to
your patch when I have a time span large enough to devour it.
Original comment by valenok
on 28 Jun 2009 at 8:55
Thanks!
I don't like ce_* defines, so I got rid of them.
Also, I refactored the code to use FILE * instead of file descriptors.
See http://code.google.com/p/mongoose/source/detail?r=438
It looks like that the only thing that is missing is strftime(). I've added a
stub.
Please verify the build.
Original comment by valenok
on 5 Jul 2009 at 9:45
Would you be willing to change the calls to localtime() to localtime_r()? This
would
simplify coding it for CE in a thread safe way. Also, localtime() may not be
thread
safe on some environments.
Original comment by gilbert....@gmail.com
on 15 Sep 2009 at 10:20
Yeah, makes sense. I'll look into that.
Original comment by valenok
on 16 Sep 2009 at 8:28
Alright, here is another pass:
- Implemented strftime().
- Changed all calls to localtime() to localtime_r() for thread safety.
- Added CE implementation of dlsym(), CE uses wide chars for name.
- Replaced strtoull() define for strtoll(), for both Windows and CE.
- Fixed INT64_FMT format for both Windows and CE.
- CE lacks strtoi64() defined strtoll() to strtol()
- Found that all HTTP headers should be using GMT per RFC.
See: http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1
Causing the following changes:
- Reintroduced gmtime(), but this time as gmtime_r()
- date_to_epoch() does not need to determine DST
- date_to_epoch() cannot use mktime() because it is only for local time, it has
been changed to fill-in and return a struct tm.
- commpare_tm() added because of lack of mktime() for GMT.
- mktime() for CE removed, as it is unused now.
- send_file() uses "GMT" instead of "%Z" in date formatting
- send_file() uses gmtime_r() instead of localtime()
Original comment by gilbert....@gmail.com
on 17 Sep 2009 at 4:53
Attachments:
Closing this until someone with WinCE environment want to revive it.
Original comment by valenok
on 20 Sep 2010 at 9:52
Original issue reported on code.google.com by
gilbert....@gmail.com
on 21 May 2009 at 6:45Attachments: