On Tue, 2008-05-20 at 17:59 +0200, Denys Vlasenko wrote:
> On Tuesday 20 May 2008 09:15, Bernhard Fischer wrote:
> > >Attached patch instroduces smallint type, and uses it
> > >for flag variables. It results in size reduction
> > >ont only for bss, but text too:
> > >
> > >    text           data     bss     dec     hex filename
> > >-    648              4      24     676     2a4 
> > >libc/misc/internals/__uClibc_main.o
> > >+    645              4      21     670     29e 
> > >libc/misc/internals/__uClibc_main.o
> > >-    129              0       4     133      85 libc/termios/tcgetsid.o
> > >+    126              0       1     127      7f libc/termios/tcgetsid.o
> > >
> > >because "flag_var = 1" is a smaller instruction now.
> > >Size in smallint can be set per-architecture.
> > >
> > >I am a bit unsire I picked suitable include files to put
> > >new definitions in.
> > >
> > >Can someone eyeball the patch?
> > >--
> > >vda
> > 
> > >diff -d -urpN uClibc.1/libc/termios/tcgetsid.c 
> > >uClibc.2/libc/termios/tcgetsid.c
> > >--- uClibc.1/libc/termios/tcgetsid.c       2008-05-19 16:23:16.000000000 
> > >+0200
> > >+++ uClibc.2/libc/termios/tcgetsid.c       2008-05-20 00:03:31.000000000 
> > >+0200
> > >@@ -34,7 +34,7 @@ tcgetsid (fd)
> > >   pid_t pgrp;
> > >   pid_t sid;
> > > #ifdef TIOCGSID
> > >-  static int tiocgsid_does_not_work;
> > >+  static smallint tiocgsid_does_not_work;
> > 
> > For cases like this i prefer to just use a bool.
> 
> Yeah, sounds logical. I'd do this too, but I don't have sufficient faith
> in gcc not being stupid.

In my opinion using bool is right thing to do and less error-prone on
userside. At least compilers will do it consistent even if wrong.

btw the you did not consider the architectures which do not define their
own smallint in wordsize.h on such arches the definition will come from
unistd.h. libc/misc/fnmatch.c change would require to include unistd.h
so that it will also get definition for other arches. As far as I see
only x86 defines smallint as of now.

btw saving three bytes in size is fine. Did you also consider/measure
the performance hit? Now a days accessing int is much faster and I would
consider this a better trade-off than size.

Thanks

-Khem

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
uClibc mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/uclibc

Reply via email to