I've been testing curl on Windows Phone a bit, using the Metro app style (i.e. non-Silverlight). Of course, that required some changes to curl code.
A first step was to replace some (more precisely: three) old APIs that are not supported for Windows Phone by more "modern", extended APIs (patch attached). Unless you need to support very old compilers or windows versions (which would required some #ifdefs), that should be an uncontroversial change.
A second, more controversial step was to add a "thread emulation" layer and include it from connect.c and select.c via a suitable #ifdef. IIRC, I took that from http://blogs.msdn.com/b/shawnhar/archive/2012/03/12/createthread-for-windows-8-metro.aspx. This "translates" the win32 thread API used by cURL to the new Metro-style thread pool API. While that was fine for my own use, I doubt it's a generally acceptable method for porting libraries, especially, if each library adds its own copy of that code. So I don't really know what to suggest here.
Thanks, it'd be great if you could take this discussion (and patches) to the curl-library mailing list, as that's where most libcurl hackers hang out.
Unfortunately, for InitializeCriticalSectionEx and GetTickCount64, Windows XP and Server 2003 are "very old Windows versions".
Unfortunately, I'm already subscribed to more mailing lists than I can reasonably handle, so subscribing to one more for just this discussion is something I'd rather avoid.
Well, one is out of support, the other is having just half a year of ongoing support, so IMO that is "very old". But adding something like e.g.
#if (WINVER < 0x0600)
#define ULONGLONG DWORD
#define GetTickCount64 GetTickCount
#endif
wouldn't be much of a problem, would it?
Last edit: Stefan Neis 2014-11-11
I've been meaning to take a look at building curl for Windows Phone 8 for a while now so this is a welcomed feature from my point of view. Especially as I've not built anything for my Lumia 820 in the two years of owning it and only touched Windows Phone 7 briefly a few years ago (never releasing the app I wrote).
Support for an OS from Microsoft and what we support are two completely different things unfortunately (unless we want to revise this??). You'll note from our download page that we offer Windows 2000/XP specific compilations as well as Generic Windows builds.
From a code point of view we have code in libcurl that detects NT 4.0 and Windows 95 at runtime (for example when loading the Security DLL).
I have personally added code into libcurl that has the following around it:
I would recommend using that or even:
...either of which are in keeping with code elsewhere in libcurl.
I will take a look at the patch in more detail later this evening but that's my thoughts for now ;-)
Hi Stefan,
As you've not signed up to the mailing list I've attached my proposed changes here.
If you could take a look at them that would be great.
Hi Steve,
Looks good to me, although, generally speaking I'm a big fan of using just one API in the code and if necessary, define platform specific "replacements" at the beginning of the file or in an include or some other appropriate place, rather than using #ifdef's ll over the code. With just one occurence of those APIs however, this is only a matter of personal preferences, anyway
[i.e., personally, instead of writing
#if !defined(_WIN32_WINNT) || !defined(_WIN32_WINNT_VISTA) || \
(_WIN32_WINNT < _WIN32_WINNT_VISTA)
int ret = (WaitForSingleObject(hnd, INFINITE) == WAIT_OBJECT_0);
#else
int ret = (WaitForSingleObjectEx(hnd, INFINITE, FALSE) == WAIT_OBJECT_0);
#endif
I'd just write
int ret = (WaitForSingleObjectEx(*hnd, INFINITE, FALSE) == WAIT_OBJECT_0);
and then find some suitable place to add
#if !defined(_WIN32_WINNT) || !defined(_WIN32_WINNT_VISTA) || \
(_WIN32_WINNT < _WIN32_WINNT_VISTA)
#define WaitForSingleObjectEx(a,b,c) WaitForSingleObject(a,b)
#endif
or even vice versa, use WaitForSingelObject in the code and define it
to WaitForSingleObjectEx for Windows version that are "too new".
]
Anyway, coming back to my original post, this is more or less cosmetic, the interesting question (IMO) is, what to do about the threading stuff...
I am looking into getting libcurl working on WP8 as well. How did you compile the library for the ARM/WP8 target? Did you create a new VS solution or modify the makefile? Could you post those files?