Skip to content

Commit 6f0a8f8

Browse files
committed
allow building against WinSDK 10.0.22621.0
1 parent 0a55e1a commit 6f0a8f8

File tree

3 files changed

+51
-7
lines changed

3 files changed

+51
-7
lines changed

c2d/idl2d.d

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,22 @@ class idl2d
622622
case "RtlFlushNonVolatileMemoryRanges":
623623
return 1;
624624

625+
// SDK 10.0.22621.0
626+
case "WIN_NOEXCEPT":
627+
case "ReadLongPtrAcquire":
628+
case "ReadLongPtrNoFence":
629+
case "ReadLongPtrRaw":
630+
case "WriteLongPtrRelease":
631+
case "WriteLongPtrNoFence":
632+
case "WriteLongPtrRaw":
633+
case "ReadULongPtrAcquire":
634+
case "ReadULongPtrNoFence":
635+
case "ReadULongPtrRaw":
636+
case "WriteULongPtrRelease":
637+
case "WriteULongPtrNoFence":
638+
case "WriteULongPtrRaw":
639+
return 1;
640+
625641
default:
626642
break;
627643
}
@@ -1086,6 +1102,8 @@ version(all)
10861102
while(replaceTokenSequence(tokens, "$_not $_ident($_ident1)($expr)", "$_not cast($_ident1)($expr)", true) > 0) {}
10871103
replaceTokenSequence(tokens, "$_not $_ident($_ident1)cast", "$_not cast($_ident1)cast", true);
10881104
replaceTokenSequence(tokens, "$_not $_ident($_ident1*)$_not_semi;", "$_not cast($_ident1*)$_not_semi", true);
1105+
replaceTokenSequence(tokens, "$_not $_ident(const $_ident1*)$_not_semi;", "$_not cast(const $_ident1*)$_not_semi", true);
1106+
replaceTokenSequence(tokens, "$_not $_ident(volatile const $_ident1*)$_not_semi;", "$_not cast(volatile const $_ident1*)$_not_semi", true);
10891107
replaceTokenSequence(tokens, "$_not $_ident(struct $_ident1*)$_not_semi;", "$_not cast(struct $_ident1*)$_not_semi", true);
10901108
replaceTokenSequence(tokens, "$_not $_ident($_ident1 $_ident2*)", "$_not cast($_ident1 $_ident2*)", true);
10911109
replaceTokenSequence(tokens, "HRESULT cast", "HRESULT", true);
@@ -1270,6 +1288,11 @@ version(all)
12701288
replaceTokenSequence(tokens, "#ifndef TRUE\n#define TRUE$def\n#endif\n", "#define TRUE 1\n", false);
12711289
}
12721290

1291+
if(currentModule == "memoryapi")
1292+
{
1293+
replaceTokenSequence(tokens, "typedef struct DECLSPEC_ALIGN($_num)", "align($_num) typedef struct", true);
1294+
}
1295+
12731296
if(currentModule == "winnt")
12741297
{
12751298
replaceTokenSequence(tokens, "#if defined(MIDL_PASS)\ntypedef struct $_ident {\n"
@@ -1299,6 +1322,11 @@ version(all)
12991322

13001323
replaceTokenSequence(tokens, "RtlZeroMemory($dest,$length)",
13011324
"import core.stdc.string: memset; memset($dest,0,$length)", true);
1325+
// win 10.0.22621.0: duplicate definition
1326+
replaceTokenSequence(tokens, "POWER_SETTING_ALTITUDE, *PPOWER_SETTING_ALTITUDE;",
1327+
"*PPOWER_SETTING_ALTITUDE;", true);
1328+
replaceTokenSequence(tokens, "FORCEINLINE BYTE ReadUCharAcquire $code WriteULong64Raw($args) { $code2 }",
1329+
"/+ $* +/", true);
13021330
}
13031331

13041332
if(currentModule == "commctrl")
@@ -1385,7 +1413,10 @@ version(all)
13851413
// type name and field name identical
13861414
replaceTokenSequence(tokens, "ImageMoniker ImageMoniker;", "ImageMoniker mImageMoniker;", true);
13871415
}
1388-
1416+
if(currentModule.startsWith("webprop"))
1417+
{
1418+
replaceTokenSequence(tokens, "importlib(\"Microsoft.VisualStudio.Interop.tlb\");", "/+ $* +/;", true);
1419+
}
13891420
// select unicode version of the API when defining without postfix A/W
13901421
replaceTokenSequence(tokens, "#ifdef UNICODE\nreturn $_identW(\n#else\nreturn $_identA(\n#endif\n",
13911422
" return $_identW(", false);
@@ -1573,6 +1604,8 @@ version(all)
15731604
enums[tok.text] = true;
15741605
break;
15751606
}
1607+
if(indexOf(tok.pretext, "\\\n") >= 0)
1608+
tok.pretext = replace(tok.pretext, "\\\n", "\n");
15761609
prevtext = tok.text;
15771610
++tokIt;
15781611
}
@@ -1653,6 +1686,10 @@ version(none) version(vsi)
16531686
replaceTokenSequence(tokens, "InterlockedCompareExchange($args __in LONG ExChange, __in LONG Comperand);", "$* +/", true);
16541687
replaceTokenSequence(tokens, "InterlockedOr(&Barrier, 0);", "InterlockedExchangeAdd(&Barrier, 0);", true); // InterlockedOr exist only as intrinsic
16551688
}
1689+
if (currentModule == "winerror")
1690+
{
1691+
replaceTokenSequence(tokens, "HRESULT HRESULT_FROM_SETUPAPI($args) { $code }", "/+ $* +/", true);
1692+
}
16561693
if(currentModule == "ocidl")
16571694
{
16581695
// move alias out of interface declaration, it causes circular definitions with dmd 2.065+
@@ -2134,6 +2171,8 @@ else
21342171
TokenIterator inAlias = tokens.end();
21352172
for(TokenIterator tokIt = tokens.begin(); !tokIt.atEnd(); ++tokIt)
21362173
{
2174+
bool isAssign(string txt) { return txt == "=" || txt == "&=" || txt == "|=" || txt == "+=" || txt == "-="; }
2175+
21372176
Token tok = *tokIt;
21382177
//tok.pretext = tok.pretext.replace("//D", "");
21392178
tok.text = translateToken(tok.text);
@@ -2150,8 +2189,9 @@ else
21502189
}
21512190
else if(tok.text == "[" && tokIt[1].text != "]")
21522191
{
2153-
if((tokIt.atBegin() || tokIt[-1].text != "{" || tokIt[-2].text != "=") &&
2192+
if((tokIt.atBegin() || tokIt[-1].text != "{" || !isAssign(tokIt[-2].text)) &&
21542193
(tokIt[1].type != Token.Number || tokIt[2].text != "]") &&
2194+
tokIt[1].text != "i" && // RtlConstantTimeEqualMemory
21552195
(tokIt[2].text != "]" || tokIt[3].text != ";"))
21562196
{
21572197
TokenIterator bit = tokIt;
@@ -2168,8 +2208,9 @@ else
21682208
{
21692209
TokenIterator openit = tokIt;
21702210
if(retreatToOpeningBracket(openit) &&
2171-
(openit.atBegin || (openit-1).atBegin || openit[-1].text != "{" || openit[-2].text != "="))
2211+
(openit.atBegin || (openit-1).atBegin || openit[-1].text != "{" || !isAssign(openit[-2].text)))
21722212
if((tokIt[-1].type != Token.Number || tokIt[-2].text != "[") &&
2213+
tokIt[-1].text != "i" && // RtlConstantTimeEqualMemory
21732214
(tokIt[-2].text != "[" || tokIt[1].text != ";"))
21742215
tok.text = "]+/";
21752216
}
@@ -2900,8 +2941,8 @@ unittest
29002941
string exptxt = "
29012942
int convert() { return " ~ "
29022943
hello; }
2903-
// #define noconvert(n,m) \\
2904-
// hallo1 |\\
2944+
// #define noconvert(n,m)
2945+
// hallo1 |
29052946
// hallo2
29062947
";
29072948
version(macro2template) exptxt = replace(exptxt, "int", "auto");

sdk/port/base.d

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ enum CCM_TRANSLATEACCELERATOR = (WM_USER+97);
175175
// msdbg*.d
176176
alias ULONG32 XINT32;
177177

178+
// Win SDK 10.0.22621.0
179+
struct _UNWIND_HISTORY_TABLE;
180+
178181
version(sdk) {}
179182
else {
180183

vdc/dmdserver/dmdserver.visualdproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@
572572
<addDepImp>0</addDepImp>
573573
<program>c:\l\d\dmd2\windows\bin\dmd.exe</program>
574574
<imppath>dmd\src ..\..</imppath>
575-
<fileImppath>dmd dmd\src\dmd\res</fileImppath>
575+
<fileImppath>dmd dmd\res dmd\src\dmd\res</fileImppath>
576576
<outdir>..\..\bin\$(ConfigurationName)</outdir>
577577
<objdir>$(OutDir)\$(PlatformName)\$(ProjectName)</objdir>
578578
<objname />
@@ -1072,7 +1072,7 @@
10721072
<addDepImp>0</addDepImp>
10731073
<program>c:\l\d\dmd2\windows\bin\dmd.exe</program>
10741074
<imppath>dmd\src ..\..</imppath>
1075-
<fileImppath>dmd dmd\res</fileImppath>
1075+
<fileImppath>dmd dmd\res dmd\src\dmd\res</fileImppath>
10761076
<outdir>..\..\bin\$(ConfigurationName)</outdir>
10771077
<objdir>$(OutDir)\$(PlatformName)\$(ProjectName)</objdir>
10781078
<objname />

0 commit comments

Comments
 (0)