lwip socket errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


Hi All,

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?

I will ask upstream to see what they have to say on the issue as well.

Thanks
Will

--
------------------------------------------------------------------------
Will Wagner                                     will_wagner@xxxxxxxxxxxx
Development Manager                      Office Tel: +44 (0)20 7371 2032
Carallon Ltd, Studio G20, Shepherds Building, Rockley Rd, London W14 0DA
------------------------------------------------------------------------

>From 106c473a344b78de23a67b749f218911006577ab Mon Sep 17 00:00:00 2001
From: Will Wagner <willw@xxxxxxxxxxxx>
Date: Fri, 18 Feb 2011 09:44:57 +0000
Subject: [PATCH] ensure that if error support is enabled, errno gets set on error in lwip

---
 packages/net/lwip_tcpip/current/cdl/lwip_net.cdl  |    2 +-
 packages/net/lwip_tcpip/current/src/api/sockets.c |    1 +
 2 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/packages/net/lwip_tcpip/current/cdl/lwip_net.cdl b/packages/net/lwip_tcpip/current/cdl/lwip_net.cdl
index 900ff1f..3f1b71b 100644
--- a/packages/net/lwip_tcpip/current/cdl/lwip_net.cdl
+++ b/packages/net/lwip_tcpip/current/cdl/lwip_net.cdl
@@ -1909,7 +1909,7 @@ cdl_package CYGPKG_NET_LWIP {
             display         "Additional compiler flags"
             flavor          data
             no_define
-            default_value   { "" }
+            default_value   { CYGPKG_ERROR_ERRNO ? "-DERRNO" : "" }
             description     "
                 This option modifies the set of compiler flags for building the
                 lwIP package. These flags are used in addition to the set of
diff --git a/packages/net/lwip_tcpip/current/src/api/sockets.c b/packages/net/lwip_tcpip/current/src/api/sockets.c
index 59d5a7a..e25bb92 100644
--- a/packages/net/lwip_tcpip/current/src/api/sockets.c
+++ b/packages/net/lwip_tcpip/current/src/api/sockets.c
@@ -150,6 +150,7 @@ static const int err_to_errno_table[] = {
     err_to_errno_table[-(err)] : EIO)
 
 #ifdef ERRNO
+#include <errno.h>
 #ifndef set_errno
 #define set_errno(err) errno = (err)
 #endif
-- 
1.7.2.3


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

[Search]     [Linux Embedded]     [U-Boot V2]     [Linux Kernel]     [Linux MIPS]     [Linux ARM]     [Linux for the Blind]     [Linux Resources]     [Photo]     [Yosemite]     [ISDN Cause Codes]     [ECOS Home]     [Site Home]

Add to Google Powered by Linux