1/************************************************************
2
3Copyright (c) 1993, Oracle and/or its affiliates.
4
5Permission is hereby granted, free of charge, to any person obtaining a
6copy of this software and associated documentation files (the "Software"),
7to deal in the Software without restriction, including without limitation
8the rights to use, copy, modify, merge, publish, distribute, sublicense,
9and/or sell copies of the Software, and to permit persons to whom the
10Software is furnished to do so, subject to the following conditions:
11
12The above copyright notice and this permission notice (including the next
13paragraph) shall be included in all copies or substantial portions of the
14Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22DEALINGS IN THE SOFTWARE.
23
24********************************************************/
25
26/*
27
28Copyright 1994, 1998  The Open Group
29
30Permission to use, copy, modify, distribute, and sell this software and its
31documentation for any purpose is hereby granted without fee, provided that
32the above copyright notice appear in all copies and that both that
33copyright notice and this permission notice appear in supporting
34documentation.
35
36The above copyright notice and this permission notice shall be included in
37all copies or substantial portions of the Software.
38
39THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
40IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
41FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
42OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
43AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
44CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
45
46Except as contained in this notice, the name of The Open Group shall not be
47used in advertising or otherwise to promote the sale, use or other dealings
48in this Software without prior written authorization from The Open Group.
49
50*/
51/* $XFree86: xc/lib/Xt/ThreadsI.h,v 3.5 2001/12/14 19:56:31 dawes Exp $ */
52
53#ifndef _XtThreadsI_h
54#define _XtThreadsI_h
55
56#include <X11/XlibConf.h>
57
58#ifdef XTHREADS
59
60typedef struct _LockRec *LockPtr;
61
62typedef void (*ThreadAppProc)(
63    XtAppContext /* app */
64);
65
66typedef void (*ThreadAppYieldLockProc)(
67    XtAppContext, /* app */
68    Boolean*, /* push_thread */
69    Boolean*, /* pushed_thread */
70    int* /* level */
71);
72
73typedef void (*ThreadAppRestoreLockProc)(
74    XtAppContext /* app */,
75    int, /* level */
76    Boolean* /* pushed_thread */
77);
78
79_XFUNCPROTOBEGIN
80
81extern void (*_XtProcessLock)(
82    void
83);
84
85extern void (*_XtProcessUnlock)(
86    void
87);
88
89extern void (*_XtInitAppLock)(
90    XtAppContext /* app */
91);
92
93_XFUNCPROTOEND
94
95#define INIT_APP_LOCK(app) if(_XtInitAppLock) (*_XtInitAppLock)(app)
96#define FREE_APP_LOCK(app) if(app && app->free_lock)(*app->free_lock)(app)
97
98#define LOCK_PROCESS if(_XtProcessLock)(*_XtProcessLock)()
99#define UNLOCK_PROCESS if(_XtProcessUnlock)(*_XtProcessUnlock)()
100#define LOCK_APP(app) if(app && app->lock)(*app->lock)(app)
101#define UNLOCK_APP(app) if(app && app->unlock)(*app->unlock)(app)
102
103#define YIELD_APP_LOCK(app,push,pushed,level)\
104	 if(app && app->yield_lock) (*app->yield_lock)(app,push,pushed,level)
105#define RESTORE_APP_LOCK(app,level,pushed)\
106	 if(app && app->restore_lock) (*app->restore_lock)(app,level,pushed)
107
108#define WIDGET_TO_APPCON(w) \
109    XtAppContext app = (w && _XtProcessLock ? \
110	XtWidgetToApplicationContext(w) : NULL)
111
112#define DPY_TO_APPCON(d) \
113    XtAppContext app = (_XtProcessLock ? XtDisplayToApplicationContext(d): NULL)
114
115#else /* defined(XTHREADS) */
116
117#define LOCK_PROCESS
118#define UNLOCK_PROCESS
119#define LOCK_APP(app)
120#define UNLOCK_APP(app)
121
122#define INIT_APP_LOCK(app)
123#define FREE_APP_LOCK(app)
124
125#define WIDGET_TO_APPCON(w)
126#define DPY_TO_APPCON(d)
127
128#endif /* !defined(XTHREADS) */
129#endif /* _XtThreadsI_h */
130