Skip to content

Support 64-bit limbs on no-asm platforms #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion bindings/rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,11 @@ fn main() {
cc.define("SCRATCH_LIMIT", "(45 * 1024)");
}
if !cfg!(debug_assertions) {
cc.opt_level(2);
if target_arch.eq("s390x") {
cc.opt_level(3);
} else {
cc.opt_level(2);
}
}
cc.files(&file_vec).compile("blst");

Expand Down
4 changes: 3 additions & 1 deletion src/no_asm.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#if LIMB_T_BITS==32
typedef unsigned long long llimb_t;
#else
typedef unsigned __int128 llimb_t;
#endif

#if !defined(__STDC_VERSION__) || __STDC_VERSION__<199901 || defined(__STDC_NO_VLA__)
Expand Down Expand Up @@ -1155,7 +1157,7 @@ limb_t div_3_limbs(const limb_t div_top[2], limb_t d_lo, limb_t d_hi)
static limb_t quot_rem_n(limb_t *div_rem, const limb_t *divisor,
limb_t quotient, size_t n)
{
__builtin_assume(n != 0 && n%2 == 0);
__builtin_assume(n != 0);
llimb_t limbx;
limb_t tmp[n+1], carry, mask, borrow;
size_t i;
Expand Down
6 changes: 4 additions & 2 deletions src/vect.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ typedef unsigned long long limb_t;
typedef unsigned __int64 limb_t;
# define LIMB_T_BITS 64

#elif defined(__BLST_NO_ASM__) || defined(__wasm64__)
#elif defined(__wasm64__)
typedef unsigned int limb_t;
# define LIMB_T_BITS 32
# ifndef __BLST_NO_ASM__
Expand All @@ -31,8 +31,10 @@ typedef unsigned long limb_t;
# define LIMB_T_BITS 64
# else
# define LIMB_T_BITS 32
# define __BLST_NO_ASM__
# endif
# ifndef __BLST_NO_ASM__
# define __BLST_NO_ASM__
# endif
#endif

/*
Expand Down