-
Notifications
You must be signed in to change notification settings - Fork 65
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
7903923: Derive C_* layouts directly from the Linker #269
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. | ||
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
|
@@ -66,21 +66,21 @@ private static HeaderFileBuilder createFirstHeader(SourceFileBuilder sfb, List<O | |
// emit basic primitive types | ||
first.appendIndentedLines(""" | ||
|
||
public static final ValueLayout.OfBoolean C_BOOL = ValueLayout.JAVA_BOOLEAN; | ||
public static final ValueLayout.OfByte C_CHAR = ValueLayout.JAVA_BYTE; | ||
public static final ValueLayout.OfShort C_SHORT = ValueLayout.JAVA_SHORT; | ||
public static final ValueLayout.OfInt C_INT = ValueLayout.JAVA_INT; | ||
public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG; | ||
public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT; | ||
public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE; | ||
public static final AddressLayout C_POINTER = ValueLayout.ADDRESS | ||
public static final ValueLayout.OfBoolean C_BOOL = (ValueLayout.OfBoolean) Linker.nativeLinker().canonicalLayouts().get("bool"); | ||
public static final ValueLayout.OfByte C_CHAR =(ValueLayout.OfByte)Linker.nativeLinker().canonicalLayouts().get("char"); | ||
public static final ValueLayout.OfShort C_SHORT = (ValueLayout.OfShort) Linker.nativeLinker().canonicalLayouts().get("short"); | ||
public static final ValueLayout.OfInt C_INT = (ValueLayout.OfInt) Linker.nativeLinker().canonicalLayouts().get("int"); | ||
public static final ValueLayout.OfLong C_LONG_LONG = (ValueLayout.OfLong) Linker.nativeLinker().canonicalLayouts().get("long"); | ||
public static final ValueLayout.OfFloat C_FLOAT = (ValueLayout.OfFloat) Linker.nativeLinker().canonicalLayouts().get("float"); | ||
public static final ValueLayout.OfDouble C_DOUBLE = (ValueLayout.OfDouble) Linker.nativeLinker().canonicalLayouts().get("double"); | ||
public static final AddressLayout C_POINTER =((AddressLayout) Linker.nativeLinker().canonicalLayouts().get("void*")) | ||
.withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, JAVA_BYTE)); | ||
"""); | ||
if (TypeImpl.IS_WINDOWS) { | ||
first.appendIndentedLines("public static final ValueLayout.OfInt C_LONG = ValueLayout.JAVA_INT;"); | ||
first.appendIndentedLines("public static final ValueLayout.OfDouble C_LONG_DOUBLE = ValueLayout.JAVA_DOUBLE;"); | ||
first.appendIndentedLines("public static final ValueLayout.OfInt C_LONG = (ValueLayout.OfInt) Linker.nativeLinker().canonicalLayouts().get(\"int\");"); | ||
first.appendIndentedLines("public static final ValueLayout.OfDouble C_LONG_DOUBLE = (ValueLayout.OfDouble) Linker.nativeLinker().canonicalLayouts().get(\"double\");"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here, there's no canonical layout for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would be okay with adding |
||
} else { | ||
first.appendIndentedLines("public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG;"); | ||
first.appendIndentedLines("public static final ValueLayout.OfLong C_LONG = (ValueLayout.OfLong) Linker.nativeLinker().canonicalLayouts().get(\"long\");"); | ||
} | ||
return first; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The canonical layout for this has name
long
. But the result is aValueLayout.OfInt
(because FFM usesint
to model values of that type on Windows). In other words, the only thing that changes in Windows is the cast that should be toOfInt
, not toOfLong
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explaining, will fix it.