diff --git a/.cirrus.yml b/.cirrus.yml index b05e32b..1624566 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -12,7 +12,7 @@ main_freebsd_task: - pip install --user Jinja2 PyYAML main_build_script: - ./autogen.sh - - ./configure --enable-debug --enable-checks-all CFLAGS='-O3' + - ./configure --enable-assert --enable-checks-all CFLAGS='-O3' - make - sudo make install main_test_script: @@ -32,7 +32,7 @@ mruby_freebsd_task: - unzip mruby-3.1.0.zip main_build_script: - ./autogen.sh - - ./configure --enable-debug CFLAGS='-O3' + - ./configure --enable-assert CFLAGS='-O3' - make - sudo make install mruby_test_script: @@ -56,7 +56,7 @@ ruby_freebsd_task: - sudo make install main_build_script: - ./autogen.sh - - ./configure --enable-debug CFLAGS='-O3' + - ./configure --enable-assert CFLAGS='-O3' - make - sudo make install ruby_build_script: @@ -78,7 +78,7 @@ rust_freebsd_task: - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y main_build_script: - ./autogen.sh - - ./configure --enable-debug CFLAGS='-O3' + - ./configure --enable-assert CFLAGS='-O3' - make - sudo make install rust_test_script: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2962234..7b64438 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,7 +24,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - debug: ['--disable-debug', '--enable-debug'] + assert: ['--disable-assert', '--enable-assert'] cc: ['gcc', 'clang', 'tcc'] opt: ['', '-O0', '-O3'] steps: @@ -34,7 +34,7 @@ jobs: - name: autogen run: ./autogen.sh - name: configure - run: ./configure ${{matrix.debug}} --enable-checks --enable-checks-pthreads --enable-checks-python CC='${{matrix.cc}}' CFLAGS='${{matrix.opt}}' + run: ./configure ${{matrix.assert}} --enable-checks --enable-checks-pthreads --enable-checks-python CC='${{matrix.cc}}' CFLAGS='${{matrix.opt}}' - name: make run: make - name: check @@ -99,7 +99,7 @@ jobs: - name: autogen run: ./autogen.sh - name: configure - run: ./configure --enable-debug --enable-checks --enable-checks-pthreads --enable-checks-python --without-${{matrix.packages.without}} ${{matrix.packages.dependencies}} + run: ./configure --enable-assert --enable-checks --enable-checks-pthreads --enable-checks-python --without-${{matrix.packages.without}} ${{matrix.packages.dependencies}} - name: make run: make - name: check @@ -111,7 +111,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - debug: ['--disable-debug', '--enable-debug'] + assert: ['--disable-assert', '--enable-assert'] steps: - uses: actions/checkout@v2 - name: apt update @@ -121,7 +121,7 @@ jobs: - name: autogen run: ./autogen.sh - name: configure - run: ./configure --host='i386-elf' ${{matrix.debug}} --enable-freestanding --with-libc CC="$(which i686-linux-gnu-gcc)" + run: ./configure --host='i386-elf' ${{matrix.assert}} --enable-freestanding --with-libc CC="$(which i686-linux-gnu-gcc)" - name: make run: make @@ -138,7 +138,7 @@ jobs: - name: extract run: tar -xzf "libkernaux-$(cat VERSION).tar.gz" - name: configure - run: cd "libkernaux-$(cat VERSION)" && ./configure --enable-debug --enable-checks --enable-checks-pthreads --enable-checks-python + run: cd "libkernaux-$(cat VERSION)" && ./configure --enable-assert --enable-checks --enable-checks-pthreads --enable-checks-python - name: make run: cd "libkernaux-$(cat VERSION)" && make - name: check diff --git a/.github/workflows/mruby.yml b/.github/workflows/mruby.yml index 64c44cc..e654d1c 100644 --- a/.github/workflows/mruby.yml +++ b/.github/workflows/mruby.yml @@ -13,7 +13,7 @@ jobs: MRUBY_YAML_USE_SYSTEM_LIBRARY: x strategy: matrix: - debug: ['--disable-debug', '--enable-debug'] + assert: ['--disable-assert', '--enable-assert'] packages: - configure: '' - configure: '--without-all' @@ -30,7 +30,7 @@ jobs: - name: autogen run: ./autogen.sh - name: configure - run: ./configure ${{matrix.debug}} ${{matrix.packages.configure}} CFLAGS='-O3' + run: ./configure ${{matrix.assert}} ${{matrix.packages.configure}} CFLAGS='-O3' - name: make run: make - name: install diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 5f7ab12..109932d 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - debug: ['--disable-debug', '--enable-debug'] + assert: ['--disable-assert', '--enable-assert'] packages: - configure: '' - configure: '--without-all' @@ -28,7 +28,7 @@ jobs: - name: autogen run: ./autogen.sh - name: configure - run: ./configure ${{matrix.debug}} ${{matrix.packages.configure}} CFLAGS='-O3' + run: ./configure ${{matrix.assert}} ${{matrix.packages.configure}} CFLAGS='-O3' - name: make run: make - name: install diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 3fb6f01..d47c2de 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - debug: ['--disable-debug', '--enable-debug'] + assert: ['--disable-assert', '--enable-assert'] packages: - configure: '' - configure: '--without-all' @@ -27,7 +27,7 @@ jobs: - name: autogen run: ./autogen.sh - name: configure - run: ./configure ${{matrix.debug}} ${{matrix.packages.configure}} CFLAGS='-O3' + run: ./configure ${{matrix.assert}} ${{matrix.packages.configure}} CFLAGS='-O3' - name: make run: make - name: install diff --git a/.openbsd.yml b/.openbsd.yml index cfd6ca3..c7a3abd 100644 --- a/.openbsd.yml +++ b/.openbsd.yml @@ -31,7 +31,7 @@ tasks: - build: | cd libkernaux ./autogen.sh - ./configure --enable-debug --enable-checks-all CFLAGS='-O3' + ./configure --enable-assert --enable-checks-all CFLAGS='-O3' make doas make install - test: | diff --git a/ChangeLog b/ChangeLog index e3d9e3d..5b6bdbf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,10 @@ 2022-12-13 Alex Kotov * tests/Makefile.am: Fix FreeBSD builds + * configure.ac: Rename feature "--(enable|disable)-debug" to + "--(enable|disable)-assert" + * include/kernaux/assert.h: Rename definition "KERNAUX_DEBUG" to + "KERNAUX_ENABLE_ASSERT" 2022-12-12 Alex Kotov diff --git a/README.md b/README.md index 4c52377..de560c1 100644 --- a/README.md +++ b/README.md @@ -100,10 +100,10 @@ zero). Work-in-progress APIs can change at any time. `#define` the following C preprocessor macros before including `` and `` files. They have effect on your code, not the library code. -* `KERNAUX_DEBUG` - enable assertions. * `KERNAUX_ACCESS_PRIVATE` - disable access modifier "private". Don't do this! * `KERNAUX_ACCESS_PROTECTED` - disable access modifier "protected". Only do this in a file where you implement an inherited type. +* `KERNAUX_ENABLE_ASSERT` - enable assertions. * `KERNAUX_BITFIELDS` - enable bitfields in packed structs. It doesn't follow the C standard and may be incompatible with some compilers. @@ -115,7 +115,7 @@ void (*kernaux_assert_cb)(const char *file, int line, const char *msg) ``` Assertion callback. It's better to always set it to some function which always -interrupts the execution, even when debugging is disabled. It may for example +interrupts the execution, even when assertions are disabled. It may for example call `abort()` in hosted environment, raise an exception in Ruby, panic in Rust or power off the machine in freestanding environment. It may also log the error location and message. @@ -152,7 +152,7 @@ stable options. #### Features -* `--(enable|disable)-debug` - debugging +* `--(enable|disable)-assert` - assertions * `--(enable|disable)-float` - floating-point arithmetic * `--(enable|disable)-werror` - fail on warning (`CFLAGS+='-Werror'`) diff --git a/configure.ac b/configure.ac index ff4a35c..bb1d583 100644 --- a/configure.ac +++ b/configure.ac @@ -42,7 +42,7 @@ AM_INIT_AUTOMAKE([1.16 subdir-objects]) ############### dnl Features (enabled by default) -AC_ARG_ENABLE([debug], AS_HELP_STRING([--disable-debug], [disable debugging])) +AC_ARG_ENABLE([assert], AS_HELP_STRING([--disable-assert], [disable assertions])) AC_ARG_ENABLE([float], AS_HELP_STRING([--disable-float], [disable floating-point arithmetic])) AC_ARG_ENABLE([werror], AS_HELP_STRING([--disable-werror], [disable -Werror])) @@ -127,7 +127,7 @@ AS_IF([test "$with_all" = no], do_without_all) ################## dnl Features (enabled by default) -AS_IF([test "$enable_debug" = no ], [enable_debug=no], [enable_debug=yes]) +AS_IF([test "$enable_assert" = no ], [enable_assert=no], [enable_assert=yes]) AS_IF([test "$enable_float" = no ], [enable_float=no], [enable_float=yes]) AS_IF([test "$enable_werror" = no ], [enable_werror=no], [enable_werror=yes]) @@ -190,7 +190,7 @@ dnl Architecture (additional) AM_CONDITIONAL([ASM_X86], [test "$host_cpu" = i386 -o "$host_cpu" = x86_64]) dnl Features (enabled by default) -AM_CONDITIONAL([ENABLE_DEBUG], [test "$enable_debug" = yes]) +AM_CONDITIONAL([ENABLE_ASSERT], [test "$enable_assert" = yes]) AM_CONDITIONAL([ENABLE_FLOAT], [test "$enable_float" = yes]) AM_CONDITIONAL([ENABLE_WERROR], [test "$enable_werror" = yes]) @@ -241,7 +241,7 @@ AS_IF([test "$host_cpu" = i386], [AC_DEFINE([ASM_X86], AS_IF([test "$host_cpu" = x86_64], [AC_DEFINE([ASM_X86], [1], [architecture is x86])]) dnl Features (enabled by default) -AS_IF([test "$enable_debug" = yes], [AC_DEFINE([ENABLE_DEBUG], [1], [enabled debugging])]) +AS_IF([test "$enable_assert" = yes], [AC_DEFINE([ENABLE_ASSERT], [1], [enabled assertions])]) AS_IF([test "$enable_float" = yes], [AC_DEFINE([ENABLE_FLOAT], [1], [enabled floating-point arithmetic])]) AS_IF([test "$enable_werror" = yes], [AC_DEFINE([ENABLE_WERROR], [1], [enabled -Werror])]) @@ -278,7 +278,7 @@ AS_IF([test "$with_arch_i386" = yes], [AC_DEFINE([WITH_ARCH_X86], AS_IF([test "$with_arch_x86_64" = yes], [AC_DEFINE([WITH_ARCH_X86], [1], [with architecture x86])]) dnl Additional -AS_IF([test "$enable_debug" = yes], [AC_DEFINE([KERNAUX_DEBUG], [1], [enabled debugging])]) +AS_IF([test "$enable_assert" = yes], [AC_DEFINE([KERNAUX_ENABLE_ASSERT], [1], [enabled assertions])]) diff --git a/examples/assert.c b/examples/assert.c index d9cdaf3..464439a 100644 --- a/examples/assert.c +++ b/examples/assert.c @@ -1,4 +1,4 @@ -#define KERNAUX_DEBUG +#define KERNAUX_ENABLE_ASSERT #include #include diff --git a/examples/panic.c b/examples/panic.c index 375e799..b79b29e 100644 --- a/examples/panic.c +++ b/examples/panic.c @@ -1,4 +1,4 @@ -#define KERNAUX_DEBUG +#define KERNAUX_ENABLE_ASSERT #include #include diff --git a/include/kernaux/assert.h b/include/kernaux/assert.h index 09e0172..2e0c997 100644 --- a/include/kernaux/assert.h +++ b/include/kernaux/assert.h @@ -5,7 +5,7 @@ extern "C" { #endif -#ifdef KERNAUX_DEBUG +#ifdef KERNAUX_ENABLE_ASSERT #define KERNAUX_PANIC(msg) (kernaux_assert_do(__FILE__, __LINE__, msg)) #define KERNAUX_ASSERT(cond) ((cond) ? (void)0 : KERNAUX_PANIC(#cond)) #else diff --git a/tests/Makefile.am b/tests/Makefile.am index 841ab08..e09bb88 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -270,7 +270,7 @@ endif # test_ntoa_assert # #################### -if ENABLE_DEBUG +if ENABLE_ASSERT if WITH_NTOA TESTS += test_ntoa_assert test_ntoa_assert_LDADD = $(top_builddir)/libkernaux.la @@ -296,7 +296,7 @@ endif # test_pfa_assert # ################### -if ENABLE_DEBUG +if ENABLE_ASSERT if WITH_PFA TESTS += test_pfa_assert test_pfa_assert_LDADD = $(top_builddir)/libkernaux.la diff --git a/tests/test_memmap.c b/tests/test_memmap.c index ff35279..2ddb9e3 100644 --- a/tests/test_memmap.c +++ b/tests/test_memmap.c @@ -36,7 +36,7 @@ static void before_assert() static void expect_assert() { -#ifdef ENABLE_DEBUG +#ifdef ENABLE_ASSERT // cppcheck-suppress assignmentInAssert assert(assert_count_ctr == ++assert_count_exp); assert(strstr(assert_last_file, "src/memmap.c") != NULL);