diff --git a/RELEASE_ANNOUNCEMENT b/RELEASE_ANNOUNCEMENT index f2d4b9e..87c6f65 100644 --- a/RELEASE_ANNOUNCEMENT +++ b/RELEASE_ANNOUNCEMENT @@ -1,4 +1,4 @@ -Release 3.4.7 of cpuminer-opt is available for download with support for +Release 3.4.8 of cpuminer-opt is available for download with support for Windows. cpuminer-opt now supports 38 algorithms on CPUs with at least SSE2 @@ -10,10 +10,10 @@ CPUs with AES_NI for even greater performance, including the Intel Westbridge and newer and AMD equivalent. See the performance comparison below. -New in 3.4.7 +New in 3.4.8 -- fixed benchmark, except for x11evo -- added CPU temperature to share submission report +- fixed API display of diff for cryptonight +- cleaned up some cpuminer-multi artifacts Users with non-SSE2 CPUs or who want to mine algos not supported by cpuminer-opt may find cpuminer-multi by TPruvot useful. diff --git a/algo-gate-api.c b/algo-gate-api.c index c2a04be..f1d1b01 100644 --- a/algo-gate-api.c +++ b/algo-gate-api.c @@ -115,7 +115,7 @@ void init_algo_gate( algo_gate_t* gate ) gate->wait_for_diff = (void*)&std_wait_for_diff; gate->get_max64 = (void*)&get_max64_0x1fffffLL; gate->gen_merkle_root = (void*)&sha256d_gen_merkle_root; - gate->stratum_get_g_work = (void*)&std_stratum_get_g_work; + gate->stratum_gen_work = (void*)&std_stratum_gen_work; gate->build_stratum_request = (void*)&std_le_build_stratum_request; gate->set_target = (void*)&std_set_target; gate->submit_getwork_result = (void*)&std_submit_getwork_result; @@ -218,7 +218,7 @@ bool register_json_rpc2( algo_gate_t *gate ) gate->wait_for_diff = (void*)&do_nothing; gate->get_new_work = (void*)&jr2_get_new_work; gate->get_nonceptr = (void*)&jr2_get_nonceptr; - gate->stratum_get_g_work = (void*)&jr2_stratum_get_g_work; + gate->stratum_gen_work = (void*)&jr2_stratum_gen_work; gate->build_stratum_request = (void*)&jr2_build_stratum_request; gate->submit_getwork_result = (void*)&jr2_submit_getwork_result; gate->longpoll_rpc_call = (void*)&jr2_longpoll_rpc_call; diff --git a/algo-gate-api.h b/algo-gate-api.h index e2f1801..4d72b09 100644 --- a/algo-gate-api.h +++ b/algo-gate-api.h @@ -115,27 +115,27 @@ void ( *hash_alt ) ( void*, const void*, uint32_t ); void ( *hash_suw ) ( void*, const void* ); //optional, safe to use default in most cases -bool ( *miner_thread_init ) (); -void ( *stratum_get_g_work ) ( struct stratum_ctx*, struct work*, int ); -void ( *get_new_work ) ( struct work*, struct work*, int, uint32_t*, - bool ); -uint32_t *( *get_nonceptr ) ( uint32_t* ); -void ( *display_extra_data ) ( struct work*, uint64_t* ); -void ( *wait_for_diff ) ( struct stratum_ctx* ); -int64_t ( *get_max64 ) (); -bool ( *work_decode ) ( const struct json_t*, struct work* ); -void ( *set_target) ( struct work*, double ); -bool ( *submit_getwork_result ) ( CURL*, struct work* ); -void ( *gen_merkle_root ) ( char*, struct stratum_ctx* ); -void ( *build_stratum_request ) ( char*, struct work*, struct stratum_ctx* ); -void ( *set_work_data_endian ) ( struct work* ); -void ( *calc_network_diff ) ( struct work* ); -void ( *build_extraheader ) ( struct work*, struct stratum_ctx* ); -bool ( *prevent_dupes ) ( struct work*, struct stratum_ctx*, int ); -void ( *resync_threads ) ( struct work* ); -bool ( *do_this_thread ) ( int ); -json_t* (*longpoll_rpc_call) ( CURL*, int*, char* ); -bool ( *stratum_handle_response ) ( json_t* ); +bool ( *miner_thread_init ) (); +void ( *stratum_gen_work ) ( struct stratum_ctx*, struct work* ); +void ( *get_new_work ) ( struct work*, struct work*, int, uint32_t*, + bool ); +uint32_t *( *get_nonceptr ) ( uint32_t* ); +void ( *display_extra_data ) ( struct work*, uint64_t* ); +void ( *wait_for_diff ) ( struct stratum_ctx* ); +int64_t ( *get_max64 ) (); +bool ( *work_decode ) ( const struct json_t*, struct work* ); +void ( *set_target) ( struct work*, double ); +bool ( *submit_getwork_result ) ( CURL*, struct work* ); +void ( *gen_merkle_root ) ( char*, struct stratum_ctx* ); +void ( *build_stratum_request ) ( char*, struct work*, struct stratum_ctx* ); +void ( *set_work_data_endian ) ( struct work* ); +void ( *calc_network_diff ) ( struct work* ); +void ( *build_extraheader ) ( struct work*, struct stratum_ctx* ); +bool ( *prevent_dupes ) ( struct work*, struct stratum_ctx*, int ); +void ( *resync_threads ) ( struct work* ); +bool ( *do_this_thread ) ( int ); +json_t* (*longpoll_rpc_call) ( CURL*, int*, char* ); +bool ( *stratum_handle_response )( json_t* ); set_t optimizations; int ntime_index; int nbits_index; @@ -200,10 +200,8 @@ void std_get_new_work( struct work *work, struct work *g_work, int thr_id, void jr2_get_new_work( struct work *work, struct work *g_work, int thr_id, uint32_t* end_nonce_ptr ); -void std_stratum_get_g_work( struct stratum_ctx *sctx, struct work *work, - int thr_id ); -void jr2_stratum_get_g_work( struct stratum_ctx *sctx, struct work *work, - int thr_id ); +void std_stratum_gen_work( struct stratum_ctx *sctx, struct work *work ); +void jr2_stratum_gen_work( struct stratum_ctx *sctx, struct work *work ); void sha256d_gen_merkle_root( char *merkle_root, struct stratum_ctx *sctx ); void SHA256_gen_merkle_root ( char *merkle_root, struct stratum_ctx *sctx ); diff --git a/algo/argon2/ar2/.dirstamp b/algo/argon2/ar2/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/blake/.dirstamp b/algo/blake/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/bmw/.dirstamp b/algo/bmw/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/bmw/sse2/bmw.c.new b/algo/bmw/sse2/bmw.c.new deleted file mode 100644 index 7dc0886..0000000 --- a/algo/bmw/sse2/bmw.c.new +++ /dev/null @@ -1,525 +0,0 @@ -/* $Id: bmw.c 227 2010-06-16 17:28:38Z tp $ */ -/* - * BMW implementation. - * - * ==========================(LICENSE BEGIN)============================ - * - * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * ===========================(LICENSE END)============================= - * - * @author Thomas Pornin - */ - -#include -#include -#include - -#ifdef __cplusplus -extern "C"{ -#endif - -#include "../sph_bmw.h" - -#ifdef _MSC_VER -#pragma warning (disable: 4146) -#endif - -static const sph_u64 bmwIV512[] = { - SPH_C64(0x8081828384858687), SPH_C64(0x88898A8B8C8D8E8F), - SPH_C64(0x9091929394959697), SPH_C64(0x98999A9B9C9D9E9F), - SPH_C64(0xA0A1A2A3A4A5A6A7), SPH_C64(0xA8A9AAABACADAEAF), - SPH_C64(0xB0B1B2B3B4B5B6B7), SPH_C64(0xB8B9BABBBCBDBEBF), - SPH_C64(0xC0C1C2C3C4C5C6C7), SPH_C64(0xC8C9CACBCCCDCECF), - SPH_C64(0xD0D1D2D3D4D5D6D7), SPH_C64(0xD8D9DADBDCDDDEDF), - SPH_C64(0xE0E1E2E3E4E5E6E7), SPH_C64(0xE8E9EAEBECEDEEEF), - SPH_C64(0xF0F1F2F3F4F5F6F7), SPH_C64(0xF8F9FAFBFCFDFEFF) -}; - -#define XCAT(x, y) XCAT_(x, y) -#define XCAT_(x, y) x ## y - -#define LPAR ( - -#define I16_16 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 -#define I16_17 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 -#define I16_18 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 -#define I16_19 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 -#define I16_20 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 -#define I16_21 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 -#define I16_22 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21 -#define I16_23 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22 -#define I16_24 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 -#define I16_25 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 -#define I16_26 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 -#define I16_27 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 -#define I16_28 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27 -#define I16_29 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28 -#define I16_30 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 -#define I16_31 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 - -#define M16_16 0, 1, 3, 4, 7, 10, 11 -#define M16_17 1, 2, 4, 5, 8, 11, 12 -#define M16_18 2, 3, 5, 6, 9, 12, 13 -#define M16_19 3, 4, 6, 7, 10, 13, 14 -#define M16_20 4, 5, 7, 8, 11, 14, 15 -#define M16_21 5, 6, 8, 9, 12, 15, 16 -#define M16_22 6, 7, 9, 10, 13, 0, 1 -#define M16_23 7, 8, 10, 11, 14, 1, 2 -#define M16_24 8, 9, 11, 12, 15, 2, 3 -#define M16_25 9, 10, 12, 13, 0, 3, 4 -#define M16_26 10, 11, 13, 14, 1, 4, 5 -#define M16_27 11, 12, 14, 15, 2, 5, 6 -#define M16_28 12, 13, 15, 16, 3, 6, 7 -#define M16_29 13, 14, 0, 1, 4, 7, 8 -#define M16_30 14, 15, 1, 2, 5, 8, 9 -#define M16_31 15, 16, 2, 3, 6, 9, 10 - -#define ss0(x) (((x) >> 1) ^ SPH_T32((x) << 3) \ - ^ SPH_ROTL32(x, 4) ^ SPH_ROTL32(x, 19)) -#define ss1(x) (((x) >> 1) ^ SPH_T32((x) << 2) \ - ^ SPH_ROTL32(x, 8) ^ SPH_ROTL32(x, 23)) -#define ss2(x) (((x) >> 2) ^ SPH_T32((x) << 1) \ - ^ SPH_ROTL32(x, 12) ^ SPH_ROTL32(x, 25)) -#define ss3(x) (((x) >> 2) ^ SPH_T32((x) << 2) \ - ^ SPH_ROTL32(x, 15) ^ SPH_ROTL32(x, 29)) -#define ss4(x) (((x) >> 1) ^ (x)) -#define ss5(x) (((x) >> 2) ^ (x)) -#define rs1(x) SPH_ROTL32(x, 3) -#define rs2(x) SPH_ROTL32(x, 7) -#define rs3(x) SPH_ROTL32(x, 13) -#define rs4(x) SPH_ROTL32(x, 16) -#define rs5(x) SPH_ROTL32(x, 19) -#define rs6(x) SPH_ROTL32(x, 23) -#define rs7(x) SPH_ROTL32(x, 27) - -#define Ks(j) SPH_T32((sph_u32)(j) * SPH_C32(0x05555555)) - -#define add_elt_s(mf, hf, j0m, j1m, j3m, j4m, j7m, j10m, j11m, j16) \ - (SPH_T32(SPH_ROTL32(mf(j0m), j1m) + SPH_ROTL32(mf(j3m), j4m) \ - - SPH_ROTL32(mf(j10m), j11m) + Ks(j16)) ^ hf(j7m)) - -#define expand1s_inner(qf, mf, hf, i16, \ - i0, i1, i2, i3, i4, i5, i6, i7, i8, \ - i9, i10, i11, i12, i13, i14, i15, \ - i0m, i1m, i3m, i4m, i7m, i10m, i11m) \ - SPH_T32(ss1(qf(i0)) + ss2(qf(i1)) + ss3(qf(i2)) + ss0(qf(i3)) \ - + ss1(qf(i4)) + ss2(qf(i5)) + ss3(qf(i6)) + ss0(qf(i7)) \ - + ss1(qf(i8)) + ss2(qf(i9)) + ss3(qf(i10)) + ss0(qf(i11)) \ - + ss1(qf(i12)) + ss2(qf(i13)) + ss3(qf(i14)) + ss0(qf(i15)) \ - + add_elt_s(mf, hf, i0m, i1m, i3m, i4m, i7m, i10m, i11m, i16)) - -#define expand1s(qf, mf, hf, i16) \ - expand1s_(qf, mf, hf, i16, I16_ ## i16, M16_ ## i16) -#define expand1s_(qf, mf, hf, i16, ix, iy) \ - expand1s_inner LPAR qf, mf, hf, i16, ix, iy) - -#define expand2s_inner(qf, mf, hf, i16, \ - i0, i1, i2, i3, i4, i5, i6, i7, i8, \ - i9, i10, i11, i12, i13, i14, i15, \ - i0m, i1m, i3m, i4m, i7m, i10m, i11m) \ - SPH_T32(qf(i0) + rs1(qf(i1)) + qf(i2) + rs2(qf(i3)) \ - + qf(i4) + rs3(qf(i5)) + qf(i6) + rs4(qf(i7)) \ - + qf(i8) + rs5(qf(i9)) + qf(i10) + rs6(qf(i11)) \ - + qf(i12) + rs7(qf(i13)) + ss4(qf(i14)) + ss5(qf(i15)) \ - + add_elt_s(mf, hf, i0m, i1m, i3m, i4m, i7m, i10m, i11m, i16)) - -#define expand2s(qf, mf, hf, i16) \ - expand2s_(qf, mf, hf, i16, I16_ ## i16, M16_ ## i16) -#define expand2s_(qf, mf, hf, i16, ix, iy) \ - expand2s_inner LPAR qf, mf, hf, i16, ix, iy) - -#if SPH_64 - -#define sb0(x) (((x) >> 1) ^ SPH_T64((x) << 3) \ - ^ SPH_ROTL64(x, 4) ^ SPH_ROTL64(x, 37)) -#define sb1(x) (((x) >> 1) ^ SPH_T64((x) << 2) \ - ^ SPH_ROTL64(x, 13) ^ SPH_ROTL64(x, 43)) -#define sb2(x) (((x) >> 2) ^ SPH_T64((x) << 1) \ - ^ SPH_ROTL64(x, 19) ^ SPH_ROTL64(x, 53)) -#define sb3(x) (((x) >> 2) ^ SPH_T64((x) << 2) \ - ^ SPH_ROTL64(x, 28) ^ SPH_ROTL64(x, 59)) -#define sb4(x) (((x) >> 1) ^ (x)) -#define sb5(x) (((x) >> 2) ^ (x)) -#define rb1(x) SPH_ROTL64(x, 5) -#define rb2(x) SPH_ROTL64(x, 11) -#define rb3(x) SPH_ROTL64(x, 27) -#define rb4(x) SPH_ROTL64(x, 32) -#define rb5(x) SPH_ROTL64(x, 37) -#define rb6(x) SPH_ROTL64(x, 43) -#define rb7(x) SPH_ROTL64(x, 53) - -#define Kb(j) SPH_T64((sph_u64)(j) * SPH_C64(0x0555555555555555)) - -#if 0 - -static const sph_u64 Kb_tab[] = { - Kb(16), Kb(17), Kb(18), Kb(19), Kb(20), Kb(21), Kb(22), Kb(23), - Kb(24), Kb(25), Kb(26), Kb(27), Kb(28), Kb(29), Kb(30), Kb(31) -}; - -#define rol_off(mf, j, off) \ - SPH_ROTL64(mf(((j) + (off)) & 15), (((j) + (off)) & 15) + 1) - -#define add_elt_b(mf, hf, j) \ - (SPH_T64(rol_off(mf, j, 0) + rol_off(mf, j, 3) \ - - rol_off(mf, j, 10) + Kb_tab[j]) ^ hf(((j) + 7) & 15)) - -#define expand1b(qf, mf, hf, i) \ - SPH_T64(sb1(qf((i) - 16)) + sb2(qf((i) - 15)) \ - + sb3(qf((i) - 14)) + sb0(qf((i) - 13)) \ - + sb1(qf((i) - 12)) + sb2(qf((i) - 11)) \ - + sb3(qf((i) - 10)) + sb0(qf((i) - 9)) \ - + sb1(qf((i) - 8)) + sb2(qf((i) - 7)) \ - + sb3(qf((i) - 6)) + sb0(qf((i) - 5)) \ - + sb1(qf((i) - 4)) + sb2(qf((i) - 3)) \ - + sb3(qf((i) - 2)) + sb0(qf((i) - 1)) \ - + add_elt_b(mf, hf, (i) - 16)) - -#define expand2b(qf, mf, hf, i) \ - SPH_T64(qf((i) - 16) + rb1(qf((i) - 15)) \ - + qf((i) - 14) + rb2(qf((i) - 13)) \ - + qf((i) - 12) + rb3(qf((i) - 11)) \ - + qf((i) - 10) + rb4(qf((i) - 9)) \ - + qf((i) - 8) + rb5(qf((i) - 7)) \ - + qf((i) - 6) + rb6(qf((i) - 5)) \ - + qf((i) - 4) + rb7(qf((i) - 3)) \ - + sb4(qf((i) - 2)) + sb5(qf((i) - 1)) \ - + add_elt_b(mf, hf, (i) - 16)) - -#else - -#define add_elt_b(mf, hf, j0m, j1m, j3m, j4m, j7m, j10m, j11m, j16) \ - (SPH_T64(SPH_ROTL64(mf(j0m), j1m) + SPH_ROTL64(mf(j3m), j4m) \ - - SPH_ROTL64(mf(j10m), j11m) + Kb(j16)) ^ hf(j7m)) - -#define expand1b_inner(qf, mf, hf, i16, \ - i0, i1, i2, i3, i4, i5, i6, i7, i8, \ - i9, i10, i11, i12, i13, i14, i15, \ - i0m, i1m, i3m, i4m, i7m, i10m, i11m) \ - SPH_T64(sb1(qf(i0)) + sb2(qf(i1)) + sb3(qf(i2)) + sb0(qf(i3)) \ - + sb1(qf(i4)) + sb2(qf(i5)) + sb3(qf(i6)) + sb0(qf(i7)) \ - + sb1(qf(i8)) + sb2(qf(i9)) + sb3(qf(i10)) + sb0(qf(i11)) \ - + sb1(qf(i12)) + sb2(qf(i13)) + sb3(qf(i14)) + sb0(qf(i15)) \ - + add_elt_b(mf, hf, i0m, i1m, i3m, i4m, i7m, i10m, i11m, i16)) - -#define expand1b(qf, mf, hf, i16) \ - expand1b_(qf, mf, hf, i16, I16_ ## i16, M16_ ## i16) -#define expand1b_(qf, mf, hf, i16, ix, iy) \ - expand1b_inner LPAR qf, mf, hf, i16, ix, iy) - -#define expand2b_inner(qf, mf, hf, i16, \ - i0, i1, i2, i3, i4, i5, i6, i7, i8, \ - i9, i10, i11, i12, i13, i14, i15, \ - i0m, i1m, i3m, i4m, i7m, i10m, i11m) \ - SPH_T64(qf(i0) + rb1(qf(i1)) + qf(i2) + rb2(qf(i3)) \ - + qf(i4) + rb3(qf(i5)) + qf(i6) + rb4(qf(i7)) \ - + qf(i8) + rb5(qf(i9)) + qf(i10) + rb6(qf(i11)) \ - + qf(i12) + rb7(qf(i13)) + sb4(qf(i14)) + sb5(qf(i15)) \ - + add_elt_b(mf, hf, i0m, i1m, i3m, i4m, i7m, i10m, i11m, i16)) - -#define expand2b(qf, mf, hf, i16) \ - expand2b_(qf, mf, hf, i16, I16_ ## i16, M16_ ## i16) -#define expand2b_(qf, mf, hf, i16, ix, iy) \ - expand2b_inner LPAR qf, mf, hf, i16, ix, iy) - -#endif - -#endif - -#define MAKE_W(tt, i0, op01, i1, op12, i2, op23, i3, op34, i4) \ - tt((M(i0) ^ H(i0)) op01 (M(i1) ^ H(i1)) op12 (M(i2) ^ H(i2)) \ - op23 (M(i3) ^ H(i3)) op34 (M(i4) ^ H(i4))) - -#define Ws0 MAKE_W(SPH_T32, 5, -, 7, +, 10, +, 13, +, 14) -#define Ws1 MAKE_W(SPH_T32, 6, -, 8, +, 11, +, 14, -, 15) -#define Ws2 MAKE_W(SPH_T32, 0, +, 7, +, 9, -, 12, +, 15) -#define Ws3 MAKE_W(SPH_T32, 0, -, 1, +, 8, -, 10, +, 13) -#define Ws4 MAKE_W(SPH_T32, 1, +, 2, +, 9, -, 11, -, 14) -#define Ws5 MAKE_W(SPH_T32, 3, -, 2, +, 10, -, 12, +, 15) -#define Ws6 MAKE_W(SPH_T32, 4, -, 0, -, 3, -, 11, +, 13) -#define Ws7 MAKE_W(SPH_T32, 1, -, 4, -, 5, -, 12, -, 14) -#define Ws8 MAKE_W(SPH_T32, 2, -, 5, -, 6, +, 13, -, 15) -#define Ws9 MAKE_W(SPH_T32, 0, -, 3, +, 6, -, 7, +, 14) -#define Ws10 MAKE_W(SPH_T32, 8, -, 1, -, 4, -, 7, +, 15) -#define Ws11 MAKE_W(SPH_T32, 8, -, 0, -, 2, -, 5, +, 9) -#define Ws12 MAKE_W(SPH_T32, 1, +, 3, -, 6, -, 9, +, 10) -#define Ws13 MAKE_W(SPH_T32, 2, +, 4, +, 7, +, 10, +, 11) -#define Ws14 MAKE_W(SPH_T32, 3, -, 5, +, 8, -, 11, -, 12) -#define Ws15 MAKE_W(SPH_T32, 12, -, 4, -, 6, -, 9, +, 13) - -#define MAKE_Qas do { \ - qt[ 0] = SPH_T32(ss0(Ws0 ) + H( 1)); \ - qt[ 1] = SPH_T32(ss1(Ws1 ) + H( 2)); \ - qt[ 2] = SPH_T32(ss2(Ws2 ) + H( 3)); \ - qt[ 3] = SPH_T32(ss3(Ws3 ) + H( 4)); \ - qt[ 4] = SPH_T32(ss4(Ws4 ) + H( 5)); \ - qt[ 5] = SPH_T32(ss0(Ws5 ) + H( 6)); \ - qt[ 6] = SPH_T32(ss1(Ws6 ) + H( 7)); \ - qt[ 7] = SPH_T32(ss2(Ws7 ) + H( 8)); \ - qt[ 8] = SPH_T32(ss3(Ws8 ) + H( 9)); \ - qt[ 9] = SPH_T32(ss4(Ws9 ) + H(10)); \ - qt[10] = SPH_T32(ss0(Ws10) + H(11)); \ - qt[11] = SPH_T32(ss1(Ws11) + H(12)); \ - qt[12] = SPH_T32(ss2(Ws12) + H(13)); \ - qt[13] = SPH_T32(ss3(Ws13) + H(14)); \ - qt[14] = SPH_T32(ss4(Ws14) + H(15)); \ - qt[15] = SPH_T32(ss0(Ws15) + H( 0)); \ - } while (0) - -#define MAKE_Qbs do { \ - qt[16] = expand1s(Qs, M, H, 16); \ - qt[17] = expand1s(Qs, M, H, 17); \ - qt[18] = expand2s(Qs, M, H, 18); \ - qt[19] = expand2s(Qs, M, H, 19); \ - qt[20] = expand2s(Qs, M, H, 20); \ - qt[21] = expand2s(Qs, M, H, 21); \ - qt[22] = expand2s(Qs, M, H, 22); \ - qt[23] = expand2s(Qs, M, H, 23); \ - qt[24] = expand2s(Qs, M, H, 24); \ - qt[25] = expand2s(Qs, M, H, 25); \ - qt[26] = expand2s(Qs, M, H, 26); \ - qt[27] = expand2s(Qs, M, H, 27); \ - qt[28] = expand2s(Qs, M, H, 28); \ - qt[29] = expand2s(Qs, M, H, 29); \ - qt[30] = expand2s(Qs, M, H, 30); \ - qt[31] = expand2s(Qs, M, H, 31); \ - } while (0) - -#define MAKE_Qs do { \ - MAKE_Qas; \ - MAKE_Qbs; \ - } while (0) - -#define Qs(j) (qt[j]) - -#define Wb0 MAKE_W(SPH_T64, 5, -, 7, +, 10, +, 13, +, 14) -#define Wb1 MAKE_W(SPH_T64, 6, -, 8, +, 11, +, 14, -, 15) -#define Wb2 MAKE_W(SPH_T64, 0, +, 7, +, 9, -, 12, +, 15) -#define Wb3 MAKE_W(SPH_T64, 0, -, 1, +, 8, -, 10, +, 13) -#define Wb4 MAKE_W(SPH_T64, 1, +, 2, +, 9, -, 11, -, 14) -#define Wb5 MAKE_W(SPH_T64, 3, -, 2, +, 10, -, 12, +, 15) -#define Wb6 MAKE_W(SPH_T64, 4, -, 0, -, 3, -, 11, +, 13) -#define Wb7 MAKE_W(SPH_T64, 1, -, 4, -, 5, -, 12, -, 14) -#define Wb8 MAKE_W(SPH_T64, 2, -, 5, -, 6, +, 13, -, 15) -#define Wb9 MAKE_W(SPH_T64, 0, -, 3, +, 6, -, 7, +, 14) -#define Wb10 MAKE_W(SPH_T64, 8, -, 1, -, 4, -, 7, +, 15) -#define Wb11 MAKE_W(SPH_T64, 8, -, 0, -, 2, -, 5, +, 9) -#define Wb12 MAKE_W(SPH_T64, 1, +, 3, -, 6, -, 9, +, 10) -#define Wb13 MAKE_W(SPH_T64, 2, +, 4, +, 7, +, 10, +, 11) -#define Wb14 MAKE_W(SPH_T64, 3, -, 5, +, 8, -, 11, -, 12) -#define Wb15 MAKE_W(SPH_T64, 12, -, 4, -, 6, -, 9, +, 13) - -#define MAKE_Qab do { \ - qt[ 0] = SPH_T64(sb0(Wb0 ) + H( 1)); \ - qt[ 1] = SPH_T64(sb1(Wb1 ) + H( 2)); \ - qt[ 2] = SPH_T64(sb2(Wb2 ) + H( 3)); \ - qt[ 3] = SPH_T64(sb3(Wb3 ) + H( 4)); \ - qt[ 4] = SPH_T64(sb4(Wb4 ) + H( 5)); \ - qt[ 5] = SPH_T64(sb0(Wb5 ) + H( 6)); \ - qt[ 6] = SPH_T64(sb1(Wb6 ) + H( 7)); \ - qt[ 7] = SPH_T64(sb2(Wb7 ) + H( 8)); \ - qt[ 8] = SPH_T64(sb3(Wb8 ) + H( 9)); \ - qt[ 9] = SPH_T64(sb4(Wb9 ) + H(10)); \ - qt[10] = SPH_T64(sb0(Wb10) + H(11)); \ - qt[11] = SPH_T64(sb1(Wb11) + H(12)); \ - qt[12] = SPH_T64(sb2(Wb12) + H(13)); \ - qt[13] = SPH_T64(sb3(Wb13) + H(14)); \ - qt[14] = SPH_T64(sb4(Wb14) + H(15)); \ - qt[15] = SPH_T64(sb0(Wb15) + H( 0)); \ - } while (0) - -#define MAKE_Qbb do { \ - qt[16] = expand1b(Qb, M, H, 16); \ - qt[17] = expand1b(Qb, M, H, 17); \ - qt[18] = expand2b(Qb, M, H, 18); \ - qt[19] = expand2b(Qb, M, H, 19); \ - qt[20] = expand2b(Qb, M, H, 20); \ - qt[21] = expand2b(Qb, M, H, 21); \ - qt[22] = expand2b(Qb, M, H, 22); \ - qt[23] = expand2b(Qb, M, H, 23); \ - qt[24] = expand2b(Qb, M, H, 24); \ - qt[25] = expand2b(Qb, M, H, 25); \ - qt[26] = expand2b(Qb, M, H, 26); \ - qt[27] = expand2b(Qb, M, H, 27); \ - qt[28] = expand2b(Qb, M, H, 28); \ - qt[29] = expand2b(Qb, M, H, 29); \ - qt[30] = expand2b(Qb, M, H, 30); \ - qt[31] = expand2b(Qb, M, H, 31); \ - } while (0) - -#define MAKE_Qb do { \ - MAKE_Qab; \ - MAKE_Qbb; \ - } while (0) - -#define Qb(j) (qt[j]) - -#define FOLD(type, mkQ, tt, rol, mf, qf, dhf) do { \ - type qt[32], xl, xh; \ - mkQ; \ - xl = qf(16) ^ qf(17) ^ qf(18) ^ qf(19) \ - ^ qf(20) ^ qf(21) ^ qf(22) ^ qf(23); \ - xh = xl ^ qf(24) ^ qf(25) ^ qf(26) ^ qf(27) \ - ^ qf(28) ^ qf(29) ^ qf(30) ^ qf(31); \ - dhf( 0) = tt(((xh << 5) ^ (qf(16) >> 5) ^ mf( 0)) \ - + (xl ^ qf(24) ^ qf( 0))); \ - dhf( 1) = tt(((xh >> 7) ^ (qf(17) << 8) ^ mf( 1)) \ - + (xl ^ qf(25) ^ qf( 1))); \ - dhf( 2) = tt(((xh >> 5) ^ (qf(18) << 5) ^ mf( 2)) \ - + (xl ^ qf(26) ^ qf( 2))); \ - dhf( 3) = tt(((xh >> 1) ^ (qf(19) << 5) ^ mf( 3)) \ - + (xl ^ qf(27) ^ qf( 3))); \ - dhf( 4) = tt(((xh >> 3) ^ (qf(20) << 0) ^ mf( 4)) \ - + (xl ^ qf(28) ^ qf( 4))); \ - dhf( 5) = tt(((xh << 6) ^ (qf(21) >> 6) ^ mf( 5)) \ - + (xl ^ qf(29) ^ qf( 5))); \ - dhf( 6) = tt(((xh >> 4) ^ (qf(22) << 6) ^ mf( 6)) \ - + (xl ^ qf(30) ^ qf( 6))); \ - dhf( 7) = tt(((xh >> 11) ^ (qf(23) << 2) ^ mf( 7)) \ - + (xl ^ qf(31) ^ qf( 7))); \ - dhf( 8) = tt(rol(dhf(4), 9) + (xh ^ qf(24) ^ mf( 8)) \ - + ((xl << 8) ^ qf(23) ^ qf( 8))); \ - dhf( 9) = tt(rol(dhf(5), 10) + (xh ^ qf(25) ^ mf( 9)) \ - + ((xl >> 6) ^ qf(16) ^ qf( 9))); \ - dhf(10) = tt(rol(dhf(6), 11) + (xh ^ qf(26) ^ mf(10)) \ - + ((xl << 6) ^ qf(17) ^ qf(10))); \ - dhf(11) = tt(rol(dhf(7), 12) + (xh ^ qf(27) ^ mf(11)) \ - + ((xl << 4) ^ qf(18) ^ qf(11))); \ - dhf(12) = tt(rol(dhf(0), 13) + (xh ^ qf(28) ^ mf(12)) \ - + ((xl >> 3) ^ qf(19) ^ qf(12))); \ - dhf(13) = tt(rol(dhf(1), 14) + (xh ^ qf(29) ^ mf(13)) \ - + ((xl >> 4) ^ qf(20) ^ qf(13))); \ - dhf(14) = tt(rol(dhf(2), 15) + (xh ^ qf(30) ^ mf(14)) \ - + ((xl >> 7) ^ qf(21) ^ qf(14))); \ - dhf(15) = tt(rol(dhf(3), 16) + (xh ^ qf(31) ^ mf(15)) \ - + ((xl >> 2) ^ qf(22) ^ qf(15))); \ - } while (0) - -#define FOLDs FOLD(sph_u32, MAKE_Qs, SPH_T32, SPH_ROTL32, M, Qs, dH) - -#define FOLDb FOLD(sph_u64, MAKE_Qb, SPH_T64, SPH_ROTL64, M, Qb, dH) - -#define DECL_BMW \ - sph_u64 bmwH[16]; \ - -/* load initial constants */ -#define BMW_I \ -do { \ - memcpy(bmwH, bmwIV512, sizeof bmwH); \ - hashptr = 0; \ - hashctA = 0; \ -} while (0) - -/* load hash for loop */ -#define BMW_U \ -do { \ - const void *data = hash; \ - size_t len = 64; \ - unsigned char *buf; \ - \ - hashctA += (sph_u64)len << 3; \ - buf = hashbuf; \ - memcpy(buf, data, 64); \ - hashptr = 64; \ -} while (0) - - -/* bmw512 hash loaded */ -/* hash = blake512(loaded) */ -#define BMW_C \ -do { \ - void *dst = hash; \ - size_t out_size_w64 = 8; \ - unsigned char *data; \ - sph_u64 *dh; \ - unsigned char *out; \ - size_t ptr, u, v; \ - unsigned z; \ - sph_u64 h1[16], h2[16], *h; \ - data = hashbuf; \ - ptr = hashptr; \ - z = 0x80 >> 0; \ - data[ptr ++] = ((0 & -z) | z) & 0xFF; \ - memset(data + ptr, 0, (sizeof(char)*128) - 8 - ptr); \ - sph_enc64le_aligned(data + (sizeof(char)*128) - 8, \ - SPH_T64(hashctA + 0)); \ - /* for break loop */ \ - /* one copy of inline FOLD */ \ - /* FOLD uses, */ \ - /* uint64 *h, data */ \ - /* uint64 dh, state */ \ - h = bmwH; \ - dh = h2; \ - for (;;) { \ - FOLDb; \ - /* dh gets changed for 2nd run */ \ - if (dh == h1) break; \ - for (u = 0; u < 16; u ++) \ - sph_enc64le_aligned(data + 8 * u, h2[u]); \ - dh = h1; \ - h = final_b; \ - } \ - /* end wrapped for break loop */ \ - out = dst; \ - sph_enc64le(out, h1[8]); \ - sph_enc64le(out + 8, h1[9]); \ - sph_enc64le(out + 16, h1[10]); \ - sph_enc64le(out + 24, h1[11]); \ - sph_enc64le(out + 32, h1[12]); \ - sph_enc64le(out + 40, h1[13]); \ - sph_enc64le(out + 48, h1[14]); \ - sph_enc64le(out + 56, h1[15]); \ -/* for (u = 0, v = 16 - out_size_w64; u < out_size_w64; u ++, v ++)*/ \ -/* sph_enc64le(out + 8 * u, h1[v]);*/ \ -} while (0) - -static void -compress_big(const unsigned char *data, const sph_u64 h[16], sph_u64 dh[16]) -{ - -#define M(x) sph_dec64le_aligned(data + 8 * (x)) -#define H(x) (h[x]) -#define dH(x) (dh[x]) - - FOLDb; - -#undef M -#undef H -#undef dH -} - -static const sph_u64 final_b[16] = { - SPH_C64(0xaaaaaaaaaaaaaaa0), SPH_C64(0xaaaaaaaaaaaaaaa1), - SPH_C64(0xaaaaaaaaaaaaaaa2), SPH_C64(0xaaaaaaaaaaaaaaa3), - SPH_C64(0xaaaaaaaaaaaaaaa4), SPH_C64(0xaaaaaaaaaaaaaaa5), - SPH_C64(0xaaaaaaaaaaaaaaa6), SPH_C64(0xaaaaaaaaaaaaaaa7), - SPH_C64(0xaaaaaaaaaaaaaaa8), SPH_C64(0xaaaaaaaaaaaaaaa9), - SPH_C64(0xaaaaaaaaaaaaaaaa), SPH_C64(0xaaaaaaaaaaaaaaab), - SPH_C64(0xaaaaaaaaaaaaaaac), SPH_C64(0xaaaaaaaaaaaaaaad), - SPH_C64(0xaaaaaaaaaaaaaaae), SPH_C64(0xaaaaaaaaaaaaaaaf) -}; - - -#ifdef __cplusplus -} -#endif diff --git a/algo/cryptonight/.dirstamp b/algo/cryptonight/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/cubehash/.dirstamp b/algo/cubehash/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/cubehash/sse2/.dirstamp b/algo/cubehash/sse2/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/echo/.dirstamp b/algo/echo/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/echo/aes_ni/.dirstamp b/algo/echo/aes_ni/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/fugue/.dirstamp b/algo/fugue/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/gost/.dirstamp b/algo/gost/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/groestl/.dirstamp b/algo/groestl/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/groestl/aes_ni/.dirstamp b/algo/groestl/aes_ni/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/groestl/sse2/.dirstamp b/algo/groestl/sse2/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/groestl/sse2/.grso.c.swo b/algo/groestl/sse2/.grso.c.swo deleted file mode 100644 index c53dbad..0000000 Binary files a/algo/groestl/sse2/.grso.c.swo and /dev/null differ diff --git a/algo/hamsi/.dirstamp b/algo/hamsi/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/haval/.dirstamp b/algo/haval/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/heavy/.dirstamp b/algo/heavy/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/hodl/.dirstamp b/algo/hodl/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/jh/.dirstamp b/algo/jh/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/keccak/.dirstamp b/algo/keccak/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/keccak/sse2/.dirstamp b/algo/keccak/sse2/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/luffa/.dirstamp b/algo/luffa/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/luffa/sse2/.dirstamp b/algo/luffa/sse2/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/luffa/sse2/luffa_for_sse2.c.bak b/algo/luffa/sse2/luffa_for_sse2.c.bak deleted file mode 100644 index 7283404..0000000 --- a/algo/luffa/sse2/luffa_for_sse2.c.bak +++ /dev/null @@ -1,558 +0,0 @@ -/* - * luffa_for_sse2.c - * Version 2.0 (Sep 15th 2009) - * - * Copyright (C) 2008-2009 Hitachi, Ltd. All rights reserved. - * - * Hitachi, Ltd. is the owner of this software and hereby grant - * the U.S. Government and any interested party the right to use - * this software for the purposes of the SHA-3 evaluation process, - * notwithstanding that this software is copyrighted. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include "luffa_for_sse2.h" - -#ifdef HASH_BIG_ENDIAN -# define BYTES_SWAP32(x) x -#else -# define BYTES_SWAP32(x) \ - ((x << 24) | ((x & 0x0000ff00) << 8) | ((x & 0x00ff0000) >> 8) | (x >> 24)) -#endif /* HASH_BIG_ENDIAN */ - -/* BYTES_SWAP256(x) stores each 32-bit word of 256 bits data in little-endian convention */ -#define BYTES_SWAP256(x) { \ - int _i = 8; while(_i--){x[_i] = BYTES_SWAP32(x[_i]);} \ -} - -#define MULT2(a0,a1,t0,t1)\ - a0 = _mm_xor_si128( a0, _mm_shuffle_epi32( _mm_and_si128(a1,MASK), 16 ) ); \ - t0 = a0; \ - a0 = _mm_or_si128( _mm_srli_si128(a0,4), _mm_slli_si128(a1,12) ); \ - a1 = _mm_or_si128( _mm_srli_si128(a1,4), _mm_slli_si128(t0,12) ); - - -/* -#define MULT2(a0,a1,t0,t1)\ - t0 = _mm_load_si128(&a1);\ - t0 = _mm_and_si128(t0,MASK);\ - t0 = _mm_shuffle_epi32(t0,16);\ - a0 = _mm_xor_si128(a0,t0);\ - t0 = _mm_load_si128(&a0);\ - t1 = _mm_load_si128(&a1);\ - a0 = _mm_srli_si128(a0,4);\ - a1 = _mm_srli_si128(a1,4);\ - t0 = _mm_slli_si128(t0,12);\ - t1 = _mm_slli_si128(t1,12);\ - a0 = _mm_or_si128(a0,t1);\ - a1 = _mm_or_si128(a1,t0); -*/ - -#define STEP_PART(x,c,t)\ - SUBCRUMB(*x,*(x+1),*(x+2),*(x+3),*t);\ - SUBCRUMB(*(x+5),*(x+6),*(x+7),*(x+4),*t);\ - MIXWORD(*x,*(x+4),*t,*(t+1));\ - MIXWORD(*(x+1),*(x+5),*t,*(t+1));\ - MIXWORD(*(x+2),*(x+6),*t,*(t+1));\ - MIXWORD(*(x+3),*(x+7),*t,*(t+1));\ - ADD_CONSTANT(*x, *(x+4), *c, *(c+1)); - -#define STEP_PART2(a0,a1,t0,t1,c0,c1,tmp0,tmp1)\ - a1 = _mm_shuffle_epi32(a1,147);\ - t0 = _mm_load_si128(&a1);\ - a1 = _mm_unpacklo_epi32(a1,a0);\ - t0 = _mm_unpackhi_epi32(t0,a0);\ - t1 = _mm_shuffle_epi32(t0,78);\ - a0 = _mm_shuffle_epi32(a1,78);\ - SUBCRUMB(t1,t0,a0,a1,tmp0);\ - t0 = _mm_unpacklo_epi32(t0,t1);\ - a1 = _mm_unpacklo_epi32(a1,a0);\ - a0 = _mm_load_si128(&a1);\ - a0 = _mm_unpackhi_epi64(a0,t0);\ - a1 = _mm_unpacklo_epi64(a1,t0);\ - a1 = _mm_shuffle_epi32(a1,57);\ - MIXWORD(a0,a1,tmp0,tmp1);\ - ADD_CONSTANT(a0,a1,c0,c1); - -#define SUBCRUMB(a0,a1,a2,a3,t)\ - t = _mm_load_si128(&a0);\ - a0 = _mm_or_si128(a0,a1);\ - a2 = _mm_xor_si128(a2,a3);\ - a1 = _mm_andnot_si128(a1,ALLONE);\ - a0 = _mm_xor_si128(a0,a3);\ - a3 = _mm_and_si128(a3,t);\ - a1 = _mm_xor_si128(a1,a3);\ - a3 = _mm_xor_si128(a3,a2);\ - a2 = _mm_and_si128(a2,a0);\ - a0 = _mm_andnot_si128(a0,ALLONE);\ - a2 = _mm_xor_si128(a2,a1);\ - a1 = _mm_or_si128(a1,a3);\ - t = _mm_xor_si128(t,a1);\ - a3 = _mm_xor_si128(a3,a2);\ - a2 = _mm_and_si128(a2,a1);\ - a1 = _mm_xor_si128(a1,a0);\ - a0 = _mm_load_si128(&t);\ - -#define MIXWORD(a,b,t1,t2)\ - b = _mm_xor_si128(a,b);\ - t1 = _mm_slli_epi32(a,2);\ - t2 = _mm_srli_epi32(a,30);\ - a = _mm_or_si128(t1,t2);\ - a = _mm_xor_si128(a,b);\ - t1 = _mm_slli_epi32(b,14);\ - t2 = _mm_srli_epi32(b,18);\ - b = _mm_or_si128(t1,t2);\ - b = _mm_xor_si128(a,b);\ - t1 = _mm_slli_epi32(a,10);\ - t2 = _mm_srli_epi32(a,22);\ - a = _mm_or_si128(t1,t2);\ - a = _mm_xor_si128(a,b);\ - t1 = _mm_slli_epi32(b,1);\ - t2 = _mm_srli_epi32(b,31);\ - b = _mm_or_si128(t1,t2); - -#define ADD_CONSTANT(a,b,c0,c1)\ - a = _mm_xor_si128(a,c0);\ - b = _mm_xor_si128(b,c1);\ - -#define NMLTOM768(r0,r1,r2,s0,s1,s2,s3,p0,p1,p2,q0,q1,q2,q3)\ - s2 = _mm_load_si128(&r1);\ - q2 = _mm_load_si128(&p1);\ - r2 = _mm_shuffle_epi32(r2,216);\ - p2 = _mm_shuffle_epi32(p2,216);\ - r1 = _mm_unpacklo_epi32(r1,r0);\ - p1 = _mm_unpacklo_epi32(p1,p0);\ - s2 = _mm_unpackhi_epi32(s2,r0);\ - q2 = _mm_unpackhi_epi32(q2,p0);\ - s0 = _mm_load_si128(&r2);\ - q0 = _mm_load_si128(&p2);\ - r2 = _mm_unpacklo_epi64(r2,r1);\ - p2 = _mm_unpacklo_epi64(p2,p1);\ - s1 = _mm_load_si128(&s0);\ - q1 = _mm_load_si128(&q0);\ - s0 = _mm_unpackhi_epi64(s0,r1);\ - q0 = _mm_unpackhi_epi64(q0,p1);\ - r2 = _mm_shuffle_epi32(r2,225);\ - p2 = _mm_shuffle_epi32(p2,225);\ - r0 = _mm_load_si128(&s1);\ - p0 = _mm_load_si128(&q1);\ - s0 = _mm_shuffle_epi32(s0,225);\ - q0 = _mm_shuffle_epi32(q0,225);\ - s1 = _mm_unpacklo_epi64(s1,s2);\ - q1 = _mm_unpacklo_epi64(q1,q2);\ - r0 = _mm_unpackhi_epi64(r0,s2);\ - p0 = _mm_unpackhi_epi64(p0,q2);\ - s2 = _mm_load_si128(&r0);\ - q2 = _mm_load_si128(&p0);\ - s3 = _mm_load_si128(&r2);\ - q3 = _mm_load_si128(&p2);\ - -#define MIXTON768(r0,r1,r2,r3,s0,s1,s2,p0,p1,p2,p3,q0,q1,q2)\ - s0 = _mm_load_si128(&r0);\ - q0 = _mm_load_si128(&p0);\ - s1 = _mm_load_si128(&r2);\ - q1 = _mm_load_si128(&p2);\ - r0 = _mm_unpackhi_epi32(r0,r1);\ - p0 = _mm_unpackhi_epi32(p0,p1);\ - r2 = _mm_unpackhi_epi32(r2,r3);\ - p2 = _mm_unpackhi_epi32(p2,p3);\ - s0 = _mm_unpacklo_epi32(s0,r1);\ - q0 = _mm_unpacklo_epi32(q0,p1);\ - s1 = _mm_unpacklo_epi32(s1,r3);\ - q1 = _mm_unpacklo_epi32(q1,p3);\ - r1 = _mm_load_si128(&r0);\ - p1 = _mm_load_si128(&p0);\ - r0 = _mm_unpackhi_epi64(r0,r2);\ - p0 = _mm_unpackhi_epi64(p0,p2);\ - s0 = _mm_unpackhi_epi64(s0,s1);\ - q0 = _mm_unpackhi_epi64(q0,q1);\ - r1 = _mm_unpacklo_epi64(r1,r2);\ - p1 = _mm_unpacklo_epi64(p1,p2);\ - s2 = _mm_load_si128(&r0);\ - q2 = _mm_load_si128(&p0);\ - s1 = _mm_load_si128(&r1);\ - q1 = _mm_load_si128(&p1);\ - -#define NMLTOM1024(r0,r1,r2,r3,s0,s1,s2,s3,p0,p1,p2,p3,q0,q1,q2,q3)\ - s1 = _mm_load_si128(&r3);\ - q1 = _mm_load_si128(&p3);\ - s3 = _mm_load_si128(&r3);\ - q3 = _mm_load_si128(&p3);\ - s1 = _mm_unpackhi_epi32(s1,r2);\ - q1 = _mm_unpackhi_epi32(q1,p2);\ - s3 = _mm_unpacklo_epi32(s3,r2);\ - q3 = _mm_unpacklo_epi32(q3,p2);\ - s0 = _mm_load_si128(&s1);\ - q0 = _mm_load_si128(&q1);\ - s2 = _mm_load_si128(&s3);\ - q2 = _mm_load_si128(&q3);\ - r3 = _mm_load_si128(&r1);\ - p3 = _mm_load_si128(&p1);\ - r1 = _mm_unpacklo_epi32(r1,r0);\ - p1 = _mm_unpacklo_epi32(p1,p0);\ - r3 = _mm_unpackhi_epi32(r3,r0);\ - p3 = _mm_unpackhi_epi32(p3,p0);\ - s0 = _mm_unpackhi_epi64(s0,r3);\ - q0 = _mm_unpackhi_epi64(q0,p3);\ - s1 = _mm_unpacklo_epi64(s1,r3);\ - q1 = _mm_unpacklo_epi64(q1,p3);\ - s2 = _mm_unpackhi_epi64(s2,r1);\ - q2 = _mm_unpackhi_epi64(q2,p1);\ - s3 = _mm_unpacklo_epi64(s3,r1);\ - q3 = _mm_unpacklo_epi64(q3,p1); - -#define MIXTON1024(r0,r1,r2,r3,s0,s1,s2,s3,p0,p1,p2,p3,q0,q1,q2,q3)\ - NMLTOM1024(r0,r1,r2,r3,s0,s1,s2,s3,p0,p1,p2,p3,q0,q1,q2,q3); - - -static void Update512(hashState_luffa *state, const BitSequence *data, DataLength databitlen); - -static void rnd512(hashState_luffa *state); - -static void finalization512(hashState_luffa *state, uint32 *b); - - -/* initial values of chaining variables */ -static const uint32 IV[40] = { - 0xdbf78465,0x4eaa6fb4,0x44b051e0,0x6d251e69, - 0xdef610bb,0xee058139,0x90152df4,0x6e292011, - 0xde099fa3,0x70eee9a0,0xd9d2f256,0xc3b44b95, - 0x746cd581,0xcf1ccf0e,0x8fc944b3,0x5d9b0557, - 0xad659c05,0x04016ce5,0x5dba5781,0xf7efc89d, - 0x8b264ae7,0x24aa230a,0x666d1836,0x0306194f, - 0x204b1f67,0xe571f7d7,0x36d79cce,0x858075d5, - 0x7cde72ce,0x14bcb808,0x57e9e923,0x35870c6a, - 0xaffb4363,0xc825b7c7,0x5ec41e22,0x6c68e9be, - 0x03e86cea,0xb07224cc,0x0fc688f1,0xf5df3999 -}; - -/* Round Constants */ -static const uint32 CNS_INIT[128] = { - 0xb213afa5,0xfc20d9d2,0xb6de10ed,0x303994a6, - 0xe028c9bf,0xe25e72c1,0x01685f3d,0xe0337818, - 0xc84ebe95,0x34552e25,0x70f47aae,0xc0e65299, - 0x44756f91,0xe623bb72,0x05a17cf4,0x441ba90d, - 0x4e608a22,0x7ad8818f,0x0707a3d4,0x6cc33a12, - 0x7e8fce32,0x5c58a4a4,0xbd09caca,0x7f34d442, - 0x56d858fe,0x8438764a,0x1c1e8f51,0xdc56983e, - 0x956548be,0x1e38e2e7,0xf4272b28,0x9389217f, - 0x343b138f,0xbb6de032,0x707a3d45,0x1e00108f, - 0xfe191be2,0x78e38b9d,0x144ae5cc,0xe5a8bce6, - 0xd0ec4e3d,0xedb780c8,0xaeb28562,0x7800423d, - 0x3cb226e5,0x27586719,0xfaa7ae2b,0x5274baf4, - 0x2ceb4882,0xd9847356,0xbaca1589,0x8f5b7882, - 0x5944a28e,0x36eda57f,0x2e48f1c1,0x26889ba7, - 0xb3ad2208,0xa2c78434,0x40a46f3e,0x96e1db12, - 0xa1c4c355,0x703aace7,0xb923c704,0x9a226e9d, - 0x00000000,0x00000000,0x00000000,0xf0d2e9e3, - 0x00000000,0x00000000,0x00000000,0x5090d577, - 0x00000000,0x00000000,0x00000000,0xac11d7fa, - 0x00000000,0x00000000,0x00000000,0x2d1925ab, - 0x00000000,0x00000000,0x00000000,0x1bcb66f2, - 0x00000000,0x00000000,0x00000000,0xb46496ac, - 0x00000000,0x00000000,0x00000000,0x6f2d9bc9, - 0x00000000,0x00000000,0x00000000,0xd1925ab0, - 0x00000000,0x00000000,0x00000000,0x78602649, - 0x00000000,0x00000000,0x00000000,0x29131ab6, - 0x00000000,0x00000000,0x00000000,0x8edae952, - 0x00000000,0x00000000,0x00000000,0x0fc053c3, - 0x00000000,0x00000000,0x00000000,0x3b6ba548, - 0x00000000,0x00000000,0x00000000,0x3f014f0c, - 0x00000000,0x00000000,0x00000000,0xedae9520, - 0x00000000,0x00000000,0x00000000,0xfc053c31 -}; - -__m128i CNS128[32]; -__m128i ALLONE; -__m128i MASK; - - - -HashReturn init_luffa(hashState_luffa *state, int hashbitlen) -{ - int i; - state->hashbitlen = hashbitlen; - - /* set the lower 32 bits to '1' */ - MASK= _mm_set_epi32(0x00000000, 0x00000000, 0x00000000, 0xffffffff); - - /* set all bits to '1' */ - ALLONE = _mm_set_epi32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff); - - /* set the 32-bit round constant values to the 128-bit data field */ - for (i=0;i<32;i++) { - CNS128[i] = _mm_loadu_si128((__m128i*)&CNS_INIT[i*4]); - } - - - for (i=0;i<10;i++) - state->chainv[i] = _mm_loadu_si128((__m128i*)&IV[i*4]); - - - state->bitlen[0] = 0; - state->bitlen[1] = 0; - state->rembitlen = 0; - - memset(state->buffer, 0, sizeof state->buffer ); - - return SUCCESS; -} - -HashReturn update_luffa(hashState_luffa *state, const BitSequence *data, DataLength databitlen) -{ - HashReturn ret=SUCCESS; - int i; - uint8 *p = (uint8*)state->buffer; - for (i=0;i<8;i++) state->buffer[i] = BYTES_SWAP32(((uint32*)data)[i]); - rnd512(state); - data += MSG_BLOCK_BYTE_LEN; - state->rembitlen = 0; - for (i=0;i<8;i++) state->buffer[i] = BYTES_SWAP32(((uint32*)data)[i]); - rnd512(state); - data += MSG_BLOCK_BYTE_LEN; - memset(p+1, 0, 31*sizeof(uint8)); - p[0] = 0x80; - for (i=0;i<8;i++) state->buffer[i] = BYTES_SWAP32(state->buffer[i]); - rnd512(state); - return ret; -} - - -HashReturn final_luffa(hashState_luffa *state, BitSequence *hashval) -{ - - finalization512(state, (uint32*) hashval); - - return SUCCESS; -} - -/***************************************************/ -/* Round function */ -/* state: hash context */ - - -static void rnd512(hashState_luffa *state) -{ - __m128i t[2]; - __m128i *chainv = state->chainv; - __m128i msg[2]; - __m128i tmp[2]; - __m128i x[8]; - int i; - - t[0] = chainv[0]; - t[1] = chainv[1]; - - t[0] = _mm_xor_si128(t[0], chainv[2]); - t[1] = _mm_xor_si128(t[1], chainv[3]); - t[0] = _mm_xor_si128(t[0], chainv[4]); - t[1] = _mm_xor_si128(t[1], chainv[5]); - t[0] = _mm_xor_si128(t[0], chainv[6]); - t[1] = _mm_xor_si128(t[1], chainv[7]); - t[0] = _mm_xor_si128(t[0], chainv[8]); - t[1] = _mm_xor_si128(t[1], chainv[9]); - - MULT2( t[0], t[1], tmp[0], tmp[1]); - - msg[0] = _mm_loadu_si128 ( (__m128i*)&state->buffer[0] ); - msg[1] = _mm_loadu_si128 ( (__m128i*)&state->buffer[4] ); - msg[0] = _mm_shuffle_epi32( msg[0], 27 ); - msg[1] = _mm_shuffle_epi32( msg[1], 27 ); - - chainv[0] = _mm_xor_si128( chainv[0], t[0] ); - chainv[1] = _mm_xor_si128( chainv[1], t[1] ); - chainv[2] = _mm_xor_si128( chainv[2], t[0] ); - chainv[3] = _mm_xor_si128( chainv[3], t[1] ); - chainv[4] = _mm_xor_si128( chainv[4], t[0] ); - chainv[5] = _mm_xor_si128( chainv[5], t[1] ); - chainv[6] = _mm_xor_si128( chainv[6], t[0] ); - chainv[7] = _mm_xor_si128( chainv[7], t[1] ); - chainv[8] = _mm_xor_si128( chainv[8], t[0] ); - chainv[9] = _mm_xor_si128( chainv[9], t[1] ); - - t[0] = chainv[0]; - t[1] = chainv[1]; - - MULT2( chainv[0], chainv[1], tmp[0], tmp[1]); - - chainv[0] = _mm_xor_si128( chainv[0], chainv[2] ); - chainv[1] = _mm_xor_si128( chainv[1], chainv[3] ); - - MULT2( chainv[2], chainv[3], tmp[0], tmp[1]); - - chainv[2] = _mm_xor_si128(chainv[2], chainv[4]); - chainv[3] = _mm_xor_si128(chainv[3], chainv[5]); - - MULT2( chainv[4], chainv[5], tmp[0], tmp[1]); - - chainv[4] = _mm_xor_si128(chainv[4], chainv[6]); - chainv[5] = _mm_xor_si128(chainv[5], chainv[7]); - - MULT2( chainv[6], chainv[7], tmp[0], tmp[1]); - - chainv[6] = _mm_xor_si128(chainv[6], chainv[8]); - chainv[7] = _mm_xor_si128(chainv[7], chainv[9]); - - MULT2( chainv[8], chainv[9], tmp[0], tmp[1]); - - chainv[8] = _mm_xor_si128( chainv[8], t[0] ); - chainv[9] = _mm_xor_si128( chainv[9], t[1] ); - - t[0] = chainv[8]; - t[1] = chainv[9]; - - MULT2( chainv[8], chainv[9], tmp[0], tmp[1]); - - chainv[8] = _mm_xor_si128( chainv[8], chainv[6] ); - chainv[9] = _mm_xor_si128( chainv[9], chainv[7] ); - - MULT2( chainv[6], chainv[7], tmp[0], tmp[1]); - - chainv[6] = _mm_xor_si128( chainv[6], chainv[4] ); - chainv[7] = _mm_xor_si128( chainv[7], chainv[5] ); - - MULT2( chainv[4], chainv[5], tmp[0], tmp[1]); - - chainv[4] = _mm_xor_si128( chainv[4], chainv[2] ); - chainv[5] = _mm_xor_si128( chainv[5], chainv[3] ); - - MULT2( chainv[2], chainv[3], tmp[0], tmp[1] ); - - chainv[2] = _mm_xor_si128( chainv[2], chainv[0] ); - chainv[3] = _mm_xor_si128( chainv[3], chainv[1] ); - - MULT2( chainv[0], chainv[1], tmp[0], tmp[1] ); - - chainv[0] = _mm_xor_si128( _mm_xor_si128( chainv[0], t[0] ), msg[0] ); - chainv[1] = _mm_xor_si128( _mm_xor_si128( chainv[1], t[1] ), msg[1] ); - - MULT2( msg[0], msg[1], tmp[0], tmp[1]); - - chainv[2] = _mm_xor_si128( chainv[2], msg[0] ); - chainv[3] = _mm_xor_si128( chainv[3], msg[1] ); - - MULT2( msg[0], msg[1], tmp[0], tmp[1]); - - chainv[4] = _mm_xor_si128( chainv[4], msg[0] ); - chainv[5] = _mm_xor_si128( chainv[5], msg[1] ); - - MULT2( msg[0], msg[1], tmp[0], tmp[1]); - - chainv[6] = _mm_xor_si128( chainv[6], msg[0] ); - chainv[7] = _mm_xor_si128( chainv[7], msg[1] ); - - MULT2( msg[0], msg[1], tmp[0], tmp[1]); - - chainv[8] = _mm_xor_si128( chainv[8], msg[0] ); - chainv[9] = _mm_xor_si128( chainv[9], msg[1] ); - - MULT2( msg[0], msg[1], tmp[0], tmp[1]); - - chainv[3] = _mm_or_si128( _mm_slli_epi32(chainv[3], 1), - _mm_srli_epi32(chainv[3], 31) ); - chainv[5] = _mm_or_si128( _mm_slli_epi32(chainv[5], 2), - _mm_srli_epi32(chainv[5], 30) ); - chainv[7] = _mm_or_si128( _mm_slli_epi32(chainv[7], 3), - _mm_srli_epi32(chainv[7], 29) ); - chainv[9] = _mm_or_si128( _mm_slli_epi32(chainv[9], 4), - _mm_srli_epi32(chainv[9], 28) ); - - - NMLTOM1024( chainv[0], chainv[2], chainv[4], chainv[6], - x[0], x[1], x[2], x[3], - chainv[1],chainv[3],chainv[5],chainv[7], - x[4], x[5], x[6], x[7] ); - - for ( i=0; i<8 ; i++ ) - { - STEP_PART( &x[0], &CNS128[i*2], &tmp[0] ); - } - - MIXTON1024( x[0], x[1], x[2], x[3], - chainv[0], chainv[2], chainv[4],chainv[6], - x[4], x[5], x[6], x[7], - chainv[1],chainv[3],chainv[5],chainv[7]); - - /* Process last 256-bit block */ - for ( i=0; i<8; i++ ) - { - STEP_PART2( chainv[8], chainv[9], t[0], t[1], CNS128[16+2*i], - CNS128[17+2*i], tmp[0], tmp[1] ); - } - - return; -} - -/***************************************************/ -/* Finalization function */ -/* state: hash context */ -/* b[8]: hash values */ - -static void finalization512(hashState_luffa *state, uint32 *b) -{ - __m128i t[2]; - uint32 hash[8]; - int i; - - /*---- blank round with m=0 ----*/ - memset(state->buffer, 0, sizeof state->buffer ); - rnd512(state); - - t[0] = _mm_load_si128(&state->chainv[0]); - t[1] = _mm_load_si128(&state->chainv[1]); - t[0] = _mm_xor_si128(t[0], state->chainv[2]); - t[1] = _mm_xor_si128(t[1], state->chainv[3]); - t[0] = _mm_xor_si128(t[0], state->chainv[4]); - t[1] = _mm_xor_si128(t[1], state->chainv[5]); - t[0] = _mm_xor_si128(t[0], state->chainv[6]); - t[1] = _mm_xor_si128(t[1], state->chainv[7]); - t[0] = _mm_xor_si128(t[0], state->chainv[8]); - t[1] = _mm_xor_si128(t[1], state->chainv[9]); - - t[0] = _mm_shuffle_epi32(t[0], 27); - t[1] = _mm_shuffle_epi32(t[1], 27); - - _mm_storeu_si128((__m128i*)&hash[0], t[0]); - _mm_storeu_si128((__m128i*)&hash[4], t[1]); - - for (i=0;i<8;i++) b[i] = BYTES_SWAP32(hash[i]); - - memset(state->buffer, 0, sizeof state->buffer ); - rnd512(state); - - t[0] = _mm_load_si128(&state->chainv[0]); - t[1] = _mm_load_si128(&state->chainv[1]); - t[0] = _mm_xor_si128(t[0], state->chainv[2]); - t[1] = _mm_xor_si128(t[1], state->chainv[3]); - t[0] = _mm_xor_si128(t[0], state->chainv[4]); - t[1] = _mm_xor_si128(t[1], state->chainv[5]); - t[0] = _mm_xor_si128(t[0], state->chainv[6]); - t[1] = _mm_xor_si128(t[1], state->chainv[7]); - t[0] = _mm_xor_si128(t[0], state->chainv[8]); - t[1] = _mm_xor_si128(t[1], state->chainv[9]); - - t[0] = _mm_shuffle_epi32(t[0], 27); - t[1] = _mm_shuffle_epi32(t[1], 27); - - _mm_storeu_si128((__m128i*)&hash[0], t[0]); - _mm_storeu_si128((__m128i*)&hash[4], t[1]); - - for (i=0;i<8;i++) b[8+i] = BYTES_SWAP32(hash[i]); - - return; -} - - - - - -/***************************************************/ diff --git a/algo/lyra2/.dirstamp b/algo/lyra2/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/m7m.c.old b/algo/m7m.c.old deleted file mode 100644 index aee1407..0000000 --- a/algo/m7m.c.old +++ /dev/null @@ -1,434 +0,0 @@ - -#include "cpuminer-config.h" -#include "miner.h" -#include "algo-gate-api.h" - -#include -#include -#include -#include -#include -#include -#include "algo/sha2/sph-sha2.h" -#include "algo/keccak/sph_keccak.h" -#include "algo/haval/sph-haval.h" -#include "algo/tiger/sph_tiger.h" -#include "algo/whirlpool/sph_whirlpool.h" -#include "algo/ripemd/sph_ripemd.h" - -#define EPS1 DBL_EPSILON -#define EPS2 3.0e-11 - -inline double exp_n(double xt) -{ - if(xt < -700.0) - return 0; - else if(xt > 700.0) - return 1e200; - else if(xt > -0.8e-8 && xt < 0.8e-8) - return (1.0 + xt); - else - return exp(xt); -} - -// 1 / (1 + exp(x1-x2)) -inline double exp_n2(double x1, double x2) -{ - double p1 = -700., p2 = -37., p3 = -0.8e-8, p4 = 0.8e-8, p5 = 37., p6 = 700.; - double xt = x1 - x2; - if (xt < p1+1.e-200) - return 1.; - else if (xt > p1 && xt < p2 + 1.e-200) - return ( 1. - exp(xt) ); - else if (xt > p2 && xt < p3 + 1.e-200) - return ( 1. / (1. + exp(xt)) ); - else if (xt > p3 && xt < p4) - return ( 1. / (2. + xt) ); - else if (xt > p4 - 1.e-200 && xt < p5) - return ( exp(-xt) / (1. + exp(-xt)) ); - else if (xt > p5 - 1.e-200 && xt < p6) - return ( exp(-xt) ); - else if (xt > p6 - 1.e-200) - return 0.; - - //return(1.0 / (1.0 + exp(x1 - x2))); -} - -double swit_(double wvnmb) -{ - return pow( (5.55243*(exp_n(-0.3*wvnmb/15.762) - exp_n(-0.6*wvnmb/15.762)))*wvnmb, 0.5) - / 1034.66 * pow(sin(wvnmb/65.), 2.); -} - -double m7mGaussianQuad_N(const double x1, const double x2) -{ - double s=0.0; - double x[6], w[6]; - //gauleg(a2, b2, x, w); - - int m,j; - double z1, z, xm, xl, pp, p3, p2, p1; - m=3; - xm=0.5*(x2+x1); - xl=0.5*(x2-x1); - for(int i=1;i<=3;i++) - { - z = (i == 1) ? 0.909632 : -0.0; - z = (i == 2) ? 0.540641 : z; - do - { - p1 = z; - p2 = 1; - p3 = 0; - - p3=1; - p2=z; - p1=((3.0 * z * z) - 1) / 2; - - p3=p2; - p2=p1; - p1=((5.0 * z * p2) - (2.0 * z)) / 3; - - p3=p2; - p2=p1; - p1=((7.0 * z * p2) - (3.0 * p3)) / 4; - - p3=p2; - p2=p1; - p1=((9.0 * z * p2) - (4.0 * p3)) / 5; - - pp=5*(z*p1-p2)/(z*z-1.0); - z1=z; - z=z1-p1/pp; - } while (fabs(z-z1) > 3.0e-11); - - x[i]=xm-xl*z; - x[5+1-i]=xm+xl*z; - w[i]=2.0*xl/((1.0-z*z)*pp*pp); - w[5+1-i]=w[i]; - } - - for(int j=1; j<=5; j++) s += w[j]*swit_(x[j]); - - return s; -} - -uint32_t m7m_sw_(int nnounce) -{ - double wmax = ((sqrt((double)(nnounce))*(1.+EPS1))/450+100); - return ((uint32_t)(m7mGaussianQuad_N(0., wmax)*(1.+EPS1)*1.e6)); -} - -static void mpz_set_uint256(mpz_t r, uint8_t *u) -{ - mpz_import(r, 32 / sizeof(unsigned long), -1, sizeof(unsigned long), -1, 0, u); -} - -static void mpz_get_uint256(mpz_t r, uint8_t *u) -{ - u=0; - mpz_export(u, 0, -1, sizeof(unsigned long), -1, 0, r); -} - -static void mpz_set_uint512(mpz_t r, uint8_t *u) -{ - mpz_import(r, 64 / sizeof(unsigned long), -1, sizeof(unsigned long), -1, 0, u); -} - -static void set_one_if_zero(uint8_t *hash512) { - for (int i = 0; i < 32; i++) { - if (hash512[i] != 0) { - return; - } - } - hash512[0] = 1; -} - -static bool fulltest_m7hash(const uint32_t *hash32, const uint32_t *target32) -{ - int i; - bool rc = true; - - const unsigned char *hash = (const unsigned char *)hash32; - const unsigned char *target = (const unsigned char *)target32; - for (i = 31; i >= 0; i--) { - if (hash[i] != target[i]) { - rc = hash[i] < target[i]; - break; - } - } - - return rc; -} - -typedef struct { - sph_sha256_context sha256; - sph_sha512_context sha512; - sph_keccak512_context keccak; - sph_whirlpool_context whirlpool; - sph_haval256_5_context haval; - sph_tiger_context tiger; - sph_ripemd160_context ripemd; -} m7m_ctx_holder; - -sph_sha256_context m7m_ctx_final_sha256; -m7m_ctx_holder m7m_ctx; - -void init_m7m_ctx() -{ - sph_sha256_init( &m7m_ctx_final_sha256 ); - sph_sha256_init( &m7m_ctx.sha256 ); - sph_sha512_init( &m7m_ctx.sha512 ); - sph_keccak512_init( &m7m_ctx.keccak ); - sph_whirlpool_init( &m7m_ctx.whirlpool ); - sph_haval256_5_init( &m7m_ctx.haval ); - sph_tiger_init( &m7m_ctx.tiger ); - sph_ripemd160_init( &m7m_ctx.ripemd ); -} - -#define BITS_PER_DIGIT 3.32192809488736234787 -#define EPS (DBL_EPSILON) - -#define NM7M 5 -#define SW_DIVS 5 -#define M7_MIDSTATE_LEN 76 -int scanhash_m7m_hash( int thr_id, struct work* work, - uint64_t max_nonce, unsigned long *hashes_done ) -{ - uint32_t *pdata = work->data; - uint32_t *ptarget = work->target; - uint32_t data[32] __attribute__((aligned(128))); - uint32_t *data_p64 = data + (M7_MIDSTATE_LEN / sizeof(data[0])); - uint32_t hash[8] __attribute__((aligned(32))); - uint8_t bhash[7][64] __attribute__((aligned(32))); - uint32_t n = pdata[19] - 1; - const uint32_t first_nonce = pdata[19]; - char data_str[161], hash_str[65], target_str[65]; - //uint8_t *bdata = 0; - uint8_t bdata[8192]; - int rc = 0; - int bytes, nnNonce2; - - m7m_ctx_holder ctx1, ctx2; - memcpy( &ctx1, &m7m_ctx, sizeof(m7m_ctx) ); - sph_sha256_context ctxf_sha256; - memcpy( &ctxf_sha256, &m7m_ctx_final_sha256, sizeof(ctxf_sha256) ); - - memcpy(data, pdata, 80); - - sph_sha256( &ctx1.sha256, data, M7_MIDSTATE_LEN ); - sph_sha512( &ctx1.sha512, data, M7_MIDSTATE_LEN ); - sph_keccak512( &ctx1.keccak, data, M7_MIDSTATE_LEN ); - sph_whirlpool( &ctx1.whirlpool, data, M7_MIDSTATE_LEN ); - sph_haval256_5( &ctx1.haval, data, M7_MIDSTATE_LEN ); - sph_tiger( &ctx1.tiger, data, M7_MIDSTATE_LEN ); - sph_ripemd160( &ctx1.ripemd, data, M7_MIDSTATE_LEN ); - - mpz_t magipi, magisw, product, bns[8]; - mpf_t magifpi, mpt1, mpt2, mptmp, mpten; - - mpz_inits( magipi, magisw, bns[0], bns[1], bns[2], bns[3], - bns[4], bns[5], bns[6], bns[7], NULL ); - mpz_init2(product, 512); - - int digits=(int)((sqrt((double)(INT_MAX))*(1.+EPS))/9000+75); - mpf_set_default_prec((long int)(digits*BITS_PER_DIGIT+16)); - - mpf_init(magifpi); - mpf_init(mpt1); - mpf_init(mpt2); - mpf_init(mptmp); - mpf_init_set_ui(mpten, 10); - - do - { - data[19] = ++n; - nnNonce2 = (int)(data[19]/2); - memset(bhash, 0, 7 * 64); - - memcpy( &ctx2, &ctx1, sizeof(m7m_ctx) ); - - sph_sha256( &ctx2.sha256, data_p64, 80 - M7_MIDSTATE_LEN ); - sph_sha256_close( &ctx2.sha256, (void*)(bhash[0]) ); - - sph_sha512( &ctx2.sha512, data_p64, 80 - M7_MIDSTATE_LEN ); - sph_sha512_close( &ctx2.sha512, (void*)(bhash[1]) ); - - sph_keccak512( &ctx2.keccak, data_p64, 80 - M7_MIDSTATE_LEN ); - sph_keccak512_close( &ctx2.keccak, (void*)(bhash[2]) ); - - sph_whirlpool( &ctx2.whirlpool, data_p64, 80 - M7_MIDSTATE_LEN ); - sph_whirlpool_close( &ctx2.whirlpool, (void*)(bhash[3]) ); - - sph_haval256_5( &ctx2.haval, data_p64, 80 - M7_MIDSTATE_LEN ); - sph_haval256_5_close( &ctx2.haval, (void*)(bhash[4])) ; - - sph_tiger( &ctx2.tiger, data_p64, 80 - M7_MIDSTATE_LEN ); - sph_tiger_close( &ctx2.tiger, (void*)(bhash[5]) ); - - sph_ripemd160( &ctx2.ripemd, data_p64, 80 - M7_MIDSTATE_LEN ); - sph_ripemd160_close( &ctx2.ripemd, (void*)(bhash[6]) ); - - for( int i=0; i < 7; i++ ) - { - set_one_if_zero(bhash[i]); - mpz_set_uint512(bns[i],bhash[i]); - } - - //mpz_set_ui(bns[7],0); - mpz_set(bns[7], bns[0]); - - for(int i=1; i < 7; i++) - mpz_add(bns[7], bns[7], bns[i]); - - //mpz_set_ui(product,1); - mpz_set(product, bns[0]); - - for(int i=1; i < 8; i++) - mpz_mul(product, product, bns[i]); - - //mpz_pow_ui(product, product, 2); - mpz_mul(product, product, product); - - bytes = mpz_sizeinbase(product, 256); - //bdata = (uint8_t *)realloc(bdata, bytes); - mpz_export((void *)bdata, NULL, -1, 1, 0, 0, product); - - sph_sha256( &ctxf_sha256, bdata, bytes ); - sph_sha256_close( &ctxf_sha256, (void*)(hash) ); - - int digits=(int)((sqrt((double)(nnNonce2))*(1.+EPS))/9000+75); - int iterations=20; - //mpf_set_default_prec((long int)(digits*BITS_PER_DIGIT+16)); - mp_bitcnt_t prec = (long int)(digits*BITS_PER_DIGIT+16); - mpf_set_prec_raw(magifpi, prec); - mpf_set_prec_raw(mptmp, prec); - mpf_set_prec_raw(mpt1, prec); - mpf_set_prec_raw(mpt2, prec); - - uint32_t usw_ = m7m_sw_(nnNonce2); - //if (usw_ < 1) usw_ = 1; - usw_ = (usw_ == 0) ? 1 : usw_; - mpz_set_ui(magisw, usw_); - //uint32_t mpzscale=mpz_size(magisw); - - uint32_t mpzscale = mpz_size(magisw); - mpzscale = (mpzscale == 0) ? 1 : ((mpzscale > 1000) ? 1000 : mpzscale); - - for(int i = 0; i < 5; i++) - { - //mpzscale = (mpzscale < 1) ? 1 : ((mpzscale > 1000) ? 1000 : mpzscale); - - mpf_set_d(mpt2, 0.25*mpzscale); - mpf_set_str(mpt1, "0.61f78a9abaa58b4698916152cf7eee1bbdf1f5b4ab3de24c3a3c159062718f716d12d59bba9c4881f@0", 16); - mpf_sub(mpt1, mpt2, mpt1); - - mpf_set_str(mpt2, "0.28bb03352962950bc65974466fd2c021e28cc50addfa74e94a3ec525f1887d66104fe025ccb43562b@0", 16); - mpf_sub(mpt2, mpt1, mpt2); - mpf_swap(mpt1, mpt2); - - mpf_set_str(mpt2, "0.3852f236e8bf02d5c6718fc775e190c575b20b91a45e1338761547573ad5e77e5f61fc760362c231@-1", 16); - mpf_sub(mpt2, mpt1, mpt2); - mpf_swap(mpt1, mpt2); - - mpf_set_str(mpt2, "0.35da65929531617012a859be186b093a9f835b39b8f14f38ac8ce59915e85f4497b3fe99c7e44e44e@-3", 16); - mpf_sub(mpt2, mpt1, mpt2); - mpf_swap(mpt1, mpt2); - - mpf_set_str(mpt2, "0.189daa22ce9d43d42f773cc46e4c97fc8f625df4c82a663970a52968d90df7aa3e05294f26eec633@-7", 16); - mpf_sub(mpt2, mpt1, mpt2); - mpf_swap(mpt1, mpt2); - - mpf_set_str(mpt2, "0.87127377035941932784771446314900974221284468466736176188550809681111589251132779066239512337e-20", 10); - mpf_sub(mpt2, mpt1, mpt2); - mpf_swap(mpt1, mpt2); - - mpf_abs(mpt1, mpt1); - mpf_set_str(magifpi, "0.717770011046129997821193223665779426657129889339984371989763663877269423125849866370161623127786e0", 10); - mpf_div(magifpi, magifpi, mpt1); - - mpf_pow_ui(mptmp, mpten, digits >> 1); - mpf_mul(magifpi, magifpi, mptmp); - - //mpf_mul_ui(magifpi, magifpi, pow(10.0, (double)(digits >> 1))); - - mpz_set_f(magipi, magifpi); - - mpz_add(product,product,magipi); - mpz_add(product,product,magisw); - - mpz_set_uint256(bns[0], (void*)(hash)); - mpz_add(bns[7], bns[7], bns[0]); - - mpz_mul(product,product,bns[7]); - mpz_cdiv_q (product, product, bns[0]); - if (mpz_sgn(product) <= 0) mpz_set_ui(product,1); - - bytes = mpz_sizeinbase(product, 256); - mpzscale=bytes; - //bdata = (uint8_t *)realloc(bdata, bytes); - mpz_export(bdata, NULL, -1, 1, 0, 0, product); - - sph_sha256( &ctxf_sha256, bdata, bytes ); - sph_sha256_close( &ctxf_sha256, (void*)(hash) ); - } - - rc = fulltest_m7hash(hash, ptarget); - if (unlikely(rc)) { - if (opt_debug) { - bin2hex(hash_str, (unsigned char *)hash, 32); - bin2hex(target_str, (unsigned char *)ptarget, 32); - bin2hex(data_str, (unsigned char *)data, 80); - applog(LOG_DEBUG, "DEBUG: [%d thread] Found share!\ndata %s\nhash %s\ntarget %s", thr_id, - data_str, - hash_str, - target_str); - } - - pdata[19] = data[19]; - - goto out; - } - } while (n < max_nonce && !work_restart[thr_id].restart); - - pdata[19] = n; - -out: - digits = (int)((sqrt((double)(INT_MAX))*(1.+EPS))/9000+75); - mp_bitcnt_t prec = (long int)(digits*BITS_PER_DIGIT+16); - mpf_set_prec_raw(magifpi, prec); - mpf_set_prec_raw(mptmp, prec); - mpf_set_prec_raw(mpt1, prec); - mpf_set_prec_raw(mpt2, prec); - mpf_clear(magifpi); - mpf_clear(mpten); - mpf_clear(mptmp); - mpf_clear(mpt1); - mpf_clear(mpt2); - - mpz_clears(magipi, magisw, product, bns[0], bns[1], bns[2], bns[3], bns[4], bns[5], bns[6], bns[7], NULL); - - //free(bdata); - - *hashes_done = n - first_nonce + 1; - return rc; -} - -void m7m_reverse_endian( struct work *work ) -{ - swab32_array( work->data, work->data, 20 ); -} - -bool register_m7m_algo( algo_gate_t *gate ) -{ - gate->optimizations = SSE2_OPT | AES_OPT | AVX_OPT; - init_m7m_ctx(); - gate->scanhash = (void*)scanhash_m7m_hash; - gate->build_stratum_request = (void*)&std_be_build_stratum_request; - gate->set_target = (void*)&scrypt_set_target; - gate->get_max64 = (void*)&get_max64_0x1ffff; - gate->set_work_data_endian = (void*)&m7m_reverse_endian; - gate->work_data_size = 80; - return true; -} - diff --git a/algo/quark/.dirstamp b/algo/quark/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/qubit/.dirstamp b/algo/qubit/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/ripemd/.dirstamp b/algo/ripemd/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/scryptjane/.dirstamp b/algo/scryptjane/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/sha2/.dirstamp b/algo/sha2/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/sha3/.dirstamp b/algo/sha3/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/shabal/.dirstamp b/algo/shabal/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/shavite/.dirstamp b/algo/shavite/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/simd/.dirstamp b/algo/simd/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/simd/sse2/.dirstamp b/algo/simd/sse2/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/skein/.dirstamp b/algo/skein/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/tiger/.dirstamp b/algo/tiger/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/whirlpool/.dirstamp b/algo/whirlpool/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/x11/.dirstamp b/algo/x11/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/x13/.dirstamp b/algo/x13/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/x14/.dirstamp b/algo/x14/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/x15/.dirstamp b/algo/x15/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/x17/.dirstamp b/algo/x17/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/algo/yescrypt/.dirstamp b/algo/yescrypt/.dirstamp deleted file mode 100644 index e69de29..0000000 diff --git a/api.c b/api.c index 594ec5b..75ccc4d 100644 --- a/api.c +++ b/api.c @@ -135,6 +135,8 @@ static char *getsummary(char *params) time_t ts = time(NULL); double uptime = difftime(ts, startup); double accps = (60.0 * accepted_count) / (uptime ? uptime : 1.0); + double diff = net_diff > 0. ? net_diff : stratum_diff; + char diff_str[16]; struct cpu_info cpu = { 0 }; #ifdef USE_MONITORING @@ -146,14 +148,20 @@ static char *getsummary(char *params) get_currentalgo(algo, sizeof(algo)); + // if diff is integer don't display decimals + if ( diff == trunc( diff ) ) + sprintf( diff_str, "%.0f", diff); + else + sprintf( diff_str, "%.6f", diff); + *buffer = '\0'; sprintf(buffer, "NAME=%s;VER=%s;API=%s;" "ALGO=%s;CPUS=%d;KHS=%.2f;ACC=%d;REJ=%d;" - "ACCMN=%.3f;DIFF=%.6f;TEMP=%.1f;FAN=%d;FREQ=%d;" + "ACCMN=%.3f;DIFF=%s;TEMP=%.1f;FAN=%d;FREQ=%d;" "UPTIME=%.0f;TS=%u|", PACKAGE_NAME, PACKAGE_VERSION, APIVERSION, algo, opt_n_threads, (double)global_hashrate / 1000.0, - accepted_count, rejected_count, accps, net_diff > 0. ? net_diff : stratum_diff, + accepted_count, rejected_count, accps, diff_str, cpu.cpu_temp, cpu.cpu_fan, cpu.cpu_clock, uptime, (uint32_t) ts); return buffer; diff --git a/api/index.php b/api/index.php index 3844154..d443fa3 100644 --- a/api/index.php +++ b/api/index.php @@ -190,7 +190,7 @@ li span.algo { display: inline-block; width: 100px; max-width: 180px; } diff --git a/compat/gmp.del/x64/mpir.lib b/compat/gmp.del/x64/mpir.lib deleted file mode 100644 index d3284db..0000000 Binary files a/compat/gmp.del/x64/mpir.lib and /dev/null differ diff --git a/compat/gmp.del/x86/mpir.lib b/compat/gmp.del/x86/mpir.lib deleted file mode 100644 index 31fdc4d..0000000 Binary files a/compat/gmp.del/x86/mpir.lib and /dev/null differ diff --git a/compat/gmp.h.del b/compat/gmp.h.del deleted file mode 100644 index 44e8a68..0000000 --- a/compat/gmp.h.del +++ /dev/null @@ -1,1928 +0,0 @@ -/* generated from gmp-h.in by gen_mpir_h.bat */ -/* Definitions for GNU multiple precision functions. -*- mode: c -*- -Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003, -2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, -Inc. -Copyright 2008 William Hart, Gonzalo Tornaria -This file is part of the MPIR Library. -The MPIR Library is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either version 3 of the License, or (at your -option) any later version. -The MPIR Library is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -License for more details. -You should have received a copy of the GNU Lesser General Public License -along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ -#ifndef __GMP_H__ -#ifdef __SUNPRO_CC /* See: http://trac.sagemath.org/sage_trac/ticket/7849 */ -#include /* This is Bill Hart's fix, but I've applied it only */ -#include /* on Sun Studio */ -#endif -#if defined (__cplusplus) -#include /* for std::istream, std::ostream, std::string */ -#include -#endif -/* Instantiated by configure. */ -#if ! defined (__GMP_WITHIN_CONFIGURE) -#ifdef _WIN32 -# ifdef _WIN64 -# define _LONG_LONG_LIMB 1 -# define GMP_LIMB_BITS 64 -# else -# define GMP_LIMB_BITS 32 -# endif -# define __GMP_BITS_PER_MP_LIMB GMP_LIMB_BITS -# define SIZEOF_MP_LIMB_T (GMP_LIMB_BITS >> 3) -# define GMP_NAIL_BITS 0 -#endif -#endif -#define GMP_NUMB_BITS (GMP_LIMB_BITS - GMP_NAIL_BITS) -#define GMP_NUMB_MASK ((~ __GMP_CAST (mp_limb_t, 0)) >> GMP_NAIL_BITS) -#define GMP_NUMB_MAX GMP_NUMB_MASK -#define GMP_NAIL_MASK (~ GMP_NUMB_MASK) -#ifndef __GNU_MP__ -#define __GNU_MP__ 4 -#define __need_size_t /* tell gcc stddef.h we only want size_t */ -#if defined (__cplusplus) -#include /* for size_t */ -#else -#include /* for size_t */ -#endif -#undef __need_size_t -/* Instantiated by configure. */ -#if ! defined (__GMP_WITHIN_CONFIGURE) -#endif -/* #if defined(__GMP_WITHIN_CONFIGURE) && defined(_WIN64) */ -#ifdef __WIN64 -#define _LONG_LONG_LIMB 1 -#endif -/* __STDC__ - some ANSI compilers define this only to 0, hence the use of - "defined" and not "__STDC__-0". In particular Sun workshop C 5.0 - sets __STDC__ to 0, but requires "##" for token pasting. - _AIX - gnu ansidecl.h asserts that all known AIX compilers are ANSI but - don't always define __STDC__. - __DECC - current versions of DEC C (5.9 for instance) for alpha are ANSI, - but don't define __STDC__ in their default mode. Don't know if old - versions might have been K&R, but let's not worry about that unless - someone is still using one. - _mips - gnu ansidecl.h says the RISC/OS MIPS compiler is ANSI in SVR4 - mode, but doesn't define __STDC__. - _MSC_VER - Microsoft C is ANSI, but __STDC__ is undefined unless the /Za - option is given (in which case it's 1). - _WIN32 - tested for by gnu ansidecl.h, no doubt on the assumption that - all w32 compilers are ansi. - Note: This same set of tests is used by gen-psqr.c and - demos/expr/expr-impl.h, so if anything needs adding, then be sure to - update those too. */ -#if defined (__STDC__) \ - || defined (__cplusplus) \ - || defined (_AIX) \ - || defined (__DECC) \ - || (defined (__mips) && defined (_SYSTYPE_SVR4)) \ - || defined (_MSC_VER) \ - || defined (_WIN32) -#define __GMP_HAVE_CONST 1 -#define __GMP_HAVE_PROTOTYPES 1 -#define __GMP_HAVE_TOKEN_PASTE 1 -#else -#define __GMP_HAVE_CONST 0 -#define __GMP_HAVE_PROTOTYPES 0 -#define __GMP_HAVE_TOKEN_PASTE 0 -#endif -#if __GMP_HAVE_CONST -#define __gmp_const const -#define __gmp_signed signed -#else -#define __gmp_const -#define __gmp_signed -#endif -/* __GMP_DECLSPEC supports Windows DLL versions of libmpir, and is empty in - all other circumstances. - When compiling objects for libmpir, __GMP_DECLSPEC is an export directive, - or when compiling for an application it's an import directive. The two - cases are differentiated by __GMP_WITHIN_GMP defined by the GMP Makefiles - (and not defined from an application). - __GMP_DECLSPEC_XX is similarly used for libmpirxx. __GMP_WITHIN_GMPXX - indicates when building libmpirxx, and in that case libmpirxx functions are - exports, but libmpir functions which might get called are imports. - libmp.la uses __GMP_DECLSPEC, just as if it were libmpir.la. libmpir and - libmp don't call each other, so there's no conflict or confusion. - Libtool DLL_EXPORT define is not used. - There's no attempt to support GMP built both static and DLL. Doing so - would mean applications would have to tell us which of the two is going - to be used when linking, and that seems very tedious and error prone if - using GMP by hand, and equally tedious from a package since autoconf and - automake don't give much help. - __GMP_DECLSPEC is required on all documented global functions and - variables, the various internals in gmp-impl.h etc can be left unadorned. - But internals used by the test programs or speed measuring programs - should have __GMP_DECLSPEC, and certainly constants or variables must - have it or the wrong address will be resolved. - In gcc __declspec can go at either the start or end of a prototype. - In Microsoft C __declspec must go at the start, or after the type like - void __declspec(...) *foo()". There's no __dllexport or anything to - guard against someone foolish #defining dllexport. _export used to be - available, but no longer. - In Borland C _export still exists, but needs to go after the type, like - "void _export foo();". Would have to change the __GMP_DECLSPEC syntax to - make use of that. Probably more trouble than it's worth. */ -#if defined (__GNUC__) -#define __GMP_DECLSPEC_EXPORT __declspec(__dllexport__) -#define __GMP_DECLSPEC_IMPORT __declspec(__dllimport__) -#endif -#if defined (_MSC_VER) || defined (__BORLANDC__) -#define __GMP_DECLSPEC_EXPORT __declspec(dllexport) -#define __GMP_DECLSPEC_IMPORT __declspec(dllimport) -#endif -#ifdef __WATCOMC__ -#define __GMP_DECLSPEC_EXPORT __export -#define __GMP_DECLSPEC_IMPORT __import -#endif -#ifdef __IBMC__ -#define __GMP_DECLSPEC_EXPORT _Export -#define __GMP_DECLSPEC_IMPORT _Import -#endif -#if defined( _MSC_VER ) -# if defined( MSC_BUILD_DLL ) -# define __GMP_LIBGMP_DLL 1 -# define __GMP_WITHIN_GMP 1 -# define __GMP_WITHIN_GMPXX 1 -# elif defined( MSC_USE_DLL ) -# define __GMP_LIBGMP_DLL 1 -# endif -#endif -#if __GMP_LIBGMP_DLL -#if __GMP_WITHIN_GMP -/* compiling to go into a DLL libmpir */ -#define __GMP_DECLSPEC __GMP_DECLSPEC_EXPORT -#else -/* compiling to go into an application which will link to a DLL libmpir */ -#define __GMP_DECLSPEC __GMP_DECLSPEC_IMPORT -#endif -#else -/* all other cases */ -#define __GMP_DECLSPEC -#endif -#ifdef __GMP_SHORT_LIMB -typedef unsigned int mp_limb_t; -typedef int mp_limb_signed_t; -#else -#ifdef _LONG_LONG_LIMB -typedef unsigned long long int mp_limb_t; -typedef long long int mp_limb_signed_t; -#else -typedef unsigned long int mp_limb_t; -typedef long int mp_limb_signed_t; -#endif -#endif -#ifdef _WIN64 -#define BITS_PER_UI BITS_PER_MP_LIMB -typedef mp_limb_t mpir_ui; -typedef mp_limb_signed_t mpir_si; -typedef mpir_ui mp_bitcnt_t; -#else -#define BITS_PER_UI BITS_PER_ULONG -typedef unsigned long mpir_ui; -typedef long mpir_si; -typedef mpir_ui mp_bitcnt_t; -#endif -#define GMP_UI_MAX ((mpir_ui)(~(mpir_ui)0)) -#define GMP_UI_HIBIT (GMP_UI_MAX ^ (GMP_UI_MAX >> 1)) -#define GMP_SI_MAX ((mpir_si)(GMP_UI_MAX ^ GMP_UI_HIBIT)) -#define GMP_SI_MIN ((mpir_si)GMP_UI_HIBIT) -#define __GMP_BITCNT_MAX (~(mp_bitcnt_t)0) -/* For reference, note that the name __mpz_struct gets into C++ mangled - function names, which means although the "__" suggests an internal, we - must leave this name for binary compatibility. */ -typedef struct -{ - int _mp_alloc; /* Number of *limbs* allocated and pointed - to by the _mp_d field. */ - int _mp_size; /* abs(_mp_size) is the number of limbs the - last field points to. If _mp_size is - negative this is a negative number. */ - mp_limb_t *_mp_d; /* Pointer to the limbs. */ -} __mpz_struct; -#endif /* __GNU_MP__ */ -typedef __mpz_struct mpz_t[1]; -typedef mp_limb_t * mp_ptr; -typedef __gmp_const mp_limb_t * mp_srcptr; -#if defined( _WIN64) -#define __GMP_MP_SIZE_T_INT 0 -typedef long long int mp_size_t; -typedef long int mp_exp_t; -#else -#define __GMP_MP_SIZE_T_INT 0 -typedef long int mp_size_t; -typedef long int mp_exp_t; -#endif -typedef struct -{ - __mpz_struct _mp_num; - __mpz_struct _mp_den; -} __mpq_struct; -typedef __mpq_struct mpq_t[1]; -typedef struct -{ - int _mp_prec; /* Max precision, in number of `mp_limb_t's. - Set by mpf_init and modified by - mpf_set_prec. The area pointed to by the - _mp_d field contains `prec' + 1 limbs. */ - int _mp_size; /* abs(_mp_size) is the number of limbs the - last field points to. If _mp_size is - negative this is a negative number. */ - mp_exp_t _mp_exp; /* Exponent, in the base of `mp_limb_t'. */ - mp_limb_t *_mp_d; /* Pointer to the limbs. */ -} __mpf_struct; -typedef __mpf_struct mpf_t[1]; -/* Available random number generation algorithms. */ -typedef enum -{ - GMP_RAND_ALG_DEFAULT = 0, - GMP_RAND_ALG_LC = GMP_RAND_ALG_DEFAULT /* Linear congruential. */ -} gmp_randalg_t; -/* Random state struct. */ -typedef struct -{ - mpz_t _mp_seed; /* _mp_d member points to state of the generator. */ - gmp_randalg_t _mp_alg; /* Currently unused. */ - union { - void *_mp_lc; /* Pointer to function pointers structure. */ - } _mp_algdata; -} __gmp_randstate_struct; -typedef __gmp_randstate_struct gmp_randstate_t[1]; -/* Types for function declarations in gmp files. */ -/* ??? Should not pollute user name space with these ??? */ -typedef __gmp_const __mpz_struct *mpz_srcptr; -typedef __mpz_struct *mpz_ptr; -typedef __gmp_const __mpf_struct *mpf_srcptr; -typedef __mpf_struct *mpf_ptr; -typedef __gmp_const __mpq_struct *mpq_srcptr; -typedef __mpq_struct *mpq_ptr; -#if __GMP_LIBGMP_DLL -#if __GMP_WITHIN_GMPXX -/* compiling to go into a DLL libmpirxx */ -#define __GMP_DECLSPEC_XX __GMP_DECLSPEC_EXPORT -#else -/* compiling to go into a application which will link to a DLL libmpirxx */ -#define __GMP_DECLSPEC_XX __GMP_DECLSPEC_IMPORT -#endif -#else -/* all other cases */ -#define __GMP_DECLSPEC_XX -#endif -#if __GMP_HAVE_PROTOTYPES -#define __GMP_PROTO(x) x -#else -#define __GMP_PROTO(x) () -#endif -#ifndef __MPN -#if __GMP_HAVE_TOKEN_PASTE -#define __MPN(x) __gmpn_##x -#else -#define __MPN(x) __gmpn_/**/x -#endif -#endif -/* For reference, "defined(EOF)" cannot be used here. In g++ 2.95.4, - defines EOF but not FILE. */ -#if defined (FILE) \ - || defined (H_STDIO) \ - || defined (_H_STDIO) /* AIX */ \ - || defined (_STDIO_H) /* glibc, Sun, SCO */ \ - || defined (_STDIO_H_) /* BSD, OSF */ \ - || defined (__STDIO_H) /* Borland */ \ - || defined (__STDIO_H__) /* IRIX */ \ - || defined (_STDIO_INCLUDED) /* HPUX */ \ - || defined (_FILE_DEFINED) /* Microsoft */ \ - || defined (__STDIO__) /* Apple MPW MrC */ \ - || defined (_MSL_STDIO_H) /* Metrowerks */ \ - || defined (_STDIO_H_INCLUDED) /* QNX4 */ \ - || defined (_ISO_STDIO_ISO_H) /* Sun C++ */ -#define _GMP_H_HAVE_FILE 1 -#endif -/* In ISO C, if a prototype involving "struct obstack *" is given without - that structure defined, then the struct is scoped down to just the - prototype, causing a conflict if it's subsequently defined for real. So - only give prototypes if we've got obstack.h. */ -#if defined (_OBSTACK_H) /* glibc */ -#define _GMP_H_HAVE_OBSTACK 1 -#endif -/* The prototypes for gmp_vprintf etc are provided only if va_list is - available, via an application having included or . - Usually va_list is a typedef so can't be tested directly, but C99 - specifies that va_start is a macro (and it was normally a macro on past - systems too), so look for that. - will define some sort of va_list for vprintf and vfprintf, but - let's not bother trying to use that since it's not standard and since - application uses for gmp_vprintf etc will almost certainly require the - whole or anyway. */ -#ifdef va_start -#define _GMP_H_HAVE_VA_LIST 1 -#endif -/* Test for gcc >= maj.min, as per __GNUC_PREREQ in glibc */ -#if defined (__GNUC__) && defined (__GNUC_MINOR__) -#define __GMP_GNUC_PREREQ(maj, min) \ - ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) -#else -#define __GMP_GNUC_PREREQ(maj, min) 0 -#endif -/* "pure" is in gcc 2.96 and up, see "(gcc)Function Attributes". Basically - it means a function does nothing but examine its arguments and memory - (global or via arguments) to generate a return value, but changes nothing - and has no side-effects. __GMP_NO_ATTRIBUTE_CONST_PURE lets - tune/common.c etc turn this off when trying to write timing loops. */ -#if __GMP_GNUC_PREREQ (2,96) && ! defined (__GMP_NO_ATTRIBUTE_CONST_PURE) -#define __GMP_ATTRIBUTE_PURE __attribute__ ((__pure__)) -#else -#define __GMP_ATTRIBUTE_PURE -#endif -/* __GMP_CAST allows us to use static_cast in C++, so our macros are clean - to "g++ -Wold-style-cast". - Casts in "extern inline" code within an extern "C" block don't induce - these warnings, so __GMP_CAST only needs to be used on documented - macros. */ -#ifdef __cplusplus -#define __GMP_CAST(type, expr) (static_cast (expr)) -#else -#define __GMP_CAST(type, expr) ((type) (expr)) -#endif -/* An empty "throw ()" means the function doesn't throw any C++ exceptions, - this can save some stack frame info in applications. - Currently it's given only on functions which never divide-by-zero etc, - don't allocate memory, and are expected to never need to allocate memory. - This leaves open the possibility of a C++ throw from a future GMP - exceptions scheme. - mpz_set_ui etc are omitted to leave open the lazy allocation scheme - described in doc/tasks.html. mpz_get_d etc are omitted to leave open - exceptions for float overflows. - Note that __GMP_NOTHROW must be given on any inlines the same as on their - prototypes (for g++ at least, where they're used together). Note also - that g++ 3.0 demands that __GMP_NOTHROW is before other attributes like - __GMP_ATTRIBUTE_PURE. */ -#if defined (__cplusplus) -#define __GMP_NOTHROW throw () -#else -#define __GMP_NOTHROW -#endif -/* PORTME: What other compilers have a useful "extern inline"? "static - inline" would be an acceptable substitute if the compiler (or linker) - discards unused statics. */ -/* gcc has __inline__ in all modes, including strict ansi. Give a prototype - for an inline too, so as to correctly specify "dllimport" on windows, in - case the function is called rather than inlined. */ -#ifdef __GNUC__ -#if defined(__APPLE_CC__) && (__APPLE_CC__ != 1) /* FSF GCC sets this flag to 1 on Apple machines */ -#if ! (__APPLE_CC__ >= 5465 && __STDC_VERSION__ >= 199901L) -#define __GMP_EXTERN_INLINE extern __inline__ -#define __GMP_INLINE_PROTOTYPES 1 -#endif -#else /*GNU CC*/ -#if defined(__GNUC_STDC_INLINE__) || defined (__GNUC_GNU_INLINE__) -#define __GMP_EXTERN_INLINE extern __inline__ __attribute__((__gnu_inline__)) -#else -#define __GMP_EXTERN_INLINE extern __inline__ -#endif -#define __GMP_INLINE_PROTOTYPES 1 -#endif -#endif -/* DEC C (eg. version 5.9) supports "static __inline foo()", even in -std1 - strict ANSI mode. Inlining is done even when not optimizing (ie. -O0 - mode, which is the default), but an unnecessary local copy of foo is - emitted unless -O is used. "extern __inline" is accepted, but the - "extern" appears to be ignored, ie. it becomes a plain global function - but which is inlined within its file. Don't know if all old versions of - DEC C supported __inline, but as a start let's do the right thing for - current versions. */ -#ifdef __DECC -#define __GMP_EXTERN_INLINE static __inline -#endif -/* SCO OpenUNIX 8 cc supports "static inline foo()" but not in -Xc strict - ANSI mode (__STDC__ is 1 in that mode). Inlining only actually takes - place under -O. Without -O "foo" seems to be emitted whether it's used - or not, which is wasteful. "extern inline foo()" isn't useful, the - "extern" is apparently ignored, so foo is inlined if possible but also - emitted as a global, which causes multiple definition errors when - building a shared libmpir. */ -#ifdef __SCO_VERSION__ -#if __SCO_VERSION__ > 400000000 && __STDC__ != 1 \ - && ! defined (__GMP_EXTERN_INLINE) -#define __GMP_EXTERN_INLINE static inline -#endif -#endif -#if defined _MSC_VER -#define __GMP_EXTERN_INLINE static __inline -#endif -/* C++ always has "inline" and since it's a normal feature the linker should - discard duplicate non-inlined copies, or if it doesn't then that's a - problem for everyone, not just GMP. */ -#if defined (__cplusplus) && ! defined (__GMP_EXTERN_INLINE) -#define __GMP_EXTERN_INLINE inline -#endif -/* Don't do any inlining within a configure run, since if the compiler ends - up emitting copies of the code into the object file it can end up - demanding the various support routines (like mpn_popcount) for linking, - making the "alloca" test and perhaps others fail. And on hppa ia64 a - pre-release gcc 3.2 was seen not respecting the "extern" in "extern - __inline__", triggering this problem too. */ -#if defined (__GMP_WITHIN_CONFIGURE) && ! __GMP_WITHIN_CONFIGURE_INLINE -#undef __GMP_EXTERN_INLINE -#endif -/* By default, don't give a prototype when there's going to be an inline - version. Note in particular that Cray C++ objects to the combination of - prototype and inline. */ -#ifdef __GMP_EXTERN_INLINE -#ifndef __GMP_INLINE_PROTOTYPES -#define __GMP_INLINE_PROTOTYPES 0 -#endif -#else -#define __GMP_INLINE_PROTOTYPES 1 -#endif -#define __GMP_ABS(x) ((x) >= 0 ? (x) : -(x)) -#define __GMP_MAX(h,i) ((h) > (i) ? (h) : (i)) -/* __GMP_USHRT_MAX is not "~ (unsigned short) 0" because short is promoted - to int by "~". */ -#define __GMP_UINT_MAX (~ (unsigned) 0) -#define __GMP_ULONG_MAX (~ (unsigned long) 0) -#define __GMP_USHRT_MAX ((unsigned short) ~0) -/* __builtin_expect is in gcc 3.0, and not in 2.95. */ -#if __GMP_GNUC_PREREQ (3,0) -#define __GMP_LIKELY(cond) __builtin_expect ((cond) != 0, 1) -#define __GMP_UNLIKELY(cond) __builtin_expect ((cond) != 0, 0) -#else -#define __GMP_LIKELY(cond) (cond) -#define __GMP_UNLIKELY(cond) (cond) -#endif -#if defined( _STDINT_H ) || defined ( _STDINT_H_ ) || defined ( _STDINT ) -#define MPIR_HAVE_STDINT 1 -#endif -/* Allow direct user access to numerator and denominator of a mpq_t object. */ -#define mpq_numref(Q) (&((Q)->_mp_num)) -#define mpq_denref(Q) (&((Q)->_mp_den)) -#if defined (__cplusplus) -extern "C" { -using std::FILE; -#endif -#define mp_set_memory_functions __gmp_set_memory_functions -__GMP_DECLSPEC void mp_set_memory_functions __GMP_PROTO ((void *(*) (size_t), - void *(*) (void *, size_t, size_t), - void (*) (void *, size_t))) __GMP_NOTHROW; -#define mp_get_memory_functions __gmp_get_memory_functions -__GMP_DECLSPEC void mp_get_memory_functions __GMP_PROTO ((void *(**) (size_t), - void *(**) (void *, size_t, size_t), - void (**) (void *, size_t))) __GMP_NOTHROW; -#define mp_bits_per_limb __gmp_bits_per_limb -__GMP_DECLSPEC extern __gmp_const int mp_bits_per_limb; -#define gmp_errno __gmp_errno -__GMP_DECLSPEC extern int gmp_errno; -#define gmp_version __gmp_version -__GMP_DECLSPEC extern __gmp_const char * __gmp_const gmp_version; -#define mpir_version __mpir_version -__GMP_DECLSPEC extern __gmp_const char * __gmp_const mpir_version; -/**************** Random number routines. ****************/ -#define gmp_randinit_default __gmp_randinit_default -__GMP_DECLSPEC void gmp_randinit_default __GMP_PROTO ((gmp_randstate_t)); -#define gmp_randinit_lc_2exp __gmp_randinit_lc_2exp -__GMP_DECLSPEC void gmp_randinit_lc_2exp __GMP_PROTO ((gmp_randstate_t, - mpz_srcptr, mpir_ui, - mp_bitcnt_t)); -#define gmp_randinit_lc_2exp_size __gmp_randinit_lc_2exp_size -__GMP_DECLSPEC int gmp_randinit_lc_2exp_size __GMP_PROTO ((gmp_randstate_t, mp_bitcnt_t)); -#define gmp_randinit_mt __gmp_randinit_mt -__GMP_DECLSPEC void gmp_randinit_mt __GMP_PROTO ((gmp_randstate_t)); -#define gmp_randinit_set __gmp_randinit_set -__GMP_DECLSPEC void gmp_randinit_set __GMP_PROTO ((gmp_randstate_t, __gmp_const __gmp_randstate_struct *)); -#define gmp_randseed __gmp_randseed -__GMP_DECLSPEC void gmp_randseed __GMP_PROTO ((gmp_randstate_t, mpz_srcptr)); -#define gmp_randseed_ui __gmp_randseed_ui -__GMP_DECLSPEC void gmp_randseed_ui __GMP_PROTO ((gmp_randstate_t, mpir_ui)); -#define gmp_randclear __gmp_randclear -__GMP_DECLSPEC void gmp_randclear __GMP_PROTO ((gmp_randstate_t)); -#define gmp_urandomb_ui __gmp_urandomb_ui -__GMP_DECLSPEC mpir_ui gmp_urandomb_ui __GMP_PROTO ((gmp_randstate_t, mpir_ui)); -#define gmp_urandomm_ui __gmp_urandomm_ui -__GMP_DECLSPEC mpir_ui gmp_urandomm_ui __GMP_PROTO ((gmp_randstate_t, mpir_ui)); -/**************** Formatted output routines. ****************/ -#define gmp_asprintf __gmp_asprintf -__GMP_DECLSPEC int gmp_asprintf __GMP_PROTO ((char **, __gmp_const char *, ...)); -#define gmp_fprintf __gmp_fprintf -#ifdef _GMP_H_HAVE_FILE -__GMP_DECLSPEC int gmp_fprintf __GMP_PROTO ((FILE *, __gmp_const char *, ...)); -#endif -#define gmp_obstack_printf __gmp_obstack_printf -#if defined (_GMP_H_HAVE_OBSTACK) -__GMP_DECLSPEC int gmp_obstack_printf __GMP_PROTO ((struct obstack *, __gmp_const char *, ...)); -#endif -#define gmp_obstack_vprintf __gmp_obstack_vprintf -#if defined (_GMP_H_HAVE_OBSTACK) && defined (_GMP_H_HAVE_VA_LIST) -__GMP_DECLSPEC int gmp_obstack_vprintf __GMP_PROTO ((struct obstack *, __gmp_const char *, va_list)); -#endif -#define gmp_printf __gmp_printf -__GMP_DECLSPEC int gmp_printf __GMP_PROTO ((__gmp_const char *, ...)); -#define gmp_snprintf __gmp_snprintf -__GMP_DECLSPEC int gmp_snprintf __GMP_PROTO ((char *, size_t, __gmp_const char *, ...)); -#define gmp_sprintf __gmp_sprintf -__GMP_DECLSPEC int gmp_sprintf __GMP_PROTO ((char *, __gmp_const char *, ...)); -#define gmp_vasprintf __gmp_vasprintf -#if defined (_GMP_H_HAVE_VA_LIST) -__GMP_DECLSPEC int gmp_vasprintf __GMP_PROTO ((char **, __gmp_const char *, va_list)); -#endif -#define gmp_vfprintf __gmp_vfprintf -#if defined (_GMP_H_HAVE_FILE) && defined (_GMP_H_HAVE_VA_LIST) -__GMP_DECLSPEC int gmp_vfprintf __GMP_PROTO ((FILE *, __gmp_const char *, va_list)); -#endif -#define gmp_vprintf __gmp_vprintf -#if defined (_GMP_H_HAVE_VA_LIST) -__GMP_DECLSPEC int gmp_vprintf __GMP_PROTO ((__gmp_const char *, va_list)); -#endif -#define gmp_vsnprintf __gmp_vsnprintf -#if defined (_GMP_H_HAVE_VA_LIST) -__GMP_DECLSPEC int gmp_vsnprintf __GMP_PROTO ((char *, size_t, __gmp_const char *, va_list)); -#endif -#define gmp_vsprintf __gmp_vsprintf -#if defined (_GMP_H_HAVE_VA_LIST) -__GMP_DECLSPEC int gmp_vsprintf __GMP_PROTO ((char *, __gmp_const char *, va_list)); -#endif -/**************** Formatted input routines. ****************/ -#define gmp_fscanf __gmp_fscanf -#ifdef _GMP_H_HAVE_FILE -__GMP_DECLSPEC int gmp_fscanf __GMP_PROTO ((FILE *, __gmp_const char *, ...)); -#endif -#define gmp_scanf __gmp_scanf -__GMP_DECLSPEC int gmp_scanf __GMP_PROTO ((__gmp_const char *, ...)); -#define gmp_sscanf __gmp_sscanf -__GMP_DECLSPEC int gmp_sscanf __GMP_PROTO ((__gmp_const char *, __gmp_const char *, ...)); -#define gmp_vfscanf __gmp_vfscanf -#if defined (_GMP_H_HAVE_FILE) && defined (_GMP_H_HAVE_VA_LIST) -__GMP_DECLSPEC int gmp_vfscanf __GMP_PROTO ((FILE *, __gmp_const char *, va_list)); -#endif -#define gmp_vscanf __gmp_vscanf -#if defined (_GMP_H_HAVE_VA_LIST) -__GMP_DECLSPEC int gmp_vscanf __GMP_PROTO ((__gmp_const char *, va_list)); -#endif -#define gmp_vsscanf __gmp_vsscanf -#if defined (_GMP_H_HAVE_VA_LIST) -__GMP_DECLSPEC int gmp_vsscanf __GMP_PROTO ((__gmp_const char *, __gmp_const char *, va_list)); -#endif -/**************** Integer (i.e. Z) routines. ****************/ -#define _mpz_realloc __gmpz_realloc -#define mpz_realloc __gmpz_realloc -__GMP_DECLSPEC void *_mpz_realloc __GMP_PROTO ((mpz_ptr, mp_size_t)); -#define mpz_abs __gmpz_abs -#define __GMP_MPZ_ABS_MIN_ALLOC(x,y) (__GMP_ABS(y->_mp_size)) -#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_abs) -__GMP_DECLSPEC void mpz_abs __GMP_PROTO ((mpz_ptr, mpz_srcptr)); -#endif -#define __GMP_MPZ_ADD_MIN_ALLOC(x,y,z) (__GMP_MAX(__GMP_ABS(y->_mp_size),__GMP_ABS(z->_mp_size))+1) -#define mpz_add __gmpz_add -__GMP_DECLSPEC void mpz_add __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); -#define __GMP_MPZ_ADD_UI_MIN_ALLOC(x,y,z) (__GMP_MAX(__GMP_ABS(y->_mp_size),1+(GMP_BITS_PER_UI-1)/GMP_NUMB_BITS)+1) -#define mpz_add_ui __gmpz_add_ui -__GMP_DECLSPEC void mpz_add_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpir_ui)); -#define mpz_addmul __gmpz_addmul -__GMP_DECLSPEC void mpz_addmul __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); -#define mpz_addmul_ui __gmpz_addmul_ui -__GMP_DECLSPEC void mpz_addmul_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpir_ui)); -#define mpz_and __gmpz_and -__GMP_DECLSPEC void mpz_and __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); -#define mpz_array_init __gmpz_array_init -__GMP_DECLSPEC void mpz_array_init __GMP_PROTO ((mpz_ptr, mp_size_t, mp_size_t)); -#define mpz_bin_ui __gmpz_bin_ui -__GMP_DECLSPEC void mpz_bin_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpir_ui)); -#define mpz_bin_uiui __gmpz_bin_uiui -__GMP_DECLSPEC void mpz_bin_uiui __GMP_PROTO ((mpz_ptr, mpir_ui, mpir_ui)); -#define mpz_cdiv_q __gmpz_cdiv_q -__GMP_DECLSPEC void mpz_cdiv_q __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); -#define mpz_cdiv_q_2exp __gmpz_cdiv_q_2exp -__GMP_DECLSPEC void mpz_cdiv_q_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, mp_bitcnt_t)); -#define mpz_cdiv_q_ui __gmpz_cdiv_q_ui -__GMP_DECLSPEC mpir_ui mpz_cdiv_q_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpir_ui)); -#define mpz_cdiv_qr __gmpz_cdiv_qr -__GMP_DECLSPEC void mpz_cdiv_qr __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr)); -#define mpz_cdiv_qr_ui __gmpz_cdiv_qr_ui -__GMP_DECLSPEC mpir_ui mpz_cdiv_qr_ui __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpir_ui)); -#define mpz_cdiv_r __gmpz_cdiv_r -__GMP_DECLSPEC void mpz_cdiv_r __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); -#define mpz_cdiv_r_2exp __gmpz_cdiv_r_2exp -__GMP_DECLSPEC void mpz_cdiv_r_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, mp_bitcnt_t)); -#define mpz_cdiv_r_ui __gmpz_cdiv_r_ui -__GMP_DECLSPEC mpir_ui mpz_cdiv_r_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpir_ui)); -#define mpz_cdiv_ui __gmpz_cdiv_ui -__GMP_DECLSPEC mpir_ui mpz_cdiv_ui __GMP_PROTO ((mpz_srcptr, mpir_ui)) __GMP_ATTRIBUTE_PURE; -#define mpz_clear __gmpz_clear -__GMP_DECLSPEC void mpz_clear __GMP_PROTO ((mpz_ptr)); -#define mpz_clears __gmpz_clears -__GMP_DECLSPEC void mpz_clears __GMP_PROTO ((mpz_ptr, ...)); -#define mpz_clrbit __gmpz_clrbit -__GMP_DECLSPEC void mpz_clrbit __GMP_PROTO ((mpz_ptr, mp_bitcnt_t)); -#define mpz_cmp __gmpz_cmp -__GMP_DECLSPEC int mpz_cmp __GMP_PROTO ((mpz_srcptr, mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpz_cmp_d __gmpz_cmp_d -__GMP_DECLSPEC int mpz_cmp_d __GMP_PROTO ((mpz_srcptr, double)) __GMP_ATTRIBUTE_PURE; -#define _mpz_cmp_si __gmpz_cmp_si -__GMP_DECLSPEC int _mpz_cmp_si __GMP_PROTO ((mpz_srcptr, mpir_si)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define _mpz_cmp_ui __gmpz_cmp_ui -__GMP_DECLSPEC int _mpz_cmp_ui __GMP_PROTO ((mpz_srcptr, mpir_ui)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpz_cmpabs __gmpz_cmpabs -__GMP_DECLSPEC int mpz_cmpabs __GMP_PROTO ((mpz_srcptr, mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpz_cmpabs_d __gmpz_cmpabs_d -__GMP_DECLSPEC int mpz_cmpabs_d __GMP_PROTO ((mpz_srcptr, double)) __GMP_ATTRIBUTE_PURE; -#define mpz_cmpabs_ui __gmpz_cmpabs_ui -__GMP_DECLSPEC int mpz_cmpabs_ui __GMP_PROTO ((mpz_srcptr, mpir_ui)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpz_com __gmpz_com -__GMP_DECLSPEC void mpz_com __GMP_PROTO ((mpz_ptr, mpz_srcptr)); -#define mpz_combit __gmpz_combit -__GMP_DECLSPEC void mpz_combit __GMP_PROTO ((mpz_ptr, mp_bitcnt_t)); -#define mpz_congruent_p __gmpz_congruent_p -__GMP_DECLSPEC int mpz_congruent_p __GMP_PROTO ((mpz_srcptr, mpz_srcptr, mpz_srcptr)) __GMP_ATTRIBUTE_PURE; -#define mpz_congruent_2exp_p __gmpz_congruent_2exp_p -__GMP_DECLSPEC int mpz_congruent_2exp_p __GMP_PROTO ((mpz_srcptr, mpz_srcptr, mp_bitcnt_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpz_congruent_ui_p __gmpz_congruent_ui_p -__GMP_DECLSPEC int mpz_congruent_ui_p __GMP_PROTO ((mpz_srcptr, mpir_ui, mpir_ui)) __GMP_ATTRIBUTE_PURE; -#define mpz_divexact __gmpz_divexact -__GMP_DECLSPEC void mpz_divexact __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); -#define mpz_divexact_ui __gmpz_divexact_ui -__GMP_DECLSPEC void mpz_divexact_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpir_ui)); -#define mpz_divisible_p __gmpz_divisible_p -__GMP_DECLSPEC int mpz_divisible_p __GMP_PROTO ((mpz_srcptr, mpz_srcptr)) __GMP_ATTRIBUTE_PURE; -#define mpz_divisible_ui_p __gmpz_divisible_ui_p -__GMP_DECLSPEC int mpz_divisible_ui_p __GMP_PROTO ((mpz_srcptr, mpir_ui)) __GMP_ATTRIBUTE_PURE; -#define mpz_divisible_2exp_p __gmpz_divisible_2exp_p -__GMP_DECLSPEC int mpz_divisible_2exp_p __GMP_PROTO ((mpz_srcptr, mp_bitcnt_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpz_dump __gmpz_dump -__GMP_DECLSPEC void mpz_dump __GMP_PROTO ((mpz_srcptr)); -#define mpz_export __gmpz_export -__GMP_DECLSPEC void *mpz_export __GMP_PROTO ((void *, size_t *, int, size_t, int, size_t, mpz_srcptr)); -#define mpz_fac_ui __gmpz_fac_ui -__GMP_DECLSPEC void mpz_fac_ui __GMP_PROTO ((mpz_ptr, mpir_ui)); -#define mpz_2fac_ui __gmpz_2fac_ui -__GMP_DECLSPEC void mpz_2fac_ui __GMP_PROTO ((mpz_ptr, mpir_ui)); -#define mpz_mfac_uiui __gmpz_mfac_uiui -__GMP_DECLSPEC void mpz_mfac_uiui __GMP_PROTO ((mpz_ptr, mpir_ui, mpir_ui)); -#define mpz_primorial_ui __gmpz_primorial_ui -__GMP_DECLSPEC void mpz_primorial_ui __GMP_PROTO ((mpz_ptr, mpir_ui)); -#define mpz_fdiv_q __gmpz_fdiv_q -__GMP_DECLSPEC void mpz_fdiv_q __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); -#define mpz_fdiv_q_2exp __gmpz_fdiv_q_2exp -__GMP_DECLSPEC void mpz_fdiv_q_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, mp_bitcnt_t)); -#define mpz_fdiv_q_ui __gmpz_fdiv_q_ui -__GMP_DECLSPEC mpir_ui mpz_fdiv_q_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpir_ui)); -#define mpz_fdiv_qr __gmpz_fdiv_qr -__GMP_DECLSPEC void mpz_fdiv_qr __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr)); -#define mpz_fdiv_qr_ui __gmpz_fdiv_qr_ui -__GMP_DECLSPEC mpir_ui mpz_fdiv_qr_ui __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpir_ui)); -#define mpz_fdiv_r __gmpz_fdiv_r -__GMP_DECLSPEC void mpz_fdiv_r __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); -#define mpz_fdiv_r_2exp __gmpz_fdiv_r_2exp -__GMP_DECLSPEC void mpz_fdiv_r_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, mp_bitcnt_t)); -#define mpz_fdiv_r_ui __gmpz_fdiv_r_ui -__GMP_DECLSPEC mpir_ui mpz_fdiv_r_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpir_ui)); -#define mpz_fdiv_ui __gmpz_fdiv_ui -__GMP_DECLSPEC mpir_ui mpz_fdiv_ui __GMP_PROTO ((mpz_srcptr, mpir_ui)) __GMP_ATTRIBUTE_PURE; -#define mpz_fib_ui __gmpz_fib_ui -__GMP_DECLSPEC void mpz_fib_ui __GMP_PROTO ((mpz_ptr, mpir_ui)); -#define mpz_fib2_ui __gmpz_fib2_ui -__GMP_DECLSPEC void mpz_fib2_ui __GMP_PROTO ((mpz_ptr, mpz_ptr, mpir_ui)); -#define mpz_fits_sint_p __gmpz_fits_sint_p -__GMP_DECLSPEC int mpz_fits_sint_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpz_fits_si_p __gmpz_fits_si_p -__GMP_DECLSPEC int mpz_fits_si_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpz_fits_slong_p __gmpz_fits_slong_p -__GMP_DECLSPEC int mpz_fits_slong_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpz_fits_sshort_p __gmpz_fits_sshort_p -__GMP_DECLSPEC int mpz_fits_sshort_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpz_fits_uint_p __gmpz_fits_uint_p -#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_uint_p) -__GMP_DECLSPEC int mpz_fits_uint_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#endif -#define mpz_fits_ui_p __gmpz_fits_ui_p -#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_ui_p) -__GMP_DECLSPEC int mpz_fits_ui_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#endif -#define mpz_fits_ulong_p __gmpz_fits_ulong_p -#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_ulong_p) -__GMP_DECLSPEC int mpz_fits_ulong_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#endif -#define mpz_fits_ushort_p __gmpz_fits_ushort_p -#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_ushort_p) -__GMP_DECLSPEC int mpz_fits_ushort_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#endif -#define mpz_gcd __gmpz_gcd -__GMP_DECLSPEC void mpz_gcd __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); -#define mpz_gcd_ui __gmpz_gcd_ui -__GMP_DECLSPEC mpir_ui mpz_gcd_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpir_ui)); -#define mpz_gcdext __gmpz_gcdext -__GMP_DECLSPEC void mpz_gcdext __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr)); -#define mpz_get_d __gmpz_get_d -__GMP_DECLSPEC double mpz_get_d __GMP_PROTO ((mpz_srcptr)) __GMP_ATTRIBUTE_PURE; -#define mpz_get_d_2exp __gmpz_get_d_2exp -__GMP_DECLSPEC double mpz_get_d_2exp __GMP_PROTO ((mpir_si *, mpz_srcptr)); -#define mpz_get_si __gmpz_get_si -__GMP_DECLSPEC /* signed */ mpir_si mpz_get_si __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpz_get_str __gmpz_get_str -__GMP_DECLSPEC char *mpz_get_str __GMP_PROTO ((char *, int, mpz_srcptr)); -#define mpz_get_ui __gmpz_get_ui -#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_get_ui) -__GMP_DECLSPEC mpir_ui mpz_get_ui __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#endif -#define mpz_getlimbn __gmpz_getlimbn -#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_getlimbn) -__GMP_DECLSPEC mp_limb_t mpz_getlimbn __GMP_PROTO ((mpz_srcptr, mp_size_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#endif -#define mpz_hamdist __gmpz_hamdist -__GMP_DECLSPEC mp_bitcnt_t mpz_hamdist __GMP_PROTO ((mpz_srcptr, mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpz_import __gmpz_import -__GMP_DECLSPEC void mpz_import __GMP_PROTO ((mpz_ptr, size_t, int, size_t, int, size_t, __gmp_const void *)); -#define mpz_init __gmpz_init -__GMP_DECLSPEC void mpz_init __GMP_PROTO ((mpz_ptr)); -#define mpz_init2 __gmpz_init2 -__GMP_DECLSPEC void mpz_init2 __GMP_PROTO ((mpz_ptr, mp_bitcnt_t)); -#define mpz_inits __gmpz_inits -__GMP_DECLSPEC void mpz_inits __GMP_PROTO ((mpz_ptr, ...)); -#define mpz_init_set __gmpz_init_set -__GMP_DECLSPEC void mpz_init_set __GMP_PROTO ((mpz_ptr, mpz_srcptr)); -#define mpz_init_set_d __gmpz_init_set_d -__GMP_DECLSPEC void mpz_init_set_d __GMP_PROTO ((mpz_ptr, double)); -#define mpz_init_set_si __gmpz_init_set_si -__GMP_DECLSPEC void mpz_init_set_si __GMP_PROTO ((mpz_ptr, mpir_si)); -#define mpz_init_set_str __gmpz_init_set_str -__GMP_DECLSPEC int mpz_init_set_str __GMP_PROTO ((mpz_ptr, __gmp_const char *, int)); -#define mpz_init_set_ui __gmpz_init_set_ui -__GMP_DECLSPEC void mpz_init_set_ui __GMP_PROTO ((mpz_ptr, mpir_ui)); -#define mpz_inp_raw __gmpz_inp_raw -#ifdef _GMP_H_HAVE_FILE -__GMP_DECLSPEC size_t mpz_inp_raw __GMP_PROTO ((mpz_ptr, FILE *)); -#endif -#define mpz_inp_str __gmpz_inp_str -#ifdef _GMP_H_HAVE_FILE -__GMP_DECLSPEC size_t mpz_inp_str __GMP_PROTO ((mpz_ptr, FILE *, int)); -#endif -#define mpz_invert __gmpz_invert -__GMP_DECLSPEC int mpz_invert __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); -#define mpz_ior __gmpz_ior -__GMP_DECLSPEC void mpz_ior __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); -#define mpz_jacobi __gmpz_jacobi -__GMP_DECLSPEC int mpz_jacobi __GMP_PROTO ((mpz_srcptr, mpz_srcptr)) __GMP_ATTRIBUTE_PURE; -#define mpz_kronecker mpz_jacobi /* alias */ -#define mpz_kronecker_si __gmpz_kronecker_si -__GMP_DECLSPEC int mpz_kronecker_si __GMP_PROTO ((mpz_srcptr, mpir_si)) __GMP_ATTRIBUTE_PURE; -#define mpz_kronecker_ui __gmpz_kronecker_ui -__GMP_DECLSPEC int mpz_kronecker_ui __GMP_PROTO ((mpz_srcptr, mpir_ui)) __GMP_ATTRIBUTE_PURE; -#define mpz_si_kronecker __gmpz_si_kronecker -__GMP_DECLSPEC int mpz_si_kronecker __GMP_PROTO ((mpir_si, mpz_srcptr)) __GMP_ATTRIBUTE_PURE; -#define mpz_ui_kronecker __gmpz_ui_kronecker -__GMP_DECLSPEC int mpz_ui_kronecker __GMP_PROTO ((mpir_ui, mpz_srcptr)) __GMP_ATTRIBUTE_PURE; -#define mpz_lcm __gmpz_lcm -__GMP_DECLSPEC void mpz_lcm __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); -#define mpz_lcm_ui __gmpz_lcm_ui -__GMP_DECLSPEC void mpz_lcm_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpir_ui)); -#define mpz_legendre mpz_jacobi /* alias */ -#define mpz_lucnum_ui __gmpz_lucnum_ui -__GMP_DECLSPEC void mpz_lucnum_ui __GMP_PROTO ((mpz_ptr, mpir_ui)); -#define mpz_lucnum2_ui __gmpz_lucnum2_ui -__GMP_DECLSPEC void mpz_lucnum2_ui __GMP_PROTO ((mpz_ptr, mpz_ptr, mpir_ui)); -#define mpz_millerrabin __gmpz_millerrabin -__GMP_DECLSPEC int mpz_millerrabin __GMP_PROTO ((mpz_srcptr, int)) __GMP_ATTRIBUTE_PURE; -#define mpz_miller_rabin __gmpz_miller_rabin -__GMP_DECLSPEC int mpz_miller_rabin __GMP_PROTO ((mpz_srcptr, int, gmp_randstate_t)) __GMP_ATTRIBUTE_PURE; -#define mpz_mod __gmpz_mod -__GMP_DECLSPEC void mpz_mod __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); -#define mpz_mod_ui mpz_fdiv_r_ui /* same as fdiv_r because divisor unsigned */ -#define __GMP_MPZ_MUL_MIN_ALLOC(x,y,z) (__GMP_ABS(y->_mp_size)+__GMP_ABS(z->_mp_size)+1) -#define mpz_mul __gmpz_mul -__GMP_DECLSPEC void mpz_mul __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); -#define mpz_mul_2exp __gmpz_mul_2exp -__GMP_DECLSPEC void mpz_mul_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, mp_bitcnt_t)); -#define __GMP_MPZ_MUL_SI_MIN_ALLOC(x,y,z) (__GMP_ABS(y->_mp_size)+(GMP_BITS_PER_UI-1)/GMP_NUMB_BITS+1) -#define mpz_mul_si __gmpz_mul_si -__GMP_DECLSPEC void mpz_mul_si __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpir_si)); -#define __GMP_MPZ_MUL_UI_MIN_ALLOC(x,y,z) (__GMP_ABS(y->_mp_size)+(GMP_BITS_PER_UI-1)/GMP_NUMB_BITS+1) -#define mpz_mul_ui __gmpz_mul_ui -__GMP_DECLSPEC void mpz_mul_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpir_ui)); -#define mpz_neg __gmpz_neg -#define __GMP_MPZ_NEG_MIN_ALLOC(x,y) (__GMP_ABS(y->_mp_size)) -#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_neg) -__GMP_DECLSPEC void mpz_neg __GMP_PROTO ((mpz_ptr, mpz_srcptr)); -#endif -#define mpz_nextprime __gmpz_nextprime -__GMP_DECLSPEC void mpz_nextprime __GMP_PROTO ((mpz_ptr, mpz_srcptr)); -#define mpz_next_prime_candidate __gmpz_next_prime_candidate -__GMP_DECLSPEC void mpz_next_prime_candidate __GMP_PROTO ((mpz_ptr, mpz_srcptr, gmp_randstate_t)); -#define mpz_out_raw __gmpz_out_raw -#ifdef _GMP_H_HAVE_FILE -__GMP_DECLSPEC size_t mpz_out_raw __GMP_PROTO ((FILE *, mpz_srcptr)); -#endif -#define mpz_out_str __gmpz_out_str -#ifdef _GMP_H_HAVE_FILE -__GMP_DECLSPEC size_t mpz_out_str __GMP_PROTO ((FILE *, int, mpz_srcptr)); -#endif -#define mpz_perfect_power_p __gmpz_perfect_power_p -__GMP_DECLSPEC int mpz_perfect_power_p __GMP_PROTO ((mpz_srcptr)) __GMP_ATTRIBUTE_PURE; -#define mpz_perfect_square_p __gmpz_perfect_square_p -#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_perfect_square_p) -__GMP_DECLSPEC int mpz_perfect_square_p __GMP_PROTO ((mpz_srcptr)) __GMP_ATTRIBUTE_PURE; -#endif -#define mpz_popcount __gmpz_popcount -#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_popcount) -__GMP_DECLSPEC mp_bitcnt_t mpz_popcount __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#endif -#define mpz_pow_ui __gmpz_pow_ui -__GMP_DECLSPEC void mpz_pow_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpir_ui)); -#define mpz_powm __gmpz_powm -__GMP_DECLSPEC void mpz_powm __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr)); -#define mpz_powm_ui __gmpz_powm_ui -__GMP_DECLSPEC void mpz_powm_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpir_ui, mpz_srcptr)); -#define mpz_probab_prime_p __gmpz_probab_prime_p -__GMP_DECLSPEC int mpz_probab_prime_p __GMP_PROTO ((mpz_srcptr, int)) __GMP_ATTRIBUTE_PURE; -#define mpz_probable_prime_p __gmpz_probable_prime_p -__GMP_DECLSPEC int mpz_probable_prime_p __GMP_PROTO ((mpz_srcptr,gmp_randstate_t, int, mpir_ui)); -#define mpz_likely_prime_p __gmpz_likely_prime_p -__GMP_DECLSPEC int mpz_likely_prime_p __GMP_PROTO ((mpz_srcptr,gmp_randstate_t, mpir_ui)); -#define mpz_realloc2 __gmpz_realloc2 -__GMP_DECLSPEC void mpz_realloc2 __GMP_PROTO ((mpz_ptr, mp_bitcnt_t)); -#define mpz_remove __gmpz_remove -__GMP_DECLSPEC mp_bitcnt_t mpz_remove __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); -#define mpz_root __gmpz_root -__GMP_DECLSPEC int mpz_root __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpir_ui)); -#define mpz_nthroot __gmpz_nthroot -__GMP_DECLSPEC void mpz_nthroot __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpir_ui)); -#define mpz_rootrem __gmpz_rootrem -__GMP_DECLSPEC void mpz_rootrem __GMP_PROTO ((mpz_ptr,mpz_ptr, mpz_srcptr, mpir_ui)); -#define mpz_rrandomb __gmpz_rrandomb -__GMP_DECLSPEC void mpz_rrandomb __GMP_PROTO ((mpz_ptr, gmp_randstate_t, mp_bitcnt_t)); -#define mpz_scan0 __gmpz_scan0 -__GMP_DECLSPEC mp_bitcnt_t mpz_scan0 __GMP_PROTO ((mpz_srcptr, mp_bitcnt_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpz_scan1 __gmpz_scan1 -__GMP_DECLSPEC mp_bitcnt_t mpz_scan1 __GMP_PROTO ((mpz_srcptr, mp_bitcnt_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define __GMP_MPZ_SET_MIN_ALLOC(x,y) __GMP_ABS(y->_mp_size) -#define mpz_set __gmpz_set -__GMP_DECLSPEC void mpz_set __GMP_PROTO ((mpz_ptr, mpz_srcptr)); -#define mpz_set_d __gmpz_set_d -__GMP_DECLSPEC void mpz_set_d __GMP_PROTO ((mpz_ptr, double)); -#define mpz_set_f __gmpz_set_f -__GMP_DECLSPEC void mpz_set_f __GMP_PROTO ((mpz_ptr, mpf_srcptr)); -#define mpz_set_q __gmpz_set_q -#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_set_q) -__GMP_DECLSPEC void mpz_set_q __GMP_PROTO ((mpz_ptr, mpq_srcptr)); -#endif -#define __GMP_MPZ_SET_SI_MIN_ALLOC(x,y) (1+(GMP_BITS_PER_UI-1)/GMP_NUMB_BITS) -#define mpz_set_si __gmpz_set_si -__GMP_DECLSPEC void mpz_set_si __GMP_PROTO ((mpz_ptr, mpir_si)); -#define mpz_set_str __gmpz_set_str -__GMP_DECLSPEC int mpz_set_str __GMP_PROTO ((mpz_ptr, __gmp_const char *, int)); -#define __GMP_MPZ_SET_UI_MIN_ALLOC(x,y) (1+(GMP_BITS_PER_UI-1)/GMP_NUMB_BITS) -#define mpz_set_ui __gmpz_set_ui -__GMP_DECLSPEC void mpz_set_ui __GMP_PROTO ((mpz_ptr, mpir_ui)); -#define mpz_setbit __gmpz_setbit -__GMP_DECLSPEC void mpz_setbit __GMP_PROTO ((mpz_ptr, mp_bitcnt_t)); -#define mpz_size __gmpz_size -#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_size) -__GMP_DECLSPEC size_t mpz_size __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#endif -#define mpz_sizeinbase __gmpz_sizeinbase -__GMP_DECLSPEC size_t mpz_sizeinbase __GMP_PROTO ((mpz_srcptr, int)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpz_sqrt __gmpz_sqrt -__GMP_DECLSPEC void mpz_sqrt __GMP_PROTO ((mpz_ptr, mpz_srcptr)); -#define mpz_sqrtrem __gmpz_sqrtrem -__GMP_DECLSPEC void mpz_sqrtrem __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr)); -#define __GMP_MPZ_SUB_MIN_ALLOC(x,y,z) (__GMP_MAX(__GMP_ABS(y->_mp_size),__GMP_ABS(z->_mp_size))+1) -#define mpz_sub __gmpz_sub -__GMP_DECLSPEC void mpz_sub __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); -#define __GMP_MPZ_SUB_UI_MIN_ALLOC(x,y,z) (__GMP_MAX(__GMP_ABS(y->_mp_size),1+(GMP_BITS_PER_UI-1)/GMP_NUMB_BITS)+1) -#define mpz_sub_ui __gmpz_sub_ui -__GMP_DECLSPEC void mpz_sub_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpir_ui)); -#define __GMP_MPZ_UI_SUB_MIN_ALLOC(x,y,z) (__GMP_MAX(__GMP_ABS(z->_mp_size),1+(GMP_BITS_PER_UI-1)/GMP_NUMB_BITS)+1) -#define mpz_ui_sub __gmpz_ui_sub -__GMP_DECLSPEC void mpz_ui_sub __GMP_PROTO ((mpz_ptr, mpir_ui, mpz_srcptr)); -#define mpz_submul __gmpz_submul -__GMP_DECLSPEC void mpz_submul __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); -#define mpz_submul_ui __gmpz_submul_ui -__GMP_DECLSPEC void mpz_submul_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpir_ui)); -#define mpz_swap __gmpz_swap -__GMP_DECLSPEC void mpz_swap __GMP_PROTO ((mpz_ptr, mpz_ptr)) __GMP_NOTHROW; -#define mpz_tdiv_ui __gmpz_tdiv_ui -__GMP_DECLSPEC mpir_ui mpz_tdiv_ui __GMP_PROTO ((mpz_srcptr, mpir_ui)) __GMP_ATTRIBUTE_PURE; -#define mpz_tdiv_q __gmpz_tdiv_q -__GMP_DECLSPEC void mpz_tdiv_q __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); -#define mpz_tdiv_q_2exp __gmpz_tdiv_q_2exp -__GMP_DECLSPEC void mpz_tdiv_q_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, mp_bitcnt_t)); -#define mpz_tdiv_q_ui __gmpz_tdiv_q_ui -__GMP_DECLSPEC mpir_ui mpz_tdiv_q_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpir_ui)); -#define mpz_tdiv_qr __gmpz_tdiv_qr -__GMP_DECLSPEC void mpz_tdiv_qr __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr)); -#define mpz_tdiv_qr_ui __gmpz_tdiv_qr_ui -__GMP_DECLSPEC mpir_ui mpz_tdiv_qr_ui __GMP_PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpir_ui)); -#define mpz_tdiv_r __gmpz_tdiv_r -__GMP_DECLSPEC void mpz_tdiv_r __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); -#define mpz_tdiv_r_2exp __gmpz_tdiv_r_2exp -__GMP_DECLSPEC void mpz_tdiv_r_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, mp_bitcnt_t)); -#define mpz_tdiv_r_ui __gmpz_tdiv_r_ui -__GMP_DECLSPEC mpir_ui mpz_tdiv_r_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpir_ui)); -#define mpz_tstbit __gmpz_tstbit -__GMP_DECLSPEC int mpz_tstbit __GMP_PROTO ((mpz_srcptr, mp_bitcnt_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpz_ui_pow_ui __gmpz_ui_pow_ui -__GMP_DECLSPEC void mpz_ui_pow_ui __GMP_PROTO ((mpz_ptr, mpir_ui, mpir_ui)); -#define mpz_urandomb __gmpz_urandomb -__GMP_DECLSPEC void mpz_urandomb __GMP_PROTO ((mpz_ptr, gmp_randstate_t, mp_bitcnt_t)); -#define mpz_urandomm __gmpz_urandomm -__GMP_DECLSPEC void mpz_urandomm __GMP_PROTO ((mpz_ptr, gmp_randstate_t, mpz_srcptr)); -#define mpz_xor __gmpz_xor -#define mpz_eor __gmpz_xor -__GMP_DECLSPEC void mpz_xor __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); -/****** Integer (i.e. Z) routines for intmaax_t/uintmax_t types ******/ -#if defined(MPIR_HAVE_STDINT) -#define __GMP_BITS_PER_UINTMAX (8*sizeof(uintmax_t)) -#define mpz_get_ux __gmpz_get_ux -__GMP_DECLSPEC uintmax_t mpz_get_ux __GMP_PROTO ((mpz_srcptr)); -#define mpz_get_sx __gmpz_get_sx -__GMP_DECLSPEC intmax_t mpz_get_sx __GMP_PROTO ((mpz_srcptr)); -#define mpz_set_ux __gmpz_set_ux -__GMP_DECLSPEC void mpz_set_ux __GMP_PROTO ((mpz_ptr, uintmax_t)); -#define mpz_set_sx __gmpz_set_sx -__GMP_DECLSPEC void mpz_set_sx __GMP_PROTO ((mpz_ptr, intmax_t)); -#define mpz_init_set_ux __gmpz_init_set_ux -__GMP_DECLSPEC void mpz_init_set_ux __GMP_PROTO ((mpz_ptr, uintmax_t)); -#define mpz_init_set_sx __gmpz_init_set_sx -__GMP_DECLSPEC void mpz_init_set_sx __GMP_PROTO ((mpz_ptr, intmax_t)); -#endif -/**************** Rational (i.e. Q) routines. ****************/ -#define mpq_abs __gmpq_abs -#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpq_abs) -__GMP_DECLSPEC void mpq_abs __GMP_PROTO ((mpq_ptr, mpq_srcptr)); -#endif -#define mpq_add __gmpq_add -__GMP_DECLSPEC void mpq_add __GMP_PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr)); -#define mpq_canonicalize __gmpq_canonicalize -__GMP_DECLSPEC void mpq_canonicalize __GMP_PROTO ((mpq_ptr)); -#define mpq_clear __gmpq_clear -__GMP_DECLSPEC void mpq_clear __GMP_PROTO ((mpq_ptr)); -#define mpq_clears __gmpq_clears -__GMP_DECLSPEC void mpq_clears __GMP_PROTO ((mpq_ptr, ...)); -#define mpq_cmp __gmpq_cmp -__GMP_DECLSPEC int mpq_cmp __GMP_PROTO ((mpq_srcptr, mpq_srcptr)) __GMP_ATTRIBUTE_PURE; -#define _mpq_cmp_si __gmpq_cmp_si -__GMP_DECLSPEC int _mpq_cmp_si __GMP_PROTO ((mpq_srcptr, mpir_si, mpir_ui)) __GMP_ATTRIBUTE_PURE; -#define _mpq_cmp_ui __gmpq_cmp_ui -__GMP_DECLSPEC int _mpq_cmp_ui __GMP_PROTO ((mpq_srcptr, mpir_ui, mpir_ui)) __GMP_ATTRIBUTE_PURE; -#define mpq_div __gmpq_div -__GMP_DECLSPEC void mpq_div __GMP_PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr)); -#define mpq_div_2exp __gmpq_div_2exp -__GMP_DECLSPEC void mpq_div_2exp __GMP_PROTO ((mpq_ptr, mpq_srcptr, mp_bitcnt_t)); -#define mpq_equal __gmpq_equal -__GMP_DECLSPEC int mpq_equal __GMP_PROTO ((mpq_srcptr, mpq_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpq_get_num __gmpq_get_num -__GMP_DECLSPEC void mpq_get_num __GMP_PROTO ((mpz_ptr, mpq_srcptr)); -#define mpq_get_den __gmpq_get_den -__GMP_DECLSPEC void mpq_get_den __GMP_PROTO ((mpz_ptr, mpq_srcptr)); -#define mpq_get_d __gmpq_get_d -__GMP_DECLSPEC double mpq_get_d __GMP_PROTO ((mpq_srcptr)) __GMP_ATTRIBUTE_PURE; -#define mpq_get_str __gmpq_get_str -__GMP_DECLSPEC char *mpq_get_str __GMP_PROTO ((char *, int, mpq_srcptr)); -#define mpq_init __gmpq_init -__GMP_DECLSPEC void mpq_init __GMP_PROTO ((mpq_ptr)); -#define mpq_inits __gmpq_inits -__GMP_DECLSPEC void mpq_inits __GMP_PROTO ((mpq_ptr, ...)); -#define mpq_inp_str __gmpq_inp_str -#ifdef _GMP_H_HAVE_FILE -__GMP_DECLSPEC size_t mpq_inp_str __GMP_PROTO ((mpq_ptr, FILE *, int)); -#endif -#define mpq_inv __gmpq_inv -__GMP_DECLSPEC void mpq_inv __GMP_PROTO ((mpq_ptr, mpq_srcptr)); -#define mpq_mul __gmpq_mul -__GMP_DECLSPEC void mpq_mul __GMP_PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr)); -#define mpq_mul_2exp __gmpq_mul_2exp -__GMP_DECLSPEC void mpq_mul_2exp __GMP_PROTO ((mpq_ptr, mpq_srcptr, mp_bitcnt_t)); -#define mpq_neg __gmpq_neg -#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpq_neg) -__GMP_DECLSPEC void mpq_neg __GMP_PROTO ((mpq_ptr, mpq_srcptr)); -#endif -#define mpq_out_str __gmpq_out_str -#ifdef _GMP_H_HAVE_FILE -__GMP_DECLSPEC size_t mpq_out_str __GMP_PROTO ((FILE *, int, mpq_srcptr)); -#endif -#define mpq_set __gmpq_set -__GMP_DECLSPEC void mpq_set __GMP_PROTO ((mpq_ptr, mpq_srcptr)); -#define mpq_set_d __gmpq_set_d -__GMP_DECLSPEC void mpq_set_d __GMP_PROTO ((mpq_ptr, double)); -#define mpq_set_den __gmpq_set_den -__GMP_DECLSPEC void mpq_set_den __GMP_PROTO ((mpq_ptr, mpz_srcptr)); -#define mpq_set_f __gmpq_set_f -__GMP_DECLSPEC void mpq_set_f __GMP_PROTO ((mpq_ptr, mpf_srcptr)); -#define mpq_set_num __gmpq_set_num -__GMP_DECLSPEC void mpq_set_num __GMP_PROTO ((mpq_ptr, mpz_srcptr)); -#define mpq_set_si __gmpq_set_si -__GMP_DECLSPEC void mpq_set_si __GMP_PROTO ((mpq_ptr, mpir_si, mpir_ui)); -#define mpq_set_str __gmpq_set_str -__GMP_DECLSPEC int mpq_set_str __GMP_PROTO ((mpq_ptr, __gmp_const char *, int)); -#define mpq_set_ui __gmpq_set_ui -__GMP_DECLSPEC void mpq_set_ui __GMP_PROTO ((mpq_ptr, mpir_ui, mpir_ui)); -#define mpq_set_z __gmpq_set_z -__GMP_DECLSPEC void mpq_set_z __GMP_PROTO ((mpq_ptr, mpz_srcptr)); -#define mpq_sub __gmpq_sub -__GMP_DECLSPEC void mpq_sub __GMP_PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr)); -#define mpq_swap __gmpq_swap -__GMP_DECLSPEC void mpq_swap __GMP_PROTO ((mpq_ptr, mpq_ptr)) __GMP_NOTHROW; -/**************** Float (i.e. F) routines. ****************/ -#define mpf_abs __gmpf_abs -__GMP_DECLSPEC void mpf_abs __GMP_PROTO ((mpf_ptr, mpf_srcptr)); -#define mpf_add __gmpf_add -__GMP_DECLSPEC void mpf_add __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr)); -#define mpf_add_ui __gmpf_add_ui -__GMP_DECLSPEC void mpf_add_ui __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpir_ui)); -#define mpf_ceil __gmpf_ceil -__GMP_DECLSPEC void mpf_ceil __GMP_PROTO ((mpf_ptr, mpf_srcptr)); -#define mpf_clear __gmpf_clear -__GMP_DECLSPEC void mpf_clear __GMP_PROTO ((mpf_ptr)); -#define mpf_clears __gmpf_clears -__GMP_DECLSPEC void mpf_clears __GMP_PROTO ((mpf_ptr, ...)); -#define mpf_cmp __gmpf_cmp -__GMP_DECLSPEC int mpf_cmp __GMP_PROTO ((mpf_srcptr, mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpf_cmp_d __gmpf_cmp_d -__GMP_DECLSPEC int mpf_cmp_d __GMP_PROTO ((mpf_srcptr, double)) __GMP_ATTRIBUTE_PURE; -#define mpf_cmp_si __gmpf_cmp_si -__GMP_DECLSPEC int mpf_cmp_si __GMP_PROTO ((mpf_srcptr, mpir_si)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpf_cmp_ui __gmpf_cmp_ui -__GMP_DECLSPEC int mpf_cmp_ui __GMP_PROTO ((mpf_srcptr, mpir_ui)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpf_div __gmpf_div -__GMP_DECLSPEC void mpf_div __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr)); -#define mpf_div_2exp __gmpf_div_2exp -__GMP_DECLSPEC void mpf_div_2exp __GMP_PROTO ((mpf_ptr, mpf_srcptr, mp_bitcnt_t)); -#define mpf_div_ui __gmpf_div_ui -__GMP_DECLSPEC void mpf_div_ui __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpir_ui)); -#define mpf_dump __gmpf_dump -__GMP_DECLSPEC void mpf_dump __GMP_PROTO ((mpf_srcptr)); -#define mpf_eq __gmpf_eq -__GMP_DECLSPEC int mpf_eq __GMP_PROTO ((mpf_srcptr, mpf_srcptr, mp_bitcnt_t)) __GMP_ATTRIBUTE_PURE; -#define mpf_fits_sint_p __gmpf_fits_sint_p -__GMP_DECLSPEC int mpf_fits_sint_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpf_fits_si_p __gmpf_fits_si_p -__GMP_DECLSPEC int mpf_fits_si_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpf_fits_slong_p __gmpf_fits_slong_p -__GMP_DECLSPEC int mpf_fits_slong_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpf_fits_sshort_p __gmpf_fits_sshort_p -__GMP_DECLSPEC int mpf_fits_sshort_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpf_fits_uint_p __gmpf_fits_uint_p -__GMP_DECLSPEC int mpf_fits_uint_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpf_fits_ui_p __gmpf_fits_ui_p -__GMP_DECLSPEC int mpf_fits_ui_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpf_fits_ulong_p __gmpf_fits_ulong_p -__GMP_DECLSPEC int mpf_fits_ulong_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpf_fits_ushort_p __gmpf_fits_ushort_p -__GMP_DECLSPEC int mpf_fits_ushort_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpf_floor __gmpf_floor -__GMP_DECLSPEC void mpf_floor __GMP_PROTO ((mpf_ptr, mpf_srcptr)); -#define mpf_get_d __gmpf_get_d -__GMP_DECLSPEC double mpf_get_d __GMP_PROTO ((mpf_srcptr)) __GMP_ATTRIBUTE_PURE; -#define mpf_get_d_2exp __gmpf_get_d_2exp -__GMP_DECLSPEC double mpf_get_d_2exp __GMP_PROTO ((mpir_si *, mpf_srcptr)); -#define mpf_get_default_prec __gmpf_get_default_prec -__GMP_DECLSPEC mp_bitcnt_t mpf_get_default_prec __GMP_PROTO ((void)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpf_get_prec __gmpf_get_prec -__GMP_DECLSPEC mp_bitcnt_t mpf_get_prec __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpf_get_si __gmpf_get_si -__GMP_DECLSPEC mpir_si mpf_get_si __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpf_get_str __gmpf_get_str -__GMP_DECLSPEC char *mpf_get_str __GMP_PROTO ((char *, mp_exp_t *, int, size_t, mpf_srcptr)); -#define mpf_get_ui __gmpf_get_ui -__GMP_DECLSPEC mpir_ui mpf_get_ui __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpf_init __gmpf_init -__GMP_DECLSPEC void mpf_init __GMP_PROTO ((mpf_ptr)); -#define mpf_init2 __gmpf_init2 -__GMP_DECLSPEC void mpf_init2 __GMP_PROTO ((mpf_ptr, mp_bitcnt_t)); -#define mpf_inits __gmpf_inits -__GMP_DECLSPEC void mpf_inits __GMP_PROTO ((mpf_ptr, ...)); -#define mpf_init_set __gmpf_init_set -__GMP_DECLSPEC void mpf_init_set __GMP_PROTO ((mpf_ptr, mpf_srcptr)); -#define mpf_init_set_d __gmpf_init_set_d -__GMP_DECLSPEC void mpf_init_set_d __GMP_PROTO ((mpf_ptr, double)); -#define mpf_init_set_si __gmpf_init_set_si -__GMP_DECLSPEC void mpf_init_set_si __GMP_PROTO ((mpf_ptr, mpir_si)); -#define mpf_init_set_str __gmpf_init_set_str -__GMP_DECLSPEC int mpf_init_set_str __GMP_PROTO ((mpf_ptr, __gmp_const char *, int)); -#define mpf_init_set_ui __gmpf_init_set_ui -__GMP_DECLSPEC void mpf_init_set_ui __GMP_PROTO ((mpf_ptr, mpir_ui)); -#define mpf_inp_str __gmpf_inp_str -#ifdef _GMP_H_HAVE_FILE -__GMP_DECLSPEC size_t mpf_inp_str __GMP_PROTO ((mpf_ptr, FILE *, int)); -#endif -#define mpf_integer_p __gmpf_integer_p -__GMP_DECLSPEC int mpf_integer_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpf_mul __gmpf_mul -__GMP_DECLSPEC void mpf_mul __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr)); -#define mpf_mul_2exp __gmpf_mul_2exp -__GMP_DECLSPEC void mpf_mul_2exp __GMP_PROTO ((mpf_ptr, mpf_srcptr, mp_bitcnt_t)); -#define mpf_mul_ui __gmpf_mul_ui -__GMP_DECLSPEC void mpf_mul_ui __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpir_ui)); -#define mpf_neg __gmpf_neg -__GMP_DECLSPEC void mpf_neg __GMP_PROTO ((mpf_ptr, mpf_srcptr)); -#define mpf_out_str __gmpf_out_str -#ifdef _GMP_H_HAVE_FILE -__GMP_DECLSPEC size_t mpf_out_str __GMP_PROTO ((FILE *, int, size_t, mpf_srcptr)); -#endif -#define mpf_pow_ui __gmpf_pow_ui -__GMP_DECLSPEC void mpf_pow_ui __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpir_ui)); -#define mpf_random2 __gmpf_random2 -__GMP_DECLSPEC void mpf_random2 __GMP_PROTO ((mpf_ptr, mp_size_t, mp_exp_t)); -#define mpf_rrandomb __gmpf_rrandomb -__GMP_DECLSPEC void mpf_rrandomb __GMP_PROTO ((mpf_ptr, gmp_randstate_t, mp_size_t, mp_exp_t)); -#define mpf_reldiff __gmpf_reldiff -__GMP_DECLSPEC void mpf_reldiff __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr)); -#define mpf_set __gmpf_set -__GMP_DECLSPEC void mpf_set __GMP_PROTO ((mpf_ptr, mpf_srcptr)); -#define mpf_set_d __gmpf_set_d -__GMP_DECLSPEC void mpf_set_d __GMP_PROTO ((mpf_ptr, double)); -#define mpf_set_default_prec __gmpf_set_default_prec -__GMP_DECLSPEC void mpf_set_default_prec __GMP_PROTO ((mp_bitcnt_t)) __GMP_NOTHROW; -#define mpf_set_prec __gmpf_set_prec -__GMP_DECLSPEC void mpf_set_prec __GMP_PROTO ((mpf_ptr, mp_bitcnt_t)); -#define mpf_set_prec_raw __gmpf_set_prec_raw -__GMP_DECLSPEC void mpf_set_prec_raw __GMP_PROTO ((mpf_ptr, mp_bitcnt_t)) __GMP_NOTHROW; -#define mpf_set_q __gmpf_set_q -__GMP_DECLSPEC void mpf_set_q __GMP_PROTO ((mpf_ptr, mpq_srcptr)); -#define mpf_set_si __gmpf_set_si -__GMP_DECLSPEC void mpf_set_si __GMP_PROTO ((mpf_ptr, mpir_si)); -#define mpf_set_str __gmpf_set_str -__GMP_DECLSPEC int mpf_set_str __GMP_PROTO ((mpf_ptr, __gmp_const char *, int)); -#define mpf_set_ui __gmpf_set_ui -__GMP_DECLSPEC void mpf_set_ui __GMP_PROTO ((mpf_ptr, mpir_ui)); -#define mpf_set_z __gmpf_set_z -__GMP_DECLSPEC void mpf_set_z __GMP_PROTO ((mpf_ptr, mpz_srcptr)); -#define mpf_size __gmpf_size -__GMP_DECLSPEC size_t mpf_size __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpf_sqrt __gmpf_sqrt -__GMP_DECLSPEC void mpf_sqrt __GMP_PROTO ((mpf_ptr, mpf_srcptr)); -#define mpf_sqrt_ui __gmpf_sqrt_ui -__GMP_DECLSPEC void mpf_sqrt_ui __GMP_PROTO ((mpf_ptr, mpir_ui)); -#define mpf_sub __gmpf_sub -__GMP_DECLSPEC void mpf_sub __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr)); -#define mpf_sub_ui __gmpf_sub_ui -__GMP_DECLSPEC void mpf_sub_ui __GMP_PROTO ((mpf_ptr, mpf_srcptr, mpir_ui)); -#define mpf_swap __gmpf_swap -__GMP_DECLSPEC void mpf_swap __GMP_PROTO ((mpf_ptr, mpf_ptr)) __GMP_NOTHROW; -#define mpf_trunc __gmpf_trunc -__GMP_DECLSPEC void mpf_trunc __GMP_PROTO ((mpf_ptr, mpf_srcptr)); -#define mpf_ui_div __gmpf_ui_div -__GMP_DECLSPEC void mpf_ui_div __GMP_PROTO ((mpf_ptr, mpir_ui, mpf_srcptr)); -#define mpf_ui_sub __gmpf_ui_sub -__GMP_DECLSPEC void mpf_ui_sub __GMP_PROTO ((mpf_ptr, mpir_ui, mpf_srcptr)); -#define mpf_urandomb __gmpf_urandomb -__GMP_DECLSPEC void mpf_urandomb __GMP_PROTO ((mpf_t, gmp_randstate_t, mp_bitcnt_t)); -/************ Low level positive-integer (i.e. N) routines. ************/ -/* This is ugly, but we need to make user calls reach the prefixed function. */ -#define mpn_add __MPN(add) -#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_add) -__GMP_DECLSPEC mp_limb_t mpn_add __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr,mp_size_t)); -#endif -#define mpn_add_1 __MPN(add_1) -#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_add_1) -__GMP_DECLSPEC mp_limb_t mpn_add_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t)) __GMP_NOTHROW; -#endif -#define mpn_add_n __MPN(add_n) -__GMP_DECLSPEC mp_limb_t mpn_add_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t)); -#define mpn_addmul_1 __MPN(addmul_1) -__GMP_DECLSPEC mp_limb_t mpn_addmul_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t)); -#define mpn_bdivmod __MPN(bdivmod) -__GMP_DECLSPEC mp_limb_t mpn_bdivmod __GMP_PROTO ((mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mpir_ui)); -#define mpn_divrem __MPN(divrem) -__GMP_DECLSPEC mp_limb_t mpn_divrem __GMP_PROTO ((mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr, mp_size_t)); -#define mpn_mulmod_Bexpp1 __MPN(mulmod_Bexpp1) -__GMP_DECLSPEC int mpn_mulmod_Bexpp1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, mp_ptr)); -#define mpn_mulmod_2expp1 __MPN(mulmod_2expp1_basecase) -__GMP_DECLSPEC int mpn_mulmod_2expp1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr,int,mpir_ui, mp_ptr)); -#define mpn_mulmod_2expm1 __MPN(mulmod_2expm1) -__GMP_DECLSPEC void mpn_mulmod_2expm1 __GMP_PROTO ((mp_ptr, mp_ptr, mp_ptr, mpir_ui, mp_ptr)); -#define mpn_cmp __MPN(cmp) -#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_cmp) -__GMP_DECLSPEC int mpn_cmp __GMP_PROTO ((mp_srcptr, mp_srcptr, mp_size_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#endif -#define mpn_redc_1 __MPN(redc_1) -__GMP_DECLSPEC void mpn_redc_1 __GMP_PROTO ((mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);) -#define mpn_redc_2 __MPN(redc_2) -__GMP_DECLSPEC void mpn_redc_2 __GMP_PROTO ((mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_srcptr)); -#define mpn_redc_n __MPN(redc_n) -__GMP_DECLSPEC void mpn_redc_n __GMP_PROTO ((mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_srcptr)); -#define mpn_divexact_by3(dst,src,size) \ - mpn_divexact_by3c (dst, src, size, __GMP_CAST (mp_limb_t, 0)) -#define mpn_divexact_by3c __MPN(divexact_by3c) -__GMP_DECLSPEC mp_limb_t mpn_divexact_by3c __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t)); -#define mpn_divmod_1(qp,np,nsize,dlimb) \ - mpn_divrem_1 (qp, __GMP_CAST (mp_size_t, 0), np, nsize, dlimb) -#define mpn_divrem_1 __MPN(divrem_1) -__GMP_DECLSPEC mp_limb_t mpn_divrem_1 __GMP_PROTO ((mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t)); -#define mpn_divrem_2 __MPN(divrem_2) -__GMP_DECLSPEC mp_limb_t mpn_divrem_2 __GMP_PROTO ((mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr)); -#define mpn_invert __MPN(invert) -__GMP_DECLSPEC void mpn_invert __GMP_PROTO ((mp_ptr xp, mp_srcptr ap, mp_size_t n)); -#define mpn_sb_divappr_q __MPN(sb_divappr_q) -__GMP_DECLSPEC mp_limb_t mpn_sb_divappr_q __GMP_PROTO ((mp_ptr qp, mp_ptr np, mp_size_t nn, - mp_srcptr dp, mp_size_t dn, mp_limb_t dip, mp_limb_t d1ip)); -#define mpn_dc_bdiv_q_n __MPN(dc_bdiv_q_n) -__GMP_DECLSPEC void mpn_dc_bdiv_q_n __GMP_PROTO ((mp_ptr qp, mp_ptr wp, mp_ptr np, mp_srcptr dp, mp_size_t n, - mp_limb_t dinv, mp_ptr scratch)); -#define mpn_inv_divappr_q_n __MPN(inv_divappr_q_n) -__GMP_DECLSPEC mp_limb_t mpn_inv_divappr_q_n __GMP_PROTO ((mp_ptr qp, mp_ptr np, mp_srcptr dp, mp_size_t n, - mp_srcptr dip)); -#define mpn_dc_divappr_q __MPN(dc_divappr_q) -__GMP_DECLSPEC mp_limb_t mpn_dc_divappr_q __GMP_PROTO ((mp_ptr qp, mp_ptr np, mp_size_t nn, mp_srcptr dp, - mp_size_t n, mp_limb_t dinv, mp_limb_t d1inv)); -#define mpn_dc_div_q __MPN(dc_div_q) -__GMP_DECLSPEC mp_limb_t mpn_dc_div_q __GMP_PROTO ((mp_ptr qp, mp_ptr np, mp_size_t nn, - mp_srcptr dp, mp_size_t dn, mp_limb_t dinv, mp_limb_t d1inv)); -#define mpn_inv_divappr_q __MPN(inv_divappr_q) -__GMP_DECLSPEC mp_limb_t mpn_inv_divappr_q __GMP_PROTO ((mp_ptr qp, mp_ptr np, mp_size_t nn, mp_srcptr dp, mp_size_t n, - mp_srcptr dinv)); -#define mpn_inv_div_q __MPN(inv_div_q) -__GMP_DECLSPEC mp_limb_t mpn_inv_div_q __GMP_PROTO ((mp_ptr qp, mp_ptr np, mp_size_t nn, - mp_srcptr dp, mp_size_t dn, mp_srcptr dinv)); -#define mpn_inv_div_qr __MPN(inv_div_qr) -__GMP_DECLSPEC mp_limb_t mpn_inv_div_qr __GMP_PROTO ((mp_ptr qp, mp_ptr np, mp_size_t nn, - mp_srcptr dp, mp_size_t dn, mp_srcptr dinv)); -#define mpn_inv_div_qr_n __MPN(inv_div_qr_n) -__GMP_DECLSPEC mp_limb_t mpn_inv_div_qr_n __GMP_PROTO ((mp_ptr qp, mp_ptr np, - mp_srcptr dp, mp_size_t dn, mp_srcptr dinv)); -#define mpn_dc_div_qr __MPN(dc_div_qr) -__GMP_DECLSPEC mp_limb_t mpn_dc_div_qr __GMP_PROTO ((mp_ptr qp, mp_ptr np, mp_size_t nn, - mp_srcptr dp, mp_size_t dn, mp_limb_t dinv, mp_limb_t d1inv)); -#define mpn_dc_div_qr_n __MPN(dc_div_qr_n) -__GMP_DECLSPEC mp_limb_t mpn_dc_div_qr_n __GMP_PROTO ((mp_ptr qp, mp_ptr np, mp_srcptr dp, mp_size_t n, - mp_limb_t dinv, mp_limb_t d1inv, mp_ptr tp)); -#define mpn_sb_div_q __MPN(sb_div_q) -__GMP_DECLSPEC mp_limb_t mpn_sb_div_q __GMP_PROTO ((mp_ptr qp, mp_ptr np, mp_size_t nn, - mp_srcptr dp, mp_size_t dn, mp_limb_t dinv, mp_limb_t d1inv)); -#define mpn_sb_bdiv_q __MPN(sb_bdiv_q) -__GMP_DECLSPEC void mpn_sb_bdiv_q __GMP_PROTO ((mp_ptr qp, mp_ptr wp, mp_ptr np, mp_size_t nn, - mp_srcptr dp, mp_size_t dn, mp_limb_t dinv)); -#define mpn_dc_bdiv_q __MPN(dc_bdiv_q) -__GMP_DECLSPEC void mpn_dc_bdiv_q __GMP_PROTO ((mp_ptr qp, mp_ptr np, mp_size_t nn, - mp_srcptr dp, mp_size_t dn, mp_limb_t dinv)); -#define mpn_dc_bdiv_qr __MPN(dc_bdiv_qr) -__GMP_DECLSPEC mp_limb_t mpn_dc_bdiv_qr __GMP_PROTO ((mp_ptr qp, mp_ptr np, mp_size_t nn, - mp_srcptr dp, mp_size_t dn, mp_limb_t dinv)); -#define mpn_dc_bdiv_qr_n __MPN(dc_bdiv_qr_n) -__GMP_DECLSPEC mp_limb_t mpn_dc_bdiv_qr_n __GMP_PROTO ((mp_ptr qp, mp_ptr np, - mp_srcptr dp, mp_size_t n, mp_limb_t dinv, mp_ptr tp)); -#define mpn_sb_div_qr __MPN(sb_div_qr) -__GMP_DECLSPEC mp_limb_t mpn_sb_div_qr __GMP_PROTO ((mp_ptr qp, mp_ptr np, mp_size_t nn, - mp_srcptr dp, mp_size_t dn, mp_limb_t dinv, mp_limb_t d1inv)); -#define mpn_sb_bdiv_qr __MPN(sb_bdiv_qr) -__GMP_DECLSPEC mp_limb_t mpn_sb_bdiv_qr __GMP_PROTO ((mp_ptr qp, mp_ptr np, mp_size_t nn, - mp_srcptr dp, mp_size_t dn, mp_limb_t dinv)); -#define mpn_tdiv_q __MPN(tdiv_q) -__GMP_DECLSPEC void mpn_tdiv_q __GMP_PROTO ((mp_ptr qp, mp_srcptr np, mp_size_t nn, - mp_srcptr dp, mp_size_t dn)); -#define mpn_divexact __MPN(divexact) -__GMP_DECLSPEC void mpn_divexact __GMP_PROTO ((mp_ptr qp, - mp_srcptr np, mp_size_t nn, mp_srcptr dp, mp_size_t dn)); -#define mpn_gcd __MPN(gcd) -__GMP_DECLSPEC mp_size_t mpn_gcd __GMP_PROTO ((mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t)); -#define mpn_gcd_1 __MPN(gcd_1) -__GMP_DECLSPEC mp_limb_t mpn_gcd_1 __GMP_PROTO ((mp_srcptr, mp_size_t, mp_limb_t)) __GMP_ATTRIBUTE_PURE; -#define mpn_gcdext_1 __MPN(gcdext_1) -__GMP_DECLSPEC mp_limb_t mpn_gcdext_1 __GMP_PROTO ((mp_limb_signed_t *, mp_limb_signed_t *, mp_limb_t, mp_limb_t)); -#define mpn_gcdext __MPN(gcdext) -__GMP_DECLSPEC mp_size_t mpn_gcdext __GMP_PROTO ((mp_ptr, mp_ptr, mp_size_t *, mp_ptr, mp_size_t, mp_ptr, mp_size_t)); -#define mpn_get_str __MPN(get_str) -__GMP_DECLSPEC size_t mpn_get_str __GMP_PROTO ((unsigned char *, int, mp_ptr, mp_size_t)); -#define mpn_hamdist __MPN(hamdist) -__GMP_DECLSPEC mp_bitcnt_t mpn_hamdist __GMP_PROTO ((mp_srcptr, mp_srcptr, mp_size_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpn_lshift __MPN(lshift) -__GMP_DECLSPEC mp_limb_t mpn_lshift __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, unsigned int)); -#define mpn_mod_1 __MPN(mod_1) -__GMP_DECLSPEC mp_limb_t mpn_mod_1 __GMP_PROTO ((mp_srcptr, mp_size_t, mp_limb_t)) __GMP_ATTRIBUTE_PURE; -#define mpn_mul __MPN(mul) -__GMP_DECLSPEC mp_limb_t mpn_mul __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t)); -#define mpn_mul_1 __MPN(mul_1) -__GMP_DECLSPEC mp_limb_t mpn_mul_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t)); -#define mpn_mul_n __MPN(mul_n) -__GMP_DECLSPEC void mpn_mul_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t)); -#define mpn_sqr __MPN(sqr) -__GMP_DECLSPEC void mpn_sqr __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t)); -#define mpn_neg_n __MPN(neg_n) -#define mpn_neg __MPN(neg_n) -__GMP_DECLSPEC mp_limb_t mpn_neg_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t)); -#define mpn_com_n __MPN(com_n) -#define mpn_com __MPN(com_n) -__GMP_DECLSPEC void mpn_com_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t)); -#define mpn_perfect_square_p __MPN(perfect_square_p) -__GMP_DECLSPEC int mpn_perfect_square_p __GMP_PROTO ((mp_srcptr, mp_size_t)) __GMP_ATTRIBUTE_PURE; -#define mpn_popcount __MPN(popcount) -__GMP_DECLSPEC mp_bitcnt_t mpn_popcount __GMP_PROTO ((mp_srcptr, mp_size_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; -#define mpn_pow_1 __MPN(pow_1) -__GMP_DECLSPEC mp_size_t mpn_pow_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr)); -/* undocumented now, but retained here for upward compatibility */ -#define mpn_preinv_mod_1 __MPN(preinv_mod_1) -__GMP_DECLSPEC mp_limb_t mpn_preinv_mod_1 __GMP_PROTO ((mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t)) __GMP_ATTRIBUTE_PURE; -#define mpn_random __MPN(random) -__GMP_DECLSPEC void mpn_random __GMP_PROTO ((mp_ptr, mp_size_t)); -#define mpn_random2 __MPN(random2) -__GMP_DECLSPEC void mpn_random2 __GMP_PROTO ((mp_ptr, mp_size_t)); -#define mpn_urandomb __MPN(urandomb) -__GMP_DECLSPEC void mpn_urandomb __GMP_PROTO ((mp_ptr, gmp_randstate_t, mpir_ui)); -#define mpn_urandomm __MPN(urandomm) -__GMP_DECLSPEC void mpn_urandomm __GMP_PROTO ((mp_ptr, gmp_randstate_t, mp_srcptr, mp_size_t)); -#define mpn_randomb __MPN(randomb) -__GMP_DECLSPEC void mpn_randomb __GMP_PROTO ((mp_ptr, gmp_randstate_t, mp_size_t)); -#define mpn_rrandom __MPN(rrandom) -__GMP_DECLSPEC void mpn_rrandom __GMP_PROTO ((mp_ptr, gmp_randstate_t, mp_size_t)); -#define mpn_rshift __MPN(rshift) -__GMP_DECLSPEC mp_limb_t mpn_rshift __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, unsigned int)); -#define mpn_scan0 __MPN(scan0) -__GMP_DECLSPEC mp_bitcnt_t mpn_scan0 __GMP_PROTO ((mp_srcptr, mp_bitcnt_t)) __GMP_ATTRIBUTE_PURE; -#define mpn_scan1 __MPN(scan1) -__GMP_DECLSPEC mp_bitcnt_t mpn_scan1 __GMP_PROTO ((mp_srcptr, mp_bitcnt_t)) __GMP_ATTRIBUTE_PURE; -#define mpn_set_str __MPN(set_str) -__GMP_DECLSPEC mp_size_t mpn_set_str __GMP_PROTO ((mp_ptr, __gmp_const unsigned char *, size_t, int)); -#define mpn_sqrtrem __MPN(sqrtrem) -__GMP_DECLSPEC mp_size_t mpn_sqrtrem __GMP_PROTO ((mp_ptr, mp_ptr, mp_srcptr, mp_size_t)); -#define mpn_sub __MPN(sub) -#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_sub) -__GMP_DECLSPEC mp_limb_t mpn_sub __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr,mp_size_t)); -#endif -#define mpn_sub_1 __MPN(sub_1) -#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_sub_1) -__GMP_DECLSPEC mp_limb_t mpn_sub_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t)) __GMP_NOTHROW; -#endif -#define mpn_sub_n __MPN(sub_n) -__GMP_DECLSPEC mp_limb_t mpn_sub_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t)); -#define mpn_submul_1 __MPN(submul_1) -__GMP_DECLSPEC mp_limb_t mpn_submul_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t)); -#define mpn_tdiv_qr __MPN(tdiv_qr) -__GMP_DECLSPEC void mpn_tdiv_qr __GMP_PROTO ((mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t)); -#define mpn_and_n __MPN(and_n) -__GMP_DECLSPEC void mpn_and_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t)); -#define mpn_andn_n __MPN(andn_n) -__GMP_DECLSPEC void mpn_andn_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t)); -#define mpn_nand_n __MPN(nand_n) -__GMP_DECLSPEC void mpn_nand_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t)); -#define mpn_ior_n __MPN(ior_n) -__GMP_DECLSPEC void mpn_ior_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t)); -#define mpn_iorn_n __MPN(iorn_n) -__GMP_DECLSPEC void mpn_iorn_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t)); -#define mpn_nior_n __MPN(nior_n) -__GMP_DECLSPEC void mpn_nior_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t)); -#define mpn_xor_n __MPN(xor_n) -__GMP_DECLSPEC void mpn_xor_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t)); -#define mpn_xnor_n __MPN(xnor_n) -__GMP_DECLSPEC void mpn_xnor_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t)); -#define mpn_copyi __MPN(copyi) -__GMP_DECLSPEC void mpn_copyi __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t)); -#define mpn_copyd __MPN(copyd) -__GMP_DECLSPEC void mpn_copyd __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t)); -#define mpn_zero __MPN(zero) -__GMP_DECLSPEC void mpn_zero __GMP_PROTO ((mp_ptr, mp_size_t)); -#ifndef mpn_sumdiff_n /* if not done with cpuvec in a fat binary of in gmp-impl.h*/ -#define mpn_sumdiff_n __MPN(sumdiff_n) -__GMP_DECLSPEC mp_limb_t mpn_sumdiff_n __GMP_PROTO ((mp_ptr, mp_ptr, mp_srcptr, mp_srcptr, mp_size_t)); -#endif -/**************** MPN API for FFT ****************/ -#define mpn_mul_fft_main __MPN(mul_fft_main) -__GMP_DECLSPEC void mpn_mul_fft_main __GMP_PROTO ((mp_ptr r1, mp_srcptr i1, mp_size_t n1, mp_srcptr i2, mp_size_t n2)); -#define mpn_mul_fft __MPN(mul_fft) -__GMP_DECLSPEC int mpn_mul_fft __GMP_PROTO((mp_ptr rp, mp_size_t rn, mp_srcptr ap, mp_size_t an, mp_srcptr bp, mp_size_t bn, int k)); -/**************** mpz inlines ****************/ -/* The following are provided as inlines where possible, but always exist as - library functions too, for binary compatibility. - Within gmp itself this inlining generally isn't relied on, since it - doesn't get done for all compilers, whereas if something is worth - inlining then it's worth arranging always. - There are two styles of inlining here. When the same bit of code is - wanted for the inline as for the library version, then __GMP_FORCE_foo - arranges for that code to be emitted and the __GMP_EXTERN_INLINE - directive suppressed, eg. mpz_fits_uint_p. When a different bit of code - is wanted for the inline than for the library version, then - __GMP_FORCE_foo arranges the inline to be suppressed, eg. mpz_abs. */ -#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpz_abs) -__GMP_EXTERN_INLINE void -mpz_abs (mpz_ptr __gmp_w, mpz_srcptr __gmp_u) -{ - if (__gmp_w != __gmp_u) - mpz_set (__gmp_w, __gmp_u); - __gmp_w->_mp_size = __GMP_ABS (__gmp_w->_mp_size); -} -#endif -#if GMP_NAIL_BITS == 0 -#define __GMPZ_FITS_UTYPE_P(z,maxval) \ - mp_size_t __gmp_n = z->_mp_size; \ - mp_ptr __gmp_p = z->_mp_d; \ - return (__gmp_n == 0 || (__gmp_n == 1 && __gmp_p[0] <= maxval)); -#else -#define __GMPZ_FITS_UTYPE_P(z,maxval) \ - mp_size_t __gmp_n = z->_mp_size; \ - mp_ptr __gmp_p = z->_mp_d; \ - return (__gmp_n == 0 || (__gmp_n == 1 && __gmp_p[0] <= maxval) \ - || (__gmp_n == 2 && __gmp_p[1] <= ((mp_limb_t) maxval >> GMP_NUMB_BITS))); -#endif -#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_uint_p) -#if ! defined (__GMP_FORCE_mpz_fits_uint_p) -__GMP_EXTERN_INLINE -#endif -int -mpz_fits_uint_p (mpz_srcptr __gmp_z) __GMP_NOTHROW -{ - __GMPZ_FITS_UTYPE_P (__gmp_z, __GMP_UINT_MAX); -} -#endif -#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_ui_p) -#if ! defined (__GMP_FORCE_mpz_fits_ui_p) -__GMP_EXTERN_INLINE -#endif -int -mpz_fits_ui_p (mpz_srcptr __gmp_z) __GMP_NOTHROW -{ - __GMPZ_FITS_UTYPE_P (__gmp_z, GMP_UI_MAX); -} -#endif -#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_ulong_p) -#if ! defined (__GMP_FORCE_mpz_fits_ulong_p) -__GMP_EXTERN_INLINE -#endif -int -mpz_fits_ulong_p (mpz_srcptr __gmp_z) __GMP_NOTHROW -{ - __GMPZ_FITS_UTYPE_P (__gmp_z, __GMP_ULONG_MAX); -} -#endif -#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_ushort_p) -#if ! defined (__GMP_FORCE_mpz_fits_ushort_p) -__GMP_EXTERN_INLINE -#endif -int -mpz_fits_ushort_p (mpz_srcptr __gmp_z) __GMP_NOTHROW -{ - __GMPZ_FITS_UTYPE_P (__gmp_z, __GMP_USHRT_MAX); -} -#endif -#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_get_ui) -#if ! defined (__GMP_FORCE_mpz_get_ui) -__GMP_EXTERN_INLINE -#endif -mpir_ui -mpz_get_ui (mpz_srcptr __gmp_z) __GMP_NOTHROW -{ - mp_ptr __gmp_p = __gmp_z->_mp_d; - mp_size_t __gmp_n = __gmp_z->_mp_size; - mp_limb_t __gmp_l = __gmp_p[0]; - /* This is a "#if" rather than a plain "if" so as to avoid gcc warnings - about "<< GMP_NUMB_BITS" exceeding the type size, and to avoid Borland - C++ 6.0 warnings about condition always true for something like - "__GMP_ULONG_MAX < GMP_NUMB_MASK". */ -#if GMP_NAIL_BITS == 0 || defined (_LONG_LONG_LIMB) - /* limb==long and no nails, or limb==longlong, one limb is enough */ - return (mpir_ui)(__gmp_n != 0 ? __gmp_l : 0); -#else - /* limb==long and nails, need two limbs when available */ - __gmp_n = __GMP_ABS (__gmp_n); - if (__gmp_n <= 1) - return (mpir_ui)(__gmp_n != 0 ? __gmp_l : 0); - else - return (mpir_ui)(__gmp_l + (__gmp_p[1] << GMP_NUMB_BITS)); -#endif -} -#endif -#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_getlimbn) -#if ! defined (__GMP_FORCE_mpz_getlimbn) -__GMP_EXTERN_INLINE -#endif -mp_limb_t -mpz_getlimbn (mpz_srcptr __gmp_z, mp_size_t __gmp_n) __GMP_NOTHROW -{ - mp_limb_t __gmp_result = 0; - if (__GMP_LIKELY (__gmp_n >= 0 && __gmp_n < __GMP_ABS (__gmp_z->_mp_size))) - __gmp_result = __gmp_z->_mp_d[__gmp_n]; - return __gmp_result; -} -#endif -#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpz_neg) -__GMP_EXTERN_INLINE void -mpz_neg (mpz_ptr __gmp_w, mpz_srcptr __gmp_u) -{ - if (__gmp_w != __gmp_u) - mpz_set (__gmp_w, __gmp_u); - __gmp_w->_mp_size = - __gmp_w->_mp_size; -} -#endif -#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_perfect_square_p) -#if ! defined (__GMP_FORCE_mpz_perfect_square_p) -__GMP_EXTERN_INLINE -#endif -int -mpz_perfect_square_p (mpz_srcptr __gmp_a) -{ - mp_size_t __gmp_asize; - int __gmp_result; - __gmp_asize = __gmp_a->_mp_size; - __gmp_result = (__gmp_asize >= 0); /* zero is a square, negatives are not */ - if (__GMP_LIKELY (__gmp_asize > 0)) - __gmp_result = mpn_perfect_square_p (__gmp_a->_mp_d, __gmp_asize); - return __gmp_result; -} -#endif -#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_popcount) -#if ! defined (__GMP_FORCE_mpz_popcount) -__GMP_EXTERN_INLINE -#endif -mp_bitcnt_t -mpz_popcount (mpz_srcptr __gmp_u) __GMP_NOTHROW -{ - mp_size_t __gmp_usize; - mp_bitcnt_t __gmp_result; - __gmp_usize = __gmp_u->_mp_size; - __gmp_result = (__gmp_usize < 0 ? __GMP_BITCNT_MAX : 0); - if (__GMP_LIKELY (__gmp_usize > 0)) - __gmp_result = mpn_popcount (__gmp_u->_mp_d, __gmp_usize); - return __gmp_result; -} -#endif -#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_set_q) -#if ! defined (__GMP_FORCE_mpz_set_q) -__GMP_EXTERN_INLINE -#endif -void -mpz_set_q (mpz_ptr __gmp_w, mpq_srcptr __gmp_u) -{ - mpz_tdiv_q (__gmp_w, mpq_numref (__gmp_u), mpq_denref (__gmp_u)); -} -#endif -#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_size) -#if ! defined (__GMP_FORCE_mpz_size) -__GMP_EXTERN_INLINE -#endif -size_t -mpz_size (mpz_srcptr __gmp_z) __GMP_NOTHROW -{ - return __GMP_ABS (__gmp_z->_mp_size); -} -#endif -/**************** mpq inlines ****************/ -#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpq_abs) -__GMP_EXTERN_INLINE void -mpq_abs (mpq_ptr __gmp_w, mpq_srcptr __gmp_u) -{ - if (__gmp_w != __gmp_u) - mpq_set (__gmp_w, __gmp_u); - __gmp_w->_mp_num._mp_size = __GMP_ABS (__gmp_w->_mp_num._mp_size); -} -#endif -#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpq_neg) -__GMP_EXTERN_INLINE void -mpq_neg (mpq_ptr __gmp_w, mpq_srcptr __gmp_u) -{ - if (__gmp_w != __gmp_u) - mpq_set (__gmp_w, __gmp_u); - __gmp_w->_mp_num._mp_size = - __gmp_w->_mp_num._mp_size; -} -#endif -/**************** mpn inlines ****************/ -/* The comments with __GMPN_ADD_1 below apply here too. - The test for FUNCTION returning 0 should predict well. If it's assumed - {yp,ysize} will usually have a random number of bits then the high limb - won't be full and a carry out will occur a good deal less than 50% of the - time. - ysize==0 isn't a documented feature, but is used internally in a few - places. - Producing cout last stops it using up a register during the main part of - the calculation, though gcc (as of 3.0) on an "if (mpn_add (...))" - doesn't seem able to move the true and false legs of the conditional up - to the two places cout is generated. */ -#define __GMPN_AORS(cout, wp, xp, xsize, yp, ysize, FUNCTION, TEST) \ - do { \ - mp_size_t __gmp_i; \ - mp_limb_t __gmp_x; \ - \ - /* ASSERT ((ysize) >= 0); */ \ - /* ASSERT ((xsize) >= (ysize)); */ \ - /* ASSERT (MPN_SAME_OR_SEPARATE2_P (wp, xsize, xp, xsize)); */ \ - /* ASSERT (MPN_SAME_OR_SEPARATE2_P (wp, xsize, yp, ysize)); */ \ - \ - __gmp_i = (ysize); \ - if (__gmp_i != 0) \ - { \ - if (FUNCTION (wp, xp, yp, __gmp_i)) \ - { \ - do \ - { \ - if (__gmp_i >= (xsize)) \ - { \ - (cout) = 1; \ - goto __gmp_done; \ - } \ - __gmp_x = (xp)[__gmp_i]; \ - } \ - while (TEST); \ - } \ - } \ - if ((wp) != (xp)) \ - __GMPN_COPY_REST (wp, xp, xsize, __gmp_i); \ - (cout) = 0; \ - __gmp_done: \ - ; \ - } while (0) -#define __GMPN_ADD(cout, wp, xp, xsize, yp, ysize) \ - __GMPN_AORS (cout, wp, xp, xsize, yp, ysize, mpn_add_n, \ - (((wp)[__gmp_i++] = (__gmp_x + 1) & GMP_NUMB_MASK) == 0)) -#define __GMPN_SUB(cout, wp, xp, xsize, yp, ysize) \ - __GMPN_AORS (cout, wp, xp, xsize, yp, ysize, mpn_sub_n, \ - (((wp)[__gmp_i++] = (__gmp_x - 1) & GMP_NUMB_MASK), __gmp_x == 0)) -/* The use of __gmp_i indexing is designed to ensure a compile time src==dst - remains nice and clear to the compiler, so that __GMPN_COPY_REST can - disappear, and the load/add/store gets a chance to become a - read-modify-write on CISC CPUs. - Alternatives: - Using a pair of pointers instead of indexing would be possible, but gcc - isn't able to recognise compile-time src==dst in that case, even when the - pointers are incremented more or less together. Other compilers would - very likely have similar difficulty. - gcc could use "if (__builtin_constant_p(src==dst) && src==dst)" or - similar to detect a compile-time src==dst. This works nicely on gcc - 2.95.x, it's not good on gcc 3.0 where __builtin_constant_p(p==p) seems - to be always false, for a pointer p. But the current code form seems - good enough for src==dst anyway. - gcc on x86 as usual doesn't give particularly good flags handling for the - carry/borrow detection. It's tempting to want some multi instruction asm - blocks to help it, and this was tried, but in truth there's only a few - instructions to save and any gain is all too easily lost by register - juggling setting up for the asm. */ -#if GMP_NAIL_BITS == 0 -#define __GMPN_AORS_1(cout, dst, src, n, v, OP, CB) \ - do { \ - mp_size_t __gmp_i; \ - mp_limb_t __gmp_x, __gmp_r; \ - \ - /* ASSERT ((n) >= 1); */ \ - /* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, n)); */ \ - \ - __gmp_x = (src)[0]; \ - __gmp_r = __gmp_x OP (v); \ - (dst)[0] = __gmp_r; \ - if (CB (__gmp_r, __gmp_x, (v))) \ - { \ - (cout) = 1; \ - for (__gmp_i = 1; __gmp_i < (n);) \ - { \ - __gmp_x = (src)[__gmp_i]; \ - __gmp_r = __gmp_x OP 1; \ - (dst)[__gmp_i] = __gmp_r; \ - ++__gmp_i; \ - if (!CB (__gmp_r, __gmp_x, 1)) \ - { \ - if ((src) != (dst)) \ - __GMPN_COPY_REST (dst, src, n, __gmp_i); \ - (cout) = 0; \ - break; \ - } \ - } \ - } \ - else \ - { \ - if ((src) != (dst)) \ - __GMPN_COPY_REST (dst, src, n, 1); \ - (cout) = 0; \ - } \ - } while (0) -#endif -#if GMP_NAIL_BITS >= 1 -#define __GMPN_AORS_1(cout, dst, src, n, v, OP, CB) \ - do { \ - mp_size_t __gmp_i; \ - mp_limb_t __gmp_x, __gmp_r; \ - \ - /* ASSERT ((n) >= 1); */ \ - /* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, n)); */ \ - \ - __gmp_x = (src)[0]; \ - __gmp_r = __gmp_x OP (v); \ - (dst)[0] = __gmp_r & GMP_NUMB_MASK; \ - if (__gmp_r >> GMP_NUMB_BITS != 0) \ - { \ - (cout) = 1; \ - for (__gmp_i = 1; __gmp_i < (n);) \ - { \ - __gmp_x = (src)[__gmp_i]; \ - __gmp_r = __gmp_x OP 1; \ - (dst)[__gmp_i] = __gmp_r & GMP_NUMB_MASK; \ - ++__gmp_i; \ - if (__gmp_r >> GMP_NUMB_BITS == 0) \ - { \ - if ((src) != (dst)) \ - __GMPN_COPY_REST (dst, src, n, __gmp_i); \ - (cout) = 0; \ - break; \ - } \ - } \ - } \ - else \ - { \ - if ((src) != (dst)) \ - __GMPN_COPY_REST (dst, src, n, 1); \ - (cout) = 0; \ - } \ - } while (0) -#endif -#define __GMPN_ADDCB(r,x,y) ((r) < (y)) -#define __GMPN_SUBCB(r,x,y) ((x) < (y)) -#define __GMPN_ADD_1(cout, dst, src, n, v) \ - __GMPN_AORS_1(cout, dst, src, n, v, +, __GMPN_ADDCB) -#define __GMPN_SUB_1(cout, dst, src, n, v) \ - __GMPN_AORS_1(cout, dst, src, n, v, -, __GMPN_SUBCB) -/* Compare {xp,size} and {yp,size}, setting "result" to positive, zero or - negative. size==0 is allowed. On random data usually only one limb will - need to be examined to get a result, so it's worth having it inline. */ -#define __GMPN_CMP(result, xp, yp, size) \ - do { \ - mp_size_t __gmp_i; \ - mp_limb_t __gmp_x, __gmp_y; \ - \ - /* ASSERT ((size) >= 0); */ \ - \ - (result) = 0; \ - __gmp_i = (size); \ - while (--__gmp_i >= 0) \ - { \ - __gmp_x = (xp)[__gmp_i]; \ - __gmp_y = (yp)[__gmp_i]; \ - if (__gmp_x != __gmp_y) \ - { \ - /* Cannot use __gmp_x - __gmp_y, may overflow an "int" */ \ - (result) = (__gmp_x > __gmp_y ? 1 : -1); \ - break; \ - } \ - } \ - } while (0) -#if defined (__GMPN_COPY) && ! defined (__GMPN_COPY_REST) -#define __GMPN_COPY_REST(dst, src, size, start) \ - do { \ - /* ASSERT ((start) >= 0); */ \ - /* ASSERT ((start) <= (size)); */ \ - __GMPN_COPY ((dst)+(start), (src)+(start), (size)-(start)); \ - } while (0) -#endif -/* Copy {src,size} to {dst,size}, starting at "start". This is designed to - keep the indexing dst[j] and src[j] nice and simple for __GMPN_ADD_1, - __GMPN_ADD, etc. */ -#if ! defined (__GMPN_COPY_REST) -#define __GMPN_COPY_REST(dst, src, size, start) \ - do { \ - mp_size_t __gmp_j; \ - /* ASSERT ((size) >= 0); */ \ - /* ASSERT ((start) >= 0); */ \ - /* ASSERT ((start) <= (size)); */ \ - /* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, size)); */ \ - for (__gmp_j = (start); __gmp_j < (size); __gmp_j++) \ - (dst)[__gmp_j] = (src)[__gmp_j]; \ - } while (0) -#endif -/* Enhancement: Use some of the smarter code from gmp-impl.h. Maybe use - mpn_copyi if there's a native version, and if we don't mind demanding - binary compatibility for it (on targets which use it). */ -#if ! defined (__GMPN_COPY) -#define __GMPN_COPY(dst, src, size) __GMPN_COPY_REST (dst, src, size, 0) -#endif -#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_add) -#if ! defined (__GMP_FORCE_mpn_add) -__GMP_EXTERN_INLINE -#endif -mp_limb_t -mpn_add (mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize) -{ - mp_limb_t __gmp_c; - __GMPN_ADD (__gmp_c, __gmp_wp, __gmp_xp, __gmp_xsize, __gmp_yp, __gmp_ysize); - return __gmp_c; -} -#endif -#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_add_1) -#if ! defined (__GMP_FORCE_mpn_add_1) -__GMP_EXTERN_INLINE -#endif -mp_limb_t -mpn_add_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) __GMP_NOTHROW -{ - mp_limb_t __gmp_c; - __GMPN_ADD_1 (__gmp_c, __gmp_dst, __gmp_src, __gmp_size, __gmp_n); - return __gmp_c; -} -#endif -#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_cmp) -#if ! defined (__GMP_FORCE_mpn_cmp) -__GMP_EXTERN_INLINE -#endif -int -mpn_cmp (mp_srcptr __gmp_xp, mp_srcptr __gmp_yp, mp_size_t __gmp_size) __GMP_NOTHROW -{ - int __gmp_result; - __GMPN_CMP (__gmp_result, __gmp_xp, __gmp_yp, __gmp_size); - return __gmp_result; -} -#endif -#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_sub) -#if ! defined (__GMP_FORCE_mpn_sub) -__GMP_EXTERN_INLINE -#endif -mp_limb_t -mpn_sub (mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize) -{ - mp_limb_t __gmp_c; - __GMPN_SUB (__gmp_c, __gmp_wp, __gmp_xp, __gmp_xsize, __gmp_yp, __gmp_ysize); - return __gmp_c; -} -#endif -#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_sub_1) -#if ! defined (__GMP_FORCE_mpn_sub_1) -__GMP_EXTERN_INLINE -#endif -mp_limb_t -mpn_sub_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) __GMP_NOTHROW -{ - mp_limb_t __gmp_c; - __GMPN_SUB_1 (__gmp_c, __gmp_dst, __gmp_src, __gmp_size, __gmp_n); - return __gmp_c; -} -#endif -#if defined (__cplusplus) -} -#endif -/* Allow faster testing for negative, zero, and positive. */ -#define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0) -#define mpf_sgn(F) ((F)->_mp_size < 0 ? -1 : (F)->_mp_size > 0) -#define mpq_sgn(Q) ((Q)->_mp_num._mp_size < 0 ? -1 : (Q)->_mp_num._mp_size > 0) -/* When using GCC, optimize certain common comparisons. */ -#if defined (__GNUC__) -#define mpz_cmp_ui(Z,UI) \ - (__builtin_constant_p (UI) && (UI) == 0 \ - ? mpz_sgn (Z) : _mpz_cmp_ui (Z,UI)) -#define mpz_cmp_si(Z,SI) \ - (__builtin_constant_p (SI) && (SI) == 0 ? mpz_sgn (Z) \ - : __builtin_constant_p (SI) && (SI) > 0 \ - ? _mpz_cmp_ui (Z, __GMP_CAST (unsigned long int, SI)) \ - : _mpz_cmp_si (Z,SI)) -#define mpq_cmp_ui(Q,NUI,DUI) \ - (__builtin_constant_p (NUI) && (NUI) == 0 \ - ? mpq_sgn (Q) : _mpq_cmp_ui (Q,NUI,DUI)) -#define mpq_cmp_si(q,n,d) \ - (__builtin_constant_p ((n) >= 0) && (n) >= 0 \ - ? mpq_cmp_ui (q, __GMP_CAST (unsigned long, n), d) \ - : _mpq_cmp_si (q, n, d)) -#else -#define mpz_cmp_ui(Z,UI) _mpz_cmp_ui (Z,UI) -#define mpz_cmp_si(Z,UI) _mpz_cmp_si (Z,UI) -#define mpq_cmp_ui(Q,NUI,DUI) _mpq_cmp_ui (Q,NUI,DUI) -#define mpq_cmp_si(q,n,d) _mpq_cmp_si(q,n,d) -#endif -/* Using "&" rather than "&&" means these can come out branch-free. Every - mpz_t has at least one limb allocated, so fetching the low limb is always - allowed. */ -#define mpz_odd_p(z) (((z)->_mp_size != 0) & __GMP_CAST (int, (z)->_mp_d[0])) -#define mpz_even_p(z) (! mpz_odd_p (z)) -/**************** C++ routines ****************/ -#ifdef __cplusplus -__GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpz_srcptr); -__GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpq_srcptr); -__GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpf_srcptr); -__GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpz_ptr); -__GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpq_ptr); -__GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpf_ptr); -#endif -/* Source-level compatibility with GMP 1. */ -#define mpz_mdiv mpz_fdiv_q -#define mpz_mdivmod mpz_fdiv_qr -#define mpz_mmod mpz_fdiv_r -#define mpz_mdiv_ui mpz_fdiv_q_ui -#define mpz_mdivmod_ui(q,r,n,d) \ - (((r) == 0) ? mpz_fdiv_q_ui (q,n,d) : mpz_fdiv_qr_ui (q,r,n,d)) -#define mpz_mmod_ui(r,n,d) \ - (((r) == 0) ? mpz_fdiv_ui (n,d) : mpz_fdiv_r_ui (r,n,d)) -#define gmp_randinit(x,y,z) gmp_randinit_lc_2exp_size(x,z) -typedef __mpz_struct MP_INT; /* gmp 1 source compatibility */ -typedef __mpq_struct MP_RAT; /* gmp 1 source compatibility */ -#define mpz_div mpz_fdiv_q -#define mpz_divmod mpz_fdiv_qr -#define mpz_div_ui mpz_fdiv_q_ui -#define mpz_divmod_ui mpz_fdiv_qr_ui -#define mpz_div_2exp mpz_fdiv_q_2exp -#define mpz_mod_2exp mpz_fdiv_r_2exp -enum -{ - GMP_ERROR_NONE = 0, - GMP_ERROR_UNSUPPORTED_ARGUMENT = 1, - GMP_ERROR_DIVISION_BY_ZERO = 2, - GMP_ERROR_SQRT_OF_NEGATIVE = 4, - GMP_ERROR_INVALID_ARGUMENT = 8 -}; -/* Major version number is the value of __GNU_MP__ too, above and in mp.h. */ -#define __GNU_MP_VERSION 5 -#define __GNU_MP_VERSION_MINOR 1 -#define __GNU_MP_VERSION_PATCHLEVEL 3 -#define GMP_VERSION "5.1.3" -#define __GNU_MP_RELEASE (__GNU_MP_VERSION * 10000 + __GNU_MP_VERSION_MINOR * 100 + __GNU_MP_VERSION_PATCHLEVEL) -#define __MPIR_VERSION 2 -#define __MPIR_VERSION_MINOR 7 -#define __MPIR_VERSION_PATCHLEVEL 0 -#if defined( _MSC_VER ) -#define _MSC_MPIR_VERSION "2.7.0" -#endif -#define __MPIR_RELEASE (__MPIR_VERSION * 10000 + __MPIR_VERSION_MINOR * 100 + __MPIR_VERSION_PATCHLEVEL) -/* These are for programs like MPFR to use the same CC and CFLAGS as MPIR */ -#if ! defined (__GMP_WITHIN_CONFIGURE) -#endif -#define __GMP_H__ -#endif /* __GMP_H__ */ diff --git a/configure.ac b/configure.ac index 50bb40e..abac203 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([cpuminer-multi], [1.2-dev]) +AC_INIT([cpuminer-opt], [4.3.8-dev) AC_PREREQ([2.59c]) AC_CANONICAL_SYSTEM diff --git a/cpu-miner.c b/cpu-miner.c index 0f7e8b3..f055c25 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -1623,7 +1623,6 @@ static void *miner_thread( void *userdata ) struct timeval tv_start, tv_end, diff; int64_t max64; int nonce_found = 0; - if ( algo_gate.do_this_thread( thr_id ) ) { if (have_stratum) @@ -2051,8 +2050,7 @@ out: return ret; } -void std_stratum_get_g_work( struct stratum_ctx *sctx, struct work *g_work, - int thr_id ) +void std_stratum_gen_work( struct stratum_ctx *sctx, struct work *g_work ) { unsigned char merkle_root[64] = { 0 }; int i; @@ -2092,10 +2090,22 @@ void std_stratum_get_g_work( struct stratum_ctx *sctx, struct work *g_work, } /* set target */ algo_gate.set_target( g_work, sctx->job.diff ); + + if ( stratum_diff != sctx->job.diff ) + { + char sdiff[32] = { 0 }; + // store for api stats + stratum_diff = sctx->job.diff; + if ( opt_showdiff && g_work->targetdiff != stratum_diff ) + { + snprintf( sdiff, 32, " (%.5f)", g_work->targetdiff ); + applog( LOG_WARNING, "Stratum difficulty set to %g%s", stratum_diff, + sdiff ); + } + } } -void jr2_stratum_get_g_work( struct stratum_ctx *sctx, struct work *g_work, - int thr_id ) +void jr2_stratum_gen_work( struct stratum_ctx *sctx, struct work *g_work ) { pthread_mutex_lock( &sctx->work_lock ); work_free( g_work ); @@ -2103,24 +2113,6 @@ void jr2_stratum_get_g_work( struct stratum_ctx *sctx, struct work *g_work, pthread_mutex_unlock( &sctx->work_lock ); } -static void stratum_gen_work( struct stratum_ctx *sctx, struct work *g_work, - int thr_id ) -{ - algo_gate.stratum_get_g_work( sctx, g_work, thr_id ); - if ( stratum_diff != sctx->job.diff ) - { - char sdiff[32] = { 0 }; - // store for api stats - stratum_diff = sctx->job.diff; - if ( opt_showdiff && g_work->targetdiff != stratum_diff ) - { - snprintf( sdiff, 32, " (%.5f)", g_work->targetdiff ); - applog( LOG_WARNING, "Stratum difficulty set to %g%s", stratum_diff, - sdiff ); - } - } -} - static void *stratum_thread(void *userdata ) { struct thr_info *mythr = (struct thr_info *) userdata; @@ -2180,7 +2172,7 @@ static void *stratum_thread(void *userdata ) (!g_work_time || strcmp(stratum.job.job_id, g_work.job_id)) ) { pthread_mutex_lock(&g_work_lock); - stratum_gen_work(&stratum, &g_work, 0 ); + algo_gate.stratum_gen_work( &stratum, &g_work ); time(&g_work_time); pthread_mutex_unlock(&g_work_lock); diff --git a/algo/argon2/.dirstamp b/m4/placeholder-to-prevent-git-from-deleting-this-directory similarity index 100% rename from algo/argon2/.dirstamp rename to m4/placeholder-to-prevent-git-from-deleting-this-directory diff --git a/util.c b/util.c index 06eb131..a70abc6 100644 --- a/util.c +++ b/util.c @@ -1622,19 +1622,19 @@ bool rpc2_job_decode(const json_t *job, struct work *work) free(blob); jobj_binary(job, "target", &target, 4); - if(rpc2_target != target) { - double hashrate = 0.0; - pthread_mutex_lock(&stats_lock); - for (int i = 0; i < opt_n_threads; i++) - hashrate += thr_hashrates[i]; - pthread_mutex_unlock(&stats_lock); - double difficulty = (((double) 0xffffffff) / target); - if (!opt_quiet) { - // xmr pool diff can change a lot... - applog(LOG_WARNING, "Stratum difficulty set to %g", difficulty); - } - stratum_diff = difficulty; - rpc2_target = target; + if(rpc2_target != target) + { + double hashrate = 0.0; + pthread_mutex_lock(&stats_lock); + for (int i = 0; i < opt_n_threads; i++) + hashrate += thr_hashrates[i]; + pthread_mutex_unlock(&stats_lock); + double diff = trunc( ( ((double)0xffffffff) / target ) ); + if (!opt_quiet) + // xmr pool diff can change a lot... + applog(LOG_WARNING, "Stratum difficulty set to %g", diff); + stratum_diff = diff; + rpc2_target = target; } if (rpc2_job_id) free(rpc2_job_id);