Skip to content

Commit eb7c056

Browse files
authored
Merge pull request #3 from lemenkov/fix_32_bit
Fix 32-bit portability issues in NIF code
2 parents 8c12bc5 + 43bda99 commit eb7c056

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

c_src/bitcask_nifs.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,9 @@ typedef struct
187187
// An entry pointer may be tagged to indicate it really points to an
188188
// list of entries with different timestamps. Those are created when
189189
// there are concurrent iterations and updates.
190-
#define IS_ENTRY_LIST(p) ((uint64_t)p&1)
191-
#define GET_ENTRY_LIST_POINTER(p) ((bitcask_keydir_entry_head*)((uint64_t)p&(uint64_t)~1))
192-
#define MAKE_ENTRY_LIST_POINTER(p) ((bitcask_keydir_entry*)((uint64_t)p|(uint64_t)1))
190+
#define IS_ENTRY_LIST(p) ((uintptr_t)p&1)
191+
#define GET_ENTRY_LIST_POINTER(p) ((bitcask_keydir_entry_head*)((uintptr_t)p&(uintptr_t)~1))
192+
#define MAKE_ENTRY_LIST_POINTER(p) ((bitcask_keydir_entry*)((uintptr_t)p|(uintptr_t)1))
193193

194194
// Holds values fetched from a regular entry or a snapshot from an entry list.
195195
typedef struct
@@ -2494,12 +2494,13 @@ ERL_NIF_TERM bitcask_nifs_file_pwrite(ErlNifEnv* env, int argc, const ERL_NIF_TE
24942494
ERL_NIF_TERM bitcask_nifs_file_read(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
24952495
{
24962496
bitcask_file_handle* handle;
2497-
size_t count;
2497+
unsigned long count_ul;
24982498

24992499
if (enif_get_resource(env, argv[0], bitcask_file_RESOURCE, (void**)&handle) &&
2500-
enif_get_ulong(env, argv[1], &count)) /* Count */
2500+
enif_get_ulong(env, argv[1], &count_ul)) /* Count */
25012501
{
25022502
ErlNifBinary bin;
2503+
size_t count = count_ul;
25032504
if (!enif_alloc_binary(count, &bin))
25042505
{
25052506
return enif_make_tuple2(env, ATOM_ERROR, ATOM_ALLOCATION_ERROR);

0 commit comments

Comments
 (0)