Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify __int64 definition in PAL to match the OS definition #77056

Merged
merged 6 commits into from
Oct 18, 2022

Conversation

janvorli
Copy link
Member

This change modifies the definition of __int64 and thus of many other types defined on the basis of it to match the OS definitions. This ensures that we can use these types in interfaces between code in coreclr and various PALs that are compiled against OS headers.

The key issue was that we were defining __int64 for 64 bit OSes as long while Unix defines it as long long. The size of those types is the same on Unix, but they are different and result in different mangling of C++ names.

The changes I had to make in runtime were due to the fact that size_t and ssize_t are not defined as __int64 anymore due to the change and many places relied on the fact those matched.

The StressLog tools were defining couple of types including size_t on its own, which collided with the new definitions. I've fixed it by including the stdint.h instead of defining the types manually.

This change modifies the definition of __int64 and thus of many other
types defined on the basis of it to match the OS definitions. This
ensures that we can use these types in interfaces between code in
coreclr and various PALs that are compiled against OS headers.

The key issue was that we were defining __int64 for 64 bit OSes as
long while Unix defines it as long long. The size of those types is the
same on Unix, but they are different and result in different mangling of
C++ names.
@janvorli janvorli added this to the 8.0.0 milestone Oct 14, 2022
@janvorli janvorli self-assigned this Oct 14, 2022
@jkotas
Copy link
Member

jkotas commented Oct 14, 2022

cc @AaronRobinsonMSFT This contributes to Win32 PAL elimination.

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jkotas jkotas merged commit fda2fee into dotnet:main Oct 18, 2022
@@ -195,12 +195,7 @@ extern "C" {
// they must be either signed or unsigned) and we want to be able to use
// __int64 as though it were intrinsic

#ifdef HOST_64BIT
Copy link
Contributor

@shushanhf shushanhf Oct 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an error after deleting this on LoongArch64.

In file included from /home/qiao/work_qiao/runtime/src/coreclr/debug/di/platformspecific.cpp:37:
/home/qiao/work_qiao/runtime/src/coreclr/debug/di/loongarch64/cordbregisterset.cpp:272:18: error: cannot initialize a variable of type 'ULONG64 *'
      (aka 'unsigned long long *') with an rvalue of type 'SIZE_T *' (aka 'unsigned long *')
        ULONG64* pSrc  = &m_rd->A0;
                 ^       ~~~~~~~~~
1 error generated.

Copy link
Contributor

@shushanhf shushanhf Oct 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkotas
Why define the ULONG64 as unsigned long long ?
While define SIZE_T as unsigned long ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkotas Why define the ULONG64 as unsigned long long ? While define SIZE_T as unsigned long ?

Thanks
I had noted #77268

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has been special cased to MacOS only in this PR: #77268, so guessing that should solve your issue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has been special cased to MacOS only in this PR: #77268, so guessing that should solve your issue?

Yes, it's ok for LA64 now.
Thanks.

mangod9 pushed a commit to mangod9/runtime that referenced this pull request Nov 10, 2022
…7056)

* Modify __int64 definition in PAL to match the OS definition

This change modifies the definition of __int64 and thus of many other
types defined on the basis of it to match the OS definitions. This
ensures that we can use these types in interfaces between code in
coreclr and various PALs that are compiled against OS headers.

The key issue was that we were defining __int64 for 64 bit OSes as
long while Unix defines it as long long. The size of those types is the
same on Unix, but they are different and result in different mangling of
C++ names.

* Fix coreclr tests build

* Fix comment on #endif in jit.h

* Reflect PR feedback

* Fix jit source formatting

* Fix FreeBSD build
@ghost ghost locked as resolved and limited conversation to collaborators Nov 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants