summaryrefslogtreecommitdiff
path: root/libc-parts
diff options
context:
space:
mode:
authormarcus <marcus>2003-09-13 00:25:50 +0000
committermarcus <marcus>2003-09-13 00:25:50 +0000
commitdb3bd625f20de535bcab489d39acfe635f7bd595 (patch)
tree5790e5b05982a69e2b1e62880ddf856b56e9b14b /libc-parts
parent1c19688db671548ef174497f7c6507773ba48221 (diff)
Add libc-parts, which takes functions out of libc.a bit by bit.
Diffstat (limited to 'libc-parts')
-rw-r--r--libc-parts/Makefile.am43
-rw-r--r--libc-parts/README20
2 files changed, 63 insertions, 0 deletions
diff --git a/libc-parts/Makefile.am b/libc-parts/Makefile.am
new file mode 100644
index 0000000..91187b4
--- /dev/null
+++ b/libc-parts/Makefile.am
@@ -0,0 +1,43 @@
+# Makefile.am - Makefile template for libc-parts.
+# Copyright (C) 2003 Free Software Foundation, Inc.
+# Written by Marcus Brinkmann.
+#
+# This file is part of the GNU Hurd.
+#
+# The GNU Hurd is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# The GNU Hurd is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+
+noinst_LIBRARIES = libc-parts.a
+
+libc_parts_a_SOURCES =
+
+routines := memcpy memmove memset bcopy bzero memchr rawmemchr \
+ strstr strtok strchr strchrnul strcpy stpcpy strcat \
+ strcmp strncmp \
+ htonl htons ntohl ntohs ffs
+
+# We have to find all modules in the archive which contain the above
+# functions.
+routines_subexp := 's/^\($(shell echo $(routines) \
+ | $(SED) -e 's/ \+/\\|/g')\) in \(.*\)$$/\2/p'
+routines_objects := $(shell $(NM) --print-armap @STATIC_GLIBC@ 2>/dev/null \
+ | $(SED) -n -e $(routines_subexp) | $(SORT) -u)
+
+# This stupid trick seems to be necessary to avoid early expansion of
+# routines_objects in Makefile.in by automake, which doesn't work at all.
+routines_varname := routines_objects
+libc_parts_a_LIBADD = $($(routines_varname))
+
+$(routines_objects): %.$(OBJEXT): @STATIC_GLIBC@
+ $(AR) -x $< $@
diff --git a/libc-parts/README b/libc-parts/README
new file mode 100644
index 0000000..2ee60e9
--- /dev/null
+++ b/libc-parts/README
@@ -0,0 +1,20 @@
+libc-parts
+==========
+
+libc-parts is a convenience library that is built by taking functions
+from the statically linked GNU C library of the host system.
+
+Even if you can not link to the whole of the C library, you can often
+link to specific functions to it, which don't have a lot of
+dependencies. This includes memory and string operations, as well as
+many other low level operations (byte swap routines, bit search
+functions, etc).
+
+These functions are usually cleverly optimized for the host processor,
+and well tested. So taking the standard implementations gives best
+over-all performance, avoids code duplications, and is the least error
+prone solution.
+
+There is obviously a boot strap issue in this approach. However, this
+is not a serious problem as the functions are not OS dependent, and
+thus any static GNU C library for the host CPU will do.