avr-gcc-list
[Top][All Lists]
Advanced

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

[avr-gcc-list] libc/fdevopen/calloc/malloc (was gcc-3.4.2 bin for win xp


From: Bernard Fouché
Subject: [avr-gcc-list] libc/fdevopen/calloc/malloc (was gcc-3.4.2 bin for win xp?)
Date: Mon, 8 Nov 2004 15:29:45 +0100

I fixed the problem I had between Linux avr-gcc 3.4.2 and WinXP WinAVR
avr-gcc 3.4.1.

The problem was that I did not copy on XP a modified version of libc I made
once on Linux because of the fdevopen/calloc/malloc problem.

This problem is a memory footprint problem: when you use fdevopen, then you
bring in the code for calloc/malloc and this code will also eat some RAM.
You bring fdevopen as soon as you need stdin/out/err since the FILE memory
reservation is made in fopendev and that this function is the 'official' way
of getting access to stdio.

For those interested, my modification is the following:

- Drop fdevopen from libc. Link the library without this function.
- add a small C file in your application that:

        - will include stdio_private.h
        - will define FILE * __iob[3] (done in fdevopen that you dropped)
        - will use __iob[3] for your own file descriptors not to waste RAM with
other FILE struct.
        - I just print with stdio, I don't use for instance fgetc() so I init 
each
__iob[] this way:

                - (file_descriptor)->put=<my putc function>;
                - (file_descriptor)->_flags|=__SWR;

It would be cool to have access to this possibility in avr-libc-1.0.5
without having to modify the libc itself. It seems that the changes should
be:

- have 'FILE *__iob[3];' in a separate C file with a particular function
name, so one can replace the function and manage the memory reservation as
wanted. So fdevopen could use it if the programmer does not define it
somewhere else or the linker won't call it if it is not needed.

- Have something like fdevopenlight() (!) that works like fdevopen but
without calls to calloc/malloc. The programmer would give a pointer to a
__iob to setup. This function would not automagically assign stdout, stdin
and stderr, so you don't have to pay for 3 _iob when you need only one.

This way one can still use fdevopen like now, or have a way to spare flash
and ram.

  Bernard
-----Message d'origine-----
De : address@hidden
[mailto:address@hidden la part de Anton Erasmus
Envoyé : vendredi 5 novembre 2004 19:51
À : address@hidden
Objet : RE: [avr-gcc-list] gcc-3.4.2 bin for win xp?


On 5 Nov 2004 at 9:49, Bernard Fouché wrote:

> I'm compiling on Linux at the office on 3.4.2. Since I need to do test
> fields, I move with a laptop on XP and I sometimes need to recompile
> on the move. I also sometimes compile at home also with XP....
>
> Cygwin seems a good choice. Is WinAVR compiled with this environment?

AFAIK WinAVR is compiled using the mingw environment. One does not need
cygwin
to run the WinAVR compiler. If you compile under cygwin, then your whole
environment
is much more like the normal linux (console) environment. You also then run
avr-gcc in
the cygwin environment. (Normally a bash shell)
Just install cygwin. Copy the sources you used to compile avr-gcc under
linux. compile
as normal and use the same as under linux.

Regards
   Anton Erasmus

> -----Message d'origine-----
> De : Anton Erasmus [mailto:address@hidden
> Envoyé : jeudi 4 novembre 2004 22:12
> À : Bernard Fouché
> Objet : Re: [avr-gcc-list] gcc-3.4.2 bin for win xp?
>
>
> On 4 Nov 2004 at 18:48, Bernard Fouché wrote:
>
> > I'm using gcc-3.4.2 on Linux and WinAVR with gcc-3.4.1 on XP. I ran
> > into a very strange problem yesterday: code compiled on Linux would
> > work, same source code compiled on XP was not working on the same
> > target. No compilation error, same Makefile. I flashed on XP with
> > avrdude and uisp without success to discard problems I had once on
> > XP with avrdude, so it could be a difference in the compilation
> > environment. I'd like to stay on 3.4.2 on Linux.
> >
> > Since I've no C compiler on XP to regenerate all the stuff, is there
> > some place where I can get gcc-3.4.2 already compiled? Or is an
> > updated WinAVR coming soon?
>
> I do not understand. You already have 3.4.2 on Linux, and you say
> you'd like to stay on Linux. So what is the problem ? If you want
> 3.4.2 under XP, then the easiest is probalby to compile from source
> under cygwin. Alternatively you can crosscompile using a Linux to
> mingw crosscompiler under Linux.
>
> Regards
>    Anton Erasmus
> --
> A J Erasmus
>

--
A J Erasmus


_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list



reply via email to

[Prev in Thread] Current Thread [Next in Thread]