thoughts on coalescing libbb/ source files

Robert P. J. Day rpjday at mindspring.com
Mon Mar 27 06:14:58 PST 2006


On Mon, 27 Mar 2006, Paul Fox wrote:

> rday wrote:

>  >   a perfect example would be all of the *error*.c files (defining
>  > functions like bb_error_msg(), bb_error_msg_and_die(),
>  > bb_herror_msg(), bb_hrror_msg_and_die(), ... and on and on.)  each of
>  > those functions is only a few lines long but is in its own source
>  > file, requiring the duplication of the copyright info and inclusion of
>  > header files and "end code" stuff.
>  >
>  >   it would seem to make more sense to pack all these error routines
>  > into a single source file (called "bb_error.c"?) so one could, if one
>  > wanted, peruse all of those related routines by scrolling through a
>  > single file, no?  at the very least, i don't see any immediate
>  > drawback to it but maybe i'm just not looking closely enough.
>
> it does seem as if some sort of multi-source technique (i.e., one
> source file, with preprocessor controls to allow rendering many
> different small objects) could be useful.

well, that's already being done in some cases as you can see from
libbb/Makefile.in.  consider the case of, say, the linked list
routines.  there's one source file -- llist.c -- that generates
several object files:

LIBBB_MSRC6:=$(srcdir)/llist.c
LIBBB_MOBJ6:=llist_add_to.o llist_add_to_end.o llist_free_one.o llist_free.o
LIBBB_MOBJ6:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ6))
$(LIBBB_MOBJ6):$(LIBBB_MSRC6)
        $(compile.c) -DL_$(notdir $*)

and that's obviously used in a number of other cases so it would seem
that it shouldn't be a big step to extend that to cover other
closely-related routines if it's really worth the trouble.

however, is it at all worth considering whether, in some cases, it's
even worth the trouble?  as an example, if someone is going to need
linked list routines, isn't it moderately reasonable to think they'll
probably need most, if not all, of those related functions?  and it's
not like, once you strip those object files, there's a whole lot of
text section left.

i realize it's a heretical suggestion but is there a point where
possibly saving a few hundred bytes becomes more trouble than it's
worth?

rday


More information about the busybox mailing list