mirror of
https://git.sr.ht/~cismonx/bookmarkfs
synced 2025-06-07 19:58:50 +00:00
chore: remove null pointer representation check
That part of code in configure.ac look stupid, remove it. If we _do_ try to run BookmarkFS on such an exotic platform with non-zero null pointers, the breakage should be detected by the tests (if it can run or even build at all).
This commit is contained in:
parent
1836692719
commit
b585a05c91
2 changed files with 7 additions and 21 deletions
16
configure.ac
16
configure.ac
|
@ -40,22 +40,6 @@ AC_PROG_CPP
|
||||||
AC_PROG_INSTALL
|
AC_PROG_INSTALL
|
||||||
AC_PROG_MAKE_SET
|
AC_PROG_MAKE_SET
|
||||||
|
|
||||||
# -- Checks for platform-specific features --
|
|
||||||
|
|
||||||
AC_MSG_CHECKING([if null pointers have an all-zero representation])
|
|
||||||
AC_RUN_IFELSE([
|
|
||||||
AC_LANG_PROGRAM([[#include <string.h>]],
|
|
||||||
[[void *ptr = NULL; char buf[sizeof(ptr)] = { 0 };
|
|
||||||
if (0 != memcmp(buf, &ptr, sizeof(ptr))) return 1;]])
|
|
||||||
], [
|
|
||||||
AC_MSG_RESULT([yes])
|
|
||||||
], [
|
|
||||||
AC_MSG_RESULT([no])
|
|
||||||
AC_MSG_ERROR(m4_normalize([
|
|
||||||
Null pointers do not have an all-zero representation on this platform.
|
|
||||||
]))
|
|
||||||
])
|
|
||||||
|
|
||||||
# -- Checks for features --
|
# -- Checks for features --
|
||||||
|
|
||||||
BOOKMARKFS_FEAT([bookmarkfs-util], [no], [the BookmarkFS utility library])
|
BOOKMARKFS_FEAT([bookmarkfs-util], [no], [the BookmarkFS utility library])
|
||||||
|
|
|
@ -300,17 +300,19 @@ hashmap_create (
|
||||||
hashmap_hash_func *entry_hash
|
hashmap_hash_func *entry_hash
|
||||||
) {
|
) {
|
||||||
size_t buckets_len = BUCKET_CNT(EXP_MIN);
|
size_t buckets_len = BUCKET_CNT(EXP_MIN);
|
||||||
// XXX: Null pointers have an implementation-defined value
|
// XXX: According to the ISO C standard, null pointers have an
|
||||||
// per ISO C standard, and should not be zero-initialized with calloc().
|
// implementation-defined value, and should not be zero-initialized
|
||||||
// However, it is guaranteed to be zero on most, if not all,
|
// with calloc() or memset().
|
||||||
// modern ABI standards that we know of.
|
|
||||||
//
|
//
|
||||||
// Nevertheless, we add a build-time check just in case (see configure.ac).
|
// However, it is guaranteed to be all-bits-zero on most,
|
||||||
|
// if not all, modern ABI standards that we know of.
|
||||||
|
// POSIX also has such requirements since POSIX.1-2024.
|
||||||
//
|
//
|
||||||
// See:
|
// See:
|
||||||
// - <https://github.com/ARM-software/abi-aa>
|
// - <https://github.com/ARM-software/abi-aa>
|
||||||
// - <https://github.com/riscv-non-isa/riscv-elf-psabi-doc>
|
// - <https://github.com/riscv-non-isa/riscv-elf-psabi-doc>
|
||||||
// - <https://gitlab.com/x86-psABIs/x86-64-ABI>
|
// - <https://gitlab.com/x86-psABIs/x86-64-ABI>
|
||||||
|
// - <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/stddef.h.html>
|
||||||
struct bucket *buckets = xcalloc(buckets_len, sizeof(struct bucket));
|
struct bucket *buckets = xcalloc(buckets_len, sizeof(struct bucket));
|
||||||
|
|
||||||
struct hashmap *h = xmalloc(sizeof(*h));
|
struct hashmap *h = xmalloc(sizeof(*h));
|
||||||
|
|
Loading…
Add table
Reference in a new issue