This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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]

Proposed Target Macro for Java Front-end: MODIFY_JNI_METHOD_CALL


Hi,

I would like to propose a new target macro 'MODIFY_JNI_METHOD_CALL'
to allow targets like Cygwin and MinGW to modify the call generated
by the GCC Java front-end to invoke a JNI (Java Native Interface)
method.

For background information on the need for such a macro, please
see the thread starting from this message:

http://gcc.gnu.org/ml/gcc/2002-11/msg00734.html

The following proposed patch to "gcc/doc/tm.texi" explains this
macro in more detail:
------------------------------- 8< -----------------------------------
--- gcc/doc/tm.texi 2002-12-05 05:00:30.000000000 +0530
+++ gcc/doc/tm.texi 2002-12-05 07:03:16.000000000 +0530
@@ -9141,4 +9141,20 @@
lists.

+@findex MODIFY_JNI_METHOD_CALL
+@item MODIFY_JNI_METHOD_CALL (@var{mdecl})
+Define this macro to a C expression representing a variant of
+the method call @var{mdecl}, if Java Native Interface (JNI) methods
+must be invoked differently than other methods on your target
+machine. For example, on 32-bit Windows, JNI methods must be invoked
+using the @code{stdcall} calling convention and this macro
+could then be defined as this expression:
+
+@smallexample
+build_type_attribute_variant (@var{mdecl},
+ build_tree_list
+ (get_identifier ("stdcall"),
+ NULL))
+@end smallexample
+
@end table
------------------------------- 8< -----------------------------------

The following proposed patch would make the Java front-end use this
macro:
------------------------------- 8< -----------------------------------
--- gcc/java/expr.c 2002-12-05 07:12:31.000000000 +0530
+++ gcc/java/expr.c 2002-12-05 07:15:34.000000000 +0530
@@ -2266,7 +2266,11 @@
tree_cons (NULL_TREE, build_utf8_ref (tem), lookup_arg));

- jni_func_type
- = build_pointer_type (build_function_type (TREE_TYPE (TREE_TYPE (method)),
- arg_types));
+ tem = build_function_type (TREE_TYPE (TREE_TYPE (method)), arg_types);
+
+ #ifdef MODIFY_JNI_METHOD_CALL
+ tem = MODIFY_JNI_METHOD_CALL (tem);
+ #endif
+
+ jni_func_type = build_pointer_type (tem);

jnifunc = build (COND_EXPR, ptr_type_node,
------------------------------- 8< -----------------------------------

Finally, the following proposed patch will make the Cygwin/MinGW targets
define this macro appropriately (mingw32.h #include-s cygwin.h):
------------------------------- 8< -----------------------------------
--- gcc/config/i386/cygwin.h 2002-12-05 07:19:36.000000000 +0530
+++ gcc/config/i386/cygwin.h 2002-12-05 07:23:10.000000000 +0530
@@ -398,4 +398,12 @@
}

+/* Java Native Interface (JNI) methods on Win32 are invoked using
+ the stdcall calling convention */
+#undef MODIFY_JNI_METHOD_CALL
+#define MODIFY_JNI_METHOD_CALL(MDECL) \
+ build_type_attribute_variant ((MDECL), build_tree_list \
+ (get_identifier ("stdcall"), \
+ NULL))
+
/* External function declarations. */
------------------------------- 8< -----------------------------------

Does this look all right? If it does, I can submit it as patches
to the gcc-patches, mingw-patches and java-patches mailing lists.

I am sorry if this is not the right way to propose a new target
macro.

Sincerely Yours,
Ranjit.

--
Ranjit Mathew Email: rmathew AT hotmail DOT com
Bangalore,
INDIA. Web: http://ranjitmathew.tripod.com/




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]