Skip to content

Commit ce31f66

Browse files
committed
Issue 10052: fix failed uint32_t / uint64_t / int32_t / int64_t detection on some platforms.
1 parent 43fb54c commit ce31f66

File tree

4 files changed

+93
-8
lines changed

4 files changed

+93
-8
lines changed

Include/pyport.h

+21-8
Original file line numberDiff line numberDiff line change
@@ -87,33 +87,46 @@ Used in: PY_LONG_LONG
8787
* uint32_t to be such a type unless stdint.h or inttypes.h defines uint32_t.
8888
* However, it doesn't set HAVE_UINT32_T, so we do that here.
8989
*/
90-
#if (defined UINT32_MAX || defined uint32_t)
91-
#ifndef PY_UINT32_T
90+
#ifdef uint32_t
9291
#define HAVE_UINT32_T 1
92+
#endif
93+
94+
#ifdef HAVE_UINT32_T
95+
#ifndef PY_UINT32_T
9396
#define PY_UINT32_T uint32_t
9497
#endif
9598
#endif
9699

97100
/* Macros for a 64-bit unsigned integer type; used for type 'twodigits' in the
98101
* long integer implementation, when 30-bit digits are enabled.
99102
*/
100-
#if (defined UINT64_MAX || defined uint64_t)
101-
#ifndef PY_UINT64_T
103+
#ifdef uint64_t
102104
#define HAVE_UINT64_T 1
105+
#endif
106+
107+
#ifdef HAVE_UINT64_T
108+
#ifndef PY_UINT64_T
103109
#define PY_UINT64_T uint64_t
104110
#endif
105111
#endif
106112

107113
/* Signed variants of the above */
108-
#if (defined INT32_MAX || defined int32_t)
109-
#ifndef PY_INT32_T
114+
#ifdef int32_t
110115
#define HAVE_INT32_T 1
116+
#endif
117+
118+
#ifdef HAVE_INT32_T
119+
#ifndef PY_INT32_T
111120
#define PY_INT32_T int32_t
112121
#endif
113122
#endif
114-
#if (defined INT64_MAX || defined int64_t)
115-
#ifndef PY_INT64_T
123+
124+
#ifdef int64_t
116125
#define HAVE_INT64_T 1
126+
#endif
127+
128+
#ifdef HAVE_INT64_T
129+
#ifndef PY_INT64_T
117130
#define PY_INT64_T int64_t
118131
#endif
119132
#endif

configure

+40
Original file line numberDiff line numberDiff line change
@@ -6755,6 +6755,21 @@ $as_echo "#define gid_t int" >>confdefs.h
67556755

67566756
fi
67576757

6758+
6759+
# There are two separate checks for each of the exact-width integer types we
6760+
# need. First we check whether the type is available using the usual
6761+
# AC_CHECK_TYPE macro with the default includes (which includes <inttypes.h>
6762+
# and <stdint.h> where available). We then also use the special type checks of
6763+
# the form AC_TYPE_UINT32_T, which in the case that uint32_t is not available
6764+
# directly, #define's uint32_t to be a suitable type.
6765+
6766+
ac_fn_c_check_type "$LINENO" "uint32_t" "ac_cv_type_uint32_t" "$ac_includes_default"
6767+
if test "x$ac_cv_type_uint32_t" = xyes; then :
6768+
6769+
$as_echo "#define HAVE_UINT32_T 1" >>confdefs.h
6770+
6771+
fi
6772+
67586773
ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t"
67596774
case $ac_cv_c_uint32_t in #(
67606775
no|yes) ;; #(
@@ -6769,6 +6784,14 @@ _ACEOF
67696784
;;
67706785
esac
67716786

6787+
6788+
ac_fn_c_check_type "$LINENO" "uint64_t" "ac_cv_type_uint64_t" "$ac_includes_default"
6789+
if test "x$ac_cv_type_uint64_t" = xyes; then :
6790+
6791+
$as_echo "#define HAVE_UINT64_T 1" >>confdefs.h
6792+
6793+
fi
6794+
67726795
ac_fn_c_find_uintX_t "$LINENO" "64" "ac_cv_c_uint64_t"
67736796
case $ac_cv_c_uint64_t in #(
67746797
no|yes) ;; #(
@@ -6783,6 +6806,14 @@ _ACEOF
67836806
;;
67846807
esac
67856808

6809+
6810+
ac_fn_c_check_type "$LINENO" "int32_t" "ac_cv_type_int32_t" "$ac_includes_default"
6811+
if test "x$ac_cv_type_int32_t" = xyes; then :
6812+
6813+
$as_echo "#define HAVE_INT32_T 1" >>confdefs.h
6814+
6815+
fi
6816+
67866817
ac_fn_c_find_intX_t "$LINENO" "32" "ac_cv_c_int32_t"
67876818
case $ac_cv_c_int32_t in #(
67886819
no|yes) ;; #(
@@ -6794,6 +6825,14 @@ _ACEOF
67946825
;;
67956826
esac
67966827

6828+
6829+
ac_fn_c_check_type "$LINENO" "int64_t" "ac_cv_type_int64_t" "$ac_includes_default"
6830+
if test "x$ac_cv_type_int64_t" = xyes; then :
6831+
6832+
$as_echo "#define HAVE_INT64_T 1" >>confdefs.h
6833+
6834+
fi
6835+
67976836
ac_fn_c_find_intX_t "$LINENO" "64" "ac_cv_c_int64_t"
67986837
case $ac_cv_c_int64_t in #(
67996838
no|yes) ;; #(
@@ -6805,6 +6844,7 @@ _ACEOF
68056844
;;
68066845
esac
68076846

6847+
68086848
ac_fn_c_check_type "$LINENO" "ssize_t" "ac_cv_type_ssize_t" "$ac_includes_default"
68096849
if test "x$ac_cv_type_ssize_t" = xyes; then :
68106850

configure.ac

+20
Original file line numberDiff line numberDiff line change
@@ -1469,10 +1469,30 @@ AC_TYPE_PID_T
14691469
AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[assume C89 semantics that RETSIGTYPE is always void])
14701470
AC_TYPE_SIZE_T
14711471
AC_TYPE_UID_T
1472+
1473+
# There are two separate checks for each of the exact-width integer types we
1474+
# need. First we check whether the type is available using the usual
1475+
# AC_CHECK_TYPE macro with the default includes (which includes <inttypes.h>
1476+
# and <stdint.h> where available). We then also use the special type checks of
1477+
# the form AC_TYPE_UINT32_T, which in the case that uint32_t is not available
1478+
# directly, #define's uint32_t to be a suitable type.
1479+
1480+
AC_CHECK_TYPE(uint32_t,
1481+
AC_DEFINE(HAVE_UINT32_T, 1, [Define if your compiler provides uint32_t.]),,)
14721482
AC_TYPE_UINT32_T
1483+
1484+
AC_CHECK_TYPE(uint64_t,
1485+
AC_DEFINE(HAVE_UINT64_T, 1, [Define if your compiler provides uint64_t.]),,)
14731486
AC_TYPE_UINT64_T
1487+
1488+
AC_CHECK_TYPE(int32_t,
1489+
AC_DEFINE(HAVE_INT32_T, 1, [Define if your compiler provides int32_t.]),,)
14741490
AC_TYPE_INT32_T
1491+
1492+
AC_CHECK_TYPE(int64_t,
1493+
AC_DEFINE(HAVE_INT64_T, 1, [Define if your compiler provides int64_t.]),,)
14751494
AC_TYPE_INT64_T
1495+
14761496
AC_CHECK_TYPE(ssize_t,
14771497
AC_DEFINE(HAVE_SSIZE_T, 1, [Define if your compiler provides ssize_t]),,)
14781498

pyconfig.h.in

+12
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,12 @@
377377
/* Define to 1 if you have the `initgroups' function. */
378378
#undef HAVE_INITGROUPS
379379

380+
/* Define if your compiler provides int32_t. */
381+
#undef HAVE_INT32_T
382+
383+
/* Define if your compiler provides int64_t. */
384+
#undef HAVE_INT64_T
385+
380386
/* Define to 1 if you have the <inttypes.h> header file. */
381387
#undef HAVE_INTTYPES_H
382388

@@ -863,6 +869,12 @@
863869
/* Define this if you have tcl and TCL_UTF_MAX==6 */
864870
#undef HAVE_UCS4_TCL
865871

872+
/* Define if your compiler provides uint32_t. */
873+
#undef HAVE_UINT32_T
874+
875+
/* Define if your compiler provides uint64_t. */
876+
#undef HAVE_UINT64_T
877+
866878
/* Define to 1 if the system has the type `uintptr_t'. */
867879
#undef HAVE_UINTPTR_T
868880

0 commit comments

Comments
 (0)