summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuilhem Lavaux <guilhem@kaffe.org>2006-03-25 17:08:50 +0000
committerGuilhem Lavaux <guilhem@kaffe.org>2006-03-25 17:08:50 +0000
commit754c78eb4fc80b8822d7dba21cc092efa24e8d20 (patch)
treed96ee2011d199f921b716afe7c6e10ce05db6bde
parent0c7e0a4e2b74bb6fdbe066f398a67e2f2868b33b (diff)
downloadclasspath-754c78eb4fc80b8822d7dba21cc092efa24e8d20.tar.gz
2006-03-25 Guilhem Lavaux <guilhem@kaffe.org>
* native/jni/java-io/Makefile.am, native/jni/java-lang/Makefile.am, native/jni/java-net/Makefile.am, native/jni/java-nio/Makefile.am: Link to libclasspathnative.la now. * native/jni/native-lib/Makefile.am: Added cpproc.c * native/jni/native-lib/cpio.c: Implemented missing functions for CPIO. * native/jni/native-lib/cpnet.c (cpnet_getHostByName): Fixed address array initialization. * native/jni/native-lib/cpproc.c: Implemented.
-rw-r--r--ChangeLog.native19
-rw-r--r--native/jni/java-io/Makefile.am3
-rw-r--r--native/jni/java-lang/Makefile.am3
-rw-r--r--native/jni/java-net/Makefile.am3
-rw-r--r--native/jni/java-nio/Makefile.am1
-rw-r--r--native/jni/native-lib/Makefile.am4
-rw-r--r--native/jni/native-lib/cpio.c96
-rw-r--r--native/jni/native-lib/cpnet.c4
-rw-r--r--native/jni/native-lib/cpproc.c131
9 files changed, 257 insertions, 7 deletions
diff --git a/ChangeLog.native b/ChangeLog.native
index 8dcc2ae13..3c88228ce 100644
--- a/ChangeLog.native
+++ b/ChangeLog.native
@@ -1,7 +1,24 @@
+2006-03-25 Guilhem Lavaux <guilhem@kaffe.org>
+
+ * native/jni/java-io/Makefile.am,
+ native/jni/java-lang/Makefile.am,
+ native/jni/java-net/Makefile.am,
+ native/jni/java-nio/Makefile.am: Link to libclasspathnative.la now.
+
+ * native/jni/native-lib/Makefile.am: Added cpproc.c
+
+ * native/jni/native-lib/cpio.c: Implemented missing functions for
+ CPIO.
+
+ * native/jni/native-lib/cpnet.c
+ (cpnet_getHostByName): Fixed address array initialization.
+
+ * native/jni/native-lib/cpproc.c: Implemented.
+
2006-03-19 Guilhem Lavaux <guilhem@kaffe.org>
* Synchronized to GNU Classpath 2006-03-18.
-
+
2006-02-19 Guilhem Lavaux <guilhem@kaffe.org>
* configure.ac: Invoke GCC_ATTRIBUTE_UNUSED.
diff --git a/native/jni/java-io/Makefile.am b/native/jni/java-io/Makefile.am
index ac7cf2872..637c74c61 100644
--- a/native/jni/java-io/Makefile.am
+++ b/native/jni/java-io/Makefile.am
@@ -4,7 +4,8 @@ libjavaio_la_SOURCES = java_io_VMFile.c \
java_io_VMObjectInputStream.c \
java_io_VMObjectStreamClass.c
-libjavaio_la_LIBADD = $(top_builddir)/native/jni/classpath/jcl.lo
+libjavaio_la_LIBADD = $(top_builddir)/native/jni/classpath/jcl.lo \
+ $(top_builddir)/native/jni/native-lib/libclasspathnative.la
AM_LDFLAGS = @CLASSPATH_MODULE@
AM_CPPFLAGS = @CLASSPATH_INCLUDES@
diff --git a/native/jni/java-lang/Makefile.am b/native/jni/java-lang/Makefile.am
index cd3ed242a..a9a71924d 100644
--- a/native/jni/java-lang/Makefile.am
+++ b/native/jni/java-lang/Makefile.am
@@ -7,7 +7,8 @@ libjavalang_la_SOURCES = java_lang_VMSystem.c \
java_lang_VMProcess.c
libjavalang_la_LIBADD = $(wildcard $(top_builddir)/native/fdlibm/*.lo) \
- $(top_builddir)/native/jni/classpath/jcl.lo
+ $(top_builddir)/native/jni/classpath/jcl.lo \
+ $(top_builddir)/native/jni/native-lib/libclasspathnative.la
libjavalangreflect_la_SOURCES = java_lang_reflect_Array.c
diff --git a/native/jni/java-net/Makefile.am b/native/jni/java-net/Makefile.am
index 5ad257f5a..d8f70b8ee 100644
--- a/native/jni/java-net/Makefile.am
+++ b/native/jni/java-net/Makefile.am
@@ -7,7 +7,8 @@ libjavanet_la_SOURCES = javanet.c \
gnu_java_net_VMPlainDatagramSocketImpl.c \
gnu_java_net_VMPlainSocketImpl.c
-libjavanet_la_LIBADD = $(top_builddir)/native/jni/classpath/jcl.lo
+libjavanet_la_LIBADD = $(top_builddir)/native/jni/classpath/jcl.lo \
+ $(top_builddir)/native/jni/native-lib/libclasspathnative.la
AM_LDFLAGS = @CLASSPATH_MODULE@
AM_CPPFLAGS = @CLASSPATH_INCLUDES@
diff --git a/native/jni/java-nio/Makefile.am b/native/jni/java-nio/Makefile.am
index af564373b..58d3e9506 100644
--- a/native/jni/java-nio/Makefile.am
+++ b/native/jni/java-nio/Makefile.am
@@ -9,6 +9,7 @@ libjavanio_la_SOURCES = gnu_java_nio_VMPipe.c \
java_nio_VMDirectByteBuffer.c
libjavanio_la_LIBADD = $(top_builddir)/native/jni/classpath/jcl.lo \
+ $(top_builddir)/native/jni/native-lib/libclasspathnative.la \
$(LTLIBICONV)
AM_LDFLAGS = @CLASSPATH_MODULE@
diff --git a/native/jni/native-lib/Makefile.am b/native/jni/native-lib/Makefile.am
index c34c83750..c8eb0367d 100644
--- a/native/jni/native-lib/Makefile.am
+++ b/native/jni/native-lib/Makefile.am
@@ -5,7 +5,9 @@ libclasspathnative_la_SOURCES = cpnet.c \
cpio.h \
cpnative.c \
cpnative.h \
- cpmath.h
+ cpmath.h \
+ cpproc.h \
+ cpproc.c
AM_LDFLAGS = @CLASSPATH_MODULE@
AM_CPPFLAGS = @CLASSPATH_INCLUDES@
diff --git a/native/jni/native-lib/cpio.c b/native/jni/native-lib/cpio.c
index d7c956754..fbbea570d 100644
--- a/native/jni/native-lib/cpio.c
+++ b/native/jni/native-lib/cpio.c
@@ -70,6 +70,8 @@ exception statement from your version. */
#include <sys/select.h>
#endif
+#include <utime.h>
+
#include "cpnative.h"
#include "cpio.h"
@@ -323,3 +325,97 @@ JNIEXPORT int cpio_setFileSize (int native_fd, jlong new_size)
return CPNATIVE_OK;
}
+
+int cpio_setFileReadonly (const char *filename)
+{
+ struct stat statbuf;
+
+ if (stat(filename, &statbuf) < 0)
+ return errno;
+
+ if (chmod(filename, statbuf.st_mode & ~(S_IRUSR | S_IRGRP | S_IROTH)) < 0)
+ return errno;
+
+ return 0;
+}
+
+int cpio_isFileExists (const char *filename)
+{
+ struct stat statbuf;
+
+ if (stat(filename, &statbuf) < 0)
+ {
+ return errno;
+ }
+
+ return 0;
+}
+
+int cpio_checkType (const char *filename, jint *entryType)
+{
+ struct stat statbuf;
+
+ if (stat(filename, &statbuf) < 0)
+ return errno;
+
+ if (S_ISDIR(statbuf.st_mode))
+ *entryType = CPFILE_DIRECTORY;
+ else
+ *entryType = CPFILE_FILE;
+
+ return 0;
+}
+
+int cpio_getModificationTime (const char *filename, jlong *mtime)
+{
+ struct stat statbuf;
+
+ if (stat(filename, &statbuf) < 0)
+ return errno;
+
+ *mtime = statbuf.st_mtime * 1000;
+
+ return 0;
+}
+
+int cpio_setModificationTime (const char *filename, jlong mtime)
+{
+ struct stat statbuf;
+ struct utimbuf buf;
+
+ if (stat(filename, &statbuf) < 0)
+ return errno;
+
+ buf.actime = statbuf.st_atime;
+ buf.modtime = mtime / 1000;
+
+ if (utime(filename, &buf) < 0)
+ return errno;
+
+ return 0;
+}
+
+int cpio_removeFile (const char *filename)
+{
+ if (unlink(filename) < 0)
+ return errno;
+
+ return 0;
+}
+
+int cpio_mkdir (const char *path)
+{
+ if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) < 0)
+ return errno;
+
+ return 0;
+}
+
+int cpio_rename (const char *old_name, const char *new_name)
+{
+ if (rename(old_name, new_name) < 0)
+ return errno;
+
+ return 0;
+}
+
diff --git a/native/jni/native-lib/cpnet.c b/native/jni/native-lib/cpnet.c
index d89932049..1ab0646eb 100644
--- a/native/jni/native-lib/cpnet.c
+++ b/native/jni/native-lib/cpnet.c
@@ -588,14 +588,14 @@ jint cpnet_getHostByName (JNIEnv *env, const char *hostname, cpnet_address ***ad
for (i = 0; i < counter; i++)
{
addr_arr[i] = cpnet_newIPV4Address(env);
- cpnet_bytesToIPV4Address(addr_arr[i], (jbyte *)hret.h_addr_list[counter]);
+ cpnet_bytesToIPV4Address(addr_arr[i], (jbyte *)hret.h_addr_list[i]);
}
break;
case AF_INET6:
for (i = 0; i < counter; i++)
{
addr_arr[i] = cpnet_newIPV6Address(env);
- cpnet_bytesToIPV6Address(addr_arr[i], (jbyte *)hret.h_addr_list[counter]);
+ cpnet_bytesToIPV6Address(addr_arr[i], (jbyte *)hret.h_addr_list[i]);
}
break;
default:
diff --git a/native/jni/native-lib/cpproc.c b/native/jni/native-lib/cpproc.c
new file mode 100644
index 000000000..7eac62b12
--- /dev/null
+++ b/native/jni/native-lib/cpproc.c
@@ -0,0 +1,131 @@
+/* cpproc.c -
+ Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+#include "config.h"
+#include <jni.h>
+#include "cpproc.h"
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <errno.h>
+#include <stdlib.h>
+
+static void close_all_fds(int *fds, int numFds)
+{
+ int i;
+
+ for (i = 0; i < numFds; i++)
+ close(fds[i]);
+}
+
+int cpproc_forkAndExec (char * const *commandLine, char * const * newEnviron, int *fds, pid_t *out_pid, const char *wd)
+{
+ int local_fds[6];
+ int i;
+ pid_t pid;
+
+ for (i = 0; i < 6; i += 2)
+ {
+ if (pipe(&local_fds[i]) < 0)
+ {
+ int err = errno;
+
+ close_all_fds(local_fds, i);
+
+ return err;
+ }
+ }
+
+ pid = fork();
+
+ switch (pid)
+ {
+ case 0:
+ dup2(local_fds[0], 0);
+ dup2(local_fds[3], 1);
+ dup2(local_fds[5], 2);
+
+ close_all_fds(local_fds, 6);
+
+ chdir(wd);
+ if (newEnviron == NULL)
+ execvp(commandLine[0], commandLine);
+ else
+ execve(commandLine[0], commandLine, newEnviron);
+
+ abort();
+
+ break;
+ case -1:
+ {
+ int err = errno;
+
+ close_all_fds(local_fds, 6);
+ return err;
+ }
+ default:
+ close(local_fds[0]);
+ close(local_fds[3]);
+ close(local_fds[5]);
+
+ fds[0] = local_fds[1];
+ fds[1] = local_fds[2];
+ fds[2] = local_fds[4];
+ *out_pid = pid;
+ return 0;
+ }
+}
+
+int cpproc_waitpid (pid_t pid, int *status, pid_t *outpid, int options)
+{
+ pid_t wp = waitpid(pid, status, options);
+
+ if (wp < 0)
+ return errno;
+
+ *outpid = wp;
+ return 0;
+}
+
+int cpproc_kill (pid_t pid, int signal)
+{
+ if (kill(pid, signal) < 0)
+ return errno;
+
+ return 0;
+}