I have been working on making an intsafe.h that is suitable for being
added to mingw-w64 and just wanted to give a status update.

Some background: The intsafe.h header provided by Microsoft has 253
inline functions for safe conversions, additions, multiplications, and
subtractions of integers.  The documentation is here:

https://msdn.microsoft.com/en-us/library/windows/desktop/ff521693

A recent patch by Jacek Caban added intsafe.h to mingw-w64, but it is
just a stub that doesn't have any of the conversion or math functions.

I have collected a few different free-software implementations of
intsafe.h in this repository:

https://github.com/DavidEGrayson/intsafe

The implementation by tta from 5 years ago is the only one that comes
close to being complete, but it is still missing 30 math conversion
functions.  The functions that it does define seem to be fine; I only
had to fix a bug in one of them.

I have been developing a test suite for intsafe.h implementations, and
running it against tta's implementation, and patching that
implementation as I find problems.  It would take forever to write
test cases for 253 functions by hand, so I am using a Ruby script to
generate test cases, and then running those test cases in a variety of
environments (32-bit and 64-bit, signed char and unsigned char, C++
and C).

This is working pretty well, so I think I might end up using Ruby to
generate intsafe.h itself.  However, I will try to do it in a way that
minimizes the size of the generated code, making it easy to check by
humans.

You can follow my progress and see some different implementations of
intsafe.h here:


I have never written a header for mingw-w64 before so any tips are welcome.

--David Grayson

------------------------------------------------------------------------------
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to