diff options
Diffstat (limited to 'libjava/gnu/gcj/runtime/natNameFinder.cc')
-rw-r--r-- | libjava/gnu/gcj/runtime/natNameFinder.cc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/libjava/gnu/gcj/runtime/natNameFinder.cc b/libjava/gnu/gcj/runtime/natNameFinder.cc index 29687cb5bb9..6605e380591 100644 --- a/libjava/gnu/gcj/runtime/natNameFinder.cc +++ b/libjava/gnu/gcj/runtime/natNameFinder.cc @@ -15,6 +15,8 @@ details. */ #include <config.h> +#include <string.h> + #include <gcj/cni.h> #include <jvm.h> #include <java/lang/String.h> @@ -28,6 +30,37 @@ details. */ #include <dlfcn.h> #endif +// On some systems, a prefix is attached to a method name before +// it is exported as a label. The GCC preprocessor predefines +// this prefix as the macro __USER_LABEL_PREFIX__ which expands to +// a string (not string constant) representing the prefix, if any. +#undef LABEL_PREFIX +#ifdef __USER_LABEL_PREFIX__ + +#define USER_LABEL_PREFIX_STRING_0(s) #s +#define USER_LABEL_PREFIX_STRING(s) USER_LABEL_PREFIX_STRING_0(s) + +#define LABEL_PREFIX USER_LABEL_PREFIX_STRING(__USER_LABEL_PREFIX__) + +#else /* __USER_LABEL_PREFIX__ */ + +#define LABEL_PREFIX "" + +#endif /* ! __USER_LABEL_PREFIX__ */ + +java::lang::String* +gnu::gcj::runtime::NameFinder::getExternalLabel (java::lang::String* name) +{ + jsize nameLen = JvGetStringUTFLength (name); + jsize pfxLen = strlen (LABEL_PREFIX); + char *newName = (char *) JvMalloc (pfxLen + nameLen + 1); + *(newName + 0) = '\0'; + strcpy (newName, LABEL_PREFIX); + JvGetStringUTFRegion (name, 0, nameLen, newName + pfxLen); + *(newName + pfxLen + nameLen) = '\0'; + return JvNewStringLatin1 (newName); +} + java::lang::String* gnu::gcj::runtime::NameFinder::getExecutable (void) { |