diff options
Diffstat (limited to 'libjava/classpath/native/jni/native-lib')
-rw-r--r-- | libjava/classpath/native/jni/native-lib/Makefile.in | 35 | ||||
-rw-r--r-- | libjava/classpath/native/jni/native-lib/cpio.c | 70 | ||||
-rw-r--r-- | libjava/classpath/native/jni/native-lib/cpio.h | 5 | ||||
-rw-r--r-- | libjava/classpath/native/jni/native-lib/cpnet.c | 65 | ||||
-rw-r--r-- | libjava/classpath/native/jni/native-lib/cpnet.h | 2 | ||||
-rw-r--r-- | libjava/classpath/native/jni/native-lib/cpproc.c | 4 |
6 files changed, 161 insertions, 20 deletions
diff --git a/libjava/classpath/native/jni/native-lib/Makefile.in b/libjava/classpath/native/jni/native-lib/Makefile.in index 4b89973bdf4..bc87d788213 100644 --- a/libjava/classpath/native/jni/native-lib/Makefile.in +++ b/libjava/classpath/native/jni/native-lib/Makefile.in @@ -44,16 +44,21 @@ am__aclocal_m4_deps = $(top_srcdir)/../../config/depstand.m4 \ $(top_srcdir)/../../config/lead-dot.m4 \ $(top_srcdir)/../../config/multi.m4 \ $(top_srcdir)/../../config/no-executables.m4 \ - $(top_srcdir)/../../libtool.m4 $(top_srcdir)/m4/acattribute.m4 \ - $(top_srcdir)/m4/accross.m4 $(top_srcdir)/m4/acinclude.m4 \ + $(top_srcdir)/../../libtool.m4 \ + $(top_srcdir)/../../ltoptions.m4 \ + $(top_srcdir)/../../ltsugar.m4 \ + $(top_srcdir)/../../ltversion.m4 \ + $(top_srcdir)/m4/acattribute.m4 $(top_srcdir)/m4/accross.m4 \ + $(top_srcdir)/m4/acinclude.m4 \ $(top_srcdir)/m4/ax_create_stdint_h.m4 \ + $(top_srcdir)/m4/ax_func_which_gethostbyname_r.m4 \ $(top_srcdir)/m4/gcc_attribute.m4 $(top_srcdir)/m4/iconv.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/pkg.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +mkinstalldirs = $(SHELL) $(top_srcdir)/../../mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) @@ -61,15 +66,15 @@ libclasspathnative_la_LIBADD = am_libclasspathnative_la_OBJECTS = cpnet.lo cpio.lo cpproc.lo libclasspathnative_la_OBJECTS = $(am_libclasspathnative_la_OBJECTS) DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include -depcomp = $(SHELL) $(top_srcdir)/depcomp +depcomp = $(SHELL) $(top_srcdir)/../../depcomp am__depfiles_maybe = depfiles COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) \ +LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) -LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ +LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(libclasspathnative_la_SOURCES) DIST_SOURCES = $(libclasspathnative_la_SOURCES) @@ -80,12 +85,15 @@ ACLOCAL = @ACLOCAL@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ AMTAR = @AMTAR@ +AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@ BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@ +CAIRO_CFLAGS = @CAIRO_CFLAGS@ +CAIRO_LIBS = @CAIRO_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ @@ -131,6 +139,7 @@ DATE = @DATE@ DEFAULT_PREFS_PEER = @DEFAULT_PREFS_PEER@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ +DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ @@ -143,15 +152,16 @@ ERROR_CFLAGS = @ERROR_CFLAGS@ EXAMPLESDIR = @EXAMPLESDIR@ EXEEXT = @EXEEXT@ FASTJAR = @FASTJAR@ +FGREP = @FGREP@ FIND = @FIND@ FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@ FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@ FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@ FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@ -FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@ -FOUND_GCJX_TRUE = @FOUND_GCJX_TRUE@ FOUND_GCJ_FALSE = @FOUND_GCJ_FALSE@ FOUND_GCJ_TRUE = @FOUND_GCJ_TRUE@ +FOUND_JAVAC_FALSE = @FOUND_JAVAC_FALSE@ +FOUND_JAVAC_TRUE = @FOUND_JAVAC_TRUE@ FOUND_JIKES_FALSE = @FOUND_JIKES_FALSE@ FOUND_JIKES_TRUE = @FOUND_JIKES_TRUE@ FOUND_KJC_FALSE = @FOUND_KJC_FALSE@ @@ -159,7 +169,6 @@ FOUND_KJC_TRUE = @FOUND_KJC_TRUE@ FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@ FREETYPE2_LIBS = @FREETYPE2_LIBS@ GCJ = @GCJ@ -GCJX = @GCJX@ GCONF_CFLAGS = @GCONF_CFLAGS@ GCONF_LIBS = @GCONF_LIBS@ GDK_CFLAGS = @GDK_CFLAGS@ @@ -169,6 +178,7 @@ GENINSRC_TRUE = @GENINSRC_TRUE@ GJDOC = @GJDOC@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ +GREP = @GREP@ GTK_CFLAGS = @GTK_CFLAGS@ GTK_LIBS = @GTK_LIBS@ INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@ @@ -180,6 +190,7 @@ INSTALL_GLIBJ_ZIP_TRUE = @INSTALL_GLIBJ_ZIP_TRUE@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +JAVAC = @JAVAC@ JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION = @JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION@ JAVA_MAINTAINER_MODE_FALSE = @JAVA_MAINTAINER_MODE_FALSE@ JAVA_MAINTAINER_MODE_TRUE = @JAVA_MAINTAINER_MODE_TRUE@ @@ -189,6 +200,7 @@ JIKES = @JIKES@ JIKESENCODING = @JIKESENCODING@ JIKESWARNINGS = @JIKESWARNINGS@ KJC = @KJC@ +LD = @LD@ LDFLAGS = @LDFLAGS@ LIBDEBUG = @LIBDEBUG@ LIBICONV = @LIBICONV@ @@ -208,6 +220,7 @@ MKDIR = @MKDIR@ MOC = @MOC@ MOZILLA_CFLAGS = @MOZILLA_CFLAGS@ MOZILLA_LIBS = @MOZILLA_LIBS@ +NM = @NM@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ @@ -229,6 +242,7 @@ RANLIB = @RANLIB@ REGEN_PARSERS_FALSE = @REGEN_PARSERS_FALSE@ REGEN_PARSERS_TRUE = @REGEN_PARSERS_TRUE@ REMOVE = @REMOVE@ +SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRICT_WARNING_CFLAGS = @STRICT_WARNING_CFLAGS@ @@ -256,8 +270,10 @@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ X_LIBS = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ ZIP = @ZIP@ +ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ ac_ct_RANLIB = @ac_ct_RANLIB@ ac_ct_STRIP = @ac_ct_STRIP@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ @@ -290,6 +306,7 @@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ multi_basedir = @multi_basedir@ diff --git a/libjava/classpath/native/jni/native-lib/cpio.c b/libjava/classpath/native/jni/native-lib/cpio.c index 2777a31b221..ac3c0b5e79c 100644 --- a/libjava/classpath/native/jni/native-lib/cpio.c +++ b/libjava/classpath/native/jni/native-lib/cpio.c @@ -352,6 +352,76 @@ int cpio_setFileReadonly (const char *filename) 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) { struct stat statbuf; diff --git a/libjava/classpath/native/jni/native-lib/cpio.h b/libjava/classpath/native/jni/native-lib/cpio.h index b388b5b501d..259fc62cf79 100644 --- a/libjava/classpath/native/jni/native-lib/cpio.h +++ b/libjava/classpath/native/jni/native-lib/cpio.h @@ -48,6 +48,9 @@ exception statement from your version. */ #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 @@ JNIEXPORT int cpio_closeOnExec(int fd); #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); diff --git a/libjava/classpath/native/jni/native-lib/cpnet.c b/libjava/classpath/native/jni/native-lib/cpnet.c index 85c4640e16f..22ce69e2797 100644 --- a/libjava/classpath/native/jni/native-lib/cpnet.c +++ b/libjava/classpath/native/jni/native-lib/cpnet.c @@ -46,23 +46,22 @@ exception statement from your version. */ #include <netinet/in.h> #include <netinet/tcp.h> #include <netdb.h> -#include <sys/ioctl.h> #include <sys/time.h> #include <unistd.h> #include <arpa/inet.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 + #include "cpnet.h" #define SOCKET_DEFAULT_TIMEOUT -1 /* milliseconds */ -#if defined (HAVE_MSG_NOSIGNAL) -#define SOCKET_NOSIGNAL MSG_NOSIGNAL -#elif defined (HAVE_SO_NOSIGPIPE) -#define SOCKET_NOSIGNAL SO_NOSIGPIPE -#else -#error "No suitable flag found to ommit a SIGPIPE on signal errors with send()." -#endif - static int socketTimeouts[FD_SETSIZE]; static jint waitForWritable(jint fd) @@ -249,6 +248,15 @@ jint cpnet_setBroadcast(JNIEnv *env UNUSED, jint fd, jint flag) return 0; } +#if defined (HAVE_MSG_NOSIGNAL) +#elif defined (HAVE_SO_NOSIGPIPE) +static int setsockopt_NOSIGPIPE (int fd) +{ + int setToTrue = 1; + return setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &setToTrue, sizeof(setToTrue)); +} +#endif + jint cpnet_send (JNIEnv *env UNUSED, jint fd, jbyte *data, jint len, jint *bytes_sent) { ssize_t ret; @@ -256,7 +264,17 @@ jint cpnet_send (JNIEnv *env UNUSED, jint fd, jbyte *data, jint len, jint *bytes if (waitForWritable(fd) < 0) return ETIMEDOUT; - ret = send(fd, data, len, SOCKET_NOSIGNAL); +#if defined (HAVE_MSG_NOSIGNAL) + ret = send(fd, data, len, MSG_NOSIGNAL); +#elif defined (HAVE_SO_NOSIGPIPE) + ret = setsockopt_NOSIGPIPE(fd); + if (ret == 0) ret = send(fd, data, len, 0); +#else + /* We want SIGPIPE to be omitted. But this configuration does not have an + * option for that. + */ + ret = send(fd, data, len, 0); +#endif if (ret < 0) return errno; @@ -272,8 +290,24 @@ jint cpnet_sendTo (JNIEnv *env UNUSED, jint fd, jbyte *data, jint len, cpnet_add if (waitForWritable(fd) < 0) return ETIMEDOUT; - ret = sendto(fd, data, len, SOCKET_NOSIGNAL, (struct sockaddr *)addr->data, +#if defined (HAVE_MSG_NOSIGNAL) + ret = sendto(fd, data, len, MSG_NOSIGNAL, (struct sockaddr *)addr->data, addr->len); +#elif defined (HAVE_SO_NOSIGPIPE) + ret = setsockopt_NOSIGPIPE(fd); + if (ret == 0) + { + ret = sendto(fd, data, len, 0, (struct sockaddr *)addr->data, + addr->len); + } +#else + /* We want SIGPIPE to be omitted. But this configuration does not have an + * option for that. + */ + ret = sendto(fd, data, len, 0, (struct sockaddr *)addr->data, + addr->len); +#endif + if (ret < 0) return errno; @@ -608,8 +642,17 @@ jint cpnet_getHostByName (JNIEnv *env, const char *hostname, cpnet_address ***ad do { buf = (char *)JCL_malloc(env, buflen); + #ifdef HAVE_GETHOSTBYNAME_R +# if defined(HAVE_FUNC_GETHOSTBYNAME_R_6) ret = gethostbyname_r (hostname, &hret, buf, buflen, &result, &herr); +# elif defined(HAVE_FUNC_GETHOSTBYNAME_R_5) + result = gethostbyname_r(hostname, &hret, buf, buflen, &herr); +# elif defined(HAVE_FUNC_GETHOSTBYNAME_R_3) +# error IMPLEMENT ME! +# else +# error unknown number of arguments for gethostbyname_r +# endif #else hret.h_addr_list = NULL; hret.h_addrtype = 0; diff --git a/libjava/classpath/native/jni/native-lib/cpnet.h b/libjava/classpath/native/jni/native-lib/cpnet.h index 3705c76ecd5..10963262731 100644 --- a/libjava/classpath/native/jni/native-lib/cpnet.h +++ b/libjava/classpath/native/jni/native-lib/cpnet.h @@ -42,7 +42,9 @@ exception statement from your version. */ #include <jcl.h> #include <string.h> +#include <sys/types.h> #include <sys/socket.h> +#include <netinet/in_systm.h> #include <netinet/in.h> #include <netinet/ip.h> diff --git a/libjava/classpath/native/jni/native-lib/cpproc.c b/libjava/classpath/native/jni/native-lib/cpproc.c index b6e9030b562..bb34f6d6e38 100644 --- a/libjava/classpath/native/jni/native-lib/cpproc.c +++ b/libjava/classpath/native/jni/native-lib/cpproc.c @@ -114,6 +114,10 @@ int cpproc_forkAndExec (char * const *commandLine, char * const * newEnviron, *out_pid = pid; return 0; } + + /* keep compiler happy */ + + return 0; } int cpproc_waitpid (pid_t pid, int *status, pid_t *outpid, int options) |