Proposed Target Macro for Java Front-end: MODIFY_JNI_METHOD_CALL
Andrew Haley
aph@redhat.com
Mon Dec 9 09:56:00 GMT 2002
Ranjit Mathew writes:
> 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
differently from
> 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:
I suggest "is defined as"
> +
> +@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< -----------------------------------
The Java parts of this are OK, but you'll need to get approval from
someone with appropriate priviliges for the i386 and genereric part.
Andrew.
More information about the Gcc
mailing list