public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] lwip socket errors
@ 2011-02-18 17:26 William Wagner
  2011-02-18 20:41 ` [ECOS] " John Dallaway
  0 siblings, 1 reply; 3+ messages in thread
From: William Wagner @ 2011-02-18 17:26 UTC (permalink / raw)
  To: ecos-discuss

[-- Attachment #1: Type: text/plain, Size: 992 bytes --]

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@carallon.com
Development Manager                      Office Tel: +44 (0)20 7371 2032
Carallon Ltd, Studio G20, Shepherds Building, Rockley Rd, London W14 0DA
------------------------------------------------------------------------


[-- Attachment #2: ecos-106c473a344b78de23a67b749f218911006577ab.patch --]
[-- Type: text/plain, Size: 1602 bytes --]

From 106c473a344b78de23a67b749f218911006577ab Mon Sep 17 00:00:00 2001
From: Will Wagner <willw@carallon.com>
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



[-- Attachment #3: Type: text/plain, Size: 148 bytes --]

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ECOS] Re: lwip socket errors
  2011-02-18 17:26 [ECOS] lwip socket errors William Wagner
@ 2011-02-18 20:41 ` John Dallaway
  2011-02-23 13:40   ` William Wagner
  0 siblings, 1 reply; 3+ messages in thread
From: John Dallaway @ 2011-02-18 20:41 UTC (permalink / raw)
  To: William Wagner; +Cc: ecos-discuss

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...

John Dallaway
eCos maintainer
http://www.dallaway.org.uk/john

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [ECOS] Re: lwip socket errors
  2011-02-18 20:41 ` [ECOS] " John Dallaway
@ 2011-02-23 13:40   ` William Wagner
  0 siblings, 0 replies; 3+ messages in thread
From: William Wagner @ 2011-02-23 13:40 UTC (permalink / raw)
  To: John Dallaway; +Cc: ecos-discuss

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_wagner@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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-02-23 13:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-18 17:26 [ECOS] lwip socket errors William Wagner
2011-02-18 20:41 ` [ECOS] " John Dallaway
2011-02-23 13:40   ` William Wagner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).