curl-library
Re: Using libcurl on top of lwip on POSIX embedded platform (take 2)
Date: Thu, 15 Mar 2012 22:46:28 +0100 (CET)
On Thu, 15 Mar 2012, Mason wrote:
> I have almost (I hope!) succeeded in generating libcurl on top of lwip for a
> (mostly) POSIX sh-superh-elf platform.
Nice!
> As far as I can tell, in libcurl, fcntl is only called on sockets (in
> nonblock.c). Therefore I think it should be possible to have libcurl call
> lwip_fcntl instead of fcntl when lwip is used.
> Proposed patch (general, untested, idea)
> +#ifdef USE_LWIPSOCK
> +#define fcntl lwip_fcntl
> +#endif
Seems fine. Possibly you can move that to setup_once.h where you do the
sclose() definition so that the lwip specific defines are made at a single
spot in the code.
If I understand you correctly, you'd then be down to only need to simple
defines done to build properly with lwip?
> For close, the solution is not so clear-cut, because curl deals with regular
> files as well as sockets, AFAIU.
Sure, but you're in luck here since for example Windows (and some others)
already require a separate close for sockets so the sclose() macro is used all
over internally when closing sockets. close() is only ever done on non-sockets
file descriptors.
> --- setup_once.h.orig 2011-11-04 23:32:57.000000000 +0100
> +++ setup_once.h 2012-03-15 13:49:19.875000000 +0100
> @@ -239,6 +239,8 @@
> # define sclose(x) closesocket((x))
> #elif defined(HAVE_CLOSESOCKET_CAMEL)
> # define sclose(x) CloseSocket((x))
> +#elif defined(USE_LWIPSOCK)
> +# define sclose(x) lwip_close((x))
> #else
> # define sclose(x) close((x))
> #endif
looks simple and clean enough!
-- / daniel.haxx.se ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.htmlReceived on 2012-03-15