Re: coreutils and GCC -fanalyzer

2020-07-01 Thread Paul Eggert
On 5/23/20 9:08 AM, Paul Eggert wrote: > So I am thinking of killing two > stones by doing the following. > > 1. Test for -fanalyzer, -Wall, -Wextra. > > 2. Test for flags not automatically enabled by -fanalyzer, -Wall, -Wextra but > flags that we want anyway. > > 3. Test for flags automaticall

[PATCH] tests: pacify gcc -fanalyzer on zerosize_ptr

2020-07-01 Thread Paul Eggert
* tests/test-memcasecmp.c (main): * tests/test-memchr.c (main): * tests/test-memchr2.c (main): * tests/test-memcmp.c (main): * tests/test-memmem.c (main): * tests/test-memrchr.c (main): * tests/unistr/test-chr.h (main): * tests/unistr/test-cmp.h (test_cmp): Check whether zerosize_ptr returns NULL b

Re: Module suggestion: Atomic operations

2020-07-01 Thread Bruno Haible
Marc Nieper-Wißkirchen wrote in : > C11 has introduced atomic types and atomic operations. When they are not > available, one can use locks/mutexes instead. > > It would be nice if there was a Gnulib module that abstracts over t

new module for async-safe spin locks

2020-07-01 Thread Bruno Haible
This patch series adds a module 'asyncsafe-spin', with async-safe spin locks. What is it? --- An async-safe spin lock is a spin lock that can be used to communicate between a thread that executes normal code and a thread that executes a signal handler. The table in section 2.4.3 of

windows-spin: Fix race condition on multiprocessor systems

2020-07-01 Thread Bruno Haible
For spin-locks that are initialized dynamically, the initial value of the lock word needs to be propagated to the other processors, before they can attempt to lock this lock. The function MemoryBarrier() is part of the Windows API.

pthread-spin: add optimized fallback for GCC versions >= 4.1, < 4.7

2020-07-01 Thread Bruno Haible
Older GCC versions have another set of built-ins for atomic operations. 2020-07-01 Bruno Haible pthread-spin: Add optimized fallback for GCC versions >= 4.1, < 4.7. * lib/pthread-spin.c (pthread_spin_init, pthread_spin_lock, pthread_spin_trylock, pthread_spin_unlock):

Re: pthread-spin: add error checking

2020-07-01 Thread Bruno Haible
A small improvement over the last patch. For some architectures, an atomic operation on a 32-bit word is simpler than an atomic operation on a single byte. You see this when looking at the "gcc -O2 -S" output of the file. 2020-07-01 Bruno Haible pthread-spin: Optimize fallback for GCC

pthread-spin: add error checking

2020-07-01 Thread Bruno Haible
This patch modifies the fallback implementation of the POSIX spin-locks so that the unlock operation verifies that the lock is indeed locked. 2020-07-01 Bruno Haible pthread-spin: Add error checking. * lib/pthread-spin.c: Include . (pthread_spin_init, pthread_spin_lock

pthread-spin: add tests

2020-07-01 Thread Bruno Haible
This patch series 1) reduces code duplication among the lock and mutex tests. 2) adds a unit test for the 'pthread-spin' module. 2020-07-01 Bruno Haible pthread-spin: Add tests. * tests/test-pthread-spin.c: New file, based on tests/test-lock.c. * modules/pthread-sp