Skip to content

Comments

Fix 32-bit portability issues in NIF code#3

Merged
martinsumner merged 1 commit intoOpenRiak:openriak-3.4from
lemenkov:fix_32_bit
Feb 23, 2026
Merged

Fix 32-bit portability issues in NIF code#3
martinsumner merged 1 commit intoOpenRiak:openriak-3.4from
lemenkov:fix_32_bit

Conversation

@lemenkov
Copy link
Contributor

  1. Use uintptr_t instead of uint64_t for pointer tagging macros (IS_ENTRY_LIST, GET_ENTRY_LIST_POINTER, MAKE_ENTRY_LIST_POINTER). Fixes warnings on 32-bit:
gcc -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m32 -march=i686 -mtune=generic -msse2 -mfpmath=sse -mstackrealign -fasynchronous-unwind-tables -fstack-clash-protection -mtls-dialect=gnu -c -I/usr/lib/erlang/usr/include c_src/bitcask_nifs.c -o c_src/bitcask_nifs.o
c_src/bitcask_nifs.c: In function ‘keydir_entry_hash’:
c_src/bitcask_nifs.c:190:27: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  190 | #define IS_ENTRY_LIST(p) ((uint64_t)p&1)
      |                           ^
  1. Use correct type for enif_get_ulong() - it expects unsigned long*, not size_t*, which may differ on some platforms.

1. Use uintptr_t instead of uint64_t for pointer tagging macros
   (IS_ENTRY_LIST, GET_ENTRY_LIST_POINTER, MAKE_ENTRY_LIST_POINTER).
   Fixes warnings on 32-bit:

```
gcc -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m32 -march=i686 -mtune=generic -msse2 -mfpmath=sse -mstackrealign -fasynchronous-unwind-tables -fstack-clash-protection -mtls-dialect=gnu -c -I/usr/lib/erlang/usr/include c_src/bitcask_nifs.c -o c_src/bitcask_nifs.o
c_src/bitcask_nifs.c: In function ‘keydir_entry_hash’:
c_src/bitcask_nifs.c:190:27: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  190 | #define IS_ENTRY_LIST(p) ((uint64_t)p&1)
      |                           ^
```

2. Use correct type for enif_get_ulong() - it expects unsigned long*,
   not size_t*, which may differ on some platforms.

Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
Assisted-by: Claude (Anthropic) <https://claude.ai>
@martinsumner
Copy link
Contributor

@aef- would you be able to provide a review for this? Seems fine to me, but I don't have a background in C.

@martinsumner martinsumner moved this to Ready For Review in OpenRiak 3.4.1 Feb 16, 2026
@aef-
Copy link
Member

aef- commented Feb 22, 2026

lgtm -- thanks for the PR

@martinsumner martinsumner merged commit eb7c056 into OpenRiak:openriak-3.4 Feb 23, 2026
2 checks passed
@github-project-automation github-project-automation bot moved this from Ready For Review to Done in OpenRiak 3.4.1 Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants