svn commit: r278889 - head/lib/libc/include

Bruce Evans brde at optusnet.com.au
Thu Feb 19 00:58:57 UTC 2015


On Wed, 18 Feb 2015, Bryan Drewery wrote:

> On 2/17/2015 2:54 AM, Konstantin Belousov wrote:
>> ...
>> Log:
>>   Restore the extern qualifier on __cleanup.
>> ...
>> Modified: head/lib/libc/include/libc_private.h
>> ==============================================================================
>> --- head/lib/libc/include/libc_private.h	Tue Feb 17 08:50:26 2015	(r278888)
>> +++ head/lib/libc/include/libc_private.h	Tue Feb 17 08:54:03 2015	(r278889)
>> @@ -271,7 +271,7 @@ void _malloc_first_thread(void);
>>  /*
>>   * Function to clean up streams, called from abort() and exit().
>>   */
>> -void (*__cleanup)(void) __hidden;
>> +extern void (*__cleanup)(void) __hidden;
>>
>>  /*
>>   * Get kern.osreldate to detect ABI revisions.  Explicitly
>>
>
> Is this a NOP?

No, since this is a data declaration.  It would be a style bug on a
prototype.

BTW, the reason for existence of __cleanup() has been broken by malloc()
and other bloatware.  It is to avoid linking anything in stdio when
only exit() is used.  But crtso now links to malloc() and malloc()
links to stdio and much more.  When correctly (that is, statically)
linked, this bloats the size of a minimal C program from to 440K + 80K
symbols on amd64 and to 390K + 60K symbols on i386.  In FreeBSD-4 and
in my version of FreeBSD-5, __cleanup still works and the minimal C
program has size 2K + 1.5K symbols.  In FreeBSD-5, malloc() is
relatively unbloated, so crtso's linking to it costs only 9K + 9K
symbols instead of 400+K.  The same program written in asm takes about
10 bytes in all versions of FreeBSD-x86.  When dynamically linked,
__cleanup() has little effect.

Bruce


More information about the svn-src-head mailing list