On 18/02/2011 20:41, John Dallaway wrote:
Hi Will
William Wagner wrote:
Been looking at getting lwip to set errno when errors occur and am
struggling a bit. The problem is in
packages\net\lwip_tcpip\current\src\api\sockets.c:152
To get it so that errno is set with the macro set_errno you must have
ERRNO defined. I have changed the cdl so that this is set. However you
then get a compilation error as errno is undefined. Attached is my
proposed patch to fix the issue. I realise this is a change to lwip code
which is best avoided but I can't see any other way of making it work.
Opinions?
According to the lwIP documentation file doc/sys_arch.txt, the file
include/arch/cc.h "must either include a system-local<errno.h> which
defines the standard *nix error codes, or it should #define
LWIP_PROVIDE_ERRNO to make lwip/arch.h define the codes which are used
throughout".
Try including errno.h from the file include/arch/cc.h and let us know if
it helps...
I have tried the below patch instead and this seems to work. I tried
just making it include cyg/error/errno.h but was running into compile
errors where the #define errno (*cyg_error_get_errno_p()) in errno.h was
meaning that subsequent uses of #include <errno.h> lead to compiler
errors saying (*cyg_error_get_errno_p()).h could not be found. I'm no
expert on preprocessor rules but I wonder if that is a compiler bug.
Either way changing cc.h to include errno.h rather than
cyg/error/errno.h fixed the issue for me. I have then tried to make it
cope when your config doesn't have isoinfra.
--- a/packages/net/lwip_tcpip/current/include/arch/cc.h
+++ b/packages/net/lwip_tcpip/current/include/arch/cc.h
@@ -34,7 +34,13 @@
#define __LWIP_ARCH_CC_H__
#include<string.h>
+#include<pkgconf/isoinfra.h> /* Configuration header */
+#ifndef CYGINT_ISO_ERRNO
#include<cyg/error/codes.h>
+#include<cyg/error/errno.h>
+#else
+#include<errno.h>
+#endif
#include<cyg/infra/cyg_type.h>
typedef int sys_prot_t;
@@ -47,6 +53,11 @@ typedef int sys_prot_t;
#define ETIME 62
#define ENSRNOTFOUND 163
+// If errno support, define ERRNO used in api/sockets.c
+#ifdef CYGPKG_ERROR_ERRNO
+#define ERRNO
+#endif
+
// Platform byteorder
#if (CYG_BYTEORDER == CYG_LSBFIRST)
#define BYTE_ORDER LITTLE_ENDIAN
John Dallaway
eCos maintainer
http://www.dallaway.org.uk/john
--
------------------------------------------------------------------------
Will Wagner will_wag...@carallon.com
Development Manager Office Tel: +44 (0)20 7371 2032
Carallon Ltd, Studio G20, Shepherds Building, Rockley Rd, London W14 0DA
------------------------------------------------------------------------
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss