This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Free BSD ioctl problem (Renesas EDOSK2674)


On Sat, Jun 05, 2004 at 10:49:12AM +0200, Uwe Kindler wrote:
> Hello Andrew,
> 
> > > ...
> > >        hw_addr: ff:ff:ff:ff:ff:ff
> >                   ^^^^^^^^^^^^^^^^^
> >
> > You should probably take a look at this. Using the broadcast address
> > is not good.
> >
> >         Andrew
> >
> 
> you should propably read my complete posting ;o) 

Actually i did read the complist posting, but i did not have time to
look at the IOCTL issue. I did notice that the MAC addresses was wrong
and assumed that was a seperate problem. I assumed your problem was
with the ioctl error:

SIOCIFADDR: Operation not supported.

I had failed to put 2 and 2 together in that the MAC address itself is
retrived with an ioctl call....

- i wrote the problem is
> the ioctl function. But I will try to explain it more clear:

I would like to complement you on the quality of your bug report. I
get fed up of emails saying that my program crashes, please tell me
what i am doing wrong. Its great to see this much detail and people on
this list are much more likely to help you when you give some real
details to work from.

So the problem boils down to that the caller is using a different
calling convention than the callee. This is a result of the function
declaration being different than the definition.

[snip]


> Changed function declaration:
> 
> int ioctl __P((int, unsigned long, unsigned long));

This fixes your problem, but unfortunetly, its not the correct
solution. The relevant part of the POSIX standard is:

http://www.opengroup.org/onlinepubs/009695399/toc.htm

NAME

    ioctl - control a STREAMS device (STREAMS)

SYNOPSIS

    [XSR] #include <stropts.h>

    int ioctl(int fildes, int request, ... /* arg */);

So in fact ... is correct, and making the 3rd argument an unsigned
long is wrong.

> So I repeat my question: Why differs the function declaration from function
> definition and what should I do in order to fix this problem?

What should you do to fix the problem?

Thats an interesting question....

http://www.gnu.org/software/libc/manual/html_node/Why-Variadic.html#Why%20Variadic

The last paragraph says:

        Some functions such as open take a fixed set of arguments, but
        occasionally ignore the last few. Strict adherence to ISO C
        requires these functions to be defined as variadic; in
        practice, however, the GNU C compiler and most other C
        compilers let you define such a function to take a fixed set
        of arguments--the most it can ever use--and then only declare
        the function as variadic (or not declare its arguments at
        all!).

That describes what is going on here. ioctl is defined to take three
parameters, the maximum it uses and the declaration is variadic.

So i would say you have a compiler bug. The fact that this code works
correctly on i386, mips, ppc, arm etc, also suggests its an H8S
compiler bug. 

I suggest you make a simple example program that demostrats the bug
and post a bug report to the gcc mailing list and maybe the gnuh8
list.

I hope this helps,

          Andrew

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]