2
Copyright (C) 2002-2010 Karl J. Runge <runge@karlrunge.com>
5
This file is part of x11vnc.
7
x11vnc is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or (at
10
your option) any later version.
12
x11vnc is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with x11vnc; if not, write to the Free Software
19
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA
20
or see <http://www.gnu.org/licenses/>.
22
In addition, as a special exception, Karl J. Runge
23
gives permission to link the code of its release of x11vnc with the
24
OpenSSL project's "OpenSSL" library (or with modified versions of it
25
that use the same license as the "OpenSSL" library), and distribute
26
the linked executables. You must obey the GNU General Public License
27
in all respects for all of the code used other than "OpenSSL". If you
28
modify this file, you may extend this exception to your version of the
29
file, but you are not obligated to do so. If you do not wish to do
30
so, delete this exception statement from your version.
1
33
#ifndef _X11VNC_UTIL_H
2
34
#define _X11VNC_UTIL_H
31
63
extern double rnow(void);
32
64
extern double rfac(void);
34
extern void rfbPE(long usec);
66
extern int rfbPE(long usec);
35
67
extern void rfbCFD(long usec);
36
68
extern double rect_overlap(int x1, int y1, int x2, int y2, int X1, int Y1,
41
73
#define NONUL(x) ((x) ? (x) : "")
76
Put this in usleep2() for debug printout.
77
fprintf(stderr, "_mysleep: %08d %10.6f %s:%d\n", (x), dnow() - x11vnc_start, __FILE__, __LINE__); \
43
80
/* XXX usleep(3) is not thread safe on some older systems... */
44
81
extern struct timeval _mysleep;
45
82
#define usleep2(x) \
73
114
#define X_UNLOCK UNLOCK(x11Mutex)
76
#define X_LOCK fprintf(stderr, "*** X_LOCK**[%05d] %d%s\n", \
77
__LINE__, hxl, hxl ? " BAD-PRE-LOCK":""); LOCK(x11Mutex); hxl = 1;
78
#define X_UNLOCK fprintf(stderr, " x_unlock[%05d] %d%s\n", \
79
__LINE__, hxl, !hxl ? " BAD-PRE-UNLOCK":""); UNLOCK(x11Mutex); hxl = 0;
117
#define X_LOCK fprintf(stderr, "*** X_LOCK** %d%s %s:%d\n", \
118
hxl, hxl ? " BAD-PRE-LOCK":"", __FILE__, __LINE__); LOCK(x11Mutex); hxl = 1;
119
#define X_UNLOCK fprintf(stderr, " x_unlock %d%s %s:%d\n", \
120
hxl, !hxl ? " BAD-PRE-UNLOCK":"", __FILE__, __LINE__); UNLOCK(x11Mutex); hxl = 0;
82
#ifdef LIBVNCSERVER_HAVE_LIBPTHREAD
83
extern MUTEX(scrollMutex);
85
123
#define SCR_LOCK if (use_threads) {LOCK(scrollMutex);}
86
124
#define SCR_UNLOCK if (use_threads) {UNLOCK(scrollMutex);}
87
125
#define SCR_INIT INIT_MUTEX(scrollMutex)
127
#define CLIENT_LOCK if (use_threads) {LOCK(clientMutex);}
128
#define CLIENT_UNLOCK if (use_threads) {UNLOCK(clientMutex);}
129
#define CLIENT_INIT INIT_MUTEX(clientMutex)
132
#define INPUT_LOCK if (use_threads) {LOCK(inputMutex);}
133
#define INPUT_UNLOCK if (use_threads) {UNLOCK(inputMutex);}
138
#define INPUT_INIT INIT_MUTEX(inputMutex)
140
#define POINTER_LOCK if (use_threads) {LOCK(pointerMutex);}
141
#define POINTER_UNLOCK if (use_threads) {UNLOCK(pointerMutex);}
142
#define POINTER_INIT INIT_MUTEX(pointerMutex)
145
* The sendMutex member was added to libvncserver 0.9.8
146
* rfb/rfb.h sets LIBVNCSERVER_SEND_MUTEX if present.
148
#if LIBVNCSERVER_HAVE_LIBPTHREAD && defined(LIBVNCSERVER_SEND_MUTEX)
149
#define SEND_LOCK(cl) if (use_threads) LOCK((cl)->sendMutex);
150
#define SEND_UNLOCK(cl) if (use_threads) UNLOCK((cl)->sendMutex);
152
#define SEND_LOCK(cl)
153
#define SEND_UNLOCK(cl)
89
156
#endif /* _X11VNC_UTIL_H */