Refine search
Memory m = new Memory(psize); int fd = LIBC.open(getFile("as").getAbsolutePath(), 0); LIBC.pread(fd, m, new NativeLong(psize), new NativeLong(pr_argp)); long argp = b64 ? m.getLong(0) : to64(m.getInt(0)); LIBC.pread(fd, m, new NativeLong(psize), new NativeLong(argp+(n*psize))); long addr = b64 ? m.getLong(0) : to64(m.getInt(0));
static void trySetMaxSizeVirtualMemory() { if (Constants.LINUX || Constants.MAC_OS_X) { final JNACLibrary.Rlimit rlimit = new JNACLibrary.Rlimit(); if (JNACLibrary.getrlimit(JNACLibrary.RLIMIT_AS, rlimit) == 0) { MAX_SIZE_VIRTUAL_MEMORY = rlimit.rlim_cur.longValue(); } else { logger.warn("unable to retrieve max size virtual memory [" + JNACLibrary.strerror(Native.getLastError()) + "]"); } } }
static void bsdImpl() { boolean supported = Constants.FREE_BSD || OPENBSD || Constants.MAC_OS_X; if (supported == false) { throw new IllegalStateException("bug: should not be trying to initialize RLIMIT_NPROC for an unsupported OS"); } JNACLibrary.Rlimit limit = new JNACLibrary.Rlimit(); limit.rlim_cur.setValue(0); limit.rlim_max.setValue(0); if (JNACLibrary.setrlimit(RLIMIT_NPROC, limit) != 0) { throw new UnsupportedOperationException("RLIMIT_NPROC unavailable: " + JNACLibrary.strerror(Native.getLastError())); } logger.debug("BSD RLIMIT_NPROC initialization successful"); }
throw new UnsupportedOperationException("seccomp unavailable: seccomp(BOGUS_OPERATION) returned " + ret); } else { int errno = Native.getLastError(); switch (errno) { case ENOSYS: break; // ok throw new UnsupportedOperationException("seccomp unavailable: seccomp(SECCOMP_SET_MODE_FILTER, BOGUS_FLAG) returned " + ret); } else { int errno = Native.getLastError(); switch (errno) { case ENOSYS: break; // ok long pointer = Pointer.nativeValue(prog.getPointer()); if (linux_syscall(arch.seccomp, SECCOMP_SET_MODE_FILTER, SECCOMP_FILTER_FLAG_TSYNC, new NativeLong(pointer)) != 0) { method = 0; int errno1 = Native.getLastError(); if (logger.isDebugEnabled()) { logger.debug("seccomp(SECCOMP_SET_MODE_FILTER): {}, falling back to prctl(PR_SET_SECCOMP)...", JNACLibrary.strerror(errno1)); logger.debug("Linux seccomp filter installation successful, threads: [{}]", method == 1 ? "all" : "app" ); return method;
logger.warn("Unable to lock JVM memory. Failed to set working set size. Error code {}", Native.getLastError()); } else { JNAKernel32Library.MemoryBasicInformation memInfo = new JNAKernel32Library.MemoryBasicInformation(); long address = 0; while (kernel.VirtualQueryEx(process, new Pointer(address), memInfo, memInfo.size()) != 0) { boolean lockable = memInfo.State.longValue() == JNAKernel32Library.MEM_COMMIT && (memInfo.Protect.longValue() & JNAKernel32Library.PAGE_NOACCESS) != JNAKernel32Library.PAGE_NOACCESS && (memInfo.Protect.longValue() & JNAKernel32Library.PAGE_GUARD) != JNAKernel32Library.PAGE_GUARD; if (lockable) { kernel.VirtualLock(memInfo.BaseAddress, new SizeT(memInfo.RegionSize.longValue()));
public DATA_BLOB(byte[] bytes) { if (bytes != null) { cbData = new Memory(bytes.length); cbData.write(0, bytes, 0, bytes.length); cbSize = new NativeLong(bytes.length); } else { cbSize = new NativeLong(0); cbData = Pointer.NULL; } }
public void destroy() { for (ByteBuffer byteBuffer : availableBuffers) { final long address = ((DirectBuffer) byteBuffer).address(); Pointer pointer = new Pointer(address); LibC.INSTANCE.munlock(pointer, new NativeLong(fileSize)); } }
private MacAddress getMacAddress(String nifName) { Pointer lpAdapter = NativePacketDllMappings.PacketOpenAdapter(nifName); long hFile = -1; if (lpAdapter != null) { if (Native.POINTER_SIZE == 4) { hFile = lpAdapter.getInt(0); } else { hFile = lpAdapter.getLong(0); } } if (hFile == -1L) { int err = Native.getLastError(); logger.error("Unable to open the NIF {}, Error Code: {}", nifName, err); return null; } Memory mem = new Memory(NativePacketDllMappings.PACKET_OID_DATA_SIZE); mem.clear(); PACKET_OID_DATA oidData = new PACKET_OID_DATA(mem); oidData.Length = new NativeLong(6L); oidData.Oid = new NativeLong(0x01010102L); int status = NativePacketDllMappings.PacketRequest(lpAdapter, 0, oidData); NativePacketDllMappings.PacketCloseAdapter(lpAdapter); if (status == 0) { logger.error("Failed to retrieve the link layer address of the NIF: {}", nifName); return null; } else { return MacAddress.getByAddress(oidData.Data); } }
public void hover() { HWNDByReference hwnd = new HWNDByReference(); NativeLongByReference x = new NativeLongByReference(); NativeLongByReference y = new NativeLongByReference(); NativeLongByReference width = new NativeLongByReference(); NativeLongByReference height = new NativeLongByReference(); int result = lib.wdeGetDetailsOnceScrolledOnToScreen(element, hwnd, x, y, width, height); errors.verifyErrorCode(result, "hover"); long midX = x.getValue().longValue() + (width.getValue().longValue() / 2); long midY = y.getValue().longValue() + (height.getValue().longValue() / 2); result = lib.wdeMouseMoveTo(hwnd.getValue(), new NativeLong(100), new NativeLong(0), new NativeLong(0), new NativeLong(midX), new NativeLong(midY)); errors.verifyErrorCode(result, "hover mouse move"); }
private String readLine(int fd, long addr, String prefix) throws IOException { if(LOGGER.isLoggable(FINEST)) LOGGER.finest("Reading "+prefix+" at "+addr); Memory m = new Memory(1); byte ch = 1; ByteArrayOutputStream buf = new ByteArrayOutputStream(); int i = 0; while(true) { if (i++ > LINE_LENGTH_LIMIT) { LOGGER.finest("could not find end of line, giving up"); throw new IOException("could not find end of line, giving up"); } LIBC.pread(fd, m, new NativeLong(1), new NativeLong(addr)); ch = m.getByte(0); if (ch == 0) break; buf.write(ch); addr++; } String line = buf.toString(); if(LOGGER.isLoggable(FINEST)) LOGGER.finest(prefix+" was "+line); return line; } }
/** * Map the given region of the given file descriptor into memory. * Returns a Pointer to the newly mapped memory throws an * IOException on error. */ public static Pointer mmap(long len, int prot, int flags, int fildes, long off) throws IOException { // we don't really have a need to change the recommended pointer. Pointer addr = new Pointer(0); Pointer result = Delegate.mmap(addr, new NativeLong(len), prot, flags, fildes, new NativeLong(off)); if(Pointer.nativeValue(result) == -1) { if(logger.isDebugEnabled()) logger.debug(errno.strerror()); throw new IOException("mmap failed: " + errno.strerror()); } return result; }
protected GCallback(NativeLong id, Callback cb) { this.id = id != null ? id : new NativeLong(0); this.cb = cb; this.connected = this.id.intValue() != 0; } void remove() {
to.tv_sec = new NativeLong(0); to.tv_usec = new NativeLong(0); throw new PcapNativeException( "SBIOCSTIME: " + NativeMappings.pcap_strerror(NativeMappings.ERRNO_P.getInt(0)).getString(0));
public String getProperty(zpool_prop_t prop) { Memory propbuf = new Memory(libzfs.ZPOOL_MAXPROPLEN); int ret = LIBZFS.zpool_get_prop(handle, new NativeLong(prop .ordinal()), propbuf, new NativeLong( libzfs.ZPOOL_MAXPROPLEN), null); return ((ret != 0) ? null : propbuf.getString(0)); }
private void setLongSockopt(int option, long optval) { NativeLong length = new NativeLong(Long.SIZE / 8); Memory value = new Memory(Long.SIZE / 8); value.setLong(0, optval); zmq.zmq_setsockopt(ptr, option, value, length); }
/** * @param val value to box to native long. * @return native long. */ @NotNull private static NativeLong nl(long val) { if (val % NL_CACHE_DIVISOR == 0 && val < CACHED_LONGS * NL_CACHE_DIVISOR) { int cacheIdx = (int)(val / NL_CACHE_DIVISOR); NativeLong curCached = nativeLongCache.get(cacheIdx); if (curCached != null) return curCached; NativeLong nl = new NativeLong(val); nativeLongCache.compareAndSet(cacheIdx, null, nl); return nl; } return new NativeLong(val); }
public void set(long v) { getValue().setValue(new NativeLong(v)); } public void set(NativeLong v) {
/** * Indirect the native pointer as a pointer to <code>long</code>. This is * equivalent to the expression * <code>*((long *)((char *)Pointer + offset))</code>. * * @param offset byte offset from pointer to perform the indirection * @return the <code>long</code> value being pointed to */ public NativeLong getNativeLong(long offset) { return new NativeLong(NativeLong.SIZE == 8 ? getLong(offset) : getInt(offset)); }
/** * Allocates align memory for use with O_DIRECT and returns native byte buffer. * @param fsBlockSize alignment, FS ans OS block size. * @param size capacity. * @return byte buffer, to be released by {@link #free(ByteBuffer)}. */ public static ByteBuffer allocate(int fsBlockSize, int size) { assert fsBlockSize > 0; assert size > 0; PointerByReference refToPtr = new PointerByReference(); int retVal = IgniteNativeIoLib.posix_memalign(refToPtr, new NativeLong(fsBlockSize), new NativeLong(size)); if (retVal != 0) throw new IgniteOutOfMemoryException("Failed to allocate memory: " + IgniteNativeIoLib.strerror(retVal)); return GridUnsafe.wrapPointer(Pointer.nativeValue(refToPtr.getValue()), size); }