-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Panamize KQueue and EPoll selector implementations #22307
Draft
AlekseiEfimov
wants to merge
1
commit into
openjdk:master
Choose a base branch
from
AlekseiEfimov:PanamizeSelectorImpls_nix
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,667
−363
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
src/java.base/linux/classes/jdk/internal/ffi/generated/BindingUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (c) 2024, 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 | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. Oracle designates this | ||
* particular file as subject to the "Classpath" exception as provided | ||
* by Oracle in the LICENSE file that accompanied this code. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
package jdk.internal.ffi.generated; | ||
|
||
import java.lang.foreign.AddressLayout; | ||
import java.lang.foreign.MemoryLayout; | ||
import java.lang.foreign.ValueLayout; | ||
|
||
import static java.lang.foreign.ValueLayout.JAVA_BYTE; | ||
|
||
@SuppressWarnings("restricted") | ||
public final class BindingUtils { | ||
private BindingUtils() { | ||
} | ||
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 | ||
.withTargetLayout(MemoryLayout.sequenceLayout(Long.MAX_VALUE, JAVA_BYTE)); | ||
public static final ValueLayout.OfLong C_LONG = ValueLayout.JAVA_LONG; | ||
} |
289 changes: 289 additions & 0 deletions
289
src/java.base/linux/classes/jdk/internal/ffi/generated/epoll/epoll_data.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,289 @@ | ||
/* | ||
* Copyright (c) 2024, 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 | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. Oracle designates this | ||
* particular file as subject to the "Classpath" exception as provided | ||
* by Oracle in the LICENSE file that accompanied this code. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
// Generated by jextract | ||
|
||
package jdk.internal.ffi.generated.epoll; | ||
|
||
import jdk.internal.ffi.generated.BindingUtils; | ||
|
||
import java.lang.foreign.*; | ||
import java.util.function.*; | ||
|
||
import static java.lang.foreign.ValueLayout.*; | ||
import static java.lang.foreign.MemoryLayout.PathElement.*; | ||
|
||
/** | ||
* {@snippet lang=c : | ||
* union epoll_data { | ||
* void *ptr; | ||
* int fd; | ||
* uint32_t u32; | ||
* uint64_t u64; | ||
* } | ||
* } | ||
*/ | ||
@SuppressWarnings("restricted") | ||
public class epoll_data { | ||
|
||
epoll_data() { | ||
// Should not be called directly | ||
} | ||
|
||
private static final GroupLayout $LAYOUT = MemoryLayout.unionLayout( | ||
BindingUtils.C_POINTER.withName("ptr"), | ||
BindingUtils.C_INT.withName("fd"), | ||
BindingUtils.C_INT.withName("u32"), | ||
BindingUtils.C_LONG.withName("u64") | ||
).withName("epoll_data"); | ||
|
||
/** | ||
* The layout of this union | ||
*/ | ||
public static final GroupLayout layout() { | ||
return $LAYOUT; | ||
} | ||
|
||
private static final AddressLayout ptr$LAYOUT = (AddressLayout)$LAYOUT.select(groupElement("ptr")); | ||
|
||
/** | ||
* Layout for field: | ||
* {@snippet lang=c : | ||
* void *ptr | ||
* } | ||
*/ | ||
public static final AddressLayout ptr$layout() { | ||
return ptr$LAYOUT; | ||
} | ||
|
||
private static final long ptr$OFFSET = 0; | ||
|
||
/** | ||
* Offset for field: | ||
* {@snippet lang=c : | ||
* void *ptr | ||
* } | ||
*/ | ||
public static final long ptr$offset() { | ||
return ptr$OFFSET; | ||
} | ||
|
||
/** | ||
* Getter for field: | ||
* {@snippet lang=c : | ||
* void *ptr | ||
* } | ||
*/ | ||
public static MemorySegment ptr(MemorySegment union) { | ||
return union.get(ptr$LAYOUT, ptr$OFFSET); | ||
} | ||
|
||
/** | ||
* Setter for field: | ||
* {@snippet lang=c : | ||
* void *ptr | ||
* } | ||
*/ | ||
public static void ptr(MemorySegment union, MemorySegment fieldValue) { | ||
union.set(ptr$LAYOUT, ptr$OFFSET, fieldValue); | ||
} | ||
|
||
private static final OfInt fd$LAYOUT = (OfInt)$LAYOUT.select(groupElement("fd")); | ||
|
||
/** | ||
* Layout for field: | ||
* {@snippet lang=c : | ||
* int fd | ||
* } | ||
*/ | ||
public static final OfInt fd$layout() { | ||
return fd$LAYOUT; | ||
} | ||
|
||
private static final long fd$OFFSET = 0; | ||
|
||
/** | ||
* Offset for field: | ||
* {@snippet lang=c : | ||
* int fd | ||
* } | ||
*/ | ||
public static final long fd$offset() { | ||
return fd$OFFSET; | ||
} | ||
|
||
/** | ||
* Getter for field: | ||
* {@snippet lang=c : | ||
* int fd | ||
* } | ||
*/ | ||
public static int fd(MemorySegment union) { | ||
return union.get(fd$LAYOUT, fd$OFFSET); | ||
} | ||
|
||
/** | ||
* Setter for field: | ||
* {@snippet lang=c : | ||
* int fd | ||
* } | ||
*/ | ||
public static void fd(MemorySegment union, int fieldValue) { | ||
union.set(fd$LAYOUT, fd$OFFSET, fieldValue); | ||
} | ||
|
||
private static final OfInt u32$LAYOUT = (OfInt)$LAYOUT.select(groupElement("u32")); | ||
|
||
/** | ||
* Layout for field: | ||
* {@snippet lang=c : | ||
* uint32_t u32 | ||
* } | ||
*/ | ||
public static final OfInt u32$layout() { | ||
return u32$LAYOUT; | ||
} | ||
|
||
private static final long u32$OFFSET = 0; | ||
|
||
/** | ||
* Offset for field: | ||
* {@snippet lang=c : | ||
* uint32_t u32 | ||
* } | ||
*/ | ||
public static final long u32$offset() { | ||
return u32$OFFSET; | ||
} | ||
|
||
/** | ||
* Getter for field: | ||
* {@snippet lang=c : | ||
* uint32_t u32 | ||
* } | ||
*/ | ||
public static int u32(MemorySegment union) { | ||
return union.get(u32$LAYOUT, u32$OFFSET); | ||
} | ||
|
||
/** | ||
* Setter for field: | ||
* {@snippet lang=c : | ||
* uint32_t u32 | ||
* } | ||
*/ | ||
public static void u32(MemorySegment union, int fieldValue) { | ||
union.set(u32$LAYOUT, u32$OFFSET, fieldValue); | ||
} | ||
|
||
private static final OfLong u64$LAYOUT = (OfLong)$LAYOUT.select(groupElement("u64")); | ||
|
||
/** | ||
* Layout for field: | ||
* {@snippet lang=c : | ||
* uint64_t u64 | ||
* } | ||
*/ | ||
public static final OfLong u64$layout() { | ||
return u64$LAYOUT; | ||
} | ||
|
||
private static final long u64$OFFSET = 0; | ||
|
||
/** | ||
* Offset for field: | ||
* {@snippet lang=c : | ||
* uint64_t u64 | ||
* } | ||
*/ | ||
public static final long u64$offset() { | ||
return u64$OFFSET; | ||
} | ||
|
||
/** | ||
* Getter for field: | ||
* {@snippet lang=c : | ||
* uint64_t u64 | ||
* } | ||
*/ | ||
public static long u64(MemorySegment union) { | ||
return union.get(u64$LAYOUT, u64$OFFSET); | ||
} | ||
|
||
/** | ||
* Setter for field: | ||
* {@snippet lang=c : | ||
* uint64_t u64 | ||
* } | ||
*/ | ||
public static void u64(MemorySegment union, long fieldValue) { | ||
union.set(u64$LAYOUT, u64$OFFSET, fieldValue); | ||
} | ||
|
||
/** | ||
* Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. | ||
* The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} | ||
*/ | ||
public static MemorySegment asSlice(MemorySegment array, long index) { | ||
return array.asSlice(layout().byteSize() * index); | ||
} | ||
|
||
/** | ||
* The size (in bytes) of this union | ||
*/ | ||
public static long sizeof() { return layout().byteSize(); } | ||
|
||
/** | ||
* Allocate a segment of size {@code layout().byteSize()} using {@code allocator} | ||
*/ | ||
public static MemorySegment allocate(SegmentAllocator allocator) { | ||
return allocator.allocate(layout()); | ||
} | ||
|
||
/** | ||
* Allocate an array of size {@code elementCount} using {@code allocator}. | ||
* The returned segment has size {@code elementCount * layout().byteSize()}. | ||
*/ | ||
public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { | ||
return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); | ||
} | ||
|
||
/** | ||
* Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). | ||
* The returned segment has size {@code layout().byteSize()} | ||
*/ | ||
public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer<MemorySegment> cleanup) { | ||
return reinterpret(addr, 1, arena, cleanup); | ||
} | ||
|
||
/** | ||
* Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). | ||
* The returned segment has size {@code elementCount * layout().byteSize()} | ||
*/ | ||
public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer<MemorySegment> cleanup) { | ||
return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); | ||
} | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
These classes could be
final
and have aprivate
constructor.