jdk/src/solaris/native/sun/awt/awt_LoadLibrary.c
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2000-2005 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#include <stdio.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include <dlfcn.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include <string.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include <stdlib.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include <jni.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include <jni_util.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include <jvm.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include "gdefs.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include <sys/param.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#include <sys/utsname.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#include "awt_Plugin.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#ifdef DEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#define VERBOSE_AWT_DEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
static void *awtHandle = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
typedef JNIEXPORT jint JNICALL JNI_OnLoad_type(JavaVM *vm, void *reserved);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
/* Initialize the Java VM instance variable when the library is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
   first loaded */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
JavaVM *jvm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
JNIEXPORT jboolean JNICALL AWTIsHeadless() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    static JNIEnv *env = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    static jboolean isHeadless;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    jmethodID headlessFn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    jclass graphicsEnvClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    if (env == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        graphicsEnvClass = (*env)->FindClass(env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
                                             "java/awt/GraphicsEnvironment");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        if (graphicsEnvClass == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
            return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        headlessFn = (*env)->GetStaticMethodID(env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
                                               graphicsEnvClass, "isHeadless", "()Z");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        if (headlessFn == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
            return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        isHeadless = (*env)->CallStaticBooleanMethod(env, graphicsEnvClass,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
                                                     headlessFn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    return isHeadless;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
jint
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
AWT_OnLoad(JavaVM *vm, void *reserved)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    Dl_info dlinfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    char buf[MAXPATHLEN];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    int32_t len;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    char *p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    JNI_OnLoad_type *JNI_OnLoad_ptr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    struct utsname name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(vm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    void *v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    char *envvar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    int xt_before_xm = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    int XAWT = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    jstring toolkit = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    jstring propname = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    if (awtHandle != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        /* Avoid several loading attempts */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        return JNI_VERSION_1_2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    jvm = vm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    /* Get address of this library and the directory containing it. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    dladdr((void *)JNI_OnLoad, &dlinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    realpath((char *)dlinfo.dli_fname, buf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    len = strlen(buf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    p = strrchr(buf, '/');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * The code below is responsible for:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * 1. Loading appropriate awt library, i.e. xawt/libmawt or headless/libwawt
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * 2. Setting "awt.toolkit" system property to use the appropriate Java toolkit class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     *    (if user has specified the toolkit in env varialble)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    propname = (*env)->NewStringUTF(env, "awt.toolkit");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    /* Check if toolkit is specified in env variable */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    envvar = getenv("AWT_TOOLKIT");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    if (envvar) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        if (strstr(envvar, "XToolkit")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            toolkit = (*env)->NewStringUTF(env, "sun.awt.X11.XToolkit");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        /* If user specified toolkit then set java system property */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        if (toolkit && propname) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            JNU_CallStaticMethodByName (env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                                        NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                                        "java/lang/System",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                                        "setProperty",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                                        "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                                        propname,toolkit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    /* Calculate toolkit name, kind of toolkit (XAWT, Motif) and library to load */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    if (AWTIsHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        strcpy(p, "/headless/libmawt");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        /* Default AWT Toolkit on Linux and Solaris is XAWT. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        strcpy(p, "/xawt/libmawt");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    if (toolkit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        (*env)->DeleteLocalRef(env, toolkit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    if (propname) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        (*env)->DeleteLocalRef(env, propname);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    strcat(p, ".so");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    JNU_CallStaticMethodByName(env, NULL, "java/lang/System", "load",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                               "(Ljava/lang/String;)V",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                               JNU_NewStringPlatform(env, buf));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    awtHandle = dlopen(buf, RTLD_LAZY | RTLD_GLOBAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
  if (dlsym(awtHandle, "AWTCharRBearing") == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
  printf("========= AWTCharRBearing not found\n"); fflush(stdout);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
  else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
  printf("========= AWTCharRBearing was found\n"); fflush(stdout);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    return JNI_VERSION_1_2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
JNI_OnLoad(JavaVM *vm, void *reserved)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    return AWT_OnLoad(vm, reserved);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
 * This entry point must remain in libawt.so as part of a contract
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
 * with the CDE variant of Java Media Framework. (sdtjmplay)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
 * Reflect this call over to the correct libmawt.so.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
Java_sun_awt_motif_XsessionWMcommand(JNIEnv *env, jobject this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                                     jobject frame, jstring jcommand)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    /* type of the old backdoor function */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    typedef JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        XsessionWMcommand_type(JNIEnv *env, jobject this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                               jobject frame, jstring jcommand);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    static XsessionWMcommand_type *XsessionWMcommand = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    if (XsessionWMcommand == NULL && awtHandle == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    XsessionWMcommand = (XsessionWMcommand_type *)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        dlsym(awtHandle, "Java_sun_awt_motif_XsessionWMcommand");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    if (XsessionWMcommand == NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    (*XsessionWMcommand)(env, this, frame, jcommand);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
 * This entry point must remain in libawt.so as part of a contract
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
 * with the CDE variant of Java Media Framework. (sdtjmplay)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
 * Reflect this call over to the correct libmawt.so.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
Java_sun_awt_motif_XsessionWMcommand_New(JNIEnv *env, jobjectArray jargv)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    typedef JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        XsessionWMcommand_New_type(JNIEnv *env, jobjectArray jargv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    static XsessionWMcommand_New_type *XsessionWMcommand = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    if (XsessionWMcommand == NULL && awtHandle == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    XsessionWMcommand = (XsessionWMcommand_New_type *)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        dlsym(awtHandle, "Java_sun_awt_motif_XsessionWMcommand_New");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    if (XsessionWMcommand == NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    (*XsessionWMcommand)(env, jargv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
#define REFLECT_VOID_FUNCTION(name, arglist, paramlist)                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
typedef name##_type arglist;                                            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
void name arglist                                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
{                                                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    static name##_type *name##_ptr = NULL;                              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    if (name##_ptr == NULL && awtHandle == NULL) {                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        return;                                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    }                                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    name##_ptr = (name##_type *)                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        dlsym(awtHandle, #name);                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    if (name##_ptr == NULL) {                                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        return;                                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    }                                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    (*name##_ptr)paramlist;                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
#define REFLECT_FUNCTION(return_type, name, arglist, paramlist)         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
typedef return_type name##_type arglist;                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
return_type name arglist                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
{                                                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    static name##_type *name##_ptr = NULL;                              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    if (name##_ptr == NULL && awtHandle == NULL) {                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        return NULL;                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    }                                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    name##_ptr = (name##_type *)                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        dlsym(awtHandle, #name);                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    if (name##_ptr == NULL) {                                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        return NULL;                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    }                                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    return (*name##_ptr)paramlist;                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
 * These entry point must remain in libawt.so ***for Java Plugin ONLY***
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
 * Reflect this call over to the correct libmawt.so.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
REFLECT_VOID_FUNCTION(getAwtLockFunctions,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                      (void (**AwtLock)(JNIEnv *), void (**AwtUnlock)(JNIEnv *),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                       void (**AwtNoFlushUnlock)(JNIEnv *), void *reserved),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                      (AwtLock, AwtUnlock, AwtNoFlushUnlock, reserved))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
REFLECT_VOID_FUNCTION(getAwtData,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                      (int32_t *awt_depth, Colormap *awt_cmap, Visual **awt_visual,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                       int32_t *awt_num_colors, void *pReserved),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                      (awt_depth, awt_cmap, awt_visual,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
                       awt_num_colors, pReserved))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
REFLECT_FUNCTION(Display *, getAwtDisplay, (void), ())