public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] include file incompatibilities...
@ 2002-06-07  9:35 Andrew Lunn
  2002-06-07 10:08 ` Andrew Lunn
  2002-06-07 10:28 ` Gary Thomas
  0 siblings, 2 replies; 4+ messages in thread
From: Andrew Lunn @ 2002-06-07  9:35 UTC (permalink / raw)
  To: eCos Disuss

I just found a problem compiling anoncvs for ebsa with the new_net
template.



arm-elf-gcc -c  -I/export/home/lunn/ecos-work-uts/install/include -I/usr/local/pkg/plcuts/ecoscvs/packages/net/common/current -I/usr/local/pkg/plcuts/ecoscvs/packages/net/common/current/src -I/usr/local/pkg/plcuts/ecoscvs/packages/net/common/current/tests -I. -I/usr/local/pkg/plcuts/ecoscvs/packages/net/common/current/src/ -mcpu=strongarm -Wall -Wpointer-arith -Wstrict-prototypes -Winline -Wundef -Woverloaded-virtual -g -O2 -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -fvtable-gc -finit-priority -D_KERNEL -D__ECOS -D__INSIDE_NET -Wp,-MD,src/inet_ntop.tmp -o src/net_common_inet_ntop.o /usr/local/pkg/plcuts/ecoscvs/packages/net/common/current/src/inet_ntop.c
In file included from /export/home/lunn/ecos-work-uts/install/include/stdio.h:74,
                 from /usr/local/pkg/plcuts/ecoscvs/packages/net/common/current/src/inet_ntop.c:48:
/export/home/lunn/ecos-work-uts/install/include/cyg/libc/stdio/stdio.h:274: `diag_printf' is an unrecognized format function type
/export/home/lunn/ecos-work-uts/install/include/cyg/libc/stdio/stdio.h:278: `diag_printf' is an unrecognized format function type
make: *** [src/inet_ntop.o.d] Error 1

The problem is that inet_ntop.c include sys/param.h. That has 

// Function mapping
#define printf     diag_printf
#define snprintf   diag_snprintf

later on inet_ntop.c include stdio.h, which has 

// Other non-ISO C functions

externC int
fnprintf( FILE * /* stream */, size_t /* length */,
          const char * /* format */, ... ) CYGBLD_ATTRIB_PRINTF_FORMAT(3, 4);

externC int
snprintf( char * /* str */, size_t /* length */, const char * /* format */,
          ... ) CYGBLD_ATTRIB_PRINTF_FORMAT(3, 4);

Now cyg/infra/cyg_type.h defines

// Teach compiler how to check format of printf-like functions
# define CYGBLD_ATTRIB_PRINTF_FORMAT(__format__, __args__) \
        __attribute__((format (printf, __format__, __args__)))

CPP is changing the printf above into a diag_print because of the
#define in sys/param.h.

Anybody have some goods on how to fix this? I don't like these
#defines in sys/param.h.

         Andrew

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

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

* Re: [ECOS] include file incompatibilities...
  2002-06-07  9:35 [ECOS] include file incompatibilities Andrew Lunn
@ 2002-06-07 10:08 ` Andrew Lunn
  2002-06-07 10:28 ` Gary Thomas
  1 sibling, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2002-06-07 10:08 UTC (permalink / raw)
  To: eCos Disuss

Hi again

It turned out to be easier to fix than i though. Please can you take a
look at this and if you think its OK check it in. Basically, the
FreeBSD stack has its own snprintf which we can use instead of stdio's.


Index: net/common/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/common/current/ChangeLog,v
retrieving revision 1.5
diff -u -5 -p -c -r1.5 ChangeLog
cvs server: conflicting specifications of output style
*** net/common/current/ChangeLog        5 Jun 2002 13:16:26 -0000       1.5
--- net/common/current/ChangeLog        7 Jun 2002 17:06:55 -0000
***************
*** 1,5 ****
--- 1,10 ----
+ 2002-06-07  Andrew Lunn  <Andrew.Lunn@ascom.ch>
+ 
+       * src/inet_ntop.c: Fixed FreeBSD stack and stdio incompatibility
+       by not using stdio when using FreeBSD.
+ 
  2002-06-05  Gary Thomas  <gary@chez-thomas.org>
  
        * src/dhcp_prot.c (_dhcp_copy): New function used to better handle
        replies that can be variable length.
  
Index: net/common/current/src/inet_ntop.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/common/current/src/inet_ntop.c,v
retrieving revision 1.1
diff -u -5 -p -c -r1.1 inet_ntop.c
cvs server: conflicting specifications of output style
*** net/common/current/src/inet_ntop.c  20 May 2002 22:25:05 -0000      1.1
--- net/common/current/src/inet_ntop.c  7 Jun 2002 17:06:55 -0000
***************
*** 43,53 ****
--- 43,55 ----
  #include <netinet/in.h>
  #include <arpa/inet.h>
  #include <arpa/nameser.h>
  #include <string.h>
  #include <errno.h>
+ #ifndef CYGPKG_NET_FREEBSD_STACK
  #include <stdio.h>
+ #endif
  
  #ifndef IN6ADDRSZ
  #define IN6ADDRSZ    16      /* IPv6 T_AAAA */
  #endif
  #ifndef INT16SZ
*************** inet_ntop4(src, dst, size)
*** 146,156 ****
        size_t size;
  {
        static const char fmt[] = "%u.%u.%u.%u";
        char tmp[sizeof "255.255.255.255"];
  
!       if (sprintf(tmp, fmt, src[0], src[1], src[2], src[3]) > size) {
                errno = ENOSPC;
                return (NULL);
        }
        strcpy(dst, tmp);
        return (dst);
--- 148,158 ----
        size_t size;
  {
        static const char fmt[] = "%u.%u.%u.%u";
        char tmp[sizeof "255.255.255.255"];
  
!       if (snprintf(tmp, sizeof(tmp), fmt, src[0], src[1], src[2], src[3]) > size) {
                errno = ENOSPC;
                return (NULL);
        }
        strcpy(dst, tmp);
        return (dst);

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

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

* Re: [ECOS] include file incompatibilities...
  2002-06-07  9:35 [ECOS] include file incompatibilities Andrew Lunn
  2002-06-07 10:08 ` Andrew Lunn
@ 2002-06-07 10:28 ` Gary Thomas
  2002-06-07 10:31   ` Andrew Lunn
  1 sibling, 1 reply; 4+ messages in thread
From: Gary Thomas @ 2002-06-07 10:28 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: eCos Disuss

On Fri, 2002-06-07 at 10:34, Andrew Lunn wrote:
> I just found a problem compiling anoncvs for ebsa with the new_net
> template.
> 
> 
> 
> arm-elf-gcc -c  -I/export/home/lunn/ecos-work-uts/install/include -I/usr/local/pkg/plcuts/ecoscvs/packages/net/common/current -I/usr/local/pkg/plcuts/ecoscvs/packages/net/common/current/src -I/usr/local/pkg/plcuts/ecoscvs/packages/net/common/current/tests -I. -I/usr/local/pkg/plcuts/ecoscvs/packages/net/common/current/src/ -mcpu=strongarm -Wall -Wpointer-arith -Wstrict-prototypes -Winline -Wundef -Woverloaded-virtual -g -O2 -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -fvtable-gc -finit-priority -D_KERNEL -D__ECOS -D__INSIDE_NET -Wp,-MD,src/inet_ntop.tmp -o src/net_common_inet_ntop.o /usr/local/pkg/plcuts/ecoscvs/packages/net/common/current/src/inet_ntop.c
> In file included from /export/home/lunn/ecos-work-uts/install/include/stdio.h:74,
>                  from /usr/local/pkg/plcuts/ecoscvs/packages/net/common/current/src/inet_ntop.c:48:
> /export/home/lunn/ecos-work-uts/install/include/cyg/libc/stdio/stdio.h:274: `diag_printf' is an unrecognized format function type
> /export/home/lunn/ecos-work-uts/install/include/cyg/libc/stdio/stdio.h:278: `diag_printf' is an unrecognized format function type
> make: *** [src/inet_ntop.o.d] Error 1
> 

What compiler is giving you these errors (version)?

> The problem is that inet_ntop.c include sys/param.h. That has 
> 
> // Function mapping
> #define printf     diag_printf
> #define snprintf   diag_snprintf
> 
> later on inet_ntop.c include stdio.h, which has 
> 
> // Other non-ISO C functions
> 
> externC int
> fnprintf( FILE * /* stream */, size_t /* length */,
>           const char * /* format */, ... ) CYGBLD_ATTRIB_PRINTF_FORMAT(3, 4);
> 
> externC int
> snprintf( char * /* str */, size_t /* length */, const char * /* format */,
>           ... ) CYGBLD_ATTRIB_PRINTF_FORMAT(3, 4);
> 
> Now cyg/infra/cyg_type.h defines
> 
> // Teach compiler how to check format of printf-like functions
> # define CYGBLD_ATTRIB_PRINTF_FORMAT(__format__, __args__) \
>         __attribute__((format (printf, __format__, __args__)))
> 
> CPP is changing the printf above into a diag_print because of the
> #define in sys/param.h.
> 
> Anybody have some goods on how to fix this? I don't like these
> #defines in sys/param.h.

They're there to minimize the changes from the imported stack, 
so we don't have any dependencies on libc and such.

Wouldn't it just work to not include <stdio.h>?


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

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

* Re: [ECOS] include file incompatibilities...
  2002-06-07 10:28 ` Gary Thomas
@ 2002-06-07 10:31   ` Andrew Lunn
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2002-06-07 10:31 UTC (permalink / raw)
  To: Gary Thomas; +Cc: eCos Disuss

On Fri, Jun 07, 2002 at 11:28:42AM -0600, Gary Thomas wrote:
> What compiler is giving you these errors (version)?

arm-elf-gcc -v
Reading specs from /usr/local/pkg/plcuts/H686-arm-elf-1.5.2/lib/gcc-lib/arm-elf/2.9-ecos-99r1-001005/specs
gcc version 2.9-ecos-99r1-001005

> Wouldn't it just work to not include <stdio.h>?

You then get warnings.... See my patch :-)

    Andrew 

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

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

end of thread, other threads:[~2002-06-07 17:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-07  9:35 [ECOS] include file incompatibilities Andrew Lunn
2002-06-07 10:08 ` Andrew Lunn
2002-06-07 10:28 ` Gary Thomas
2002-06-07 10:31   ` Andrew Lunn

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