Coder Social home page Coder Social logo

shiftmediaproject / gmp Goto Github PK

View Code? Open in Web Editor NEW
83.0 13.0 43.0 26.57 MB

Unofficial GMP with added custom native Visual Studio project build tools. GMP: GMP is a free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating-point numbers.

Home Page: https://gmplib.org/

License: GNU Lesser General Public License v3.0

Shell 0.91% C++ 5.25% C 53.71% Perl 0.59% Makefile 0.59% Assembly 34.59% Fortran 0.02% Emacs Lisp 0.13% M4 4.17% GDB 0.01% Batchfile 0.02%
gmp visualstudio visual-studio msvc

gmp's Introduction

ShiftMediaProject GMP

Build status Github All Releases GitHub release GitHub issues license donate

ShiftMediaProject

Shift Media Project aims to provide native Windows development libraries for gmp and associated dependencies to support simpler creation and debugging of rich media content directly within Visual Studio. https://shiftmediaproject.github.io/

GMP

GMP is a free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating-point numbers. https://gmplib.org/

Downloads

Development libraries are available from the releases page. These libraries are available for each supported Visual Studio version with a different download for each version. Each download contains both static and dynamic libraries to choose from in both 32bit and 64bit versions.

Code

This repository contains code from the corresponding upstream project with additional modifications to allow it to be compiled with Visual Studio. New custom Visual Studio projects are provided within the 'SMP' sub-directory. Refer to the 'readme' contained within the 'SMP' directory for further details.

Issues

Any issues related to the ShiftMediaProject specific changes should be sent to the issues page for the repository. Any issues related to the upstream project should be sent upstream directly (see the issues information of the upstream repository for more details).

License

ShiftMediaProject original code is released under LGPLv2.1. All code from the upstream repository remains under its original license (see the license information of the upstream repository for more details).

Copyright

As this repository includes code from upstream project(s) it includes many copyright owners. ShiftMediaProject makes NO claim of copyright on any upstream code. However, all original ShiftMediaProject authored code is copyright ShiftMediaProject. For a complete copyright list please checkout the source code to examine license headers. Unless expressly stated otherwise all code submitted to the ShiftMediaProject project (in any form) is licensed under LGPLv2.1 and copyright is donated to ShiftMediaProject. If you submit code that is not your own work it is your responsibility to place a header stating the copyright.

Contributing

Patches related to the ShiftMediaProject specific changes should be sent as pull requests to the main repository. Any changes related to the upstream project should be sent upstream directly (see the contributing information of the upstream repository for more details).

gmp's People

Contributors

astiob avatar davem330 avatar doughdemon avatar hughmcmaster avatar kryde avatar ln5 avatar mglisse avatar niels-moller avatar peterbrei avatar sethtroisi avatar sibras avatar vinc17fr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gmp's Issues

In windows x64 build

Context

Expected Behavior

Actual Behavior

Steps to Reproduce

1>alt_bn128_g1.obj : error LNK2019: unresolved external symbol ___gmp_printf referenced in function "public: void __thiscall libsnark::alt_bn128_G1::print(void)const " (?print@alt_bn128_G1@libsnark@@QBEXXZ)
1>alt_bn128_g2.obj : error LNK2001: unresolved external symbol ___gmp_printf
1>libzsl.obj : error LNK2001: unresolved external symbol ___gmpn_add_n
1>alt_bn128_g1.obj : error LNK2001: unresolved external symbol ___gmpn_add_n
1>alt_bn128_g2.obj : error LNK2001: unresolved external symbol ___gmpn_add_n
1>alt_bn128_init.obj : error LNK2001: unresolved external symbol ___gmpn_add_n
1>alt_bn128_pairing.obj : error LNK2001: unresolved external symbol ___gmpn_add_n
1>libzsl.obj : error LNK2001: unresolved external symbol ___gmpn_addmul_1
1>alt_bn128_g1.obj : error LNK2001: unresolved external symbol ___gmpn_addmul_1
1>alt_bn128_g2.obj : error LNK2001: unresolved external symbol ___gmpn_addmul_1
1>alt_bn128_init.obj : error LNK2001: unresolved external symbol ___gmpn_addmul_1
1>alt_bn128_pairing.obj : error LNK2001: unresolved external symbol ___gmpn_addmul_1
1>libzsl.obj : error LNK2001: unresolved external symbol ___gmpn_gcdext
1>alt_bn128_g1.obj : error LNK2001: unresolved external symbol ___gmpn_gcdext
1>alt_bn128_g2.obj : error LNK2001: unresolved external symbol ___gmpn_gcdext
1>alt_bn128_init.obj : error LNK2001: unresolved external symbol ___gmpn_gcdext
1>alt_bn128_pairing.obj : error LNK2001: unresolved external symbol ___gmpn_gcdext
1>libzsl.obj : error LNK2001: unresolved external symbol ___gmpn_mul_n
1>alt_bn128_g1.obj : error LNK2001: unresolved external symbol ___gmpn_mul_n
1>alt_bn128_g2.obj : error LNK2001: unresolved external symbol ___gmpn_mul_n
1>alt_bn128_init.obj : error LNK2001: unresolved external symbol ___gmpn_mul_n
1>alt_bn128_pairing.obj : error LNK2001: unresolved external symbol ___gmpn_mul_n
1>libzsl.obj : error LNK2001: unresolved external symbol ___gmpn_sub_n
1>alt_bn128_g1.obj : error LNK2001: unresolved external symbol ___gmpn_sub_n
1>alt_bn128_g2.obj : error LNK2001: unresolved external symbol ___gmpn_sub_n
1>alt_bn128_init.obj : error LNK2001: unresolved external symbol ___gmpn_sub_n
1>alt_bn128_pairing.obj : error LNK2001: unresolved external symbol ___gmpn_sub_n
1>libzsl.obj : error LNK2001: unresolved external symbol ___gmpn_tdiv_qr
1>alt_bn128_g1.obj : error LNK2001: unresolved external symbol ___gmpn_tdiv_qr
1>alt_bn128_g2.obj : error LNK2001: unresolved external symbol ___gmpn_tdiv_qr
1>alt_bn128_init.obj : error LNK2001: unresolved external symbol ___gmpn_tdiv_qr
1>alt_bn128_pairing.obj : error LNK2001: unresolved external symbol ___gmpn_tdiv_qr
1>libzsl.obj : error LNK2001: unresolved external symbol ___gmpn_copyi
1>alt_bn128_g1.obj : error LNK2001: unresolved external symbol ___gmpn_copyi
1>alt_bn128_g2.obj : error LNK2001: unresolved external symbol ___gmpn_copyi
1>alt_bn128_init.obj : error LNK2001: unresolved external symbol ___gmpn_copyi
1>alt_bn128_pairing.obj : error LNK2001: unresolved external symbol ___gmpn_copyi
1>libzsl.obj : error LNK2001: unresolved external symbol ___gmpn_zero
1>alt_bn128_g1.obj : error LNK2001: unresolved external symbol ___gmpn_zero
1>alt_bn128_g2.obj : error LNK2001: unresolved external symbol ___gmpn_zero
1>alt_bn128_init.obj : error LNK2001: unresolved external symbol ___gmpn_zero
1>alt_bn128_pairing.obj : error LNK2001: unresolved external symbol ___gmpn_zero
1>alt_bn128_init.obj : error LNK2019: unresolved external symbol ___gmpn_set_str referenced in function "public: __thiscall libsnark::bigint<4>::bigint<4>(char const *)" (??0?$bigint@$03@libsnark@@QAE@PBD@Z)
1>alt_bn128_pairing.obj : error LNK2001: unresolved external symbol ___gmpn_set_str
1>libzsl.obj : error LNK2019: unresolved external symbol ___gmpn_rshift referenced in function "class std::vector<__int64,class std::allocator<__int64> > __cdecl libsnark::find_wnaf<4>(unsigned __int64,class libsnark::bigint<4> const &)" (??$find_wnaf@$03@libsnark@@ya?AV?$vector@_JV?$allocator@_J@std@@@std@@_KABV?$bigint@$03@0@@z)
1>....\build\win32\dbin\gmp.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'x86'
1>E:\work\bubi\project\test_atl_bn128\zsl\build\win32\dbin\LibZsl.exe : fatal error LNK1120: 11 unresolved externals
1>Done building project "LibZsl.vcxproj" -- FAILED.

Your Environment

  • Version Used:
  • Operating System and Version:
  • Compiler and Version(s):

Possible Fix

Erroneous results from mpz_popcount()

Context

I encounter erroneous, unpredictable results from the mpz_popcount() function.
I have included a minimal C++ program to demonstrate the behaviour below:

#include <iostream>

#include <gmpxx.h>

int main ()
{
    mpz_t n;
    mpz_init_set_ui (n, 65535);
    std::cout << mpz_popcount (n);
    mpz_clear (n);
    return 0;
}

Expected Behavior

As 65535 is 2^16 - 1, it contains 16 1's in its binary representation, and mpz_popcount(n) should return 16.

Actual Behavior

On five consecutive runs, mpz_popcount(n) returns 160, 146, 168, 137, and 141.

Environment

  • CPU: AMD Ryzen 7 7730U (Zen3 architecture)
  • Operating System and Version: Windows 11 Home, 22631.3447
  • Compiler and Version(s): Microsoft (R) C/C++ Optimizing Compiler Version 19.39.33523 for x86
  • Visual Studio 2022, version 17.9.6 with VSYASM

Possible Fix

I am guessing that the error lies in the assembly file SMP/mpn/x86_64/popcount.s. Since the function output is not consistent across runs, I suspect that the assembly code is reading data past the end of the mpz_t. However, I am not familiar with assembly, so I do not have a specific suggestion for a fix. I compared to the GMP repo on their official site, and did not find a matching implementation of mpn_popcount, so I think this bug is specific to the ShiftMediaProject fork.

[VS2019 16.7.2]error MSB3843: Project "libgmp" targets platform "Windows", but references SDK "Visual C++ 2015 Runtime for Universal Windows Platform Apps v14.0" which targets platform "UAP

Hi All,

We found that gmp with x64-uwp failed on vs2019 16.7.2 with following failure:

error MSB3843: Project "libgmp" targets platform "Windows", but references SDK "Visual C++ 2015 Runtime for Universal Windows Platform Apps v14.0" which targets platform "UAP"

The project configuration is ReleaseDLLWinRT | x64, confirming with msbuild team, that mixing configurations with different application types is not supported, and this has never been supported, not sure why it works before, could you please take a look? thank you in advance!

See repro steps and full failure log in issue microsoft/vcpkg#13172.

Thanks,
Phoebe

mpf_clear after mpf_set_prec_raw causes error

My test program(Pi) uses procedure mpf_set_prec_raw several times. This procedure

void
mpf_set_prec_raw (mpf_ptr x, mp_bitcnt_t prec_in_bits) __GMP_NOTHROW
{
  x->_mp_prec = __GMPF_BITS_TO_PREC (prec_in_bits);
}

only set field _mp_prec and don't manipulate with memory. For example 7 change to 2.
Next, mpf_clear calls __gmp_default_free with parameter PREC(x) + 1.
In mode Debug is error when I compile sources of libgmp as standalone exe. If project is compiled as library (even Debug) no error appears. Checking magic deadbeef+deafdeed is unnecessary because always will free the same size what is allocated? But what will if user increase precision by mpf_set_prec_raw? I don't know why compiling as library not causes error.

I link to a 64bit gmp.lib library,in vs2019

Context

Expected Behavior

Actual Behavior

Steps to Reproduce

1>alt_bn128_g1.obj : error LNK2019: unresolved external symbol ___gmp_printf referenced in function "public: void __thiscall libsnark::alt_bn128_G1::print(void)const " (?print@alt_bn128_G1@libsnark@@QBEXXZ)
1>alt_bn128_g2.obj : error LNK2001: unresolved external symbol ___gmp_printf
1>libzsl.obj : error LNK2001: unresolved external symbol ___gmpn_add_n
1>alt_bn128_g1.obj : error LNK2001: unresolved external symbol ___gmpn_add_n
1>alt_bn128_g2.obj : error LNK2001: unresolved external symbol ___gmpn_add_n
1>alt_bn128_init.obj : error LNK2001: unresolved external symbol ___gmpn_add_n
1>alt_bn128_pairing.obj : error LNK2001: unresolved external symbol ___gmpn_add_n
1>libzsl.obj : error LNK2001: unresolved external symbol ___gmpn_addmul_1
1>alt_bn128_g1.obj : error LNK2001: unresolved external symbol ___gmpn_addmul_1
1>alt_bn128_g2.obj : error LNK2001: unresolved external symbol ___gmpn_addmul_1
1>alt_bn128_init.obj : error LNK2001: unresolved external symbol ___gmpn_addmul_1
1>alt_bn128_pairing.obj : error LNK2001: unresolved external symbol ___gmpn_addmul_1
1>libzsl.obj : error LNK2001: unresolved external symbol ___gmpn_gcdext
1>alt_bn128_g1.obj : error LNK2001: unresolved external symbol ___gmpn_gcdext
1>alt_bn128_g2.obj : error LNK2001: unresolved external symbol ___gmpn_gcdext
1>alt_bn128_init.obj : error LNK2001: unresolved external symbol ___gmpn_gcdext
1>alt_bn128_pairing.obj : error LNK2001: unresolved external symbol ___gmpn_gcdext
1>libzsl.obj : error LNK2001: unresolved external symbol ___gmpn_mul_n
1>alt_bn128_g1.obj : error LNK2001: unresolved external symbol ___gmpn_mul_n
1>alt_bn128_g2.obj : error LNK2001: unresolved external symbol ___gmpn_mul_n
1>alt_bn128_init.obj : error LNK2001: unresolved external symbol ___gmpn_mul_n
1>alt_bn128_pairing.obj : error LNK2001: unresolved external symbol ___gmpn_mul_n
1>libzsl.obj : error LNK2001: unresolved external symbol ___gmpn_sub_n
1>alt_bn128_g1.obj : error LNK2001: unresolved external symbol ___gmpn_sub_n
1>alt_bn128_g2.obj : error LNK2001: unresolved external symbol ___gmpn_sub_n
1>alt_bn128_init.obj : error LNK2001: unresolved external symbol ___gmpn_sub_n
1>alt_bn128_pairing.obj : error LNK2001: unresolved external symbol ___gmpn_sub_n
1>libzsl.obj : error LNK2001: unresolved external symbol ___gmpn_tdiv_qr
1>alt_bn128_g1.obj : error LNK2001: unresolved external symbol ___gmpn_tdiv_qr
1>alt_bn128_g2.obj : error LNK2001: unresolved external symbol ___gmpn_tdiv_qr
1>alt_bn128_init.obj : error LNK2001: unresolved external symbol ___gmpn_tdiv_qr
1>alt_bn128_pairing.obj : error LNK2001: unresolved external symbol ___gmpn_tdiv_qr
1>libzsl.obj : error LNK2001: unresolved external symbol ___gmpn_copyi
1>alt_bn128_g1.obj : error LNK2001: unresolved external symbol ___gmpn_copyi
1>alt_bn128_g2.obj : error LNK2001: unresolved external symbol ___gmpn_copyi
1>alt_bn128_init.obj : error LNK2001: unresolved external symbol ___gmpn_copyi
1>alt_bn128_pairing.obj : error LNK2001: unresolved external symbol ___gmpn_copyi
1>libzsl.obj : error LNK2001: unresolved external symbol ___gmpn_zero
1>alt_bn128_g1.obj : error LNK2001: unresolved external symbol ___gmpn_zero
1>alt_bn128_g2.obj : error LNK2001: unresolved external symbol ___gmpn_zero
1>alt_bn128_init.obj : error LNK2001: unresolved external symbol ___gmpn_zero
1>alt_bn128_pairing.obj : error LNK2001: unresolved external symbol ___gmpn_zero
1>alt_bn128_init.obj : error LNK2019: unresolved external symbol ___gmpn_set_str referenced in function "public: __thiscall libsnark::bigint<4>::bigint<4>(char const *)" (??0?$bigint@$03@libsnark@@QAE@PBD@Z)
1>alt_bn128_pairing.obj : error LNK2001: unresolved external symbol ___gmpn_set_str
1>libzsl.obj : error LNK2019: unresolved external symbol ___gmpn_rshift referenced in function "class std::vector<__int64,class std::allocator<__int64> > __cdecl libsnark::find_wnaf<4>(unsigned __int64,class libsnark::bigint<4> const &)" (??$find_wnaf@$03@libsnark@@ya?AV?$vector@_JV?$allocator@_J@std@@@std@@_KABV?$bigint@$03@0@@z)
1>....\build\win32\dbin\gmp.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'x86'
1>E:\work\bubi\project\test_atl_bn128\zsl\build\win32\dbin\LibZsl.exe : fatal error LNK1120: 11 unresolved externals
image
image
image
image

Your Environment

  • Version Used:
  • Operating System and Version:
  • Compiler and Version(s):

Possible Fix

gmpxx.h is missing

Context

Porting a Linux application that is using gmp on windows

Expected Behavior

The Linux application is including in several sources #include <gmpxx.h>

Actual Behavior

Include <gmpxx.h> not found

Steps to Reproduce

Not availabel

Your Environment

Windows10, VisualStudio 2015

Possible Fix

GMP core on _gmpn_copyi call

GMP core on _gmpn_copyi call. This happens on 10 years old AMD Phenom II X4 910e.

The exception code 0xc000001d means:
NTSTATUS message for 0xc000001d (3221225501): {EXCEPTION} Illegal Instruction An attempt was made to execute an illegal instruction.

main!_gmpn_copyi+0x198:
00007ff7`adf48958 660f3a0ffe08 palignr xmm7,xmm6,8
0:000> k

Child-SP RetAddr Call Site

00 0000009cd17ef4c0 0000000000000000 main!_gmpn_copyi+0x198 [C:\gmp\gmp-6.2.0\SNP\mpn\x86_64\copyi.s @ 222]

Possibly the problem is related to CPU instructions FMA3 and AVX, because both instructions are not available on this host as I can see via CPU-Z.

for e.g. AMD FX-6200 (since 2012) got FMA3 and AVX and functionality works without any issue

Your Environment

  • Version Used:
    GMP 6.2.0 (lib)
  • Operating System and Version:
    Windows Server 2016
  • Compiler and Version(s):
    Visual Studio 2019
  • Processor:
    AMD Phenom II X4 910e (This CPU has no AVX and FMA4 instructions )

Possible Fix

Disable copyi.s optimization

compile error with last build

compile project with VS2015 will get a error

Context

get_d_2exp.c missed to include gmp.h file

Expected Behavior

Actual Behavior

Steps to Reproduce

Your Environment

  • Version Used:
  • Operating System and Version:
  • Compiler and Version(s):

Possible Fix

Request for clarification: What target is actually built?

It would be good to know this, but it isn't part of the documentation:

  • Is the generation identical to --enable-fat- so contains code for all CPUs (bigger lib)?
  • Is the generation identical to generic target (so much smaller than the above, but worst performance, also working on all CPUs)?
  • Generation for CPU x?

Is it possible to explicit generate for a specific CPU?

C++ input/output functions for gmp types are not exported by a dynamic library for Windows

Context

Some functions (mostly operator<<, and operator>>) are not included in libgmp.def and therefore are not exported by a dynamic library for Windows.

Expected Behavior

The code below should compile and link successfully against gmp built as a dynamic library.

Actual Behavior

The linker can't find some functions. E.g. operator<< defined in osmpq.cc.

main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl operator<<(class std::basic_ostream<cha
r,struct std::char_traits<char> > &,struct __mpq_struct const *)" (__imp_??6@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AEAV01@PEBU__mpq_struct@@@Z) referenced in function "class
std::basic_ostream<char,struct std::char_traits<char> > & __cdecl operator<<<struct __mpq_struct [1],struct __mpq_struct [1]>(class std::basic_ostream<char,struct std::char_traits<char> >
 &,class __gmp_expr<struct __mpq_struct [1],struct __mpq_struct [1]> const &)" (??$?6$$BY00U__mpq_struct@@$$BY00U0@@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AEAV01@AEBV?$__gmp_
expr@$$BY00U__mpq_struct@@$$BY00U1@@@@Z) [D:\dev\gmp-test\build\main.vcxproj]
D:\dev\gmp-test\build\Debug\main.exe : fatal error LNK1120: 1 unresolved externals [D:\dev\gmp-test\build\main.vcxproj]

Steps to Reproduce

#include <iostream>
#include <gmpxx.h>

int main() {
  std::cout << mpq_class(1) << std::endl;
  return 0;
}

Possible Fix

Add missing names into libgmp.def. An obstacle is that C++ functions names are mangled with mangling rules dependent on a compiler version. An alternative is to patch sources and add __declspec(dllexport).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.