public static MemoryBlock mmap(FileDescriptor fd, long offset, long size, MapMode mapMode) throws IOException { if (size == 0) { // You can't mmap(2) a zero-length region, but Java allows it. return new MemoryBlock(0, 0); } // Check just those errors mmap(2) won't detect. if (offset < 0 || size < 0 || offset > Integer.MAX_VALUE || size > Integer.MAX_VALUE) { throw new IllegalArgumentException("offset=" + offset + " size=" + size); } int prot; int flags; if (mapMode == MapMode.PRIVATE) { prot = PROT_READ|PROT_WRITE; flags = MAP_PRIVATE; } else if (mapMode == MapMode.READ_ONLY) { prot = PROT_READ; flags = MAP_SHARED; } else { // mapMode == MapMode.READ_WRITE prot = PROT_READ|PROT_WRITE; flags = MAP_SHARED; } try { long address = Libcore.os.mmap(0L, size, prot, flags, fd, offset); return new MemoryMappedBlock(address, size); } catch (ErrnoException errnoException) { throw errnoException.rethrowAsIOException(); } }
public static MemoryBlock mmap(FileDescriptor fd, long offset, long size, MapMode mapMode) throws IOException { if (size == 0) { // You can't mmap(2) a zero-length region, but Java allows it. return new MemoryBlock(0, 0); } // Check just those errors mmap(2) won't detect. if (offset < 0 || size < 0 || offset > Integer.MAX_VALUE || size > Integer.MAX_VALUE) { throw new IllegalArgumentException("offset=" + offset + " size=" + size); } int prot; int flags; if (mapMode == MapMode.PRIVATE) { prot = PROT_READ|PROT_WRITE; flags = MAP_PRIVATE; } else if (mapMode == MapMode.READ_ONLY) { prot = PROT_READ; flags = MAP_SHARED; } else { // mapMode == MapMode.READ_WRITE prot = PROT_READ|PROT_WRITE; flags = MAP_SHARED; } try { long address = Libcore.os.mmap(0L, size, prot, flags, fd, offset); return new MemoryMappedBlock(address, size); } catch (ErrnoException errnoException) { throw errnoException.rethrowAsIOException(); } }
public static MemoryBlock mmap(FileDescriptor fd, long offset, long size, MapMode mapMode) throws IOException { if (size == 0) { // You can't mmap(2) a zero-length region, but Java allows it. return new MemoryBlock(0, 0); } // Check just those errors mmap(2) won't detect. if (offset < 0 || size < 0 || offset > Integer.MAX_VALUE || size > Integer.MAX_VALUE) { throw new IllegalArgumentException("offset=" + offset + " size=" + size); } int prot; int flags; if (mapMode == MapMode.PRIVATE) { prot = PROT_READ|PROT_WRITE; flags = MAP_PRIVATE; } else if (mapMode == MapMode.READ_ONLY) { prot = PROT_READ; flags = MAP_SHARED; } else { // mapMode == MapMode.READ_WRITE prot = PROT_READ|PROT_WRITE; flags = MAP_SHARED; } try { long address = Libcore.os.mmap(0L, size, prot, flags, fd, offset); return new MemoryMappedBlock(address, size); } catch (ErrnoException errnoException) { throw errnoException.rethrowAsIOException(); } }
public static MemoryBlock mmap(FileDescriptor fd, long offset, long size, MapMode mapMode) throws IOException { if (size == 0) { // You can't mmap(2) a zero-length region, but Java allows it. return new MemoryBlock(0, 0); } // Check just those errors mmap(2) won't detect. if (offset < 0 || size < 0 || offset > Integer.MAX_VALUE || size > Integer.MAX_VALUE) { throw new IllegalArgumentException("offset=" + offset + " size=" + size); } int prot; int flags; if (mapMode == MapMode.PRIVATE) { prot = PROT_READ|PROT_WRITE; flags = MAP_PRIVATE; } else if (mapMode == MapMode.READ_ONLY) { prot = PROT_READ; flags = MAP_SHARED; } else { // mapMode == MapMode.READ_WRITE prot = PROT_READ|PROT_WRITE; flags = MAP_SHARED; } try { long address = Libcore.os.mmap(0L, size, prot, flags, fd, offset); return new MemoryMappedBlock(address, size); } catch (ErrnoException errnoException) { throw errnoException.rethrowAsIOException(); } }
public static MemoryBlock mmap(FileDescriptor fd, long offset, long size, MapMode mapMode) throws IOException { if (size == 0) { // You can't mmap(2) a zero-length region, but Java allows it. return new MemoryBlock(0, 0); } // Check just those errors mmap(2) won't detect. if (offset < 0 || size < 0 || offset > Integer.MAX_VALUE || size > Integer.MAX_VALUE) { throw new IllegalArgumentException("offset=" + offset + " size=" + size); } int prot; int flags; if (mapMode == MapMode.PRIVATE) { prot = PROT_READ|PROT_WRITE; flags = MAP_PRIVATE; } else if (mapMode == MapMode.READ_ONLY) { prot = PROT_READ; flags = MAP_SHARED; } else { // mapMode == MapMode.READ_WRITE prot = PROT_READ|PROT_WRITE; flags = MAP_SHARED; } try { long address = Libcore.os.mmap(0L, size, prot, flags, fd, offset); return new MemoryMappedBlock(address, size); } catch (ErrnoException errnoException) { throw errnoException.rethrowAsIOException(); } }
public static MemoryBlock mmap(FileDescriptor fd, long offset, long size, MapMode mapMode) throws IOException { if (size == 0) { // You can't mmap(2) a zero-length region, but Java allows it. return new MemoryBlock(0, 0); } // Check just those errors mmap(2) won't detect. if (offset < 0 || size < 0 || offset > Integer.MAX_VALUE || size > Integer.MAX_VALUE) { throw new IllegalArgumentException("offset=" + offset + " size=" + size); } int prot; int flags; if (mapMode == MapMode.PRIVATE) { prot = PROT_READ|PROT_WRITE; flags = MAP_PRIVATE; } else if (mapMode == MapMode.READ_ONLY) { prot = PROT_READ; flags = MAP_SHARED; } else { // mapMode == MapMode.READ_WRITE prot = PROT_READ|PROT_WRITE; flags = MAP_SHARED; } try { long address = Libcore.os.mmap(0L, size, prot, flags, fd, offset); return new MemoryMappedBlock(address, size); } catch (ErrnoException errnoException) { throw errnoException.rethrowAsIOException(); } }
public static MemoryBlock mmap(FileDescriptor fd, long offset, long size, MapMode mapMode) throws IOException { if (size == 0) { // You can't mmap(2) a zero-length region, but Java allows it. return new MemoryBlock(0, 0); } // Check just those errors mmap(2) won't detect. if (offset < 0 || size < 0 || offset > Integer.MAX_VALUE || size > Integer.MAX_VALUE) { throw new IllegalArgumentException("offset=" + offset + " size=" + size); } int prot; int flags; if (mapMode == MapMode.PRIVATE) { prot = PROT_READ|PROT_WRITE; flags = MAP_PRIVATE; } else if (mapMode == MapMode.READ_ONLY) { prot = PROT_READ; flags = MAP_SHARED; } else { // mapMode == MapMode.READ_WRITE prot = PROT_READ|PROT_WRITE; flags = MAP_SHARED; } try { long address = Libcore.os.mmap(0L, size, prot, flags, fd, offset); return new MemoryMappedBlock(address, size); } catch (ErrnoException errnoException) { throw errnoException.rethrowAsIOException(); } }