Skip to content

Commit

Permalink
project: Add minor missing features.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sibras committed Oct 20, 2021
1 parent 3a424d0 commit 7d6ea11
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
81 changes: 81 additions & 0 deletions SMP/SMP.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
diff --git a/longlong.h b/longlong.h
index edbaf568e..f079b1ba6 100644
--- a/longlong.h
+++ b/longlong.h
@@ -1964,6 +1964,76 @@ extern UWtype __MPN(udiv_qrnnd) (UWtype *, UWtype, UWtype, UWtype);

#endif /* NO_ASM */

+#ifdef _MSC_VER
+#include <intrin.h>
+#include <immintrin.h>
+#if W_TYPE_SIZE == 32
+#ifndef count_leading_zeros
+#define count_leading_zeros(count, x) \
+ do { \
+ USItype __cbtmp; \
+ ASSERT ((x) != 0); \
+ _BitScanReverse(&__cbtmp, x); \
+ (count) = __cbtmp ^ 31; \
+ } while (0)
+#endif
+
+#ifndef count_trailing_zeros
+#define count_trailing_zeros(count, x) \
+ do { \
+ ASSERT ((x) != 0); \
+ _BitScanForward(&(count), x); \
+ } while (0)
+#endif
+
+#elif W_TYPE_SIZE == 64
+#ifndef count_leading_zeros
+#define count_leading_zeros(count, x) \
+ do { \
+ USItype __cbtmp; \
+ ASSERT ((x) != 0); \
+ _BitScanReverse64(&__cbtmp, x); \
+ (count) = __cbtmp ^ 63; \
+ } while (0)
+#endif
+
+#ifndef count_trailing_zeros
+#define count_trailing_zeros(count, x) \
+ do { \
+ ASSERT ((x) != 0); \
+ _BitScanForward64(&(count), x); \
+ } while (0)
+#endif
+
+#ifndef umul_ppmm
+#define umul_ppmm(w1, w0, u, v) \
+ do { \
+ (w0) = _umul128(u, v, &(w1)); \
+ } while (0)
+#endif
+
+#ifndef smul_ppmm
+#define smul_ppmm(w1, w0, u, v) \
+ do { \
+ (w0) = _mul128(u, v, &(w1)); \
+ } while (0)
+#endif
+
+#ifndef udiv_qrnnd
+#define udiv_qrnnd(q, r, n1, n0, dx) \
+ do { \
+ (q) = _udiv128(n1, n0, dx, &(r)); \
+ } while (0)
+#endif
+
+#ifndef sdiv_qrnnd
+#define sdiv_qrnnd(q, r, n1, n0, dx) \
+ do { \
+ (q) = _div128(n1, n0, dx, &(r)); \
+ } while (0)
+#endif
+#endif
+#endif

/* FIXME: "sidi" here is highly doubtful, should sometimes be "diti". */
#if !defined (umul_ppmm) && defined (__umulsidi3)
5 changes: 5 additions & 0 deletions SMP/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@

/* Define one of the following to 1 for the host CPU, as per the output of
./config.guess. If your CPU is not listed here, leave all undefined. */
#if defined(__x86_64) || defined(_M_X64)
# define HAVE_HOST_CPU_core2 1
#else
# define HAVE_HOST_CPU_i686 1
#endif
/* #undef HAVE_HOST_CPU_alphaev67 */
/* #undef HAVE_HOST_CPU_alphaev68 */
/* #undef HAVE_HOST_CPU_alphaev7 */
Expand Down
1 change: 1 addition & 0 deletions SMP/libgmp.def
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ __gmp_randclear
__gmp_urandomb_ui
__gmp_urandomm_ui
__gmp_asprintf
__gmp_vasprintf
__gmp_fprintf
__gmp_printf
__gmp_snprintf
Expand Down

0 comments on commit 7d6ea11

Please sign in to comment.