ThreadsI.h revision 2265a131
1/* $Xorg: ThreadsI.h,v 1.4 2001/02/09 02:03:59 xorgcvs Exp $ */
2
3/************************************************************
4Copyright 1993 by Sun Microsystems, Inc. Mountain View, CA.
5
6                    All Rights Reserved
7
8Permission  to  use,  copy,  modify,  and  distribute   this
9software  and  its documentation for any purpose and without
10fee is hereby granted, provided that the above copyright no-
11tice  appear  in all copies and that both that copyright no-
12tice and this permission notice appear in  supporting  docu-
13mentation,  and  that the name Sun not be used in advertising
14or publicity pertaining to distribution  of  the software
15without specific prior written permission. Sun makes no
16representations about the suitability of this software for
17any purpose. It is provided "as is" without any express or
18implied warranty.
19
20SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
21INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
22NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
23ABLE  FOR  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
24ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,  DATA  OR
25PROFITS,  WHETHER  IN  AN  ACTION OF CONTRACT, NEGLIGENCE OR
26OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
27THE USE OR PERFORMANCE OF THIS SOFTWARE.
28
29********************************************************/
30
31/*
32
33Copyright 1994, 1998  The Open Group
34
35Permission to use, copy, modify, distribute, and sell this software and its
36documentation for any purpose is hereby granted without fee, provided that
37the above copyright notice appear in all copies and that both that
38copyright notice and this permission notice appear in supporting
39documentation.
40
41The above copyright notice and this permission notice shall be included in
42all copies or substantial portions of the Software.
43
44THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
46FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
47OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
48AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
49CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
50
51Except as contained in this notice, the name of The Open Group shall not be
52used in advertising or otherwise to promote the sale, use or other dealings
53in this Software without prior written authorization from The Open Group.
54
55*/
56/* $XFree86: xc/lib/Xt/ThreadsI.h,v 3.5 2001/12/14 19:56:31 dawes Exp $ */
57
58#ifndef _XtThreadsI_h
59#define _XtThreadsI_h
60
61#include <X11/XlibConf.h>
62
63#ifdef XTHREADS
64
65typedef struct _LockRec *LockPtr;
66
67typedef void (*ThreadAppProc)(
68    XtAppContext /* app */
69);
70
71typedef void (*ThreadAppYieldLockProc)(
72    XtAppContext, /* app */
73    Boolean*, /* push_thread */
74    Boolean*, /* pushed_thread */
75    int* /* level */
76);
77
78typedef void (*ThreadAppRestoreLockProc)(
79    XtAppContext /* app */,
80    int, /* level */
81    Boolean* /* pushed_thread */
82);
83
84_XFUNCPROTOBEGIN
85
86extern void (*_XtProcessLock)(
87    void
88);
89
90extern void (*_XtProcessUnlock)(
91    void
92);
93
94extern void (*_XtInitAppLock)(
95    XtAppContext /* app */
96);
97
98_XFUNCPROTOEND
99
100#define INIT_APP_LOCK(app) if(_XtInitAppLock) (*_XtInitAppLock)(app)
101#define FREE_APP_LOCK(app) if(app && app->free_lock)(*app->free_lock)(app)
102
103#define LOCK_PROCESS if(_XtProcessLock)(*_XtProcessLock)()
104#define UNLOCK_PROCESS if(_XtProcessUnlock)(*_XtProcessUnlock)()
105#define LOCK_APP(app) if(app && app->lock)(*app->lock)(app)
106#define UNLOCK_APP(app) if(app && app->unlock)(*app->unlock)(app)
107
108#define YIELD_APP_LOCK(app,push,pushed,level)\
109	 if(app && app->yield_lock) (*app->yield_lock)(app,push,pushed,level)
110#define RESTORE_APP_LOCK(app,level,pushed)\
111	 if(app && app->restore_lock) (*app->restore_lock)(app,level,pushed)
112
113#define WIDGET_TO_APPCON(w) \
114    XtAppContext app = (w && _XtProcessLock ? \
115	XtWidgetToApplicationContext(w) : NULL)
116
117#define DPY_TO_APPCON(d) \
118    XtAppContext app = (_XtProcessLock ? XtDisplayToApplicationContext(d): NULL)
119
120#else /* defined(XTHREADS) */
121
122#define LOCK_PROCESS
123#define UNLOCK_PROCESS
124#define LOCK_APP(app)
125#define UNLOCK_APP(app)
126
127#define INIT_APP_LOCK(app)
128#define FREE_APP_LOCK(app)
129
130#define WIDGET_TO_APPCON(w)
131#define DPY_TO_APPCON(d)
132
133#endif /* !defined(XTHREADS) */
134#endif /* _XtThreadsI_h */
135