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