Thread overview
[Issue 24130] ImportC: Windows headers use inline asm with different syntax
[Issue 24130] ImportC: Windows - Cannot build nearly program that uses most system headers as 32-bit.
Sep 01, 2023
Jeffrey H. Johnson
Sep 05, 2023
Walter Bright
Sep 05, 2023
Jeffrey H. Johnson
Sep 06, 2023
anonymous4
Sep 06, 2023
Jeffrey H. Johnson
Sep 09, 2023
Walter Bright
Sep 09, 2023
Walter Bright
Sep 09, 2023
Dlang Bot
Sep 11, 2023
Dlang Bot
Sep 11, 2023
anonymous4
September 01, 2023
https://issues.dlang.org/show_bug.cgi?id=24130

Jeffrey H. Johnson <trnsz@pobox.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |trnsz@pobox.com

--
September 05, 2023
https://issues.dlang.org/show_bug.cgi?id=24130

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> ---
Can you please take a look at the generated test.i file and post which lines in it are failing?

--
September 05, 2023
https://issues.dlang.org/show_bug.cgi?id=24130

--- Comment #2 from Jeffrey H. Johnson <trnsz@pobox.com> ---
(In reply to Walter Bright from comment #1)
> Can you please take a look at the generated test.i file and post which lines in it are failing?

Yes, I'll try to get this done today.

--
September 06, 2023
https://issues.dlang.org/show_bug.cgi?id=24130

--- Comment #3 from anonymous4 <dfj1esp02@sneakemail.com> ---
I have this code around that line:

__inline ULONGLONG
NTAPI
Int64ShrlMod32 (
    _In_ ULONGLONG Value,
    _In_ DWORD ShiftCount
    )
{
    __asm    {
        mov     ecx, ShiftCount
        mov     eax, dword ptr [Value]
        mov     edx, dword ptr [Value+4]
        shrd    eax, edx, cl
        shr     edx, cl
    }
}

So D complains about absence of semicolon after the asm statement.

--
September 06, 2023
https://issues.dlang.org/show_bug.cgi?id=24130

--- Comment #4 from Jeffrey H. Johnson <trnsz@pobox.com> ---
> So D complains about absence of semicolon after the asm statement.

Can confirm.

--
September 09, 2023
https://issues.dlang.org/show_bug.cgi?id=24130

--- Comment #5 from Walter Bright <bugzilla@digitalmars.com> ---
Looking at the file winnt.h, the inline assembler:

--------------
#if defined(MIDL_PASS) || defined(RC_INVOKED) || defined(_M_CEE_PURE) \
    || defined(_68K_) || defined(_MPPC_) \
    || defined(_M_IA64) || defined(_M_AMD64) || defined(_M_ARM) ||
defined(_M_ARM64) \
    || defined(_M_HYBRID_X86_ARM64)

//
// Midl does not understand inline assembler. Therefore, the Rtl functions
// are used for shifts by 0..31 and multiplies of 32-bits times 32-bits to
// form a 64-bit product.
//
//
// IA64 and AMD64 have native 64-bit operations that are just as fast as their
// 32-bit counter parts. Therefore, the int64 data type is used directly to
form
// shifts of 0..31 and multiplies of 32-bits times 32-bits to form a 64-bit
// product.
//

#define Int32x32To64(a, b)  (((__int64)((long)(a))) * ((__int64)((long)(b))))
#define UInt32x32To64(a, b) (((unsigned __int64)((unsigned int)(a))) *
((unsigned __int64)((unsigned int)(b))))

#define Int64ShllMod32(a, b) (((unsigned __int64)(a)) << (b))
#define Int64ShraMod32(a, b) (((__int64)(a)) >> (b))
#define Int64ShrlMod32(a, b) (((unsigned __int64)(a)) >> (b))


#elif defined(_M_IX86)

... inline assembler versions go here ...

#endif
---------------------------------

And, well, the inline assembler format is different than ImportC's.

So, try #define'ing _M_CEE_PURE to be 1 and see if that helps.


As for the line 13826 errors, I cannot find "i64" in the version of winnt.h that I have. Perhaps you could quote the offending lines, please?

--
September 09, 2023
https://issues.dlang.org/show_bug.cgi?id=24130

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |iasm, ImportC
            Summary|ImportC: Windows - Cannot   |ImportC: Windows headers
                   |build nearly program that   |use inline asm with
                   |uses most system headers as |different syntax
                   |32-bit.                     |

--
September 09, 2023
https://issues.dlang.org/show_bug.cgi?id=24130

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #6 from Dlang Bot <dlang-bot@dlang.rocks> ---
@WalterBright created dlang/dmd pull request #15595 "fix Issue 24130 - ImportC: Windows headers use inline asm with differ…" fixing this issue:

- fix Issue 24130 - ImportC: Windows headers use inline asm with different syntax

https://github.com/dlang/dmd/pull/15595

--
September 11, 2023
https://issues.dlang.org/show_bug.cgi?id=24130

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #7 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #15595 "fix Issue 24130 - ImportC: Windows headers use inline asm with differ…" was merged into master:

- 05403c7aaf342af2bbb92f5a8cec121dda5dce98 by Walter Bright:
  fix Issue 24130 - ImportC: Windows headers use inline asm with different
syntax

https://github.com/dlang/dmd/pull/15595

--
September 11, 2023
https://issues.dlang.org/show_bug.cgi?id=24130

--- Comment #8 from anonymous4 <dfj1esp02@sneakemail.com> ---
i64 is used in some kind of cpu feature constants (Extended processor state
configuration):
#define XSTATE_MASK_LEGACY_FLOATING_POINT   (1ui64 <<
(XSTATE_LEGACY_FLOATING_POINT))
#define XSTATE_MASK_LEGACY_SSE              (1ui64 << (XSTATE_LEGACY_SSE))

--