Skip to content

Commit 00505d6

Browse files
committed
Define $Config{i_stdckdint} and 'I_STDCKDINT' when stdckdint.h is locatable && functional.
For more info and context, see: #23703
1 parent 3858926 commit 00505d6

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

MANIFEST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6788,6 +6788,7 @@ win32/config_H.gc Win32 config header (MinGW build)
67886788
win32/config_h.PL Perl code to convert Win32 config.sh to config.h
67896789
win32/config_H.vc Win32 config header (Visual C++ build)
67906790
win32/config_sh.PL Perl code to update Win32 config.sh from Makefile
6791+
win32/configure/have_stdckdint.c check for availability of stdckdint.h
67916792
win32/configure/rt.c identify default runtime
67926793
win32/create_perllibst_h.pl creates perllibst.h file for inclusion from perllib.c
67936794
win32/distclean.bat Remove _ALL_ files not listed here in MANIFEST

win32/config_sh.PL

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ if (exists $opt{cc}) {
158158
chomp($opt{libc} = `$opt{cc} -o rt.exe configure/rt.c 1>nul 2>&1 && rt`);
159159
if(-e 'rt.exe') { unlink 'rt.exe' } # rt.exe no longer needed
160160
else { die "Failed to identify default runtime" }
161+
162+
`$opt{cc} -o have_stdckdint.exe configure/have_stdckdint.c 1>nul 2>&1`;
163+
if(-e 'have_stdckdint.exe') {
164+
$opt{i_stdckdint} = 'define' if `have_stdckdint` eq '0';
165+
unlink 'have_stdckdint.exe'; # have_stdckdint.exe no longer needed
166+
}
161167
}
162168
}
163169

win32/configure/have_stdckdint.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
Check whether stdckdint.h functionality is available.
3+
If it's available, then 'have_stdckdint.exe' will be created
4+
by config_sh.PL.
5+
$Config{i_stdckdint} and the XS symbol I_STDCKDINT will be
6+
defined if and only if 'have_stdckdint.exe' prints '0'
7+
when executed.
8+
Else $Config{i_stdckdint} and I_STDCKDINT will be undef.
9+
10+
The stdckdint.h functionality should be available only if
11+
gcc version >= 14 && $Config{cc} is 'gcc'.
12+
*/
13+
14+
#include <stdio.h>
15+
#include <stdckdint.h>
16+
int func_l(long *resultptr, long a, long b) {
17+
return (ckd_add(resultptr, a, b) ||
18+
ckd_sub(resultptr, a, b) ||
19+
ckd_mul(resultptr, a, b)) ? 1 : 0;
20+
}
21+
22+
int func_ll(long long *resultptr, long long a, long long b) {
23+
return (ckd_add(resultptr, a, b) ||
24+
ckd_sub(resultptr, a, b) ||
25+
ckd_mul(resultptr, a, b)) ? 1 : 0;
26+
}
27+
28+
int main(int argc, char **argv) {
29+
long lresult_1, lresult_2;
30+
long long llresult_1, llresult_2;
31+
int ret, lret_1, lret_2, llret_1, llret_2;
32+
lret_1 = func_l(&lresult_1, 42L, 53L);
33+
lret_2 = func_l(&lresult_2, 10485777L, 1048555L);
34+
llret_1 = func_ll(&llresult_1, 42LL, 53LL);
35+
llret_2 = func_ll(&llresult_2, 34359738333LL, 34359738887LL);
36+
37+
if(lret_1 == 0 && llret_1 == 0 &&
38+
lret_2 == 1 && llret_2 == 1 &&
39+
lresult_1 == 2226L && llresult_1 == 2226LL &&
40+
lresult_2 == -202375525L && llresult_2 == 16630113351947LL ) ret = 0;
41+
else ret = -1;
42+
printf("%d", ret);
43+
return 0;
44+
}
45+

0 commit comments

Comments
 (0)