svn commit: r281004 - in head/lib/libc: arm/sys mips/sys powerpc powerpc/sys powerpc64 powerpc64/sys sparc64 sparc64/sys sys

Bruce Evans brde at optusnet.com.au
Thu Apr 2 23:55:12 UTC 2015


On Thu, 2 Apr 2015, Ed Maste wrote:

> Log:
>  libc: Eliminate duplicate copies of __vdso_gettc.c
> ...
> Modified: head/lib/libc/arm/sys/Makefile.inc
> ==============================================================================
> --- head/lib/libc/arm/sys/Makefile.inc	Thu Apr  2 20:14:51 2015	(r281003)
> +++ head/lib/libc/arm/sys/Makefile.inc	Thu Apr  2 21:18:11 2015	(r281004)
> @@ -1,6 +1,6 @@
> # $FreeBSD$
>
> -SRCS+=	__vdso_gettc.c
> +SRCS+=	trivial-vdso_tc.c

The new file name is much worse than the old one.

The old one was too long.  It didn't even match the name of the single
function that it implements, since it implements several functions.  It
has excessive leading underscores.  Leading underscores are sometimes
needed in function names to keep them out of the application namespace,
or just to keep layers of them separate, but the equivalent is rarely
needed for function names.

libc previously had just 26 file names with 2 leading underscores.
Almost 1/3 of them for __vdso*:

X ./powerpc64/sys/__vdso_gettc.c
X ./sys/__vdso_gettimeofday.c
X ./sys/__error.c
X ./i386/sys/__vdso_gettc.c
X ./iconv/__iconv_free_list.c
X ./iconv/__iconv.c
X ./iconv/__iconv_get_list.3
X ./iconv/__iconv_get_list.c
X ./arm/gen/__aeabi_read_tp.S
X ./arm/sys/__vdso_gettc.c
X ./sparc64/sys/__sparc_utrap_fp_disabled.S
X ./sparc64/sys/__sparc_sigtramp_setup.c
X ./sparc64/sys/__sparc_utrap_setup.c
X ./sparc64/sys/__sparc_utrap_emul.c
X ./sparc64/sys/__sparc_utrap_install.c
X ./sparc64/sys/__vdso_gettc.c
X ./sparc64/sys/__sparc_utrap_private.h
X ./sparc64/sys/__sparc_utrap_align.c
X ./sparc64/sys/__sparc_utrap.c
X ./sparc64/sys/__sparc_utrap_gen.S
X ./amd64/sys/__vdso_gettc.c
X ./mips/sys/__vdso_gettc.c
X ./gen/__pthread_mutex_init_calloc_cb_stub.c
X ./gen/__xuname.c
X ./gen/__getosreldate.c
X ./powerpc/sys/__vdso_gettc.c

Another 1/3 of these are probably externally-imposed (the sparc64 trap
ones).

The sparc64 names are disgustingly verbose, but not nearly as bad as
the internal spam __pthread_mutex_init_calloc_cb_stub.c (37 characters).
This file contains a single stub function with a not quite equally
bad name.  The file name doesn't even match the function name -- the
function name only has 1 leading underscore.

FreeBSD ls -C handles long names especially badly.  It uses a tabbed
format with all columns wide enough for the widest file name.  37
is barely less than 40, so it only reduces the number of columns to
2 on terminals of width 80-119.  gnu ls aligns to non-tab boundaries
and uses variable-width columns.  1 long file name only bloats the
column that it is in.  For more normal short file names (not longer
than 15, with an average of less than 8 from good names like cp),
FreeBSD ls -C always gives 5 columns of width 16 each on an 80-column
terminal, while gnu ls -C usually gives 8-10.  The densely packed names
can be hard to read, but not as bad as ones that scroll off due to
the low density.

The new name removes the double underscores.  Good, but now it doesn't
match the name of even one of the functions in it.

"trivial" in the new name doesn't describe what it does.  It is not a
trivial (simple) implementation of the functions in it, but a stub
(non-functional) implementation of these functions.  Though disgusting,
the name __pthread_mutex_init_calloc_cb_stub.c at least says "stub"
instead of "trivial".

In BSD, words in file names are conventionally separated by underscores.
The new name separates one pair of words with a hyphen instead.  This is
gnu-style.  A case can be made for using underscores to echo function
names that have them and hyphens for everything else, to keep these
splittings separate.  But function names shouldn't be echoed in file
names anyway.  Echoing is only possible when the file implements only
a single function (unless you want to make the file name even more
disgusting by making it the concatenation of all the function names,
with exceptions only when the length of this exceeds {NAME_MAX}.

Previously, only 44 names in libc had a hyphen (581 had an underscore):
X ./stdio/printf-pos.c
X ./powerpc64/softfloat/powerpc-gcc.h
X ./iconv/iconv-internal.h
X ./tests/Makefile.netbsd-tests
X ./arm/softfloat/arm-gcc.h
X ./db/mpool/mpool-compat.c
X ./mips/softfloat/mips-gcc.h
X ./gen/trivial-getcontextx.c
X ./gen/fts-compat.h
X ./gen/gen-private.h
X ./gen/fts-compat.c
X ./gen/unvis-compat.c
X ./include/un-namespace.h
X ./compat-43
X ./powerpc/softfloat/powerpc-gcc.h
X ./softfloat/softfloat-for-gcc.h
X ./softfloat/softfloat-specialize
X ./softfloat/templates/softfloat-specialize
X ./softfloat/softfloat-source.txt
X ./softfloat/bits64/softfloat-macros
X ./softfloat/bits32/softfloat-macros
X ./softfloat/softfloat-history.txt
X ./nls/mn_MN.UTF-8.msg
X ./nls/pl_PL.ISO8859-2.msg
X ./nls/ca_ES.ISO8859-1.msg
X ./nls/ru_RU.KOI8-R.msg
X ./nls/nl_NL.ISO8859-1.msg
X ./nls/el_GR.ISO8859-7.msg
X ./nls/it_IT.ISO8859-15.msg
X ./nls/fr_FR.ISO8859-1.msg
X ./nls/gl_ES.ISO8859-1.msg
X ./nls/sk_SK.ISO8859-2.msg
X ./nls/hu_HU.ISO8859-2.msg
X ./nls/be_BY.UTF-8.msg
X ./nls/sv_SE.ISO8859-1.msg
X ./nls/fi_FI.ISO8859-1.msg
X ./nls/pt_BR.ISO8859-1.msg
X ./nls/no_NO.ISO8859-1.msg
X ./nls/zh_CN.UTF-8.msg
X ./nls/ko_KR.UTF-8.msg
X ./nls/es_ES.ISO8859-1.msg
X ./nls/de_DE.ISO8859-1.msg
X ./nls/uk_UA.UTF-8.msg
X ./nls/ja_JP.UTF-8.msg

1/4 of these are probably externally imposed (for softfloat).  Half of
them are for NLS names where they are correct because the locale name
has a hyphen and this needs to be in the file name for related output
files.  This leaves just 11 names with a hyphen.  4.4BSD is responsible
for compat-43, and I am responsible for un-namespace.h.

In /sys, there are now 1357 broken names with hyphens :-(.  Many
externally-imposed.  6230 with underscores. 14939 total.

In 4.4BSD-Lite2 /sys, there are 11 names with hyphens, 559 with
underscores, 2337 total.

Bruce


More information about the svn-src-all mailing list