In order to make the DLL version work, I had to make two simple changes (see attached files).
Popcnt.c needed a non-GMP call to compute bitcount. I only fixed it for 64 bits. Flint.h needs to have alloca defined as _alloca using a macro. I saw that there is a macro in config.h that does this, but for whatever reason (I did not bother to trace it) it had to be changed here also. Since native windows threads are not used, I also had to add a pthread library (trivial, of course to do it). See file: \flint-2.5.0\fmpz_mod_poly\compose_mod_brent_kung_vec_preinv_threaded.c From: Bill Hart [mailto:goodwillh...@googlemail.com] Sent: Saturday, August 8, 2015 3:01 AM To: mpir-devel <mpir-devel@googlegroups.com>; Dann Corbit <dcor...@connx.com> Subject: Re: [mpir-devel] [ANN] Flint 2.5 released Hi Dann, I have pushed a fix from Brian which hopefully rectifies the issue you noted. It would be very helpful if you could confirm that this resolves the issue you found. Bill. On 8 August 2015 at 06:22, Dann Corbit <dcor...@connx.com<mailto:dcor...@connx.com>> wrote: Won’t build on Windows. There is a problem with the Conway polynomial stuff. There is no file CPimport.h as required by the file \flint-2.5.0\qadic\ctx_init_conway.c and no script that I saw generates that file on Windows. There is a text file cpimport.txt, however. I guess that it is used to generate the file. int flint_conway_polynomials [] = { #if !defined( _MSC_VER) #include "../build/CPimport.h" #else //#include "CPimport.h" // THIS IS MISSING #endif 0 }; That is the only error that I have trying to build lib_flint, From: mpir-devel@googlegroups.com<mailto:mpir-devel@googlegroups.com> [mailto:mpir-devel@googlegroups.com<mailto:mpir-devel@googlegroups.com>] Sent: Friday, August 7, 2015 2:33 PM To: flint-devel <flint-de...@googlegroups.com<mailto:flint-de...@googlegroups.com>>; mpir-devel <mpir-devel@googlegroups.com<mailto:mpir-devel@googlegroups.com>>; sage-de...@googlegroups.com<mailto:sage-de...@googlegroups.com> Cc: han...@mathematik.uni-kl.de<mailto:han...@mathematik.uni-kl.de>; Motsak Oleksandr <mot...@gmail.com<mailto:mot...@gmail.com>>; Claus Fieker <fie...@mathematik.uni-kl.de<mailto:fie...@mathematik.uni-kl.de>>; Tommy Hofmann <thofm...@mathematik.uni-kl.de<mailto:thofm...@mathematik.uni-kl.de>> Subject: [mpir-devel] [ANN] Flint 2.5 released Hi all, We are very pleased to present Flint version 2.5.0. It can be downloaded from our website: http://http://flintlib.org/ FLINT is a C library for arithmetic in support of Number Theory, including polynomial arithmetic and linear algebra over Z, Z/nZ, Q, p-adics, q-adics, F_q, and univariate factorisation over those rings. It depends on GMP or MPIR and MPFR. New features/improvements in this release include: * LLL (rational, Nguyen-Stehle, from Gram matrix, with_removal, Storjohann/ULLL) [1] * Hermite normal form (naive, xgcd, Domich-Kannan-Trotter, Kannan-Bachem, Pernet-Stein) [1] * Smith normal form (diagonal, Kannen-Bachem, Iliopoulos) [1] * Paterson-Stockmeyer algorithm * modular resultant * half gcd style resultant * polynomial discriminant * multithreaded multimodular Taylor shift * multithreaded Brent-Kung composition * multithreaded Kaltofen-Shoup distinct degree factorisation * multiplication based reduced row echelon form * inline functions included in library for use by foreign function interfaces * Primality tests for large integers (Pocklington, Morrison) * Probable prime tests for large integers (Lucas, Baillie-PSW, strong-psp, Brillhart-Lehmer-Selfridge) * CRT for large integers * Dixon algorithm for nullspace [1] * Brent-Kung composition in irreducibility and distinct degree factorisation * floating point QR decomposition * Schwarz-Rutishauser Gram-Schmidt algorithm * Ogita-Rump-Oishi dot product * matrix window functions * MSVC support (Brian Gladman) * fast cube/nth-root (Newton, Kahan, magic number, Chebyshev) * Bodrato matrix squaring * matrix concatenation functions * matrix content * faster n_gcd * faster n_sqrtmod and fmpz_sqrtmod * additional functions for returning factor of modulus in polys over Z/nZ * Hadamard matrix construction * series addition/subtraction * faster prime_pi bounds * speedup creation of sparse polynomials * speedup n_isprime and n_nextprime * speedup n_isprime_pocklington * speedups to fmpq_poly and fmpz_poly arithmetic * speedup polynomial irreducibility testing over Z/pZ * speedup of rank computation over ZZ * made CPimport compile time dependency only * teach flint_printf/sprintf about explicit width format specifiers * support relative paths in configure * library soname versioning * ARM64 patches * Support MSYS2 * Progress towards supporting MIPS64 * Many build system improvements * Fix a serious bug in fmpz_poly_signature Contributors to this release include: Abinhav Baid, Alex Best, Fredrik Johansson, William Hart, Brian Gladman, Jean-Pierre Flori, Martin Lee, Curtis Bright, Daniel Fabian, Julian Ospald, Dan Grayson, Dana Jacobsen, Vladimir Glazachev, Kushagra Singh, Ashish Kedia, Anubhav Srivistava, Prabhdeep Singh, Alena Sergeicheva, Sebastian Pancratz, mgkurtz, Tommy Hofmann, Daniel Roche, Max Goldfar, Andreas Enge, Francois Bissey, Denis Kryskov, Anton Mellit, and numerous others. [1] Thanks to Google for funding students through its Google Summer of Code. Abinhav Baid and Alex Best contributed to Flint through this program. Best wishes, The Flint Development Team. -- You received this message because you are subscribed to the Google Groups "mpir-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to mpir-devel+unsubscr...@googlegroups.com<mailto:mpir-devel+unsubscr...@googlegroups.com>. To post to this group, send email to mpir-devel@googlegroups.com<mailto:mpir-devel@googlegroups.com>. Visit this group at http://groups.google.com/group/mpir-devel. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "mpir-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to mpir-devel+unsubscr...@googlegroups.com<mailto:mpir-devel+unsubscr...@googlegroups.com>. To post to this group, send email to mpir-devel@googlegroups.com<mailto:mpir-devel@googlegroups.com>. Visit this group at http://groups.google.com/group/mpir-devel. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "mpir-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to mpir-devel+unsubscr...@googlegroups.com. To post to this group, send email to mpir-devel@googlegroups.com. Visit this group at http://groups.google.com/group/mpir-devel. For more options, visit https://groups.google.com/d/optout.
#include <gmp.h> #include "flint.h" #include "ulong_extras.h" #include "fmpz.h" #ifdef _MSC_VER #include <intrin.h> #endif #ifdef POPCNT_INTRINSICS static __inline__ mp_bitcnt_t shortCount(slong val) { #if defined(_WIN64) || defined(__mips64) #ifdef _MSC_VER return (mp_bitcnt_t) __popcnt64(val); #else return __builtin_popcountll(val); #endif #else return __builtin_popcountl(val); #endif } #else /* A naive implementation if neither your processor nor your compiler want to * do the work. */ static __inline__ mp_bitcnt_t shortCount(slong val) { mp_bitcnt_t cnt; for(cnt=0; val; val >>= 1) { cnt += val & 1; } return cnt; } #endif mp_bitcnt_t fmpz_popcnt(const fmpz_t c) { fmpz c1; c1 = *c; if(!COEFF_IS_MPZ(c1)) { if(*c < 0) return 0; else return shortCount(*c); } else { __mpz_struct *t = COEFF_TO_PTR(c1); if(flint_mpz_cmp_si(t,0) < 0) return 0; else return mpz_popcount(t); } }
/*============================================================================= This file is part of FLINT. FLINT is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. FLINT 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 General Public License for more details. You should have received a copy of the GNU General Public License along with FLINT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =============================================================================*/ /****************************************************************************** Copyright (C) 2009 William Hart ******************************************************************************/ #ifndef FLINT_H #define FLINT_H #undef ulong #define ulong ulongxx /* ensure vendor doesn't typedef ulong */ #if !defined(_MSC_VER) #include <sys/param.h> /* for BSD define */ #else #define alloca _alloca #endif #include <gmp.h> #include <mpfr.h> #include <stdio.h> #include <stdlib.h> /* for alloca on FreeBSD */ #if !defined(BSD) && !defined(__MINGW64__) && !defined(__MINGW32__) && !defined(_MSC_VER) /* MinGW and FreeBSD have alloca, but not alloca.h */ #include <alloca.h> #endif #if defined(__MINGW32__) #include <malloc.h> /* for alloca on MinGW */ #endif #include "limits.h" #include "longlong.h" #include "config.h" #undef ulong #if HAVE_GC #include "gc.h" #endif #if WANT_ASSERT #include <assert.h> #endif #ifdef __cplusplus extern "C" { #endif /* flint version number */ #define __FLINT_VERSION 2 #define __FLINT_VERSION_MINOR 5 #define __FLINT_VERSION_PATCHLEVEL 0 #define FLINT_VERSION "2.5.0" #define __FLINT_RELEASE (__FLINT_VERSION * 10000 + \ __FLINT_VERSION_MINOR * 100 + \ __FLINT_VERSION_PATCHLEVEL) /* Check mpir and mpfr version numbers */ #if __GNU_MP_VERSION < 5 #error GMP 5.0.0 or MPIR 2.6.0 or later are required #endif #if MPFR_VERSION_MAJOR < 3 #error MPFR 3.0.0 or later is required #endif /* We define alternative key words for "asm" and "inline", allowing the code to be compiled with the "-ansi" flag under GCC */ #ifndef __GNUC__ #define __asm__ asm #define __inline__ inline #endif extern char version[]; #define ulong mp_limb_t #define slong mp_limb_signed_t void * flint_malloc(size_t size); void * flint_realloc(void * ptr, size_t size); void * flint_calloc(size_t num, size_t size); FLINT_DLL void flint_free(void * ptr); typedef void (*flint_cleanup_function_t)(void); FLINT_DLL void flint_register_cleanup_function(flint_cleanup_function_t cleanup_function); FLINT_DLL void flint_cleanup(void); #if defined(_WIN64) || defined(__mips64) #define WORD_FMT "%ll" #define WORD_WIDTH_FMT "%*ll" #define WORD(xx) (xx##LL) #define UWORD(xx) (xx##ULL) #define UWORD_MAX ULLONG_MAX #define UWORD_MIN ULLONG_MIN #define WORD_MAX LLONG_MAX #define WORD_MIN LLONG_MIN #else #define WORD_FMT "%l" #define WORD_WIDTH_FMT "%*l" #define WORD(xx) (xx##L) #define UWORD(xx) (xx##UL) #define UWORD_MAX ULONG_MAX #define UWORD_MIN ULONG_MIN #define WORD_MAX LONG_MAX #define WORD_MIN LONG_MIN #endif #if GMP_LIMB_BITS == 64 #define FLINT_BITS 64 #define FLINT_D_BITS 53 #define FLINT64 1 #else #define FLINT_BITS 32 #define FLINT_D_BITS 31 #endif #define mp_bitcnt_t ulong #if HAVE_TLS #ifdef _MSC_VER #define FLINT_TLS_PREFIX __declspec(thread) #else #define FLINT_TLS_PREFIX __thread #endif #else #define FLINT_TLS_PREFIX #endif FLINT_DLL int flint_get_num_threads(void); FLINT_DLL void flint_set_num_threads(int num_threads); FLINT_DLL int flint_test_multiplier(void); typedef struct { gmp_randstate_t gmp_state; int gmp_init; mp_limb_t __randval; mp_limb_t __randval2; } flint_rand_s; typedef flint_rand_s flint_rand_t[1]; static __inline__ void flint_randinit(flint_rand_t state) { state->gmp_init = 0; #if FLINT64 state->__randval = UWORD(13845646450878251009); state->__randval2 = UWORD(13142370077570254774); #else state->__randval = UWORD(4187301858); state->__randval2 = UWORD(3721271368); #endif } static __inline__ void flint_randseed(flint_rand_t state, ulong seed1, ulong seed2) { state->__randval = seed1; state->__randval2 = seed2; } static __inline__ void _flint_rand_init_gmp(flint_rand_t state) { if (!state->gmp_init) { gmp_randinit_default(state->gmp_state); state->gmp_init = 1; } } static __inline__ void flint_randclear(flint_rand_t state) { if (state->gmp_init) gmp_randclear(state->gmp_state); } #if HAVE_GC #define FLINT_GC_INIT() GC_init() #else #define FLINT_GC_INIT() #endif #define FLINT_TEST_INIT(xxx) \ flint_rand_t xxx; \ FLINT_GC_INIT(); \ flint_randinit(xxx) #define FLINT_TEST_CLEANUP(xxx) \ flint_randclear(xxx); \ flint_cleanup(); /* We define this here as there is no mpfr.h */ typedef __mpfr_struct mpfr; #if WANT_ASSERT #define FLINT_ASSERT(param) assert(param) #else #define FLINT_ASSERT(param) #endif #if defined(__GNUC__) #define FLINT_UNUSED(x) UNUSED_ ## x __attribute__((unused)) #else #define FLINT_UNUSED(x) x #endif #define FLINT_MAX(x, y) ((x) > (y) ? (x) : (y)) #define FLINT_MIN(x, y) ((x) > (y) ? (y) : (x)) #define FLINT_ABS(x) ((slong)(x) < 0 ? (-(x)) : (x)) #define MP_PTR_SWAP(x, y) \ do { \ mp_limb_t * __txxx; \ __txxx = x; \ x = y; \ y = __txxx; \ } while (0) #define r_shift(in, shift) \ ((shift == FLINT_BITS) ? WORD(0) : ((in) >> (shift))) #define l_shift(in, shift) \ ((shift == FLINT_BITS) ? WORD(0) : ((in) << (shift))) #ifdef NEED_CLZ_TAB FLINT_DLL extern const unsigned char __flint_clz_tab[128]; #endif static __inline__ unsigned int FLINT_BIT_COUNT(mp_limb_t x) { unsigned int zeros = FLINT_BITS; if (x) count_leading_zeros(zeros, x); return FLINT_BITS - zeros; } #define FLINT_FLOG2(k) (FLINT_BIT_COUNT(k) - 1) #define FLINT_CLOG2(k) FLINT_BIT_COUNT((k) - 1) #define flint_mpn_zero(xxx, nnn) \ do \ { \ slong ixxx; \ for (ixxx = 0; ixxx < (nnn); ixxx++) \ (xxx)[ixxx] = UWORD(0); \ } while (0) #define flint_mpn_copyi(xxx, yyy, nnn) \ do { \ slong ixxx; \ for (ixxx = 0; ixxx < (nnn); ixxx++) \ (xxx)[ixxx] = (yyy)[ixxx]; \ } while (0) #define flint_mpn_copyd(xxx, yyy, nnn) \ do { \ slong ixxx; \ for (ixxx = nnn - 1; ixxx >= 0; ixxx--) \ (xxx)[ixxx] = (yyy)[ixxx]; \ } while (0) #define flint_mpn_store(xxx, nnn, yyy) \ do \ { \ slong ixxx; \ for (ixxx = 0; ixxx < nnn; ixxx++) \ (xxx)[ixxx] = yyy; \ } while (0) /* temporary allocation */ #define TMP_INIT \ typedef struct __tmp_struct { \ void * block; \ struct __tmp_struct * next; \ } __tmp_t; \ __tmp_t * __tmp_root; \ __tmp_t * __tpx #define TMP_START \ __tmp_root = NULL #define TMP_ALLOC(size) \ ((size) > 8192 ? \ (__tpx = (__tmp_t *) alloca(sizeof(__tmp_t)), \ __tpx->next = __tmp_root, \ __tmp_root = __tpx, \ __tpx->block = flint_malloc(size)) : \ alloca(size)) #define TMP_END \ while (__tmp_root) { \ flint_free(__tmp_root->block); \ __tmp_root = __tmp_root->next; \ } /* compatibility between gmp and mpir */ #ifndef mpn_com_n #define mpn_com_n mpn_com #endif #ifndef mpn_neg_n #define mpn_neg_n mpn_neg #endif #ifndef mpn_tdiv_q /* substitute for mpir's mpn_tdiv_q */ static __inline__ void mpn_tdiv_q(mp_ptr qp, mp_srcptr np, mp_size_t nn, mp_srcptr dp, mp_size_t dn) { mp_ptr _scratch; TMP_INIT; TMP_START; _scratch = (mp_ptr) TMP_ALLOC(dn * sizeof(mp_limb_t)); mpn_tdiv_qr(qp, _scratch, 0, np, nn, dp, dn); TMP_END; } #endif /* Newton iteration macros */ #define FLINT_NEWTON_INIT(from, to) \ { \ slong __steps[FLINT_BITS], __i, __from, __to; \ __steps[__i = 0] = __to = (to); \ __from = (from); \ while (__to > __from) \ __steps[++__i] = (__to = (__to + 1) / 2); \ #define FLINT_NEWTON_BASECASE(bc_to) { slong bc_to = __to; #define FLINT_NEWTON_END_BASECASE } #define FLINT_NEWTON_LOOP(step_from, step_to) \ { \ for (__i--; __i >= 0; __i--) \ { \ slong step_from = __steps[__i+1]; \ slong step_to = __steps[__i]; \ #define FLINT_NEWTON_END_LOOP }} #define FLINT_NEWTON_END } FLINT_DLL int parse_fmt(int * floating, const char * fmt); FLINT_DLL int flint_printf(const char * str, ...); /* flint version of printf */ FLINT_DLL int flint_fprintf(FILE * f, const char * str, ...); /* flint version of fprintf */ FLINT_DLL int flint_sprintf(char * s, const char * str, ...); /* flint version of sprintf */ FLINT_DLL int flint_scanf(const char * str, ...); /* flint version of scanf */ FLINT_DLL int flint_fscanf(FILE * f, const char * str, ...); /* flint version of fscanf */ FLINT_DLL int flint_sscanf(const char * s, const char * str, ...); /* flint version of sscanf */ #include "gmpcompat.h" #ifdef __cplusplus } #endif #endif