newlib and the use of fcntl by java

Richard Earnshaw rearnsha@arm.com
Fri Sep 20 02:00:00 GMT 2002


> >>>>> "Richard" == Richard Earnshaw <rearnsha@cambridge.arm.com> writes:
>> Richard> Hmm, it appears that java is making use of the fcntl function
> Richard> in newlib (or at least, it is trying to). This is a problem,
> Richard> since most embedded targets don't provide this function.
>> Was this resolved to your satisfaction?
>> Tom

Well Jeff has changed Newlib so that fcntl now always returns -1 and sets 
errno to ENOSYS on configurations that don't really have fcntl support. 
That will fix the linkage problems.
I haven't had a chance yet to rerun all the libjava tests, and I don't 
know if they will trip the following anyway (or even if they are really 
relevant on an embedded target), but a quick audit of libjava shows the 
following cases where we use fcntl:
java/lang/natPosixProcess.cc:
 // Create pipes for I/O. MSGP is for communicating exec()
 // status.
 if (pipe (inp) || pipe (outp) || pipe (errp) || pipe (msgp)
 || fcntl (msgp[1], F_SETFD, FD_CLOEXEC))
 throw new IOException (JvNewStringLatin1 (strerror (errno)));
Should we really throw the exception if the fcntl is not supported? (I 
suspect it may not matter, since we can't start processes without a proper 
OS anyway).
Other cases in that file ignore the return value, so may be ok.
java/net/natPlainSocketImpl.cc
 int flags = ::fcntl (fnum, F_GETFL);
 ::fcntl (fnum, F_SETFL, flags | O_NONBLOCK);
 
This is setting properties of a socket, which also isn't really supported 
on a bare-metal system.
R. 


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /