-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1,实现probe以及添加默认操作符合法性校验 2,修复一个潜在的wakeup失败的问题
- Loading branch information
1 parent
a04ec1b
commit 08c2a9d
Showing
11 changed files
with
239 additions
and
70 deletions.
There are no files selected for viewing
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
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
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
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
46 changes: 46 additions & 0 deletions
46
panama-uring/src/main/java/top/dreamlike/panama/uring/nativelib/helper/OSIoUringProbe.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,46 @@ | ||
package top.dreamlike.panama.uring.nativelib.helper; | ||
|
||
import top.dreamlike.panama.generator.proxy.NativeArray; | ||
import top.dreamlike.panama.generator.proxy.StructProxyGenerator; | ||
import top.dreamlike.panama.uring.nativelib.Instance; | ||
|
||
import java.lang.foreign.MemorySegment; | ||
|
||
public class OSIoUringProbe { | ||
|
||
private final int lastOp; | ||
|
||
private final IoUringProbeOp[] ops; | ||
|
||
public OSIoUringProbe() { | ||
var probe = Instance.LIB_URING.io_uring_get_probe(); | ||
if (probe == null) { | ||
throw new RuntimeException("Failed to get probe"); | ||
} | ||
lastOp = probe.getLastOp(); | ||
byte len = probe.getOpsLen(); | ||
ops = new IoUringProbeOp[len]; | ||
MemorySegment opsBase = StructProxyGenerator.findMemorySegment(probe) | ||
.asSlice(top.dreamlike.panama.uring.nativelib.struct.liburing.IoUringProbe.OPS_OFFSET) | ||
.reinterpret(len * top.dreamlike.panama.uring.nativelib.struct.liburing.IoUringProbeOp.LAYOUT.byteSize()); | ||
|
||
NativeArray<top.dreamlike.panama.uring.nativelib.struct.liburing.IoUringProbeOp> ops = Instance.STRUCT_PROXY_GENERATOR.enhanceArray(opsBase); | ||
for (byte i = 0; i < len; i++) { | ||
top.dreamlike.panama.uring.nativelib.struct.liburing.IoUringProbeOp op = ops.get(i); | ||
this.ops[i] = new IoUringProbeOp(op.getOp(), op.getFlags()); | ||
} | ||
|
||
Instance.LIB_URING.io_uring_free_probe(probe); | ||
} | ||
|
||
public int getLastOp() { | ||
return lastOp; | ||
} | ||
|
||
public IoUringProbeOp[] getOps() { | ||
return ops; | ||
} | ||
|
||
public record IoUringProbeOp(byte op, short flags) { | ||
} | ||
} |
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
66 changes: 66 additions & 0 deletions
66
...ring/src/main/java/top/dreamlike/panama/uring/nativelib/struct/liburing/IoUringProbe.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,66 @@ | ||
package top.dreamlike.panama.uring.nativelib.struct.liburing; | ||
|
||
import top.dreamlike.panama.generator.annotation.NativeArrayMark; | ||
import top.dreamlike.panama.uring.nativelib.Instance; | ||
|
||
import java.lang.foreign.MemoryLayout; | ||
import java.lang.foreign.MemorySegment; | ||
|
||
public class IoUringProbe { | ||
|
||
public static final MemoryLayout LAYOUT = Instance.STRUCT_PROXY_GENERATOR.extract(IoUringProbe.class); | ||
|
||
public static final long OPS_OFFSET = LAYOUT.byteOffset(MemoryLayout.PathElement.groupElement("ops")); | ||
|
||
private byte lastOp; | ||
|
||
private byte opsLen; | ||
|
||
private short resv; | ||
|
||
@NativeArrayMark(size = int.class, length = 3) | ||
private MemorySegment resv2; | ||
|
||
@NativeArrayMark(size = IoUringProbeOp.class, length = 0) | ||
private MemorySegment ops; | ||
|
||
public byte getLastOp() { | ||
return lastOp; | ||
} | ||
|
||
public void setLastOp(byte lastOp) { | ||
this.lastOp = lastOp; | ||
} | ||
|
||
public byte getOpsLen() { | ||
return opsLen; | ||
} | ||
|
||
public void setOpsLen(byte opsLen) { | ||
this.opsLen = opsLen; | ||
} | ||
|
||
public short getResv() { | ||
return resv; | ||
} | ||
|
||
public void setResv(short resv) { | ||
this.resv = resv; | ||
} | ||
|
||
public MemorySegment getResv2() { | ||
return resv2; | ||
} | ||
|
||
public void setResv2(MemorySegment resv2) { | ||
this.resv2 = resv2; | ||
} | ||
|
||
public MemorySegment getOps() { | ||
return ops; | ||
} | ||
|
||
public void setOps(MemorySegment ops) { | ||
this.ops = ops; | ||
} | ||
} |
Oops, something went wrong.