I did write one for MinGW. Please see the attached archive for details. Though it is still not well-tested and may have bugs or typos.
headers for intsafe.h functions
Thank you for your contribution. I'll look in more detail to your suggested implementation and will come back to this later.
Kai, did you commit this change at all?
I am trying to build Microsoft's USBView application with mingw-w64 (using MSYS2) and the lack of intsafe.h is the first problem I encountered.
Thanks for your contribution, tta. I will push for this to get added to mingw-w64. I confirmed (using bash and grep) that it has every function that is documented by Microsoft, and I was able to compile it under the latest version of mingw-w64 fairly easily. You can follow my progress on building/testing it here:
I'll also post on the mingw-w64 mailing list at some point.
Actually, I spotted this line in tta's implementation, in intsafe_64.h:
int64_t tmp = (int64_t)(op1 + op2);
Since op1 and op2 are signed integers (which can be seen from context I did not include here), and signed integer overflow is undefined behavior, the line above is dangerous and should not be used. Here is an example of what can go wrong if you use code like that:
I am working on a better one over at https://github.com/DavidEGrayson/intsafe