Skip to content

Commit fffe642

Browse files
authored
Remove HAVE_PTRDIFF_T and SIZEOF_PTRDIFF_T (#18968)
The ptrdiff_t is a C89 standard type defined in `<stddef.h>` and widely available on current platforms. Using it conditionally as in these occurrences is not needed anymore.
1 parent 984bcb5 commit fffe642

File tree

7 files changed

+4
-33
lines changed

7 files changed

+4
-33
lines changed

UPGRADING.INTERNALS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ PHP 8.5 INTERNALS UPGRADE NOTES
5050
2. Build system changes
5151
========================
5252

53+
- Abstract
54+
. Preprocessor macro SIZEOF_PTRDIFF_T has been removed.
55+
5356
- Windows build system changes
5457
. SAPI() and ADD_SOURCES() now suport the optional `duplicate_sources`
5558
parameter. If truthy, no rules to build the object files are generated.
@@ -69,6 +72,7 @@ PHP 8.5 INTERNALS UPGRADE NOTES
6972
. Autoconf macro PHP_DEF_HAVE has been removed (use AC_DEFINE).
7073
. Autoconf macro PHP_OUTPUT has been removed (use AC_CONFIG_FILES).
7174
. Autoconf macro PHP_TEST_BUILD has been removed (use AC_* macros).
75+
. Preprocessor macro HAVE_PTRDIFF_T has been removed.
7276

7377
========================
7478
3. Module changes

configure.ac

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,6 @@ AC_CHECK_TYPES([socklen_t], [], [], [
454454
dnl These are defined elsewhere than stdio.h.
455455
PHP_CHECK_SIZEOF([intmax_t], [0])
456456
PHP_CHECK_SIZEOF([ssize_t], [8])
457-
PHP_CHECK_SIZEOF([ptrdiff_t], [8])
458457

459458
dnl Check stdint types (must be after header check).
460459
PHP_CHECK_STDINT_TYPES

ext/intl/collator/collator_sort.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
#include "collator_convert.h"
2525
#include "intl_convert.h"
2626

27-
#if !defined(HAVE_PTRDIFF_T) && !defined(_PTRDIFF_T_DEFINED)
28-
typedef zend_long ptrdiff_t;
29-
#endif
30-
3127
/**
3228
* Declare 'index' which will point to sort key in sort key
3329
* buffer.

main/snprintf.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -621,11 +621,7 @@ static size_t format_converter(buffy * odp, const char *fmt, va_list ap) /* {{{
621621
break;
622622
case 't':
623623
fmt++;
624-
#if SIZEOF_PTRDIFF_T
625624
modifier = LM_PTRDIFF_T;
626-
#else
627-
modifier = LM_SIZE_T;
628-
#endif
629625
break;
630626
case 'p':
631627
{
@@ -694,11 +690,9 @@ static size_t format_converter(buffy * odp, const char *fmt, va_list ap) /* {{{
694690
i_num = (int64_t) va_arg(ap, uintmax_t);
695691
break;
696692
#endif
697-
#if SIZEOF_PTRDIFF_T
698693
case LM_PTRDIFF_T:
699694
i_num = (int64_t) va_arg(ap, ptrdiff_t);
700695
break;
701-
#endif
702696
}
703697
/*
704698
* The rest also applies to other integer formats, so fall
@@ -737,11 +731,9 @@ static size_t format_converter(buffy * odp, const char *fmt, va_list ap) /* {{{
737731
i_num = (int64_t) va_arg(ap, intmax_t);
738732
break;
739733
#endif
740-
#if SIZEOF_PTRDIFF_T
741734
case LM_PTRDIFF_T:
742735
i_num = (int64_t) va_arg(ap, ptrdiff_t);
743736
break;
744-
#endif
745737
}
746738
}
747739
s = ap_php_conv_10(i_num, (*fmt) == 'u', &is_negative,
@@ -783,11 +775,9 @@ static size_t format_converter(buffy * odp, const char *fmt, va_list ap) /* {{{
783775
ui_num = (uint64_t) va_arg(ap, uintmax_t);
784776
break;
785777
#endif
786-
#if SIZEOF_PTRDIFF_T
787778
case LM_PTRDIFF_T:
788779
ui_num = (uint64_t) va_arg(ap, ptrdiff_t);
789780
break;
790-
#endif
791781
}
792782
s = ap_php_conv_p2(ui_num, 3, *fmt, &num_buf[NUM_BUF_SIZE], &s_len);
793783
FIX_PRECISION(adjust_precision, precision, s, s_len);
@@ -822,11 +812,9 @@ static size_t format_converter(buffy * odp, const char *fmt, va_list ap) /* {{{
822812
ui_num = (uint64_t) va_arg(ap, uintmax_t);
823813
break;
824814
#endif
825-
#if SIZEOF_PTRDIFF_T
826815
case LM_PTRDIFF_T:
827816
ui_num = (uint64_t) va_arg(ap, ptrdiff_t);
828817
break;
829-
#endif
830818
}
831819
s = ap_php_conv_p2(ui_num, 4, *fmt, &num_buf[NUM_BUF_SIZE], &s_len);
832820
FIX_PRECISION(adjust_precision, precision, s, s_len);

main/snprintf.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@ typedef enum {
116116
#if SIZEOF_INTMAX_T
117117
LM_INTMAX_T,
118118
#endif
119-
#if SIZEOF_PTRDIFF_T
120119
LM_PTRDIFF_T,
121-
#endif
122120
#if SIZEOF_LONG_LONG
123121
LM_LONG_LONG,
124122
#endif

main/spprintf.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,7 @@ static void xbuf_format_converter(void *xbuf, bool is_char, const char *fmt, va_
321321
break;
322322
case 't':
323323
fmt++;
324-
#if SIZEOF_PTRDIFF_T
325324
modifier = LM_PTRDIFF_T;
326-
#else
327-
modifier = LM_SIZE_T;
328-
#endif
329325
break;
330326
case 'p':
331327
{
@@ -403,11 +399,9 @@ static void xbuf_format_converter(void *xbuf, bool is_char, const char *fmt, va_
403399
i_num = (int64_t) va_arg(ap, uintmax_t);
404400
break;
405401
#endif
406-
#if SIZEOF_PTRDIFF_T
407402
case LM_PTRDIFF_T:
408403
i_num = (int64_t) va_arg(ap, ptrdiff_t);
409404
break;
410-
#endif
411405
}
412406
/*
413407
* The rest also applies to other integer formats, so fall
@@ -446,11 +440,9 @@ static void xbuf_format_converter(void *xbuf, bool is_char, const char *fmt, va_
446440
i_num = (int64_t) va_arg(ap, intmax_t);
447441
break;
448442
#endif
449-
#if SIZEOF_PTRDIFF_T
450443
case LM_PTRDIFF_T:
451444
i_num = (int64_t) va_arg(ap, ptrdiff_t);
452445
break;
453-
#endif
454446
}
455447
}
456448
s = ap_php_conv_10(i_num, (*fmt) == 'u', &is_negative,
@@ -491,11 +483,9 @@ static void xbuf_format_converter(void *xbuf, bool is_char, const char *fmt, va_
491483
ui_num = (uint64_t) va_arg(ap, uintmax_t);
492484
break;
493485
#endif
494-
#if SIZEOF_PTRDIFF_T
495486
case LM_PTRDIFF_T:
496487
ui_num = (uint64_t) va_arg(ap, ptrdiff_t);
497488
break;
498-
#endif
499489
}
500490
s = ap_php_conv_p2(ui_num, 3, *fmt,
501491
&num_buf[NUM_BUF_SIZE], &s_len);
@@ -531,11 +521,9 @@ static void xbuf_format_converter(void *xbuf, bool is_char, const char *fmt, va_
531521
ui_num = (uint64_t) va_arg(ap, uintmax_t);
532522
break;
533523
#endif
534-
#if SIZEOF_PTRDIFF_T
535524
case LM_PTRDIFF_T:
536525
ui_num = (uint64_t) va_arg(ap, ptrdiff_t);
537526
break;
538-
#endif
539527
}
540528
s = ap_php_conv_p2(ui_num, 4, *fmt,
541529
&num_buf[NUM_BUF_SIZE], &s_len);

win32/build/config.w32.h.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,8 @@
8484
#define ssize_t SSIZE_T
8585
#ifdef _WIN64
8686
# define SIZEOF_SIZE_T 8
87-
# define SIZEOF_PTRDIFF_T 8
8887
#else
8988
# define SIZEOF_SIZE_T 4
90-
# define SIZEOF_PTRDIFF_T 4
9189
#endif
9290
#define SIZEOF_OFF_T 4
9391
#define HAVE_FNMATCH

0 commit comments

Comments
 (0)