This commit is contained in:
Alex Kotov 2022-12-13 08:51:17 +04:00
parent c4698fb204
commit 667da18fb3
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
14 changed files with 35 additions and 31 deletions

View File

@ -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:

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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: |

View File

@ -1,6 +1,10 @@
2022-12-13 Alex Kotov <kotovalexarian@gmail.com>
* 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 <kotovalexarian@gmail.com>

View File

@ -100,10 +100,10 @@ zero). Work-in-progress APIs can change at any time.
`#define` the following C preprocessor macros before including `<kernaux.h>` and
`<kernaux/*.h>` 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'`)

View File

@ -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])])

View File

@ -1,4 +1,4 @@
#define KERNAUX_DEBUG
#define KERNAUX_ENABLE_ASSERT
#include <kernaux/assert.h>
#include <assert.h>

View File

@ -1,4 +1,4 @@
#define KERNAUX_DEBUG
#define KERNAUX_ENABLE_ASSERT
#include <kernaux/assert.h>
#include <assert.h>

View File

@ -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

View File

@ -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

View File

@ -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);