Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions librhash/algorithms.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ void rhash_init_algorithms(void)
rhash_gost94_init_table();
#endif
table_init_sha_ext();

#if defined(_MSC_VER)
/* ensure that (LONG*)&algorithms_initialized_flag is valid */
RHASH_ASSERT(sizeof(LONG) == sizeof(unsigned));
#endif
atomic_compare_and_swap(&algorithms_initialized_flag, 0, 1);
}

Expand Down
3 changes: 2 additions & 1 deletion librhash/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ extern "C" {
#elif defined(_MSC_VER)
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# define atomic_compare_and_swap(ptr, oldval, newval) InterlockedCompareExchange(ptr, newval, oldval)
# define atomic_compare_and_swap(ptr, oldval, newval) \
InterlockedCompareExchange((LONG volatile*)(ptr), (LONG)(newval), (LONG)(oldval))
#elif defined(__sun)
# include <atomic.h>
# define atomic_compare_and_swap(ptr, oldval, newval) atomic_cas_32(ptr, oldval, newval)
Expand Down
Loading