Skip to content

Commit 6a53dbc

Browse files
committed
[Win32] Define I_STDCKDINT and $Config{i_stdckdint} when appropriate.
For context and further info see: #23703
1 parent b7b77ff commit 6a53dbc

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-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
@@ -148,6 +148,12 @@ my $ver = `ver 2>nul`;
148148
$opt{osvers} = $ver =~ /\b(\d+(?:\.\d+)+)\b/ ? $1 : '4.0';
149149

150150
if (exists $opt{cc}) {
151+
`$opt{cc} -o have_stdckdint.exe configure/have_stdckdint.c 1>nul 2>&1`;
152+
if (-e 'have_stdckdint.exe') {
153+
$opt{i_stdckdint} = 'define' if `have_stdckdint` eq '0';
154+
unlink 'have_stdckdint.exe'; # have_stdckdint.exe no longer needed
155+
}
156+
151157
# cl version detection borrowed from Test::Smoke's configsmoke.pl
152158
if ($opt{cc} =~ /\b(?:cl|icl)/) { #MSVC can come as clarm.exe, icl=Intel C
153159
my $output = `$opt{cc} 2>&1`;

win32/configure/have_stdckdint.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
11+
#include <stdio.h>
12+
#include <stdckdint.h>
13+
int func_l(long *resultptr, long a, long b) {
14+
return (ckd_add(resultptr, a, b) ||
15+
ckd_sub(resultptr, a, b) ||
16+
ckd_mul(resultptr, a, b)) ? 1 : 0;
17+
}
18+
19+
int func_ll(long long *resultptr, long long a, long long b) {
20+
return (ckd_add(resultptr, a, b) ||
21+
ckd_sub(resultptr, a, b) ||
22+
ckd_mul(resultptr, a, b)) ? 1 : 0;
23+
}
24+
25+
int main(int argc, char **argv) {
26+
long lresult_1, lresult_2;
27+
long long llresult_1, llresult_2;
28+
int ret, lret_1, lret_2, llret_1, llret_2;
29+
lret_1 = func_l(&lresult_1, 42L, 53L);
30+
lret_2 = func_l(&lresult_2, 10485777L, 1048555L);
31+
llret_1 = func_ll(&llresult_1, 42LL, 53LL);
32+
llret_2 = func_ll(&llresult_2, 34359738333LL, 34359738887LL);
33+
34+
if(lret_1 == 0 && llret_1 == 0 &&
35+
lret_2 == 1 && llret_2 == 1 &&
36+
lresult_1 == 2226L && llresult_1 == 2226LL &&
37+
lresult_2 == -202375525L && llresult_2 == 16630113351947LL ) ret = 0;
38+
else ret = -1;
39+
printf("%d", ret);
40+
return 0;
41+
}
42+

0 commit comments

Comments
 (0)