Skip to content

Remove HAVE_PTRDIFF_T and SIZEOF_PTRDIFF_T #18968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ PHP 8.5 INTERNALS UPGRADE NOTES
2. Build system changes
========================

- Abstract
. Preprocessor macro SIZEOF_PTRDIFF_T has been removed.

- Windows build system changes
. SAPI() and ADD_SOURCES() now suport the optional `duplicate_sources`
parameter. If truthy, no rules to build the object files are generated.
Expand All @@ -69,6 +72,7 @@ PHP 8.5 INTERNALS UPGRADE NOTES
. Autoconf macro PHP_DEF_HAVE has been removed (use AC_DEFINE).
. Autoconf macro PHP_OUTPUT has been removed (use AC_CONFIG_FILES).
. Autoconf macro PHP_TEST_BUILD has been removed (use AC_* macros).
. Preprocessor macro HAVE_PTRDIFF_T has been removed.

========================
3. Module changes
Expand Down
1 change: 0 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ AC_CHECK_TYPES([socklen_t], [], [], [
dnl These are defined elsewhere than stdio.h.
PHP_CHECK_SIZEOF([intmax_t], [0])
Copy link
Member

@Girgias Girgias Jun 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential follow-up, we don't need to check for intmax_t as it is a C99 type and we require C99

Just saw you opened: #18971

PHP_CHECK_SIZEOF([ssize_t], [8])
PHP_CHECK_SIZEOF([ptrdiff_t], [8])

dnl Check stdint types (must be after header check).
PHP_CHECK_STDINT_TYPES
Expand Down
4 changes: 0 additions & 4 deletions ext/intl/collator/collator_sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
#include "collator_convert.h"
#include "intl_convert.h"

#if !defined(HAVE_PTRDIFF_T) && !defined(_PTRDIFF_T_DEFINED)
typedef zend_long ptrdiff_t;
#endif

/**
* Declare 'index' which will point to sort key in sort key
* buffer.
Expand Down
12 changes: 0 additions & 12 deletions main/snprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -621,11 +621,7 @@ static size_t format_converter(buffy * odp, const char *fmt, va_list ap) /* {{{
break;
case 't':
fmt++;
#if SIZEOF_PTRDIFF_T
modifier = LM_PTRDIFF_T;
#else
modifier = LM_SIZE_T;
#endif
break;
case 'p':
{
Expand Down Expand Up @@ -694,11 +690,9 @@ static size_t format_converter(buffy * odp, const char *fmt, va_list ap) /* {{{
i_num = (int64_t) va_arg(ap, uintmax_t);
break;
#endif
#if SIZEOF_PTRDIFF_T
case LM_PTRDIFF_T:
i_num = (int64_t) va_arg(ap, ptrdiff_t);
break;
#endif
}
/*
* The rest also applies to other integer formats, so fall
Expand Down Expand Up @@ -737,11 +731,9 @@ static size_t format_converter(buffy * odp, const char *fmt, va_list ap) /* {{{
i_num = (int64_t) va_arg(ap, intmax_t);
break;
#endif
#if SIZEOF_PTRDIFF_T
case LM_PTRDIFF_T:
i_num = (int64_t) va_arg(ap, ptrdiff_t);
break;
#endif
}
}
s = ap_php_conv_10(i_num, (*fmt) == 'u', &is_negative,
Expand Down Expand Up @@ -783,11 +775,9 @@ static size_t format_converter(buffy * odp, const char *fmt, va_list ap) /* {{{
ui_num = (uint64_t) va_arg(ap, uintmax_t);
break;
#endif
#if SIZEOF_PTRDIFF_T
case LM_PTRDIFF_T:
ui_num = (uint64_t) va_arg(ap, ptrdiff_t);
break;
#endif
}
s = ap_php_conv_p2(ui_num, 3, *fmt, &num_buf[NUM_BUF_SIZE], &s_len);
FIX_PRECISION(adjust_precision, precision, s, s_len);
Expand Down Expand Up @@ -822,11 +812,9 @@ static size_t format_converter(buffy * odp, const char *fmt, va_list ap) /* {{{
ui_num = (uint64_t) va_arg(ap, uintmax_t);
break;
#endif
#if SIZEOF_PTRDIFF_T
case LM_PTRDIFF_T:
ui_num = (uint64_t) va_arg(ap, ptrdiff_t);
break;
#endif
}
s = ap_php_conv_p2(ui_num, 4, *fmt, &num_buf[NUM_BUF_SIZE], &s_len);
FIX_PRECISION(adjust_precision, precision, s, s_len);
Expand Down
2 changes: 0 additions & 2 deletions main/snprintf.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ typedef enum {
#if SIZEOF_INTMAX_T
LM_INTMAX_T,
#endif
#if SIZEOF_PTRDIFF_T
LM_PTRDIFF_T,
#endif
#if SIZEOF_LONG_LONG
LM_LONG_LONG,
#endif
Expand Down
12 changes: 0 additions & 12 deletions main/spprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,7 @@ static void xbuf_format_converter(void *xbuf, bool is_char, const char *fmt, va_
break;
case 't':
fmt++;
#if SIZEOF_PTRDIFF_T
modifier = LM_PTRDIFF_T;
#else
modifier = LM_SIZE_T;
#endif
break;
case 'p':
{
Expand Down Expand Up @@ -403,11 +399,9 @@ static void xbuf_format_converter(void *xbuf, bool is_char, const char *fmt, va_
i_num = (int64_t) va_arg(ap, uintmax_t);
break;
#endif
#if SIZEOF_PTRDIFF_T
case LM_PTRDIFF_T:
i_num = (int64_t) va_arg(ap, ptrdiff_t);
break;
#endif
}
/*
* The rest also applies to other integer formats, so fall
Expand Down Expand Up @@ -446,11 +440,9 @@ static void xbuf_format_converter(void *xbuf, bool is_char, const char *fmt, va_
i_num = (int64_t) va_arg(ap, intmax_t);
break;
#endif
#if SIZEOF_PTRDIFF_T
case LM_PTRDIFF_T:
i_num = (int64_t) va_arg(ap, ptrdiff_t);
break;
#endif
}
}
s = ap_php_conv_10(i_num, (*fmt) == 'u', &is_negative,
Expand Down Expand Up @@ -491,11 +483,9 @@ static void xbuf_format_converter(void *xbuf, bool is_char, const char *fmt, va_
ui_num = (uint64_t) va_arg(ap, uintmax_t);
break;
#endif
#if SIZEOF_PTRDIFF_T
case LM_PTRDIFF_T:
ui_num = (uint64_t) va_arg(ap, ptrdiff_t);
break;
#endif
}
s = ap_php_conv_p2(ui_num, 3, *fmt,
&num_buf[NUM_BUF_SIZE], &s_len);
Expand Down Expand Up @@ -531,11 +521,9 @@ static void xbuf_format_converter(void *xbuf, bool is_char, const char *fmt, va_
ui_num = (uint64_t) va_arg(ap, uintmax_t);
break;
#endif
#if SIZEOF_PTRDIFF_T
case LM_PTRDIFF_T:
ui_num = (uint64_t) va_arg(ap, ptrdiff_t);
break;
#endif
}
s = ap_php_conv_p2(ui_num, 4, *fmt,
&num_buf[NUM_BUF_SIZE], &s_len);
Expand Down
2 changes: 0 additions & 2 deletions win32/build/config.w32.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,8 @@
#define ssize_t SSIZE_T
#ifdef _WIN64
# define SIZEOF_SIZE_T 8
# define SIZEOF_PTRDIFF_T 8
#else
# define SIZEOF_SIZE_T 4
# define SIZEOF_PTRDIFF_T 4
#endif
#define SIZEOF_OFF_T 4
#define HAVE_FNMATCH
Expand Down