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

 
 

bug #23783: Putchar/getchar use causes code growth

Submitted by:  Wouter <wutje>
Submitted on:  Sun 06 Jul 2008 12:27:47 PM UTC  
 
Category: Feature RequestSeverity: 2 - Minor
Priority: 4Item Group: libc code
Status: Works For MePercent Complete: 0%
Assigned to: NoneOpen/Closed: Closed
Release: AnyFixed Release: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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

Closing for lack of feedback.

Eric Weddington <arcanum>
Project 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>
Project 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.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 7 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 12 May 2011 03:13:53 AM UTCarcanumStatusNeed Info=>Works For Me
      Open/ClosedOpen=>Closed
    Tue 22 Feb 2011 10:09:22 PM UTCarcanumPriority3 - Low=>4
      StatusNone=>Need Info
    Mon 11 Aug 2008 02:49:09 AM UTCarcanumSeverity3 - Normal=>2 - Minor
      Priority5 - Normal=>3 - Low
    Fri 18 Jul 2008 04:11:48 AM UTCarcanumCategoryNone=>Feature Request

    Back to the top


    Powered by Savane 3.1-cleanup1