diff options
| author | Mattias Andrée <maandree@kth.se> | 2016-04-29 21:54:39 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2016-04-29 21:55:15 +0200 |
| commit | 4bba6e7176632b4d760ba9362a1515552471d741 (patch) | |
| tree | edd86d32b0867990bf953568164800391b769589 /src/internals.h | |
| parent | refsheet: fix type of second parameter for zseti, zsetu, zcmpi, and zcmpu (diff) | |
| download | libzahl-4bba6e7176632b4d760ba9362a1515552471d741.tar.gz libzahl-4bba6e7176632b4d760ba9362a1515552471d741.tar.bz2 libzahl-4bba6e7176632b4d760ba9362a1515552471d741.tar.xz | |
Some optimisations, fix refsheet, and disable const/pure attributes in gmp in benchmark
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/internals.h')
| -rw-r--r-- | src/internals.h | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/src/internals.h b/src/internals.h index 6faa254..a049e1a 100644 --- a/src/internals.h +++ b/src/internals.h @@ -105,11 +105,12 @@ extern void *libzahl_temp_allocation; #define SET_SIGNUM(a, signum) ZAHL_SET_SIGNUM(a, signum) #define SET(a, b) ZAHL_SET(a, b) -#define ENSURE_SIZE(a, n) do { if ((a)->alloced < (n)) libzahl_realloc(a, (n)); } while (0) +#define ENSURE_SIZE(a, n) ZAHL_ENSURE_SIZE(a, n) #define TRIM(a) ZAHL_TRIM(a) #define TRIM_NONZERO(a) ZAHL_TRIM_NONZERO(a) #define TRIM_AND_ZERO(a) ZAHL_TRIM_AND_ZERO(a) #define TRIM_AND_SIGN(a, s) ZAHL_TRIM_AND_SIGN(a, s) +#define SWAP(a, b, t, m) ((t)->m = (a)->m, (a)->m = (b)->m, (b)->m = (t)->m) #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define znegative(a) (zsignum(a) < 0) @@ -120,8 +121,9 @@ extern void *libzahl_temp_allocation; #define zpositive2(a, b) (zsignum(a) + zsignum(b) == 2) #define zzero2(a, b) (!(zsignum(a) | zsignum(b))) #define zmemmove(d, s, n) memmove((d), (s), (n) * sizeof(zahl_char_t)) +#define zmemcpy(d, s, n) libzahl_memcpy(d, s, n) +#define zmemset(a, v, n) libzahl_memset(a, v, n) -void libzahl_realloc(z_t a, size_t need); void zmul_impl(z_t a, z_t b, z_t c); void zsqr_impl(z_t a, z_t b); @@ -151,20 +153,6 @@ libzahl_memfailure(void) libzahl_failure(errno); } -static inline void -zmemcpy(zahl_char_t *restrict d, const zahl_char_t *restrict s, register size_t n) -{ - while (n--) - d[n] = s[n]; -} - -static inline void -zmemset(zahl_char_t *a, register zahl_char_t v, register size_t n) -{ - while (n--) - a[n] = v; -} - /* * libzahl_msb_nz_zu * ^^^ ^^ ^^ @@ -218,6 +206,17 @@ libzahl_add_overflow(zahl_char_t *rp, zahl_char_t a, zahl_char_t b) #endif static inline void +zsplit_pz(z_t high, z_t low, z_t a, size_t delim) +{ + if (unlikely(zzero(a))) { + SET_SIGNUM(high, 0); + SET_SIGNUM(low, 0); + } else { + zsplit(high, low, a, delim); + } +} + +static inline void zrsh_taint(z_t a, size_t bits) { size_t i, chars, cbits; |
