RC5 - compiler warnings (Windows x64) #306
Labels
No labels
bug
duplicate
enhancement
feature
help wanted
improve API
invalid
needs documentation
not-planned
rtfm
stale
support
wishlist
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-libtom/libtomcrypt#306
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Visual C/C++ 2008
related to:
@sjaeckel do we want to fix them?
IMO the following stuff is not completely correct:
Because with MS C/C++ compiler for x86_64:
mp_digitis 32bit unsigned integerltc_mp_digitis 64bit unsigned integerunsigned longis 32bit unsigned integerYeah, I also think we should fix this.
Not 100% sure, but I guess that's the correct question to resolve this: Why is
mp_digit32bits with MS C/C++ compiler for x86_64?Because ltm is not MSVC+64bit friendly. Even on 64bit Windows you have just:
Frankly, it is so bad that "stock" ltm does not even compile with Visual C/C++ 2008, I have to use my patched version (you perhaps remember my lost battle regarding
stdint.h).I am not sure what is the right fix here.
typedef ulong32 ltc_mp_digit;?typedef unsigned long ltc_mp_digit;?I don't see where you've lost a battle there. I count it as a victory against cruft caused by
crappyancient toolchainsI think that's definitively the wrong approach
that's the way it was before which was less than optimal for the world where
unsigned longon 64bit is only 32bit, but at least consistent across the platform the libs are built for...I'd say
either drop support for MSVC+64bit orfix the ltm buildIn my opinion
ltc_mp_digitis correctly typedef'ed, as I defined that the MPI provider's digit shall have the same bitwidth as the architeture so we can at least get out of theunsinged longhell.btw I just tried to setup the windows toolchain (nmake etc.) in a vm to reproduce this mess and after spending more than an hour I feel like I've lost several days of my life...
where's the real problem of getting ltm built correctly for MSVC+64bit? could it be solved by something like packaging the mentioned
pstdint.hand adding#if _MSC_VER #include "pstdint.h" #else #include <stdint.h> #endif? or does it need more?Edit: FTR https://github.com/libtom/libtommath/issues/45
IMO we build ltm on 64bit architectures like this:
mp_word) then goDIGIT_BIT 60way (which means 64bitmp_digit)DIGIT_BIT 28way (which means 32bitmp_digit- even on 64bit arch)Any way to confirm a match when init'ing a MP?
.
BTW when talking about 128bit integers:
stdint.hnorpstdint.his gonna save youtypedef unsigned __int128 mp_word;seems to not work with MSVCtypedef uint128_t mp_word;works only if you define your ownuint128_ttomcrypt.hare inevitableLet's have look at GMP:
set_int(void *a, ltc_mp_digit b)callsmpz_set_ui(((__mpz_struct *)a), b)void mpz_set_ui (mpz_t rop, unsigned long int op)unsigned long int opis 32bitI am starting to like the old good
unsigned longapproach.since 1.0.1 we build ltm on 64bit archtitectures like this v1.0.1/tommath.h:30:
no natural way
yeah, it's a mess
looks like I dreamed of a better world when I added this... looks also like nobody uses ltm on 64bit windows...
me too
Perhaps a cautionary note in the PDF that all users should confirm the bit-architectures of their libraries match? Getting folks to pay attention to a single line in a 200-page manual is problematic so perhaps in the README? ???
.
okay, let's summarize what we have and what we need to support (at least for the linux vs windows part. I guess we can squeeze the other *nix platforms in linux m32/64, or not @karel-m ?)
__x86_64__+ ILP32)Tested
typedef unsigned long my128type __attribute__ ((mode(TI)));*gcc 4.4.7/i686-redhat-linux complainserror: unable to emulate ‘TI’**gcc 5.4.0/i686-pc-cygwin complainserror: unable to emulate ‘TI’***gcc 4.9.2/i686-w64-mingw32 complainserror: unable to emulate 'TI'I saw that there is _m128i on msvc, but I guess it can't be used for that purpose as it seems to be a struct from the msvc documentation...
+ I've created https://github.com/libtom/libtommath/pull/91
@karel-m thanks for filling in the values, linux mx32 has 128bit int's for sure as it's 64bit architecture but with 32bit wide pointers.
Could this be the correct patch?
Edit: I just tested the three architectures (-m32 -mx32 -m64) on x86_64 with gcc 5.4.0 and they were all still fine
There is IMO no guarantee that
LLP64 will be defined on
all LLP64 platforms.
I am for unconditional:
typedef unsigned long ltc_mp_digit;yes, there are certain properties of implementations that can not be detected at compile time with preprocessor hacks.... that's why most projects use configure scripts to test such properties (and that makes a ton of sense).
this breaks
x32which was the reason why I introducedltc_mp_digit(c.f. #51)better like that?
yeah, as soon as we're done with this release I'm open to accept PR's and maintainerships regarding the build-environment
UPDATE: also broken, does not cover mingw-gcc/win64
Anyhow, we should perhaps recommend not to pass integers bigger than
0xFFFFFFFF(32bit) to any ofmp_cmp_d,mp_add_d,mp_sub_d,mp_mul_d,mp_mod_d,mp_set_int.damn, right
I would simply ignore it for now, it is not worse than it used to be.
To me the GMP approach (
*_ui+unsigned long) seems the right way:mp_add_d(void *a, unsigned long b, void *c)>mpz_add_ui(mpz_t rop, const mpz_t op1, unsigned long int op2)mp_add_d(void *a, unsigned long b, void *c)>mp_add_ui(mp_int *a, unsigned long b, mp_int *c)mp_add_uiknows how to convertunsigned longtomp_digit, as inside LTM it has all necessary information about how the LTM was built, DIGIT_BITS, how bigmp_digitis etc.mp_digit)I've pushed again to https://github.com/libtom/libtomcrypt/tree/fix/306 after accidentally pushing the incomplete commit to the release branch...
This was tested on 64bit cygwin, 64bit mingw, linux m32 mx32 & m64
Can you please try with MSVC
...Don't forget to use the correct branch of ltm..
IMO there are two good types for
bofmp_add_d()unsigned intunsigned long longEdit: or probably also not... IDK... probably it should also be
uint32_toruint64_tand we don't have to care anymore about data models... yada yadafix/306seems to build fine with MSVC@sjaeckel fix/306 can be merged, or did you already?
already merged and branch removed