This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Hi,
Here is another part of the native C cleanup.
2004-04-09 Mark Wielaard <mark@klomp.org>
* configure.ac (AM_CFLAGS): Don't define _POSIX_SOURCE.
* native/jni/gtk-peer/gthread-jni.c (maybe_rethrow): Explicitly
malloc and free buf.
* native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c
(GET_NATIVE_FD): Remove macro.
(get_native_fd): Replace GET_NATIVE_FD macro.
* native/target/generic/target_generic_misc.h
(TARGET_NATIVE_MISC_FORMAT_STRING): Remove unused macro.
With this I believe the only things that make the native sources
uncompilable with gcc-2.95 are the following:
../../../../classpath-cvs/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c:670: warning: ISO C forbids passing arg 6 of `g_signal_handlers_block_matched' between function pointer and `void *'
../../../../classpath-cvs/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c: In function `Java_gnu_java_awt_peer_gtk_GtkComponentPeer_removeExposeFilter':
../../../../classpath-cvs/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c:714: warning: ISO C forbids passing arg 6 of `g_signal_handlers_disconnect_matched' between function pointer and `void *'
../../../../classpath-cvs/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c:716: warning: ISO C forbids passing arg 6 of `g_signal_handlers_unblock_matched' between function pointer and `void *'
Could one of the gtk-peer hackers look at those?
It seems just casting the argument to a gpointer fixes all, but there is
some c macro magic going on here.
BTW. There are some other interesting warnings in the gtk-peer sources.
Cheers,
Mark
Index: configure.ac
===================================================================
RCS file: /cvsroot/classpath/classpath/configure.ac,v
retrieving revision 1.15
diff -u -r1.15 configure.ac
--- configure.ac 9 Apr 2004 14:04:48 -0000 1.15
+++ configure.ac 9 Apr 2004 17:32:24 -0000
@@ -125,7 +125,7 @@
if test "x${GCC}" = xyes; then
dnl We want ISO C90 pedantic ansi, but with longlong (jlong) support
dnl and modern POSIX and BSD C library funtions/prototypes.
- AM_CFLAGS='-ansi -std=c89 -pedantic -Wall -Wno-long-long -D_POSIX_SOURCE -D_BSD_SOURCE'
+ AM_CFLAGS='-ansi -std=c89 -pedantic -Wall -Wno-long-long -D_BSD_SOURCE'
fi
AC_SUBST(AM_CFLAGS)
Index: native/jni/gtk-peer/gthread-jni.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/gtk-peer/gthread-jni.c,v
retrieving revision 1.9
diff -u -r1.9 gthread-jni.c
--- native/jni/gtk-peer/gthread-jni.c 7 Apr 2004 20:28:54 -0000 1.9
+++ native/jni/gtk-peer/gthread-jni.c 9 Apr 2004 17:32:24 -0000
@@ -91,28 +91,40 @@
static void maybe_rethrow(JNIEnv *gdk_env, char *message, char *file, int line) {
jthrowable cause;
- /* rethrow if an exception happened */
- if ((cause = (*gdk_env)->ExceptionOccurred(gdk_env)) != NULL) {
jstring jmessage;
- jclass obj_class;
+ jclass obj_class;
jobject obj;
jmethodID ctor;
+ int len;
+ char *buf;
- /* allocate local message in Java */
- int len = strlen(message) + strlen(file) + 25;
- char buf[ len ];
- bzero(buf, len);
- sprintf(buf, "%s (at %s:%d)", message, file, line);
- jmessage = (*gdk_env)->NewStringUTF(gdk_env, buf);
+ /* rethrow if an exception happened */
+ if ((cause = (*gdk_env)->ExceptionOccurred(gdk_env)) != NULL)
+ {
+
+ /* allocate local message in Java */
+ len = strlen(message) + strlen(file) + 25;
+ buf = (char *) malloc(len);
+ if (buf != NULL)
+ {
+ bzero(buf, len);
+ sprintf(buf, "%s (at %s:%d)", message, file, line);
+ jmessage = (*gdk_env)->NewStringUTF(gdk_env, buf);
+ free(buf);
+ }
+ else
+ jmessage = NULL;
- /* create RuntimeException wrapper object */
- obj_class = (*gdk_env)->FindClass (gdk_env, "java/lang/RuntimeException");
- ctor = (*gdk_env)->GetMethodID(gdk_env, obj_class, "<init>", "(Ljava/langString;Ljava/lang/Throwable)V");
- obj = (*gdk_env)->NewObject (gdk_env, obj_class, ctor, jmessage, cause);
+ /* create RuntimeException wrapper object */
+ obj_class = (*gdk_env)->FindClass (gdk_env,
+ "java/lang/RuntimeException");
+ ctor = (*gdk_env)->GetMethodID(gdk_env, obj_class, "<init>",
+ "(Ljava/langString;Ljava/lang/Throwable)V");
+ obj = (*gdk_env)->NewObject (gdk_env, obj_class, ctor, jmessage, cause);
- /* throw it */
- (*gdk_env)->Throw(gdk_env, (jthrowable)obj);
- }
+ /* throw it */
+ (*gdk_env)->Throw(gdk_env, (jthrowable)obj);
+ }
}
/* This macro is used to include a source location in the exception message */
Index: native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c,v
retrieving revision 1.2
diff -u -r1.2 gnu_java_nio_channels_FileChannelImpl.c
--- native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c 9 Apr 2004 14:04:50 -0000 1.2
+++ native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c 9 Apr 2004 17:32:25 -0000
@@ -90,21 +90,27 @@
#define CONVERT_SSIZE_T_TO_JINT(x) ((jint)(x & 0xFFFFFFFF))
#define CONVERT_JINT_TO_SSIZE_T(x) (x)
-#define GET_NATIVE_FD(native_fd) \
- jclass clazz_fc = (*env)->FindClass (env, "gnu/java/nio/channels/FileChannelImpl"); \
- if (!clazz_fc) \
- { \
- JCL_ThrowException(env, IO_EXCEPTION, "Internal error"); \
- native_fd = -1; \
- } \
- jfieldID field_fd = (*env)->GetFieldID (env, clazz_fc, "fd", "I"); \
- if (!field_fd) \
- { \
- JCL_ThrowException(env, IO_EXCEPTION, "Internal error"); \
- native_fd = -1; \
- } \
- \
- native_fd = (*env)->GetIntField (env, obj, field_fd);
+static jint get_native_fd(JNIEnv *env, jobject obj)
+{
+ jclass clazz_fc;
+ jfieldID field_fd;
+
+ clazz_fc = (*env)->FindClass (env, "gnu/java/nio/channels/FileChannelImpl");
+ if (!clazz_fc)
+ {
+ JCL_ThrowException(env, IO_EXCEPTION, "Internal error");
+ return -1;
+ }
+
+ field_fd = (*env)->GetFieldID (env, clazz_fc, "fd", "I");
+ if (!field_fd)
+ {
+ JCL_ThrowException(env, IO_EXCEPTION, "Internal error");
+ return -1;
+ }
+
+ return (*env)->GetIntField (env, obj, field_fd);
+}
/*
* Library initialization routine. Called as part of java.io.FileDescriptor
@@ -222,7 +228,7 @@
int native_fd;
int result;
- GET_NATIVE_FD(native_fd);
+ native_fd = get_native_fd(env, obj);
TARGET_NATIVE_FILE_CLOSE(native_fd,result);
if (result != TARGET_NATIVE_OK)
@@ -243,7 +249,7 @@
jlong bytes_available;
int result;
- GET_NATIVE_FD(native_fd);
+ native_fd = get_native_fd(env, obj);
TARGET_NATIVE_FILE_AVAILABLE(native_fd,bytes_available,result);
if (result != TARGET_NATIVE_OK)
@@ -275,7 +281,7 @@
jlong file_size;
int result;
- GET_NATIVE_FD(native_fd);
+ native_fd = get_native_fd(env, obj);
TARGET_NATIVE_FILE_SIZE(native_fd, file_size, result);
if (result != TARGET_NATIVE_OK)
@@ -299,7 +305,7 @@
jlong current_offset;
int result;
- GET_NATIVE_FD(native_fd);
+ native_fd = get_native_fd(env, obj);
TARGET_NATIVE_FILE_TELL(native_fd, current_offset, result);
if (result != TARGET_NATIVE_OK)
@@ -323,7 +329,7 @@
jlong new_offset;
int result;
- GET_NATIVE_FD(native_fd);
+ native_fd = get_native_fd(env, obj);
#if 0
/* Should there be such an exception? All native layer macros should
@@ -370,7 +376,7 @@
char data;
int result;
- GET_NATIVE_FD(native_fd);
+ native_fd = get_native_fd(env, obj);
#if 0
/* Should there be such an exception? All native layer macros should
@@ -488,7 +494,7 @@
ssize_t bytes_read;
int result;
- GET_NATIVE_FD(native_fd);
+ native_fd = get_native_fd(env, obj);
bytes_read = 0;
do
@@ -524,7 +530,7 @@
ssize_t n;
int result;
- GET_NATIVE_FD(native_fd);
+ native_fd = get_native_fd(env, obj);
bufptr = (*env)->GetByteArrayElements(env, buffer, 0);
if (!bufptr)
@@ -572,7 +578,7 @@
ssize_t bytes_written;
int result;
- GET_NATIVE_FD(native_fd);
+ native_fd = get_native_fd(env, obj);
native_data = (char)(CONVERT_JINT_TO_INT(b) & 0xFF);
do
@@ -601,7 +607,7 @@
ssize_t n;
int result;
- GET_NATIVE_FD(native_fd);
+ native_fd = get_native_fd(env, obj);
bufptr = (*env)->GetByteArrayElements(env, buffer, 0);
if (!bufptr)
Index: native/target/generic/target_generic_misc.h
===================================================================
RCS file: /cvsroot/classpath/classpath/native/target/generic/target_generic_misc.h,v
retrieving revision 1.9
diff -u -r1.9 target_generic_misc.h
--- native/target/generic/target_generic_misc.h 29 Mar 2004 07:07:40 -0000 1.9
+++ native/target/generic/target_generic_misc.h 9 Apr 2004 17:32:25 -0000
@@ -68,38 +68,6 @@
/****************************** Macros *********************************/
/***********************************************************************\
-* Name : TARGET_NATIVE_MISC_FORMAT_STRING
-* Purpose : format a string with arguments
-* Input : buffer - buffer for string
-* bufferSize - size of buffer
-* format - format string (like printf)
-* args - optional arguments (GNU CPP only!)
-* Output : -
-* Return : -
-* Side-effect: unknown
-* Notes : - this macro can only be used with a GNU gcc (CPP)
-* - this is a "safe" macro to format string; buffer-
-* overflows will be avoided. Direct usage of e. g.
-* snprintf() is not permitted because it is not ANSI C
-* (not portable!)
-* - do not use this routine in a function without
-* variable number of arguments (ellipses), because
-* va_list/va_start/va_end is used!
-\***********************************************************************/
-
-#ifndef TARGET_NATIVE_MISC_FORMAT_STRING
- #ifdef __GNUC__
- #include <stdarg.h>
- #define TARGET_NATIVE_MISC_FORMAT_STRING(buffer,bufferSize,format,args...) \
- do { \
- snprintf(buffer,bufferSize,format, ## args); \
- } while (0)
- #else
- #error TARGET_NATIVE_MISC_FORMAT_STRING with variable number of arguments is only supported by GNU gcc! Use TARGET_NATIVE_FORMAT_STRING<n> instead.
- #endif
-#endif
-
-/***********************************************************************\
* Name : TARGET_NATIVE_MISC_FORMAT_STRING<n>
* Purpose : format a string (with a fixed number of) arguments
* Input : buffer - buffer for string
Attachment:
signature.asc
Description: This is a digitally signed message part
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |