jdk/src/solaris/native/sun/awt/awt_util.h
author alitvinov
Wed, 04 Dec 2013 12:29:18 +0400
changeset 21939 5169fd314636
parent 18754 3db51db1e3d5
child 24165 fb4f67872b27
permissions -rw-r--r--
8025775: JNI warnings in TryXShmAttach Reviewed-by: art, anthony
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
17679
a81555868357 8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents: 11093
diff changeset
     2
 * Copyright (c) 1995, 2013, 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
#ifndef _AWT_UTIL_H_
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#define _AWT_UTIL_H_
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include "gdefs.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
21939
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 18754
diff changeset
    32
#define WITH_XERROR_HANDLER(f) do {             \
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 18754
diff changeset
    33
    XSync(awt_display, False);                  \
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 18754
diff changeset
    34
    current_native_xerror_handler = (f);        \
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
} while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
21939
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 18754
diff changeset
    37
#define RESTORE_XERROR_HANDLER do {             \
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 18754
diff changeset
    38
    XSync(awt_display, False);                  \
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 18754
diff changeset
    39
    current_native_xerror_handler = NULL;       \
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 18754
diff changeset
    40
} while (0)
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 18754
diff changeset
    41
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 18754
diff changeset
    42
#define EXEC_WITH_XERROR_HANDLER(f, code) do {  \
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 18754
diff changeset
    43
    WITH_XERROR_HANDLER(f);                     \
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 18754
diff changeset
    44
    do {                                        \
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 18754
diff changeset
    45
        code;                                   \
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 18754
diff changeset
    46
    } while (0);                                \
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 18754
diff changeset
    47
    RESTORE_XERROR_HANDLER;                     \
17679
a81555868357 8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents: 11093
diff changeset
    48
} while (0)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
/*
21939
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 18754
diff changeset
    51
 * Called by "ToolkitErrorHandler" function in "XlibWrapper.c" file.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 */
21939
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 18754
diff changeset
    53
extern XErrorHandler current_native_xerror_handler;
18754
3db51db1e3d5 8015730: PIT: On Linux, OGL=true and fbobject=false leads to deadlock or infinite loop
alitvinov
parents: 17679
diff changeset
    54
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
#ifndef INTERSECTS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
#define INTERSECTS(r1_x1,r1_x2,r1_y1,r1_y2,r2_x1,r2_x2,r2_y1,r2_y2) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
!((r2_x2 <= r1_x1) ||\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
  (r2_y2 <= r1_y1) ||\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
  (r2_x1 >= r1_x2) ||\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
  (r2_y1 >= r1_y2))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
#ifndef MIN
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
#define MIN(a,b) ((a) < (b) ? (a) : (b))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
#ifndef MAX
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
#define MAX(a,b) ((a) > (b) ? (a) : (b))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
struct DPos {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    int32_t x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    int32_t y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    int32_t mapped;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    void *data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    void *peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    int32_t echoC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
extern void awtJNI_ThreadYield(JNIEnv *env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * Functions for accessing fields by name and signature
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
JNIEXPORT jobject JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
JNU_GetObjectField(JNIEnv *env, jobject self, const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
                   const char *sig);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
JNU_SetObjectField(JNIEnv *env, jobject self, const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
                   const char *sig, jobject val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
JNU_GetLongField(JNIEnv *env, jobject self, const char *name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
JNU_GetIntField(JNIEnv *env, jobject self, const char *name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
JNU_SetIntField(JNIEnv *env, jobject self, const char *name, jint val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
JNU_SetLongField(JNIEnv *env, jobject self, const char *name, jlong val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
JNU_GetBooleanField(JNIEnv *env, jobject self, const char *name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
JNU_SetBooleanField(JNIEnv *env, jobject self, const char *name, jboolean val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
JNU_GetCharField(JNIEnv *env, jobject self, const char *name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
#endif           /* _AWT_UTIL_H_ */