bugAVR C Runtime Library - Bugs: bug #23783, Putchar/getchar use causes code...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #23783: Putchar/getchar use causes code growth

Submitter:  Wouter <wutje>
Submitted:  Sun 06 Jul 2008 12:27:47 PM UTC
   
 
Category:  Feature Request Severity:  2 - Minor
Priority:  4 Item Group:  libc code
Status:  Works For Me Assigned to:  None
Percent Complete:  0% Open/Closed:  Closed
Release:  Any Fixed Release:  None

Thu 12 May 2011 03:13:53 AM UTC, comment #2: 

Closing for lack of feedback.

Eric Weddington <arcanum>
Group administrator
Tue 22 Feb 2011 10:09:22 PM UTC, comment #1: 

I did some experiments and I don't see how this actually saves any code size.

Could you attach some sample compilable code that shows how your proposal works?

Eric Weddington <arcanum>
Group administrator
Sun 06 Jul 2008 12:27:47 PM UTC, original submission:  

Currently putchar is defined as
#define putchar(__c)   fputc(__c, stdout)

which causes C code like this:
putchar(' ')

To generate assembler like this:
lds r22,__iob+2
lds r23,(__iob+2)+1
ldi r24,lo8(32)
ldi r25,hi8(32)
call fputc

This is 8 bytes (lds == 4 bytes) for loading the stream pointer.
If we change this to a "real" putchar call we would save 8 bytes per putchar call. the putchar call would then load the correct stream:

int putchar(int c)
{
return fputc(stdout, c);
}

Since most of libc's user go for size instead of speed this change seems acceptable. The users who want faster access can still create there own routines todo as it is done currently.

Wouter <wutje>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by arcanum (Updated the item)
  • -email is unavailable- added by wutje (Submitted the item)
  •  

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-05-12 arcanum StatusNeed Info Works For Me
        Open/ClosedOpen Closed
    2011-02-22 arcanum Priority3 - Low 4
        StatusNone Need Info
    2008-08-11 arcanum Severity3 - Normal 2 - Minor
        Priority5 - Normal 3 - Low
    2008-07-18 arcanum CategoryNone Feature Request

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code