From owner-freebsd-java Mon Feb 26 15:36: 6 2001 Delivered-To: freebsd-java@freebsd.org Received: from cypherpunks.ai (cypherpunks.ai [209.88.68.47]) by hub.freebsd.org (Postfix) with ESMTP id DF66937B491 for ; Mon, 26 Feb 2001 15:36:02 -0800 (PST) (envelope-from jeroen@vangelderen.org) Received: from vangelderen.org (grolsch.ai [209.88.68.214]) by cypherpunks.ai (Postfix) with ESMTP id D390149 for ; Mon, 26 Feb 2001 19:35:59 -0400 (AST) Message-ID: <3A9AE85F.C6F06D96@vangelderen.org> Date: Mon, 26 Feb 2001 19:35:59 -0400 From: "Jeroen C. van Gelderen" X-Mailer: Mozilla 4.73 [en] (X11; I; Linux 2.2.12 i386) X-Accept-Language: en MIME-Version: 1.0 To: FreeBSD Java Subject: Are syscall wrappers needed in JNI? Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Hi, I'm currently working on some native code libraries for our very own FreeBSD JDK 1.2. Sun of course provides near zero documentation for JNI and especially no documentation regarding native code interaction with the threading model so this is a less than pleasant experience... My JNI library uses sockets and reads and writes on those things. I'm left wondering how one actually properly calls these libc functions in the face of the JVM threading model. I had a look at the FreeBSD CommAPI implementation. It seems to just mark it's filedescriptors as O_NONBLOCK and uses the plain system calls from then on. The native code backing java.net.SocketImpl on the other hand wraps all it's calls with an INTERRUPT_IO macro[1] which seems to be neccessary for correct operation of the JVM threads. None of the above two options seems to be documented but the java.net approach is not really feasible without calling private and undocumented JVM functions. So... I'm hoping that someone here has the magic knowledge in his/her brain... How does one properly use libc from within Java? TIA, Jeroen [1] It is an indirect call to JVM_Listen which calls sysListen which is defined as INTERRUPT_IO(int, listen(fd, count)) in freebsd/hpi/green_threads/src/sys_api_td.c. -- Jeroen C. van Gelderen - jeroen@vangelderen.org "If I could save the Union without freeing any slave I would do it; and if I could save it by freeing some and leaving others alone I would also do that." -- Abraham Lincoln, August 22, 1862 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message