Skip to content

Commit 076f6b1

Browse files
committed
Add support for 32-bit atomics
1 parent 4708ddd commit 076f6b1

21 files changed

+1672
-488
lines changed

erts/aclocal.m4

+130-2
Original file line numberDiff line numberDiff line change
@@ -747,9 +747,124 @@ case "$THR_LIB_NAME" in
747747
if test $found_win32_winnt = no; then
748748
AC_MSG_ERROR([-D_WIN32_WINNT missing in CPPFLAGS])
749749
fi
750-
ethr_have_native_atomics=yes
751-
ethr_have_native_spinlock=yes
750+
752751
AC_DEFINE(ETHR_WIN32_THREADS, 1, [Define if you have win32 threads])
752+
753+
have_ilckd=no
754+
AC_MSG_CHECKING([for _InterlockedCompareExchange64()])
755+
AC_TRY_LINK([
756+
#define WIN32_LEAN_AND_MEAN
757+
#include <windows.h>
758+
],
759+
[
760+
volatile __int64 *var;
761+
_InterlockedCompareExchange64(var, (__int64) 1, (__int64) 0);
762+
return 0;
763+
],
764+
have_ilckd=yes)
765+
AC_MSG_RESULT([$have_ilckd])
766+
test $have_ilckd = yes && AC_DEFINE(ETHR_HAVE__INTERLOCKEDCOMPAREEXCHANGE64, 1, [Define if you have _InterlockedCompareExchange64()])
767+
768+
AC_CHECK_SIZEOF(void *)
769+
case "$ac_cv_sizeof_void_p-$have_ilckd" in
770+
8-no)
771+
ethr_have_native_atomics=no
772+
ethr_have_native_spinlock=no;;
773+
*)
774+
ethr_have_native_atomics=yes
775+
ethr_have_native_spinlock=yes;;
776+
esac
777+
778+
have_ilckd=no
779+
AC_MSG_CHECKING([for _InterlockedDecrement64()])
780+
AC_TRY_LINK([
781+
#define WIN32_LEAN_AND_MEAN
782+
#include <windows.h>
783+
],
784+
[
785+
volatile __int64 *var;
786+
_InterlockedDecrement64(var);
787+
return 0;
788+
],
789+
have_ilckd=yes)
790+
AC_MSG_RESULT([$have_ilckd])
791+
test $have_ilckd = yes && AC_DEFINE(ETHR_HAVE__INTERLOCKEDDECREMENT64, 1, [Define if you have _InterlockedDecrement64()])
792+
793+
have_ilckd=no
794+
AC_MSG_CHECKING([for _InterlockedIncrement64()])
795+
AC_TRY_LINK([
796+
#define WIN32_LEAN_AND_MEAN
797+
#include <windows.h>
798+
],
799+
[
800+
volatile __int64 *var;
801+
_InterlockedIncrement64(var);
802+
return 0;
803+
],
804+
have_ilckd=yes)
805+
AC_MSG_RESULT([$have_ilckd])
806+
test $have_ilckd = yes && AC_DEFINE(ETHR_HAVE__INTERLOCKEDINCREMENT64, 1, [Define if you have _InterlockedIncrement64()])
807+
808+
have_ilckd=no
809+
AC_MSG_CHECKING([for _InterlockedExchangeAdd64()])
810+
AC_TRY_LINK([
811+
#define WIN32_LEAN_AND_MEAN
812+
#include <windows.h>
813+
],
814+
[
815+
volatile __int64 *var;
816+
_InterlockedExchangeAdd64(var, (__int64) 1);
817+
return 0;
818+
],
819+
have_ilckd=yes)
820+
AC_MSG_RESULT([$have_ilckd])
821+
test $have_ilckd = yes && AC_DEFINE(ETHR_HAVE__INTERLOCKEDEXCHANGEADD64, 1, [Define if you have _InterlockedExchangeAdd64()])
822+
823+
have_ilckd=no
824+
AC_MSG_CHECKING([for _InterlockedExchange64()])
825+
AC_TRY_LINK([
826+
#define WIN32_LEAN_AND_MEAN
827+
#include <windows.h>
828+
],
829+
[
830+
volatile __int64 *var;
831+
_InterlockedExchange64(var, (__int64) 1);
832+
return 0;
833+
],
834+
have_ilckd=yes)
835+
AC_MSG_RESULT([$have_ilckd])
836+
test $have_ilckd = yes && AC_DEFINE(ETHR_HAVE__INTERLOCKEDEXCHANGE64, 1, [Define if you have _InterlockedExchange64()])
837+
838+
have_ilckd=no
839+
AC_MSG_CHECKING([for _InterlockedAnd64()])
840+
AC_TRY_LINK([
841+
#define WIN32_LEAN_AND_MEAN
842+
#include <windows.h>
843+
],
844+
[
845+
volatile __int64 *var;
846+
_InterlockedAnd64(var, (__int64) 1);
847+
return 0;
848+
],
849+
have_ilckd=yes)
850+
AC_MSG_RESULT([$have_ilckd])
851+
test $have_ilckd = yes && AC_DEFINE(ETHR_HAVE__INTERLOCKEDAND64, 1, [Define if you have _InterlockedAnd64()])
852+
853+
have_ilckd=no
854+
AC_MSG_CHECKING([for _InterlockedOr64()])
855+
AC_TRY_LINK([
856+
#define WIN32_LEAN_AND_MEAN
857+
#include <windows.h>
858+
],
859+
[
860+
volatile __int64 *var;
861+
_InterlockedOr64(var, (__int64) 1);
862+
return 0;
863+
],
864+
have_ilckd=yes)
865+
AC_MSG_RESULT([$have_ilckd])
866+
test $have_ilckd = yes && AC_DEFINE(ETHR_HAVE__INTERLOCKEDOR64, 1, [Define if you have _InterlockedOr64()])
867+
753868
;;
754869
755870
pthread)
@@ -1096,6 +1211,19 @@ AC_DEFINE_UNQUOTED(ETHR_SIZEOF_LONG_LONG, $ac_cv_sizeof_long_long, [Define to th
10961211
AC_CHECK_SIZEOF(__int64)
10971212
AC_DEFINE_UNQUOTED(ETHR_SIZEOF___INT64, $ac_cv_sizeof___int64, [Define to the size of __int64])
10981213
1214+
1215+
case X$erl_xcomp_bigendian in
1216+
X) ;;
1217+
Xyes|Xno) ac_cv_c_bigendian=$erl_xcomp_bigendian;;
1218+
*) AC_MSG_ERROR([Bad erl_xcomp_bigendian value: $erl_xcomp_bigendian]);;
1219+
esac
1220+
1221+
AC_C_BIGENDIAN
1222+
1223+
if test "$ac_cv_c_bigendian" = "yes"; then
1224+
AC_DEFINE(ETHR_BIGENDIAN, 1, [Define if bigendian])
1225+
fi
1226+
10991227
AC_ARG_ENABLE(native-ethr-impls,
11001228
AS_HELP_STRING([--disable-native-ethr-impls],
11011229
[disable native ethread implementations]),

0 commit comments

Comments
 (0)