Skip to content

Commit 3a8df42

Browse files
committed
Add test for intsafe.h to config
1 parent dca8f72 commit 3a8df42

File tree

7 files changed

+31
-14
lines changed

7 files changed

+31
-14
lines changed

cmake/compilerOptions.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ check_symbol_exists(localeconv locale.h HAVE_LOCALECONV)
1313
include(CheckIncludeFile)
1414
check_include_file(inttypes.h HAVE_INTTYPES_H)
1515
check_include_file(stdint.h HAVE_STDINT_H)
16+
check_include_file(intsafe.h HAVE_INTSAFE_H)
1617
check_include_file(strings.h HAVE_STRINGS_H)
1718
check_include_file(ctype.h HAVE_CTYPE_H)
1819
check_include_file(stdlib.h HAVE_STDLIB_H)

cmake/matioConfig.cmake.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959
/* Define to 1 if you have the <inttypes.h> header file. */
6060
#cmakedefine HAVE_INTTYPES_H 1
6161

62+
/* Define to 1 if you have the <intsafe.h> header file. */
63+
#cmakedefine HAVE_INTSAFE_H 1
64+
6265
/* Define to 1 if you have the `m' library (-lm). */
6366
#cmakedefine HAVE_LIBM 1
6467

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ AC_CHECK_HEADERS_ONCE([stdarg.h])
148148
AC_CHECK_HEADERS_ONCE([varargs.h])
149149
AC_CHECK_HEADER([inttypes.h],[AC_DEFINE_UNQUOTED([MATIO_HAVE_INTTYPES_H],[1],[Matio has access to inttypes.h])])
150150
AC_CHECK_HEADER([stdint.h],[AC_DEFINE_UNQUOTED([MATIO_HAVE_STDINT_H],[1],[Matio has access to stdint.h])])
151+
AC_CHECK_HEADER([intsafe.h],[AC_DEFINE_UNQUOTED([HAVE_INTSAFE_H],[1],[Matio has access to intsafe.h])])
151152
AC_CHECK_HEADER([strings.h],[AC_DEFINE_UNQUOTED([HAVE_STRINGS_H],[1],[Matio has access to strings.h])])
152153
AC_CHECK_HEADER([unistd.h],[AC_DEFINE_UNQUOTED([HAVE_UNISTD_H],[1],[Matio has access to unistd.h])])
153154
AC_CHECK_HEADERS([locale.h stddef.h])

src/matioConfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959
/* Define to 1 if you have the <inttypes.h> header file. */
6060
#undef HAVE_INTTYPES_H
6161

62+
/* Define to 1 if you have the <intsafe.h> header file. */
63+
#undef HAVE_INTSAFE_H
64+
6265
/* Define to 1 if you have the `m' library (-lm). */
6366
#undef HAVE_LIBM
6467

src/safe-math.h

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
# elif defined(__GNUC__) && (__GNUC__ >= 5) && !defined(__INTEL_COMPILER)
2020
# define PSNIP_SAFE_HAVE_BUILTIN_OVERFLOW
2121
# endif
22-
# if defined(__has_include)
22+
# if defined(HAVE_INTSAFE_H)
23+
# define PSNIP_SAFE_HAVE_INTSAFE_H
24+
# elif defined(__has_include)
2325
# if __has_include(<intsafe.h>)
2426
# define PSNIP_SAFE_HAVE_INTSAFE_H
2527
# endif
@@ -716,9 +718,9 @@ PSNIP_SAFE_DEFINE_BUILTIN_BINARY_OP(unsigned short, ushort, add)
716718
PSNIP_SAFE_DEFINE_BUILTIN_BINARY_OP(unsigned short, ushort, sub)
717719
PSNIP_SAFE_DEFINE_BUILTIN_BINARY_OP(unsigned short, ushort, mul)
718720
#elif defined(PSNIP_SAFE_HAVE_INTSAFE_H)
719-
PSNIP_SAFE_DEFINE_INTSAFE(unsigned short, ushort, add, UShortAdd)
720-
PSNIP_SAFE_DEFINE_INTSAFE(unsigned short, ushort, sub, UShortSub)
721-
PSNIP_SAFE_DEFINE_INTSAFE(unsigned short, ushort, mul, UShortMult)
721+
PSNIP_SAFE_DEFINE_INTSAFE(USHORT, ushort, add, UShortAdd)
722+
PSNIP_SAFE_DEFINE_INTSAFE(USHORT, ushort, sub, UShortSub)
723+
PSNIP_SAFE_DEFINE_INTSAFE(USHORT, ushort, mul, UShortMult)
722724
#elif defined(PSNIP_SAFE_HAVE_LARGER_USHORT)
723725
PSNIP_SAFE_DEFINE_PROMOTED_UNSIGNED_BINARY_OP(unsigned short, ushort, add, USHRT_MAX)
724726
PSNIP_SAFE_DEFINE_PROMOTED_UNSIGNED_BINARY_OP(unsigned short, ushort, sub, USHRT_MAX)
@@ -753,9 +755,9 @@ PSNIP_SAFE_DEFINE_BUILTIN_BINARY_OP(unsigned int, uint, add)
753755
PSNIP_SAFE_DEFINE_BUILTIN_BINARY_OP(unsigned int, uint, sub)
754756
PSNIP_SAFE_DEFINE_BUILTIN_BINARY_OP(unsigned int, uint, mul)
755757
#elif defined(PSNIP_SAFE_HAVE_INTSAFE_H)
756-
PSNIP_SAFE_DEFINE_INTSAFE(unsigned int, uint, add, UIntAdd)
757-
PSNIP_SAFE_DEFINE_INTSAFE(unsigned int, uint, sub, UIntSub)
758-
PSNIP_SAFE_DEFINE_INTSAFE(unsigned int, uint, mul, UIntMult)
758+
PSNIP_SAFE_DEFINE_INTSAFE(UINT, uint, add, UIntAdd)
759+
PSNIP_SAFE_DEFINE_INTSAFE(UINT, uint, sub, UIntSub)
760+
PSNIP_SAFE_DEFINE_INTSAFE(UINT, uint, mul, UIntMult)
759761
#elif defined(PSNIP_SAFE_HAVE_LARGER_UINT)
760762
PSNIP_SAFE_DEFINE_PROMOTED_UNSIGNED_BINARY_OP(unsigned int, uint, add, UINT_MAX)
761763
PSNIP_SAFE_DEFINE_PROMOTED_UNSIGNED_BINARY_OP(unsigned int, uint, sub, UINT_MAX)
@@ -790,9 +792,9 @@ PSNIP_SAFE_DEFINE_BUILTIN_BINARY_OP(unsigned long, ulong, add)
790792
PSNIP_SAFE_DEFINE_BUILTIN_BINARY_OP(unsigned long, ulong, sub)
791793
PSNIP_SAFE_DEFINE_BUILTIN_BINARY_OP(unsigned long, ulong, mul)
792794
#elif defined(PSNIP_SAFE_HAVE_INTSAFE_H)
793-
PSNIP_SAFE_DEFINE_INTSAFE(unsigned long, ulong, add, ULongAdd)
794-
PSNIP_SAFE_DEFINE_INTSAFE(unsigned long, ulong, sub, ULongSub)
795-
PSNIP_SAFE_DEFINE_INTSAFE(unsigned long, ulong, mul, ULongMult)
795+
PSNIP_SAFE_DEFINE_INTSAFE(ULONG, ulong, add, ULongAdd)
796+
PSNIP_SAFE_DEFINE_INTSAFE(ULONG, ulong, sub, ULongSub)
797+
PSNIP_SAFE_DEFINE_INTSAFE(ULONG, ulong, mul, ULongMult)
796798
#elif defined(PSNIP_SAFE_HAVE_LARGER_ULONG)
797799
PSNIP_SAFE_DEFINE_PROMOTED_UNSIGNED_BINARY_OP(unsigned long, ulong, add, ULONG_MAX)
798800
PSNIP_SAFE_DEFINE_PROMOTED_UNSIGNED_BINARY_OP(unsigned long, ulong, sub, ULONG_MAX)
@@ -827,9 +829,9 @@ PSNIP_SAFE_DEFINE_BUILTIN_BINARY_OP(unsigned long long, ullong, add)
827829
PSNIP_SAFE_DEFINE_BUILTIN_BINARY_OP(unsigned long long, ullong, sub)
828830
PSNIP_SAFE_DEFINE_BUILTIN_BINARY_OP(unsigned long long, ullong, mul)
829831
#elif defined(PSNIP_SAFE_HAVE_INTSAFE_H)
830-
PSNIP_SAFE_DEFINE_INTSAFE(unsigned long long, ullong, add, ULongLongAdd)
831-
PSNIP_SAFE_DEFINE_INTSAFE(unsigned long long, ullong, sub, ULongLongSub)
832-
PSNIP_SAFE_DEFINE_INTSAFE(unsigned long long, ullong, mul, ULongLongMult)
832+
PSNIP_SAFE_DEFINE_INTSAFE(ULONGLONG, ullong, add, ULongLongAdd)
833+
PSNIP_SAFE_DEFINE_INTSAFE(ULONGLONG, ullong, sub, ULongLongSub)
834+
PSNIP_SAFE_DEFINE_INTSAFE(ULONGLONG, ullong, mul, ULongLongMult)
833835
#elif defined(PSNIP_SAFE_HAVE_LARGER_ULLONG)
834836
PSNIP_SAFE_DEFINE_PROMOTED_UNSIGNED_BINARY_OP(unsigned long long, ullong, add, ULLONG_MAX)
835837
PSNIP_SAFE_DEFINE_PROMOTED_UNSIGNED_BINARY_OP(unsigned long long, ullong, sub, ULLONG_MAX)

visual_studio/matioConfig.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@
6464
#undef HAVE_INTTYPES_H
6565
#endif
6666

67+
/* Define to 1 if you have the <intsafe.h> header file. */
68+
#if defined(_MSC_VER) && _MSC_VER >= 1600
69+
#define HAVE_INTSAFE_H 1
70+
#else
71+
#undef HAVE_INTSAFE_H
72+
#endif
73+
6774
/* Define to 1 if you have the `m' library (-lm). */
6875
#undef HAVE_LIBM
6976

visual_studio/matio_pubconf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
typedef _mat_uint8_t mat_uint8_t;
154154
#endif
155155

156-
/*
156+
/*
157157
The following macros handle noreturn attributes according to the latest
158158
C11/C++11 standard with fallback to the MSVC extension if using an older
159159
compiler.

0 commit comments

Comments
 (0)