[kaffe] CVS kaffe (kaz): FAQ/FAQ.freebsd: New file.
Kaffe CVS
cvs-commits at kaffe.org
Fri May 25 17:13:46 PDT 2007
PatchSet 7481
Date: 2007/05/26 00:12:18
Author: kaz
Branch: HEAD
Tag: (none)
Log:
2007-05-26 Ito Kazumitsu <kaz at maczuka.gcd.org>
* FAQ/FAQ.freebsd: New file.
* libraries/javalib/external/classpath/native/jni/java-nio/gnu_java_nio_
VMChannel.c,
libraries/javalib/external/classpath/native/jni/native-lib/cpio.c,
libraries/javalib/external/classpath/native/jni/native-lib/cpio.h:
Copied from GNU Classpath so that a FreeBSD problem can have a
workaround.
Members:
ChangeLog:1.4980->1.4981
FAQ/FAQ.freebsd:INITIAL->1.1
libraries/javalib/external/classpath/native/jni/java-nio/gnu_java_nio_VMChannel.c:1.8->1.9
libraries/javalib/external/classpath/native/jni/native-lib/cpio.c:1.3->1.4
libraries/javalib/external/classpath/native/jni/native-lib/cpio.h:1.3->1.4
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4980 kaffe/ChangeLog:1.4981
--- kaffe/ChangeLog:1.4980 Wed May 9 15:52:22 2007
+++ kaffe/ChangeLog Sat May 26 00:12:18 2007
@@ -1,3 +1,12 @@
+2007-05-26 Ito Kazumitsu <kaz at maczuka.gcd.org>
+
+ * FAQ/FAQ.freebsd: New file.
+ * libraries/javalib/external/classpath/native/jni/java-nio/gnu_java_nio_VMChannel.c,
+ libraries/javalib/external/classpath/native/jni/native-lib/cpio.c,
+ libraries/javalib/external/classpath/native/jni/native-lib/cpio.h:
+ Copied from GNU Classpath so that a FreeBSD problem can have a
+ workaround.
+
2007-05-10 Kiyo Inaba <inaba at src.ricoh.co.jp>
* config/arm/jit3-arm.def: Updated to new LOUT etc scheme.
===================================================================
Checking out kaffe/FAQ/FAQ.freebsd
RCS: /home/cvs/kaffe/kaffe/FAQ/FAQ.freebsd,v
VERS: 1.1
***************
--- /dev/null Sun Aug 4 19:57:58 2002
+++ kaffe/FAQ/FAQ.freebsd Sat May 26 00:13:45 2007
@@ -0,0 +1,27 @@
+FAQ for FreeBSD
+===============
+
+BufferedInputStreamAvailableTest.java fails.
+--------------------------------------------
+
+This is due to GNU Classpath's native library. See this bug report
+for details.
+
+http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31927
+
+A workaround for this problem follows.
+
+Go to libraries/javalib/external/classpath/native/jni and edit
+java-nio/gnu_java_nio_VMChannel.c and native-lib/cpio.c.
+
+These have functions named Java_gnu_java_nio_VMChannel_available
+and cpio_availableBytes respectively.
+
+These have a line which reads
+
+#if defined (FIONREAD)
+
+Change this line so that this #if part may be ignored.
+
+#if defined (FIONREAD) && 0
+
Index: kaffe/libraries/javalib/external/classpath/native/jni/java-nio/gnu_java_nio_VMChannel.c
diff -u kaffe/libraries/javalib/external/classpath/native/jni/java-nio/gnu_java_nio_VMChannel.c:1.8 kaffe/libraries/javalib/external/classpath/native/jni/java-nio/gnu_java_nio_VMChannel.c:1.9
--- kaffe/libraries/javalib/external/classpath/native/jni/java-nio/gnu_java_nio_VMChannel.c:1.8 Sun Jan 28 13:56:22 2007
+++ kaffe/libraries/javalib/external/classpath/native/jni/java-nio/gnu_java_nio_VMChannel.c Sat May 26 00:12:19 2007
@@ -1,5 +1,5 @@
/* gnu_java_nio_VMChannel.c -
- Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,7 +43,6 @@
#include <config-int.h>
#include <sys/types.h>
-#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/socket.h>
#include <sys/stat.h>
@@ -67,6 +66,14 @@
#include <fcntl.h>
#endif /* HAVE_FCNTL_H */
+#if defined(HAVE_SYS_IOCTL_H)
+#define BSD_COMP /* Get FIONREAD on Solaris2 */
+#include <sys/ioctl.h>
+#endif
+#if defined(HAVE_SYS_FILIO_H) /* Get FIONREAD on Solaris 2.5 */
+#include <sys/filio.h>
+#endif
+
#define CONNECT_EXCEPTION "java/net/ConnectException"
#define IO_EXCEPTION "java/io/IOException"
#define SOCKET_EXCEPTION "java/net/SocketException"
@@ -1575,6 +1582,8 @@
jclass c __attribute__((unused)),
jint fd)
{
+#if defined (FIONREAD)
+
jint avail = 0;
/* NIODBG("fd: %d", fd); */
@@ -1583,6 +1592,53 @@
/* NIODBG("avail: %d", avail); */
return avail;
+
+#elif defined(HAVE_FSTAT)
+
+ jint avail = 0;
+
+ struct stat statBuffer;
+ off_t n;
+
+ if ((fstat (fd, &statBuffer) == 0) && S_ISREG (statBuffer.st_mode))
+ {
+ n = lseek (fd, 0, SEEK_CUR);
+ if (n != -1)
+ {
+ avail = statBuffer.st_size - n;
+ return avail;
+ }
+ }
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+
+#elif defined(HAVE_SELECT)
+
+ jint avail = 0;
+ fd_set filedescriptset;
+ struct timeval tv;
+
+ FD_ZERO (&filedescriptset);
+ FD_SET (fd,&filedescriptset);
+ memset (&tv, 0, sizeof(tv));
+
+ switch (select (fd+1, &filedescriptset, NULL, NULL, &tv))
+ {
+ case -1:
+ break;
+ case 0:
+ avail = 0;
+ return avail;
+ default:
+ avail = 1;
+ return avail;
+ }
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+
+#else
+
+ JCL_ThrowException (env, IO_EXCEPTION, "No native method for available");
+
+#endif
}
@@ -1609,8 +1665,6 @@
int nmode = 0;
int ret;
const char *npath;
- mode_t mask = umask (0);
- umask (mask);
if ((mode & CPNIO_READ) && (mode & CPNIO_WRITE))
nmode = O_RDWR;
@@ -1630,7 +1684,7 @@
/* NIODBG("path: %s; mode: %x", npath, nmode); */
- ret = open (npath, nmode, 0777 & ~mask);
+ ret = open (npath, nmode, 0666);
/* NIODBG("ret: %d\n", ret); */
Index: kaffe/libraries/javalib/external/classpath/native/jni/native-lib/cpio.c
diff -u kaffe/libraries/javalib/external/classpath/native/jni/native-lib/cpio.c:1.3 kaffe/libraries/javalib/external/classpath/native/jni/native-lib/cpio.c:1.4
--- kaffe/libraries/javalib/external/classpath/native/jni/native-lib/cpio.c:1.3 Fri Jan 5 19:15:38 2007
+++ kaffe/libraries/javalib/external/classpath/native/jni/native-lib/cpio.c Sat May 26 00:12:19 2007
@@ -158,14 +158,14 @@
off_t n;
int result;
- *bytes_available = 0
+ *bytes_available = 0;
if ((fstat (fd, &statBuffer) == 0) && S_ISREG (statBuffer.st_mode))
{
n = lseek (fd, 0, SEEK_CUR);
if (n != -1)
{
*bytes_available = statBuffer.st_size - n;
- result = 0;
+ result = CPNATIVE_OK;
}
else
{
@@ -189,7 +189,7 @@
FD_SET (fd,&filedescriptset);
memset (&tv, 0, sizeof(tv));
- switch (select (fd+1, &filedescriptset, NULL, NULL, &timeval)) \
+ switch (select (fd+1, &filedescriptset, NULL, NULL, &tv))
{
case -1:
result=errno;
@@ -350,6 +350,76 @@
return errno;
return 0;
+}
+
+int cpio_chmod (const char *filename, int permissions)
+{
+ struct stat statbuf;
+ int perms = 0;
+
+ if (stat(filename, &statbuf) < 0)
+ return errno;
+
+ /* check for permission flags */
+ if (permissions & CPFILE_FLAG_USR)
+ {
+ if (permissions & CPFILE_FLAG_READ)
+ perms |= S_IRUSR;
+
+ if (permissions & CPFILE_FLAG_WRITE)
+ perms |= S_IWUSR;
+
+ if (permissions & CPFILE_FLAG_EXEC)
+ perms |= S_IXUSR;
+ }
+ else
+ {
+ if (permissions & CPFILE_FLAG_READ)
+ perms |= (S_IRUSR | S_IRGRP | S_IROTH);
+
+ if (permissions & CPFILE_FLAG_WRITE)
+ perms |= (S_IWUSR | S_IWGRP | S_IWOTH);
+
+ if (permissions & CPFILE_FLAG_EXEC)
+ perms |= (S_IXUSR | S_IXGRP | S_IXOTH);
+ }
+
+ if (permissions & CPFILE_FLAG_OFF)
+ perms = statbuf.st_mode & ~perms;
+ else
+ perms = statbuf.st_mode | perms;
+
+ if (chmod(filename, perms) < 0)
+ return errno;
+
+ return 0;
+}
+
+int cpio_checkAccess (const char *filename, unsigned int flag)
+{
+ struct stat statbuf;
+ unsigned int perms = 0;
+
+ if (stat(filename, &statbuf) < 0)
+ return errno;
+
+ switch (flag)
+ {
+ case CPFILE_FLAG_READ:
+ perms = R_OK;
+ break;
+
+ case CPFILE_FLAG_WRITE:
+ perms = W_OK;
+ break;
+
+ case CPFILE_FLAG_EXEC:
+ default:
+ perms = X_OK;
+ break;
+ }
+
+ return (access (filename, perms));
}
int cpio_isFileExists (const char *filename)
Index: kaffe/libraries/javalib/external/classpath/native/jni/native-lib/cpio.h
diff -u kaffe/libraries/javalib/external/classpath/native/jni/native-lib/cpio.h:1.3 kaffe/libraries/javalib/external/classpath/native/jni/native-lib/cpio.h:1.4
--- kaffe/libraries/javalib/external/classpath/native/jni/native-lib/cpio.h:1.3 Fri Jan 5 19:15:38 2007
+++ kaffe/libraries/javalib/external/classpath/native/jni/native-lib/cpio.h Sat May 26 00:12:19 2007
@@ -48,6 +48,9 @@
#define CPFILE_FLAG_BINARY 0x0020
#define CPFILE_FLAG_READ 0x0040
#define CPFILE_FLAG_WRITE 0x0080
+#define CPFILE_FLAG_EXEC 0x0100
+#define CPFILE_FLAG_USR 0x0400
+#define CPFILE_FLAG_OFF 0x0800
#define CPFILE_PERMISSION_NORMAL 1
@@ -70,6 +73,8 @@
#define CPFILE_DIRECTORY 1
JNIEXPORT int cpio_setFileReadonly (const char *filename);
+JNIEXPORT int cpio_chmod (const char *filename, int permissions);
+JNIEXPORT int cpio_checkAccess (const char *filename, unsigned int flag);
JNIEXPORT int cpio_isFileExists (const char *filename);
JNIEXPORT int cpio_checkType (const char *filename, jint *entryType);
JNIEXPORT int cpio_getModificationTime (const char *filename, jlong *mtime);
More information about the kaffe
mailing list