Hi,
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/extra/locale/gen_collate.c uClibc.2/extra/locale/gen_collate.c
--- uClibc.1/extra/locale/gen_collate.c 2008-05-19 16:23:09.000000000 +0200
+++ uClibc.2/extra/locale/gen_collate.c 2008-05-20 00:03:31.000000000 +0200
@@ -3482,7 +3482,7 @@ int nu_memcmp(const void *a, const void
size_t newopt(tbl_item *ut, size_t usize, int shift, table_data *tbl)
{
- static int recurse = 0;
+ static smallint recurse;
tbl_item *ti[RANGE]; /* table index */
size_t numblocks;
size_t blocksize;
diff -d -urpN uClibc.1/extra/locale/gen_wctype.c uClibc.2/extra/locale/gen_wctype.c
--- uClibc.1/extra/locale/gen_wctype.c 2008-05-19 16:23:09.000000000 +0200
+++ uClibc.2/extra/locale/gen_wctype.c 2008-05-20 00:03:31.000000000 +0200
@@ -767,7 +767,7 @@ int main(int argc, char **argv)
size_t newopt(unsigned char *ut, size_t usize, int shift, table_data *tbl)
{
- static int recurse = 0;
+ static smallint recurse;
unsigned char *ti[RANGE+1]; /* table index */
size_t numblocks;
size_t blocksize;
diff -d -urpN uClibc.1/include/unistd.h uClibc.2/include/unistd.h
--- uClibc.1/include/unistd.h 2008-05-19 16:23:07.000000000 +0200
+++ uClibc.2/include/unistd.h 2008-05-20 00:08:57.000000000 +0200
@@ -1107,4 +1107,14 @@ extern char *ctermid (char *__s) __THROW
__END_DECLS
+
+#ifdef UCLIBC_INTERNAL
+#ifndef smallint /* if arch didn't override it in bits/wordsize.h */
+typedef int smallint;
+typedef unsigned smalluint;
+#define smallint smallint
+#endif
+#endif
+
+
#endif /* unistd.h */
diff -d -urpN uClibc.1/ldso/libdl/libdl.c uClibc.2/ldso/libdl/libdl.c
--- uClibc.1/ldso/libdl/libdl.c 2008-05-19 16:23:13.000000000 +0200
+++ uClibc.2/ldso/libdl/libdl.c 2008-05-20 00:03:31.000000000 +0200
@@ -164,7 +164,7 @@ void *dlopen(const char *libname, int fl
struct init_fini_list *tmp, *runp, *runp2, *dep_list;
unsigned int nlist, i;
struct elf_resolve **init_fini_list;
- static int _dl_init = 0;
+ static smallint _dl_init;
/* A bit of sanity checking... */
if (!(flag & (RTLD_LAZY|RTLD_NOW))) {
diff -d -urpN uClibc.1/libc/misc/internals/__uClibc_main.c uClibc.2/libc/misc/internals/__uClibc_main.c
--- uClibc.1/libc/misc/internals/__uClibc_main.c 2008-05-19 20:07:35.000000000 +0200
+++ uClibc.2/libc/misc/internals/__uClibc_main.c 2008-05-20 00:03:31.000000000 +0200
@@ -22,7 +22,6 @@
#include <link.h>
#include <bits/uClibc_page.h>
#include <paths.h>
-#include <unistd.h>
#include <asm/errno.h>
#include <fcntl.h>
#include <sys/stat.h>
@@ -183,7 +182,7 @@ extern void __uClibc_init(void);
libc_hidden_proto(__uClibc_init)
void __uClibc_init(void)
{
- static int been_there_done_that = 0;
+ static smallint been_there_done_that;
if (been_there_done_that)
return;
diff -d -urpN uClibc.1/libc/stdlib/getpt.c uClibc.2/libc/stdlib/getpt.c
--- uClibc.1/libc/stdlib/getpt.c 2008-05-19 16:23:15.000000000 +0200
+++ uClibc.2/libc/stdlib/getpt.c 2008-05-20 00:03:31.000000000 +0200
@@ -50,7 +50,7 @@ int
getpt (void)
{
#if !defined __UNIX98PTY_ONLY__
- static int have_no_dev_ptmx;
+ static smallint have_no_dev_ptmx;
#endif
int fd;
@@ -65,7 +65,7 @@ getpt (void)
return fd;
#else
struct statfs fsbuf;
- static int devpts_mounted;
+ static smallint devpts_mounted;
/* Check that the /dev/pts filesystem is mounted
or if /dev is a devfs filesystem (this implies /dev/pts). */
diff -d -urpN uClibc.1/libc/stdlib/malloc/heap_debug.c uClibc.2/libc/stdlib/malloc/heap_debug.c
--- uClibc.1/libc/stdlib/malloc/heap_debug.c 2008-05-19 16:23:15.000000000 +0200
+++ uClibc.2/libc/stdlib/malloc/heap_debug.c 2008-05-20 00:03:31.000000000 +0200
@@ -49,7 +49,7 @@ __heap_dump_freelist (struct heap *heap)
void
__heap_dump (struct heap *heap, const char *str)
{
- static int recursed = 0;
+ static smallint recursed;
if (! recursed)
{
diff -d -urpN uClibc.1/libc/stdlib/malloc/malloc.c uClibc.2/libc/stdlib/malloc/malloc.c
--- uClibc.1/libc/stdlib/malloc/malloc.c 2008-05-19 16:23:15.000000000 +0200
+++ uClibc.2/libc/stdlib/malloc/malloc.c 2008-05-20 00:03:31.000000000 +0200
@@ -184,7 +184,7 @@ malloc (size_t size)
{
void *mem;
#ifdef MALLOC_DEBUGGING
- static int debugging_initialized = 0;
+ static smallint debugging_initialized;
if (! debugging_initialized)
{
debugging_initialized = 1;
diff -d -urpN uClibc.1/libc/sysdeps/linux/i386/bits/wordsize.h uClibc.2/libc/sysdeps/linux/i386/bits/wordsize.h
--- uClibc.1/libc/sysdeps/linux/i386/bits/wordsize.h 2008-05-19 16:23:23.000000000 +0200
+++ uClibc.2/libc/sysdeps/linux/i386/bits/wordsize.h 2008-05-20 00:07:53.000000000 +0200
@@ -17,3 +17,11 @@
02111-1307 USA. */
#define __WORDSIZE 32
+
+#ifdef UCLIBC_INTERNAL
+#ifndef smallint
+typedef signed char smallint;
+typedef unsigned char smalluint;
+#define smallint smallint
+#endif
+#endif
diff -d -urpN uClibc.1/libc/sysdeps/linux/nios/crtend.c uClibc.2/libc/sysdeps/linux/nios/crtend.c
--- uClibc.1/libc/sysdeps/linux/nios/crtend.c 2008-05-19 16:23:27.000000000 +0200
+++ uClibc.2/libc/sysdeps/linux/nios/crtend.c 2008-05-20 00:03:31.000000000 +0200
@@ -25,7 +25,7 @@ static void dummy_init(void) __attribute
void
dummy_init(void)
{
- static int initialized = 0;
+ static smallint initialized;
static void (*volatile call__ctors)(void) = __do_global_ctors_aux;
/*
* Call global constructors.
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;
if (! tiocgsid_does_not_work)
{
_______________________________________________
uClibc mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/uclibc