Skip to content

Commit

Permalink
Merge branch 'waywardgeek-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Pornin committed Aug 25, 2018
2 parents 3dfabaa + 7a350ff commit 1d59202
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
14 changes: 7 additions & 7 deletions inc/cttk.h
Original file line number Diff line number Diff line change
Expand Up @@ -2814,7 +2814,7 @@ cttk_bool cttk_i31_leq(const uint32_t *x, const uint32_t *y);
cttk_bool cttk_i31_gt(const uint32_t *x, const uint32_t *y);
cttk_bool cttk_i31_geq(const uint32_t *x, const uint32_t *y);
int cttk_i31_sign(const uint32_t *x);
int cttk_i31_cmp(const uint32_t *x, const uint32_t *y);
int32_t cttk_i31_cmp(const uint32_t *x, const uint32_t *y);
void cttk_i31_copy(uint32_t *d, const uint32_t *s);
void cttk_i31_cond_copy(cttk_bool ctl, uint32_t *d, const uint32_t *s);
void cttk_i31_swap(uint32_t *a, uint32_t *b);
Expand Down Expand Up @@ -2847,12 +2847,12 @@ cttk_i31_rem(uint32_t *r, const uint32_t *a, const uint32_t *b)
{
cttk_i31_divrem(NULL, r, a, b);
}
void cttk_i31_mod(uint32_t *m, const uint32_t *a, const uint32_t *b);
void cttk_i31_and(uint32_t *m, const uint32_t *a, const uint32_t *b);
void cttk_i31_or(uint32_t *m, const uint32_t *a, const uint32_t *b);
void cttk_i31_xor(uint32_t *m, const uint32_t *a, const uint32_t *b);
void cttk_i31_eqv(uint32_t *m, const uint32_t *a, const uint32_t *b);
void cttk_i31_not(uint32_t *m, const uint32_t *a);
void cttk_i31_mod(uint32_t *d, const uint32_t *a, const uint32_t *b);
void cttk_i31_and(uint32_t *d, const uint32_t *a, const uint32_t *b);
void cttk_i31_or(uint32_t *d, const uint32_t *a, const uint32_t *b);
void cttk_i31_xor(uint32_t *d, const uint32_t *a, const uint32_t *b);
void cttk_i31_eqv(uint32_t *d, const uint32_t *a, const uint32_t *b);
void cttk_i31_not(uint32_t *d, const uint32_t *a);

#endif

Expand Down
26 changes: 13 additions & 13 deletions src/int31.c
Original file line number Diff line number Diff line change
Expand Up @@ -1037,22 +1037,22 @@ cttk_i31_cmp(const uint32_t *x, const uint32_t *y)

/* see cttk.h */
void
cttk_i31_copy(uint32_t *d, const uint32_t *a)
cttk_i31_copy(uint32_t *d, const uint32_t *s)
{
if (d != a) {
if ((uint32_t)((d[0] ^ a[0]) << 1) != 0) {
if (d != s) {
if ((uint32_t)((d[0] ^ s[0]) << 1) != 0) {
d[0] |= 0x80000000;
return;
}
memcpy(d, a, (((a[0] & 0x7FFFFFFF) + 63) >> 5) * sizeof *a);
memcpy(d, s, (((s[0] & 0x7FFFFFFF) + 63) >> 5) * sizeof *s);
}
}

/* see cttk.h */
void
cttk_i31_cond_copy(cttk_bool ctl, uint32_t *d, const uint32_t *a)
cttk_i31_cond_copy(cttk_bool ctl, uint32_t *d, const uint32_t *s)
{
cttk_i31_mux(ctl, d, a, d);
cttk_i31_mux(ctl, d, s, d);
}

/* see cttk.h */
Expand Down Expand Up @@ -1769,7 +1769,7 @@ static const uint32_t p2m31[] = {

/* see cttk.h */
void
cttk_i31_lsh(uint32_t *d, const uint32_t *a, unsigned n)
cttk_i31_lsh(uint32_t *d, const uint32_t *a, uint32_t n)
{
cttk_bool r;

Expand Down Expand Up @@ -1803,7 +1803,7 @@ cttk_i31_lsh_prot(uint32_t *d, const uint32_t *a, uint32_t n)

/* see cttk.h */
void
cttk_i31_lsh_trunc(uint32_t *d, const uint32_t *a, unsigned n)
cttk_i31_lsh_trunc(uint32_t *d, const uint32_t *a, uint32_t n)
{
if (((d[0] ^ a[0]) << 1) != 0) {
d[0] |= 0x80000000;
Expand Down Expand Up @@ -1831,7 +1831,7 @@ cttk_i31_lsh_trunc_prot(uint32_t *d, const uint32_t *a, uint32_t n)

/* see cttk.h */
void
cttk_i31_rsh(uint32_t *d, const uint32_t *a, unsigned n)
cttk_i31_rsh(uint32_t *d, const uint32_t *a, uint32_t n)
{
if (((d[0] ^ a[0]) << 1) != 0) {
d[0] |= 0x80000000;
Expand Down Expand Up @@ -2263,16 +2263,16 @@ cttk_i31_divrem(uint32_t *q, uint32_t *r, const uint32_t *a, const uint32_t *b)

/* see cttk.h */
void
cttk_i31_mod(uint32_t *m, const uint32_t *a, const uint32_t *b)
cttk_i31_mod(uint32_t *d, const uint32_t *a, const uint32_t *b)
{
uint32_t h;

h = m[0] & 0x7FFFFFFF;
h = d[0] & 0x7FFFFFFF;
if (h != (a[0] & 0x7FFFFFFF) || h != (b[0] & 0x7FFFFFFF)) {
m[0] |= 0x80000000;
d[0] |= 0x80000000;
return;
}
gendiv(NULL, m, a, b, 1);
gendiv(NULL, d, a, b, 1);
}

/* see cttk.h */
Expand Down

0 comments on commit 1d59202

Please sign in to comment.