jdk/src/solaris/native/sun/awt/awt.h
author ohair
Tue, 28 Dec 2010 15:53:50 -0800
changeset 7668 d4a77089c587
parent 6825 795e9fe949d3
child 11093 e753252dc8a9
permissions -rw-r--r--
6962318: Update copyright year Reviewed-by: xdono
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
7668
d4a77089c587 6962318: Update copyright year
ohair
parents: 6825
diff changeset
     2
 * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
2
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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * Common AWT definitions
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#ifndef _AWT_
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#define _AWT_
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include "jvm.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include "jni_util.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include "debug_util.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#include <X11/Intrinsic.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
/* The JVM instance: defined in awt_MToolkit.c */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
extern JavaVM *jvm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
extern jclass tkClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
extern jmethodID awtLockMID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
extern jmethodID awtUnlockMID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
extern jmethodID awtWaitMID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
extern jmethodID awtNotifyMID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
extern jmethodID awtNotifyAllMID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
extern jboolean awtLockInited;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
/* Perform sanity and consistency checks on AWT locking */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
#ifdef DEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
#define DEBUG_AWT_LOCK
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * The following locking primitives should be defined
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
#define AWT_LOCK()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
#define AWT_NOFLUSH_UNLOCK()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
#define AWT_WAIT(tm)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
#define AWT_NOTIFY()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
#define AWT_NOTIFY_ALL()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * Convenience macros based on AWT_NOFLUSH_UNLOCK
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
extern void awt_output_flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
#define AWT_UNLOCK() AWT_FLUSH_UNLOCK()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
#define AWT_FLUSH_UNLOCK() do {                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    awt_output_flush();                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    AWT_NOFLUSH_UNLOCK();                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
} while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
#define AWT_LOCK_IMPL() \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    (*env)->CallStaticVoidMethod(env, tkClass, awtLockMID)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
#define AWT_NOFLUSH_UNLOCK_IMPL() \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    (*env)->CallStaticVoidMethod(env, tkClass, awtUnlockMID)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
#define AWT_WAIT_IMPL(tm) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    (*env)->CallStaticVoidMethod(env, tkClass, awtWaitMID, (jlong)(tm))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
#define AWT_NOTIFY_IMPL() \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    (*env)->CallStaticVoidMethod(env, tkClass, awtNotifyMID)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
#define AWT_NOTIFY_ALL_IMPL() \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    (*env)->CallStaticVoidMethod(env, tkClass, awtNotifyAllMID)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * Unfortunately AWT_LOCK debugging does not work with XAWT due to mixed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * Java/C use of AWT lock.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
#if defined(DEBUG_AWT_LOCK) && !defined(XAWT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
extern int awt_locked;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
extern char *lastF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
extern int lastL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
#define AWT_LOCK() do {                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    if (!awtLockInited) {                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        jio_fprintf(stderr, "AWT lock error, awt_lock is null\n");      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    }                                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    if (awt_locked < 0) {                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        jio_fprintf(stderr,                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                    "AWT lock error (%s,%d) (last held by %s,%d) %d\n", \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                    __FILE__, __LINE__, lastF, lastL, awt_locked);      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    }                                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    lastF = __FILE__;                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    lastL = __LINE__;                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    AWT_LOCK_IMPL();                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    ++awt_locked;                                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
} while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
#define AWT_NOFLUSH_UNLOCK() do {                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    lastF = "";                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    lastL = -1;                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    if (awt_locked < 1) {                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        jio_fprintf(stderr, "AWT unlock error (%s,%d,%d)\n",    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                    __FILE__, __LINE__, awt_locked);            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    }                                                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    --awt_locked;                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    AWT_NOFLUSH_UNLOCK_IMPL();                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
} while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
#define AWT_WAIT(tm) do {                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    int old_lockcount = awt_locked;                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    if (awt_locked < 1) {                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        jio_fprintf(stderr, "AWT wait error (%s,%d,%d)\n",      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                    __FILE__, __LINE__, awt_locked);            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    }                                                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    awt_locked = 0;                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    AWT_WAIT_IMPL(tm);                                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    awt_locked = old_lockcount;                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
} while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
#define AWT_NOTIFY() do {                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    if (awt_locked < 1) {                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        jio_fprintf(stderr, "AWT notify error (%s,%d,%d)\n",    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                    __FILE__, __LINE__, awt_locked);            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    }                                                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    AWT_NOTIFY_IMPL();                                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
} while(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
#define AWT_NOTIFY_ALL() do {                                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    if (awt_locked < 1) {                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        jio_fprintf(stderr, "AWT notify all error (%s,%d,%d)\n",        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                    __FILE__, __LINE__, awt_locked);                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    }                                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    AWT_NOTIFY_ALL_IMPL();                                              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
} while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
#define AWT_LOCK()           AWT_LOCK_IMPL()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
#define AWT_NOFLUSH_UNLOCK() AWT_NOFLUSH_UNLOCK_IMPL()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
#define AWT_WAIT(tm)         AWT_WAIT_IMPL(tm)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
#define AWT_NOTIFY()         AWT_NOTIFY_IMPL()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
#define AWT_NOTIFY_ALL()     AWT_NOTIFY_ALL_IMPL()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
#endif /* DEBUG_AWT_LOCK && !XAWT */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
#ifndef HEADLESS
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   162
extern Display         *awt_display; /* awt_GraphicsEnv.c */
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   163
extern Boolean          awt_ModLockIsShiftLock; /* XToolkit.c */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
#endif /* ! _AWT_ */