@Test @DisplayName("dmaAllocate(long, boolean, boolean)") @SuppressWarnings({"CodeBlock2Expr", "ResultOfMethodCallIgnored"}) void dmaAllocate() { assumeTrue(mmanager != null); for (val huge : Arrays.asList(false, true)) { for (val lock : Arrays.asList(false, true)) { val bytes = createSize(0xFFFF); val dma = mmanager.dmaAllocate(bytes, huge, lock); val softly = new SoftAssertions(); softly.assertThat(dma.getPhysical()).isNotZero(); softly.assertThat(dma.getPhysical() & (mmanager.getPageSize() - 1)) .isEqualTo(dma.getVirtual() & (mmanager.getPageSize() - 1)); mmanager.free(dma.getVirtual(), bytes, huge, lock); softly.assertAll(); } } }
@Override @Contract(value = "_, _, _ -> fail", pure = true) @SuppressWarnings({"deprecation", "BooleanParameter"}) public @NotNull DmaMemory dmaAllocate(final long bytes, final boolean huge, final boolean lock) { if (!OPTIMIZED) { if (unsafe == null) throw new NullPointerException("The Unsafe object is not available."); if (bytes <= 0) throw new IllegalArgumentException("The parameter 'bytes' MUST BE positive."); } val virtual = allocate(bytes, huge, lock); if (virtual != 0) putByte(virtual, getByte(virtual)); val physical = virt2phys(virtual); return new DmaMemory(virtual, physical); }
SmartUnsafeMemoryManager extends UnsafeMemoryManager { @Override @Contract(value = "_, _, _ -> fail", pure = true) @SuppressWarnings({"deprecation", "BooleanParameter"}) public @NotNull DmaMemory dmaAllocate(final long bytes, final boolean huge, final boolean lock) { if (!OPTIMIZED) { if (unsafe == null) throw new NullPointerException("The Unsafe object is not available."); if (bytes <= 0) throw new IllegalArgumentException("The parameter 'bytes' MUST BE positive."); } val virtual = allocate(bytes, huge, lock); if (virtual != 0) putByte(virtual, getByte(virtual)); val physical = virt2phys(virtual); return new DmaMemory(virtual, physical); } }
SmartUnsafeMemoryManager extends UnsafeMemoryManager { @Override @Contract(value = "_, _, _ -> fail", pure = true) @SuppressWarnings({"deprecation", "BooleanParameter"}) public @NotNull DmaMemory dmaAllocate(final long bytes, final boolean huge, final boolean lock) { if (!OPTIMIZED) { if (unsafe == null) throw new NullPointerException("The Unsafe object is not available."); if (bytes <= 0) throw new IllegalArgumentException("The parameter 'bytes' MUST BE positive."); } val virtual = allocate(bytes, huge, lock); if (virtual != 0) putByte(virtual, getByte(virtual)); val physical = virt2phys(virtual); return new DmaMemory(virtual, physical); } private  SmartUnsafeMemoryManager(); }
SmartUnsafeMemoryManager extends UnsafeMemoryManager { @Override @Contract(value = "_, _, _ -> fail", pure = true) @SuppressWarnings({"deprecation", "BooleanParameter"}) public @NotNull DmaMemory dmaAllocate(final long bytes, final boolean huge, final boolean lock) { if (!OPTIMIZED) { if (unsafe == null) throw new NullPointerException("The Unsafe object is not available."); if (bytes <= 0) throw new IllegalArgumentException("The parameter 'bytes' MUST BE positive."); } val virtual = allocate(bytes, huge, lock); if (virtual != 0) putByte(virtual, getByte(virtual)); val physical = virt2phys(virtual); return new DmaMemory(virtual, physical); } private  SmartUnsafeMemoryManager(); @Override @Contract(pure = true) boolean isValid(); @Override @Contract(pure = true) long getPageSize(); @Override @Contract(value = " -> fail", pure = true) @SuppressWarnings({"deprecation", "PMD.DataflowAnomalyAnalysis"}) long getHugepageSize(); @Override @Contract(pure = true) @SuppressWarnings("BooleanParameter") long allocate(long bytes, boolean huge, boolean lock); @Override @SuppressWarnings("BooleanParameter") void free(long address, long bytes, final boolean huge, final boolean lock); @Override @Contract(pure = true) @SuppressWarnings({"deprecation", "BooleanParameter", "IOResourceOpenedButNotSafelyClosed", "resource"}) long mmap(final @NotNull File file, final boolean huge, final boolean lock); @Override @SuppressWarnings({"deprecation", "BooleanParameter", "PMD.DataflowAnomalyAnalysis"}) void munmap(final long address, final @NotNull File file, final boolean huge, final boolean lock); @Override @Contract(pure = true) @SuppressWarnings("deprecation") @SuppressFBWarnings("") long virt2phys(final long address); @Override @Contract(value = "_, _, _ -> fail", pure = true) @SuppressWarnings({"deprecation", "BooleanParameter"}) @NotNull DmaMemory dmaAllocate(final long bytes, final boolean huge, final boolean lock); }
SmartUnsafeMemoryManager extends UnsafeMemoryManager { @Override @Contract(value = "_, _, _ -> fail", pure = true) @SuppressWarnings({"deprecation", "BooleanParameter"}) public @NotNull DmaMemory dmaAllocate(final long bytes, final boolean huge, final boolean lock) { if (!OPTIMIZED) { if (unsafe == null) throw new NullPointerException("The Unsafe object is not available."); if (bytes <= 0) throw new IllegalArgumentException("The parameter 'bytes' MUST BE positive."); } val virtual = allocate(bytes, huge, lock); if (virtual != 0) putByte(virtual, getByte(virtual)); val physical = virt2phys(virtual); return new DmaMemory(virtual, physical); } private  SmartUnsafeMemoryManager(); @Override @Contract(pure = true) boolean isValid(); @Override @Contract(pure = true) long getPageSize(); @Override @Contract(value = " -> fail", pure = true) @SuppressWarnings({"deprecation", "PMD.DataflowAnomalyAnalysis"}) long getHugepageSize(); @Override @Contract(pure = true) @SuppressWarnings("BooleanParameter") long allocate(long bytes, boolean huge, boolean lock); @Override @SuppressWarnings("BooleanParameter") void free(long address, long bytes, final boolean huge, final boolean lock); @Override @Contract(pure = true) @SuppressWarnings({"deprecation", "BooleanParameter", "IOResourceOpenedButNotSafelyClosed", "resource"}) long mmap(final @NotNull File file, final boolean huge, final boolean lock); @Override @SuppressWarnings({"deprecation", "BooleanParameter", "PMD.DataflowAnomalyAnalysis"}) void munmap(final long address, final @NotNull File file, final boolean huge, final boolean lock); @Override @Contract(pure = true) @SuppressWarnings("deprecation") @SuppressFBWarnings("") long virt2phys(final long address); @Override @Contract(value = "_, _, _ -> fail", pure = true) @SuppressWarnings({"deprecation", "BooleanParameter"}) @NotNull DmaMemory dmaAllocate(final long bytes, final boolean huge, final boolean lock);  }