Comments (18)
According to my research with MSVC the stdint.h
is available in Visual Studio 2010 or newer.
from libtommath.
Can I recommend Paul Hsieh's pstdint.h as a substitute?
from libtommath.
I follow #37 (comment) of @tomstdenis, made right before we introduced the dependecy to stdint.h
from libtommath.
I see your point. On the other hand providing that in libtommath we need just to handle these:
typedef unsigned char mp_uint8;
typedef unsigned short mp_uint16;
typedef unsigned int mp_uint32;
#ifdef _MSC_VER
typedef unsigned __int64 mp_uint64;
#else
typedef unsigned long long mp_uint64;
#endif
I am not sure that introducing the dependency on stdint.h
is worth the portability troubles.
from libtommath.
Well already unsigned long
is 64 bit on x86_64 on linux (in case you're not compiling for x32 ...)
I prefer moving the trouble to platforms who think providing an ancient compiler is enough ... as c99 is now 17 years old where stdint.h was introduced
from libtommath.
Well already unsigned long is 64 bit on x86_64 on linux (in case you're not compiling for x32 ...)
yes, my example is not completely correct, perhaps typedef unsigned int mp_uint32;
would be better but the working code was not purpose of my previous post.
I prefer moving the trouble to platforms who think providing an ancient compiler is enough ... as c99 is now 17 years old where stdint.h was introduced
It is true but for example MS Visual Studio 2008 which comes without stdint.h is perhaps not that ancient.
Frankly speaking to me both libtommath + libtomcrypt are too much oriented towards gcc compiler. Once you step out of gcc river you very quickly get into portability troubles (I mean compiler portability, not platform portability).
from libtommath.
yes, my example is not completely correct...
and that's why I prefer to use stdint.h instead of the old mess. If your compiler doesn't have stdint.h, create it with the valid typedefs and you're done
It is true but for example MS Visual Studio 2008 which comes without stdint.h is perhaps not that ancient.
as the mainstream support of VS2008 has ended 2013 even MS considers it as ancient :-)
Frankly speaking to me both libtommath + libtomcrypt are too much oriented towards gcc compiler
really, you think that? what exactly? ...besides the LTC_FAST
hack in ltc which is only enabled if your compiler is gcc...
I think we have to fix these parts if there are any!
from libtommath.
as the mainstream support of VS2008 has ended 2013 even MS considers it as ancient :-)
So what are libtommath_VS2005.sln, libtommath_VS2005.vcproj, libtommath_VS2008.sln, libtommath_VS2008.vcproj files good for?
really, you think that?
yes
what exactly?
follow my PRs and issues
I think we have to fix these parts if there are any!
glad to hear it
from libtommath.
So what are libtommath_VS2005.sln, libtommath_VS2005.vcproj, libtommath_VS2008.sln, libtommath_VS2008.vcproj files good for?
they're unmaintained VS project files -> we should probably state that in the readme...
from libtommath.
To support VS2005 + VS2008 we need something like this https://github.com/karel-m/libtommath/commit/2fa838b4479c8810f87f32685c270cfb4e68d6dc
Otherwise these files should be removed or converted to Visual Studio 2010 (+ we should state in readme that VS2008 and earlier are not supported).
from libtommath.
Ideally we wouldn't have any project files at all, and have them automatically generated.
from libtommath.
Ideally we wouldn't have any project files at all, and have them automatically generated.
Feel free to create a PR for whatever you want to generate the project files but you'll also take over maintenance of that part. (I'll be fine if it is automated as it's currently done.)
from libtommath.
The solution that comes to mind is CMake, but that would involve redoing the build system.
from libtommath.
@TazeTSchnitzel CMake? Tried it. Tried it hard. Really! To no avail. Had to stop because I already spend way too many hours trying to squeeze all the special conditions and rules of LibTomMath into the corset of CMake. Some time went by since than and it might be a better fit by now, so you might give it a second chance.
from libtommath.
Does LibTomMath do something weird when it builds? Is it not a codebase that can be essentially built with cc *.c
?
from libtommath.
@TazeTSchnitzel Not LibTomMath but the people who build it. They may want all, or only parts of it. Some parts depend on others, they don't want to check the dependencies by hand they want it done automagically. Some want it optimized for speed, some for size, some have mixed feelings about it (the last one is not offered yet, but would be nice). You may want to get the size of the limb (MP_DIGITS) defined for you or define it yourself and so on and so forth. LibTomMath has many screws and levers to play around with and all of them make sense for somebody.
In theory CMake can do all of it and than some, but I couldn't get it to do so. You might have more luck.
from libtommath.
I see, thank you.
from libtommath.
To close this already closed discussion - here is my preferred way without stdint.h
:
/* unsigned int types */
typedef unsigned char mp_uint8;
typedef unsigned short mp_uint16;
typedef unsigned int mp_uint32;
#ifdef _MSC_VER
typedef unsigned __int64 mp_uint64;
#else
typedef unsigned long long mp_uint64;
#endif
/* detect 64-bit mode if possible */
#if !(defined(MP_32BIT) || defined(MP_16BIT) || defined(MP_8BIT))
#if defined(__x86_64__)
#if defined(__GNUC__)
typedef unsigned long mp_uint128 __attribute__ ((mode(TI)));
#define MP_64BIT
#elif defined(_MSC_VER)
typedef unsigned __int128 mp_uint128;
#define MP_64BIT
#endif
#endif
#endif
/* some default configurations.
*
* A "mp_digit" must be able to hold DIGIT_BIT + 1 bits
* A "mp_word" must be able to hold 2*DIGIT_BIT + 1 bits
*
* At the very least a mp_digit must be able to hold 7 bits
* [any size beyond that is ok provided it doesn't overflow the data type]
*/
#ifdef MP_8BIT
typedef mp_uint8 mp_digit;
typedef mp_uint16 mp_word;
#define DIGIT_BIT 7
#elif defined(MP_16BIT)
typedef mp_uint16 mp_digit;
typedef mp_uint32 mp_word;
#define DIGIT_BIT 15
#elif defined(MP_64BIT)
typedef mp_uint64 mp_digit;
typedef mp_uint128 mp_word;
#define DIGIT_BIT 60
#elif defined(MP_32BIT)
typedef mp_uint32 mp_digit;
typedef mp_uint64 mp_word;
#define DIGIT_BIT 31
#else
typedef mp_uint32 mp_digit;
typedef mp_uint64 mp_word;
#define DIGIT_BIT 28
#define MP_28BIT
#endif
I am leaving this discussion.
from libtommath.
Related Issues (20)
- Build fails on Linux/Sparc with 32 bit userspace HOT 3
- CryptAcquireContextW and CryptGenRandom are deprecated HOT 3
- Potentially lossy conversion in s_read_wincsp HOT 1
- Dependency on dead code elimination HOT 4
- s_read_wincsp leaks handle HOT 2
- Is the memory representation stable? HOT 6
- mp_is_square says 0 is not a square HOT 3
- Library can not be used in android (arm64) HOT 24
- Next release with SPM support
- tommath_c89.h versus other solutions for backward compatibility with <C99 HOT 2
- should i>=x.used better? HOT 14
- does it support cross-build? HOT 1
- typos HOT 6
- s_mp_invmod_odd returns wrong result for negative numbers HOT 2
- speed please!? HOT 1
- Compiler & base OS versions
- mp_fwrite should not write \0 character HOT 3
- cmake HOT 2
- mp_exptmod incorrect result since version 0.32 HOT 3
- No more tommath.pdf ?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libtommath.