Coder Social home page Coder Social logo

Comments (18)

karel-m avatar karel-m commented on June 10, 2024

According to my research with MSVC the stdint.h is available in Visual Studio 2010 or newer.

from libtommath.

lpsantil avatar lpsantil commented on June 10, 2024

Can I recommend Paul Hsieh's pstdint.h as a substitute?

from libtommath.

sjaeckel avatar sjaeckel commented on June 10, 2024

I follow #37 (comment) of @tomstdenis, made right before we introduced the dependecy to stdint.h

from libtommath.

karel-m avatar karel-m commented on June 10, 2024

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.

sjaeckel avatar sjaeckel commented on June 10, 2024

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.

karel-m avatar karel-m commented on June 10, 2024

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.

sjaeckel avatar sjaeckel commented on June 10, 2024

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.

karel-m avatar karel-m commented on June 10, 2024

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.

sjaeckel avatar sjaeckel commented on June 10, 2024

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.

karel-m avatar karel-m commented on June 10, 2024

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.

hikari-no-yume avatar hikari-no-yume commented on June 10, 2024

Ideally we wouldn't have any project files at all, and have them automatically generated.

from libtommath.

sjaeckel avatar sjaeckel commented on June 10, 2024

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.

hikari-no-yume avatar hikari-no-yume commented on June 10, 2024

The solution that comes to mind is CMake, but that would involve redoing the build system.

from libtommath.

czurnieden avatar czurnieden commented on June 10, 2024

@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.

hikari-no-yume avatar hikari-no-yume commented on June 10, 2024

Does LibTomMath do something weird when it builds? Is it not a codebase that can be essentially built with cc *.c?

from libtommath.

czurnieden avatar czurnieden commented on June 10, 2024

@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.

hikari-no-yume avatar hikari-no-yume commented on June 10, 2024

I see, thank you.

from libtommath.

karel-m avatar karel-m commented on June 10, 2024

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)

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.