free(), getpagesize(), and space optimizations.

Carmelo AMOROSO carmelo.amoroso at st.com
Fri Dec 17 08:06:56 UTC 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 12/16/2010 11:06 AM, Peter Barfuss wrote:
> Hi,
> 
> In its current implementation, free() needs to call malloc_getpagesize
> once in order to determine the size of a page (most commonly 4K, but
> ultimately architecture/CPU model-dependent). Thus malloc_getpagesize
> calls code to detect it at load: problem: currently this routine is
> sysconf(_SC_PAGESIZE). Despite this basically immediately collapsing
> to a call to getpagesize() internally in sysconf.c, followed by a
> break and a return, the linker is unable to actually optimize
> statically linking in the relevant portions of sysconf(), as it cannot
> tell that you don't need all of sysconf() and its associated API
> helper functions, linking in about 5K worth of garbage code, which is
> sort of annoying.
> 
> The way I patched it is by making malloc_getpagesize refer directly to
> __getpagesize(), which seems to be exactly the way that it's done
> internally in sysconf() anyway, and I have not had any issues with
> this, despite running a lot of software under it since, so I've
> decided to forward the patch here.
> 
> Comments?
> 
> -Peter
> 

Hi,
what about using the internal variable __pagesize instead ?

Anyway you should provide as with a proper patch with the full patch -p1
applicable. There are 3 different malloc.h file in the uClibc source
tree. A git diff patch would be the best.

Cheers,
Carmelo


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk0LGh8ACgkQoRq/3BrK1s+qsQCgoYh4bLAOLBUQUzVAqIYog/Co
UD8AoI65LAC19Myj0mNLxbG+ecuDMKP1
=jixI
-----END PGP SIGNATURE-----


More information about the uClibc mailing list