From 05e449ee2ce401266bcbd74977393c2f9c84ad3b Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sun, 25 Dec 2022 14:06:58 +0400 Subject: [PATCH] Move libc --- .github/workflows/main.yml | 2 +- .gitignore | 4 --- CONTRIBUTING.md | 4 +-- Makefile.am | 37 ++++++++++++------------ README.md | 21 +++++--------- configure.ac | 19 ------------ {libc/include => include}/Makefile.am | 0 {libc/include => include}/ctype.h | 0 {libc/include => include}/errno.h | 0 {libc/include => include}/inttypes.h | 0 {libc/include => include}/kernaux/libc.h | 0 {libc/include => include}/setjmp.h | 0 {libc/include => include}/stdlib.h | 0 {libc/include => include}/string.h | 0 {libc/include => include}/sys/types.h | 0 libc/Makefile.am | 30 ------------------- make/checks.am | 2 -- make/shared.am | 6 ---- {libc/src => src}/asm/i386/longjmp.S | 0 {libc/src => src}/asm/i386/setjmp.S | 0 {libc/src => src}/asm/x86_64/longjmp.S | 0 {libc/src => src}/asm/x86_64/setjmp.S | 0 {libc/src => src}/ctype.c | 0 {libc/src => src}/errno.c | 0 {libc/src => src}/kernaux.c | 0 {libc/src => src}/stdlib.c | 0 {libc/src => src}/string.c | 0 27 files changed, 29 insertions(+), 96 deletions(-) rename {libc/include => include}/Makefile.am (100%) rename {libc/include => include}/ctype.h (100%) rename {libc/include => include}/errno.h (100%) rename {libc/include => include}/inttypes.h (100%) rename {libc/include => include}/kernaux/libc.h (100%) rename {libc/include => include}/setjmp.h (100%) rename {libc/include => include}/stdlib.h (100%) rename {libc/include => include}/string.h (100%) rename {libc/include => include}/sys/types.h (100%) delete mode 100644 libc/Makefile.am rename {libc/src => src}/asm/i386/longjmp.S (100%) rename {libc/src => src}/asm/i386/setjmp.S (100%) rename {libc/src => src}/asm/x86_64/longjmp.S (100%) rename {libc/src => src}/asm/x86_64/setjmp.S (100%) rename {libc/src => src}/ctype.c (100%) rename {libc/src => src}/errno.c (100%) rename {libc/src => src}/kernaux.c (100%) rename {libc/src => src}/stdlib.c (100%) rename {libc/src => src}/string.c (100%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 694c22b..00e9c9a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -114,7 +114,7 @@ jobs: - name: autogen run: ./autogen.sh - name: configure - run: ./configure --host='i386-elf' --enable-freestanding --with-libc CC="$(which i686-linux-gnu-gcc)" + run: ./configure --host='i386-elf' --enable-freestanding CC="$(which i686-linux-gnu-gcc)" - name: make run: make diff --git a/.gitignore b/.gitignore index 6edae8a..fd9ead8 100644 --- a/.gitignore +++ b/.gitignore @@ -43,8 +43,6 @@ /Makefile.in /include/Makefile.in -/libc/Makefile.in -/libc/include/Makefile.in /tests/Makefile.in ########################################### @@ -71,8 +69,6 @@ /Makefile /include/Makefile -/libc/Makefile -/libc/include/Makefile /tests/Makefile /libkernaux.pc diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 712a949..8857098 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,8 +4,8 @@ Common * Add your name to [COPYING](/COPYING). * Don't add your name to `AUTHORS` - it's for maintainers. * Add copyright notice in the beginning of changed files except the headers. -* If you change the behavior (even just fix a bug) of **libkernaux** (stable) or - [libc](/libc), add a record to [ChangeLog](/ChangeLog). +* If you change the behavior (even just fix a bug) of **libkernaux** (stable), + add a record to [ChangeLog](/ChangeLog). Prohibitions: diff --git a/Makefile.am b/Makefile.am index f40fe90..d338a6a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,22 +4,12 @@ include $(top_srcdir)/make/checks.am ACLOCAL_AMFLAGS = -I m4 EXTRA_DIST = autogen.sh CONTRIBUTING.md sha256sums.txt -SUBDIRS = include - -if WITH_LIBC -# FIXME: after "make clean" libc is not rebuiling -SUBDIRS += libc -endif - -SUBDIRS += . +SUBDIRS = include . if ENABLE_CHECKS SUBDIRS += tests endif -libc/libc.la: - $(MAKE) $(AM_MAKEFLAGS) -C $(top_builddir)/libc libc.la - AM_CFLAGS += -DKERNAUX_ACCESS_PRIVATE lib_LTLIBRARIES = libkernaux.la @@ -34,13 +24,24 @@ endif ################## libkernaux_la_LDFLAGS = -version-info @PACKAGE_VERSION_SO@ -libkernaux_la_LIBADD = -libkernaux_la_SOURCES = src/xxxxx.c -######## -# libc # -######## +libkernaux_la_SOURCES = \ + src/ctype.c \ + src/errno.c \ + src/kernaux.c \ + src/stdlib.c \ + src/string.c -if WITH_LIBC -libkernaux_la_LIBADD += libc/libc.la +if ASM_I386 +libkernaux_la_SOURCES += \ + src/asm/i386/longjmp.S \ + src/asm/i386/setjmp.S endif + +if ASM_X86_64 +libkernaux_la_SOURCES += \ + src/asm/x86_64/longjmp.S \ + src/asm/x86_64/setjmp.S +endif + +# TODO: implement setjmp/longjmp for riscv64 diff --git a/README.md b/README.md index 03be0f3..49e79de 100644 --- a/README.md +++ b/README.md @@ -38,14 +38,13 @@ We use [semantic versioning](https://semver.org) for stable APIs. Stable APIs may only change when major version number is increased (or minor while major is zero). Work-in-progress APIs can change at any time. -* libc replacement (*work in progress*) - * [ctype.h](/libc/include/ctype.h) - * [errno.h](/libc/include/errno.h) - * [inttypes.h](/libc/include/inttypes.h) - * [setjmp.h](/libc/include/setjmp.h) - * [stdlib.h](/libc/include/stdlib.h) - * [string.h](/libc/include/string.h) - * [sys/types.h](/libc/include/sys/types.h) +* [ctype.h](/include/ctype.h) +* [errno.h](/include/errno.h) +* [inttypes.h](/include/inttypes.h) +* [setjmp.h](/include/setjmp.h) +* [stdlib.h](/include/stdlib.h) +* [string.h](/include/string.h) +* [sys/types.h](/include/sys/types.h) @@ -70,11 +69,6 @@ stable options. * `--enable-pkg-config[=PATH]` - install pkg-config files [PATH='${libdir}/pkgconfig'] -#### Packages - -* `--with-libc` - provides the replacement for some standard C functions. - Useful in freestanding environment, where no libc is present. - ### Default options #### Features @@ -129,7 +123,6 @@ without it in `$PATH`: --host='i386-elf' \ --disable-shared \ --enable-freestanding \ - --with-libc \ CC="$(which i386-elf-gcc)" ``` diff --git a/configure.ac b/configure.ac index 5876979..0764a57 100644 --- a/configure.ac +++ b/configure.ac @@ -27,8 +27,6 @@ AC_CONFIG_FILES([ Makefile libkernaux.pc include/Makefile - libc/Makefile - libc/include/Makefile tests/Makefile ]) @@ -52,14 +50,10 @@ AC_ARG_ENABLE([freestanding], AS_HELP_STRING([--enable-freestanding], [bui AC_ARG_ENABLE([checks], AS_HELP_STRING([--enable-checks], [enable usual tests])) AC_ARG_ENABLE([checks-all], AS_HELP_STRING([--enable-checks-all], [enable all checks])) AC_ARG_ENABLE([checks-cppcheck], AS_HELP_STRING([--enable-checks-cppcheck], [enable cppcheck])) -AC_ARG_ENABLE([split-libc], AS_HELP_STRING([--enable-split-libc], [split off libc])) dnl Features (with parameter) AC_ARG_ENABLE([pkg-config], AS_HELP_STRING([--enable-pkg-config@<:@=PATH@:>@], [install pkg-config files @<:@PATH='${libdir}/pkgconfig'@:>@])) -dnl Packages (disabled by default) -AC_ARG_WITH( [libc], AS_HELP_STRING([--with-libc], [with libc replacement])) - ################ @@ -88,15 +82,11 @@ AS_IF([test "$enable_freestanding" = yes], [enable_freestanding=yes], [ena AS_IF([test "$enable_checks" = yes], [enable_checks=yes], [enable_checks=no]) AS_IF([test "$enable_checks_all" = yes], [enable_checks_all=yes], [enable_checks_all=no]) AS_IF([test "$enable_checks_cppcheck" = yes], [enable_checks_cppcheck=yes], [enable_checks_cppcheck=no]) -AS_IF([test "$enable_split_libc" = yes], [enable_split_libc=yes], [enable_split_libc=no]) dnl Features (with parameter) AS_IF([test "$enable_pkg_config" = yes], [enable_pkg_config='${libdir}/pkgconfig']) AS_IF([test "$enable_pkg_config" = no ], [enable_pkg_config='']) -dnl Packages (disabled by default) -AS_IF([test "$with_libc" = yes], [with_libc=yes], [with_libc=no]) - ############# @@ -104,7 +94,6 @@ AS_IF([test "$with_libc" = yes], [with_libc=yes], [wit ############# AS_IF([test "$enable_checks" = yes -a "$enable_freestanding" = yes], AC_MSG_ERROR([can not build freestanding tests])) -AS_IF([test "$enable_checks" = yes -a "$with_libc" = yes], AC_MSG_ERROR([can not use package `libc' with tests])) @@ -128,14 +117,10 @@ dnl Features (disabled by default) AM_CONDITIONAL([ENABLE_FREESTANDING], [test "$enable_freestanding" = yes]) AM_CONDITIONAL([ENABLE_CHECKS], [test "$enable_checks" = yes]) AM_CONDITIONAL([ENABLE_CHECKS_CPPCHECK], [test "$enable_checks_cppcheck" = yes]) -AM_CONDITIONAL([ENABLE_SPLIT_LIBC], [test "$enable_split_libc" = yes]) dnl Features (with parameter) AM_CONDITIONAL([ENABLE_PKG_CONFIG], [test ! -z "$enable_pkg_config"]) -dnl Packages (disabled by default) -AM_CONDITIONAL([WITH_LIBC], [test "$with_libc" = yes]) - #################### @@ -159,10 +144,6 @@ dnl Features (disabled by default) AS_IF([test "$enable_freestanding" = yes], [AC_DEFINE([ENABLE_FREESTANDING], [1], [build for freestanding environment])]) AS_IF([test "$enable_checks" = yes], [AC_DEFINE([ENABLE_CHECKS], [1], [enabled usual tests])]) AS_IF([test "$enable_checks_cppcheck" = yes], [AC_DEFINE([ENABLE_CHECKS_CPPCHECK], [1], [enabled cppcheck])]) -AS_IF([test "$enable_split_libc" = yes], [AC_DEFINE([ENABLE_SPLIT_LIBC], [1], [split off libc])]) - -dnl Packages (disabled by default) -AS_IF([test "$with_libc" = yes], [AC_DEFINE([WITH_LIBC], [1], [with libc replacement])]) diff --git a/libc/include/Makefile.am b/include/Makefile.am similarity index 100% rename from libc/include/Makefile.am rename to include/Makefile.am diff --git a/libc/include/ctype.h b/include/ctype.h similarity index 100% rename from libc/include/ctype.h rename to include/ctype.h diff --git a/libc/include/errno.h b/include/errno.h similarity index 100% rename from libc/include/errno.h rename to include/errno.h diff --git a/libc/include/inttypes.h b/include/inttypes.h similarity index 100% rename from libc/include/inttypes.h rename to include/inttypes.h diff --git a/libc/include/kernaux/libc.h b/include/kernaux/libc.h similarity index 100% rename from libc/include/kernaux/libc.h rename to include/kernaux/libc.h diff --git a/libc/include/setjmp.h b/include/setjmp.h similarity index 100% rename from libc/include/setjmp.h rename to include/setjmp.h diff --git a/libc/include/stdlib.h b/include/stdlib.h similarity index 100% rename from libc/include/stdlib.h rename to include/stdlib.h diff --git a/libc/include/string.h b/include/string.h similarity index 100% rename from libc/include/string.h rename to include/string.h diff --git a/libc/include/sys/types.h b/include/sys/types.h similarity index 100% rename from libc/include/sys/types.h rename to include/sys/types.h diff --git a/libc/Makefile.am b/libc/Makefile.am deleted file mode 100644 index 524872f..0000000 --- a/libc/Makefile.am +++ /dev/null @@ -1,30 +0,0 @@ -include $(top_srcdir)/make/shared.am - -SUBDIRS = include - -if ENABLE_SPLIT_LIBC -lib_LTLIBRARIES = libc.la -else -EXTRA_LTLIBRARIES = libc.la -endif - -libc_la_SOURCES = \ - src/ctype.c \ - src/errno.c \ - src/kernaux.c \ - src/stdlib.c \ - src/string.c - -if ASM_I386 -libc_la_SOURCES += \ - src/asm/i386/longjmp.S \ - src/asm/i386/setjmp.S -endif - -if ASM_X86_64 -libc_la_SOURCES += \ - src/asm/x86_64/longjmp.S \ - src/asm/x86_64/setjmp.S -endif - -# TODO: implement setjmp/longjmp for riscv64 diff --git a/make/checks.am b/make/checks.am index 255d544..c79e716 100644 --- a/make/checks.am +++ b/make/checks.am @@ -25,8 +25,6 @@ CPPCHECK_SUPPRESS = \ CPPCHECK_PATHS = \ $(top_builddir)/include \ $(top_srcdir)/include \ - $(top_builddir)/libc \ - $(top_srcdir)/libc \ $(top_builddir)/src \ $(top_srcdir)/src \ $(top_builddir)/tests \ diff --git a/make/shared.am b/make/shared.am index 767a8db..0f94fd0 100644 --- a/make/shared.am +++ b/make/shared.am @@ -9,12 +9,6 @@ AM_CFLAGS = \ -I$(top_srcdir)/include \ -D_POSIX_C_SOURCE=200809L -if WITH_LIBC -AM_CFLAGS += \ - -I$(top_builddir)/libc/include \ - -I$(top_srcdir)/libc/include -endif - if ENABLE_WERROR AM_CFLAGS += -Werror endif diff --git a/libc/src/asm/i386/longjmp.S b/src/asm/i386/longjmp.S similarity index 100% rename from libc/src/asm/i386/longjmp.S rename to src/asm/i386/longjmp.S diff --git a/libc/src/asm/i386/setjmp.S b/src/asm/i386/setjmp.S similarity index 100% rename from libc/src/asm/i386/setjmp.S rename to src/asm/i386/setjmp.S diff --git a/libc/src/asm/x86_64/longjmp.S b/src/asm/x86_64/longjmp.S similarity index 100% rename from libc/src/asm/x86_64/longjmp.S rename to src/asm/x86_64/longjmp.S diff --git a/libc/src/asm/x86_64/setjmp.S b/src/asm/x86_64/setjmp.S similarity index 100% rename from libc/src/asm/x86_64/setjmp.S rename to src/asm/x86_64/setjmp.S diff --git a/libc/src/ctype.c b/src/ctype.c similarity index 100% rename from libc/src/ctype.c rename to src/ctype.c diff --git a/libc/src/errno.c b/src/errno.c similarity index 100% rename from libc/src/errno.c rename to src/errno.c diff --git a/libc/src/kernaux.c b/src/kernaux.c similarity index 100% rename from libc/src/kernaux.c rename to src/kernaux.c diff --git a/libc/src/stdlib.c b/src/stdlib.c similarity index 100% rename from libc/src/stdlib.c rename to src/stdlib.c diff --git a/libc/src/string.c b/src/string.c similarity index 100% rename from libc/src/string.c rename to src/string.c