diff '--color=auto' -Naur a/lib/locks.h b/lib/locks.h
--- a/lib/locks.h	2026-11-07 09:40:39.206388274 +0000
+++ b/lib/locks.h	2026-11-07 10:00:30.042608730 +0000
@@ -37,6 +37,20 @@
 # define VALGRIND_HG_DISABLE_CHECKING(X, Y)
 #endif
 
+#ifndef assert_perror
+# include <stdlib.h>
+# include <stdio.h>
+# include <errno.h>
+# define assert_perror(errnum) do { \
+    int _errnum = (errnum);         \
+    if (_errnum != 0) {             \
+      errno = _errnum;              \
+      perror("assert_perror");      \
+      abort();                      \
+    }                               \
+} while(0)
+#endif
+
 #ifdef USE_LOCKS
 # include <pthread.h>
 # include <assert.h>
