2003-11-14 16:54:54 +01:00
|
|
|
/***********************************************************
|
|
|
|
|
|
|
|
Copyright 1987, 1998 The Open Group
|
|
|
|
|
|
|
|
Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
the above copyright notice appear in all copies and that both that
|
|
|
|
copyright notice and this permission notice appear in supporting
|
|
|
|
documentation.
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
|
|
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
Except as contained in this notice, the name of The Open Group shall not be
|
|
|
|
used in advertising or otherwise to promote the sale, use or other dealings
|
|
|
|
in this Software without prior written authorization from The Open Group.
|
|
|
|
|
|
|
|
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
|
|
|
|
|
|
|
|
All Rights Reserved
|
|
|
|
|
2014-10-31 00:45:12 +01:00
|
|
|
Permission to use, copy, modify, and distribute this software and its
|
|
|
|
documentation for any purpose and without fee is hereby granted,
|
2003-11-14 16:54:54 +01:00
|
|
|
provided that the above copyright notice appear in all copies and that
|
2014-10-31 00:45:12 +01:00
|
|
|
both that copyright notice and this permission notice appear in
|
2003-11-14 16:54:54 +01:00
|
|
|
supporting documentation, and that the name of Digital not be
|
|
|
|
used in advertising or publicity pertaining to distribution of the
|
2014-10-31 00:45:12 +01:00
|
|
|
software without specific, written prior permission.
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
|
|
|
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
|
|
|
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
|
|
|
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
|
|
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
|
|
|
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
|
|
SOFTWARE.
|
|
|
|
|
|
|
|
Copyright 1992, 1993 Data General Corporation;
|
2014-10-31 00:45:12 +01:00
|
|
|
Copyright 1992, 1993 OMRON Corporation
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
documentation for any purpose is hereby granted without fee, provided that the
|
|
|
|
above copyright notice appear in all copies and that both that copyright
|
|
|
|
notice and this permission notice appear in supporting documentation, and that
|
|
|
|
neither the name OMRON or DATA GENERAL be used in advertising or publicity
|
|
|
|
pertaining to distribution of the software without specific, written prior
|
2014-10-31 00:45:12 +01:00
|
|
|
permission of the party whose name is to be used. Neither OMRON or
|
2003-11-14 16:54:54 +01:00
|
|
|
DATA GENERAL make any representation about the suitability of this software
|
2014-10-31 00:45:12 +01:00
|
|
|
for any purpose. It is provided "as is" without express or implied warranty.
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
OMRON AND DATA GENERAL EACH DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
|
|
|
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
|
|
|
|
IN NO EVENT SHALL OMRON OR DATA GENERAL BE LIABLE FOR ANY SPECIAL, INDIRECT
|
|
|
|
OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
|
|
|
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
|
|
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
|
|
|
OF THIS SOFTWARE.
|
|
|
|
|
|
|
|
******************************************************************/
|
|
|
|
#ifndef MISC_H
|
|
|
|
#define MISC_H 1
|
|
|
|
/*
|
2014-10-31 00:45:12 +01:00
|
|
|
* X internal definitions
|
2003-11-14 16:54:54 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <X11/Xosdefs.h>
|
|
|
|
#include <X11/Xfuncproto.h>
|
|
|
|
#include <X11/Xmd.h>
|
|
|
|
#include <X11/X.h>
|
2003-11-14 17:49:22 +01:00
|
|
|
#include <X11/Xdefs.h>
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
#include <stddef.h>
|
2011-02-28 19:10:20 +01:00
|
|
|
#include <stdint.h>
|
2015-12-08 20:37:51 +01:00
|
|
|
#include <pthread.h>
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
#ifndef MAXSCREENS
|
2003-11-14 17:49:22 +01:00
|
|
|
#define MAXSCREENS 16
|
2003-11-14 16:54:54 +01:00
|
|
|
#endif
|
2012-06-05 18:09:38 +02:00
|
|
|
#ifndef MAXGPUSCREENS
|
|
|
|
#define MAXGPUSCREENS 16
|
|
|
|
#endif
|
2016-05-26 08:43:49 +02:00
|
|
|
#define MAXCLIENTS 2048
|
2015-07-07 18:19:50 +02:00
|
|
|
#define LIMITCLIENTS 256 /* Must be a power of 2 and <= MAXCLIENTS */
|
2008-03-04 08:41:10 +01:00
|
|
|
#define MAXEXTENSIONS 128
|
2004-07-17 22:44:14 +02:00
|
|
|
#define MAXFORMATS 8
|
2019-10-18 07:47:37 +02:00
|
|
|
#ifndef MAXDEVICES
|
|
|
|
#define MAXDEVICES 256 /* input devices */
|
|
|
|
#endif
|
2012-06-05 18:09:38 +02:00
|
|
|
#define GPU_SCREEN_OFFSET 256
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2011-12-10 22:31:43 +01:00
|
|
|
/* 128 event opcodes for core + extension events, excluding GE */
|
|
|
|
#define MAXEVENTS 128
|
2008-10-31 06:53:34 +01:00
|
|
|
#define EXTENSION_EVENT_BASE 64
|
|
|
|
#define EXTENSION_BASE 128
|
|
|
|
|
2011-02-28 19:10:20 +01:00
|
|
|
typedef uint32_t ATOM;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
#ifndef TRUE
|
|
|
|
#define TRUE 1
|
|
|
|
#define FALSE 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _XTYPEDEF_CALLBACKLISTPTR
|
2012-03-21 20:55:09 +01:00
|
|
|
typedef struct _CallbackList *CallbackListPtr; /* also in dix.h */
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
#define _XTYPEDEF_CALLBACKLISTPTR
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct _xReq *xReqPtr;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
#include "os.h" /* for ALLOCATE_LOCAL and DEALLOCATE_LOCAL */
|
|
|
|
#include <X11/Xfuncs.h> /* for bcopy, bzero, and bcmp */
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
#define NullBox ((BoxPtr)0)
|
|
|
|
#define MILLI_PER_MIN (1000 * 60)
|
|
|
|
#define MILLI_PER_SECOND (1000)
|
|
|
|
|
|
|
|
/* this next is used with None and ParentRelative to tell
|
|
|
|
PaintWin() what to use to paint the background. Also used
|
|
|
|
in the macro IS_VALID_PIXMAP */
|
|
|
|
|
|
|
|
#define USE_BACKGROUND_PIXEL 3
|
|
|
|
#define USE_BORDER_PIXEL 3
|
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
#undef min
|
|
|
|
#undef max
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
#define min(a, b) (((a) < (b)) ? (a) : (b))
|
|
|
|
#define max(a, b) (((a) > (b)) ? (a) : (b))
|
2003-11-14 17:49:22 +01:00
|
|
|
/* abs() is a function, not a macro; include the file declaring
|
|
|
|
* it in case we haven't done that yet.
|
2006-07-19 00:16:12 +02:00
|
|
|
*/
|
2003-11-14 17:49:22 +01:00
|
|
|
#include <stdlib.h>
|
2003-11-14 16:54:54 +01:00
|
|
|
#define sign(x) ((x) < 0 ? -1 : ((x) > 0 ? 1 : 0))
|
|
|
|
/* this assumes b > 0 */
|
|
|
|
#define modulus(a, b, d) if (((d) = (a) % (b)) < 0) (d) += (b)
|
|
|
|
/*
|
|
|
|
* return the least significant bit in x which is set
|
|
|
|
*
|
|
|
|
* This works on 1's complement and 2's complement machines.
|
|
|
|
* If you care about the extra instruction on 2's complement
|
|
|
|
* machines, change to ((x) & (-(x)))
|
|
|
|
*/
|
|
|
|
#define lowbit(x) ((x) & (~(x) + 1))
|
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
/* XXX Not for modules */
|
|
|
|
#include <limits.h>
|
|
|
|
#if !defined(MAXSHORT) || !defined(MINSHORT) || \
|
|
|
|
!defined(MAXINT) || !defined(MININT)
|
|
|
|
/*
|
|
|
|
* Some implementations #define these through <math.h>, so preclude
|
|
|
|
* #include'ing it later.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
#undef MAXSHORT
|
|
|
|
#define MAXSHORT SHRT_MAX
|
|
|
|
#undef MINSHORT
|
|
|
|
#define MINSHORT SHRT_MIN
|
|
|
|
#undef MAXINT
|
|
|
|
#define MAXINT INT_MAX
|
|
|
|
#undef MININT
|
|
|
|
#define MININT INT_MIN
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <ctype.h>
|
2012-03-21 20:55:09 +01:00
|
|
|
#include <stdio.h> /* for fopen, etc... */
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
#endif
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2011-03-09 01:17:27 +01:00
|
|
|
#ifndef PATH_MAX
|
|
|
|
#include <sys/param.h>
|
|
|
|
#ifndef PATH_MAX
|
|
|
|
#ifdef MAXPATHLEN
|
|
|
|
#define PATH_MAX MAXPATHLEN
|
|
|
|
#else
|
|
|
|
#define PATH_MAX 1024
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2009-06-29 05:09:57 +02:00
|
|
|
/**
|
|
|
|
* Calculate the number of bytes needed to hold bits.
|
|
|
|
* @param bits The minimum number of bits needed.
|
|
|
|
* @return The number of bytes needed to hold bits.
|
|
|
|
*/
|
|
|
|
static inline int
|
2012-03-21 20:55:09 +01:00
|
|
|
bits_to_bytes(const int bits)
|
|
|
|
{
|
2009-06-29 05:09:57 +02:00
|
|
|
return ((bits + 7) >> 3);
|
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2009-06-29 05:09:57 +02:00
|
|
|
/**
|
|
|
|
* Calculate the number of 4-byte units needed to hold the given number of
|
|
|
|
* bytes.
|
|
|
|
* @param bytes The minimum number of bytes needed.
|
|
|
|
* @return The number of 4-byte units needed to hold bytes.
|
|
|
|
*/
|
|
|
|
static inline int
|
2012-03-21 20:55:09 +01:00
|
|
|
bytes_to_int32(const int bytes)
|
|
|
|
{
|
2009-06-29 05:09:57 +02:00
|
|
|
return (((bytes) + 3) >> 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculate the number of bytes (in multiples of 4) needed to hold bytes.
|
|
|
|
* @param bytes The minimum number of bytes needed.
|
|
|
|
* @return The closest multiple of 4 that is equal or higher than bytes.
|
|
|
|
*/
|
|
|
|
static inline int
|
2012-03-21 20:55:09 +01:00
|
|
|
pad_to_int32(const int bytes)
|
|
|
|
{
|
2009-06-29 05:09:57 +02:00
|
|
|
return (((bytes) + 3) & ~3);
|
|
|
|
}
|
|
|
|
|
2012-07-10 04:12:44 +02:00
|
|
|
/**
|
|
|
|
* Calculate padding needed to bring the number of bytes to an even
|
|
|
|
* multiple of 4.
|
|
|
|
* @param bytes The minimum number of bytes needed.
|
|
|
|
* @return The bytes of padding needed to arrive at the closest multiple of 4
|
|
|
|
* that is equal or higher than bytes.
|
|
|
|
*/
|
|
|
|
static inline int
|
|
|
|
padding_for_int32(const int bytes)
|
|
|
|
{
|
|
|
|
return ((-bytes) & 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-27 16:11:53 +02:00
|
|
|
extern _X_EXPORT char **xstrtokenize(const char *str, const char *separators);
|
2012-08-13 06:24:36 +02:00
|
|
|
extern void FormatInt64(int64_t num, char *string);
|
2012-04-06 19:13:45 +02:00
|
|
|
extern void FormatUInt64(uint64_t num, char *string);
|
|
|
|
extern void FormatUInt64Hex(uint64_t num, char *string);
|
2013-01-10 04:20:12 +01:00
|
|
|
extern void FormatDouble(double dbl, char *string);
|
2010-02-10 06:36:49 +01:00
|
|
|
|
2011-05-11 04:20:50 +02:00
|
|
|
/**
|
|
|
|
* Compare the two version numbers comprising of major.minor.
|
|
|
|
*
|
|
|
|
* @return A value less than 0 if a is less than b, 0 if a is equal to b,
|
|
|
|
* or a value greater than 0
|
|
|
|
*/
|
|
|
|
static inline int
|
2014-05-22 00:43:52 +02:00
|
|
|
version_compare(uint32_t a_major, uint32_t a_minor,
|
|
|
|
uint32_t b_major, uint32_t b_minor)
|
2011-05-11 04:20:50 +02:00
|
|
|
{
|
2014-05-22 00:43:52 +02:00
|
|
|
if (a_major > b_major)
|
|
|
|
return 1;
|
|
|
|
if (a_major < b_major)
|
|
|
|
return -1;
|
|
|
|
if (a_minor > b_minor)
|
|
|
|
return 1;
|
|
|
|
if (a_minor < b_minor)
|
|
|
|
return -1;
|
2011-05-11 04:20:50 +02:00
|
|
|
|
2014-05-22 00:43:52 +02:00
|
|
|
return 0;
|
2011-05-11 04:20:50 +02:00
|
|
|
}
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
/* some macros to help swap requests, replies, and events */
|
|
|
|
|
|
|
|
#define LengthRestB(stuff) \
|
|
|
|
((client->req_len << 2) - sizeof(*stuff))
|
|
|
|
|
|
|
|
#define LengthRestS(stuff) \
|
|
|
|
((client->req_len << 1) - (sizeof(*stuff) >> 1))
|
|
|
|
|
|
|
|
#define LengthRestL(stuff) \
|
|
|
|
(client->req_len - (sizeof(*stuff) >> 2))
|
|
|
|
|
|
|
|
#define SwapRestS(stuff) \
|
|
|
|
SwapShorts((short *)(stuff + 1), LengthRestS(stuff))
|
|
|
|
|
|
|
|
#define SwapRestL(stuff) \
|
|
|
|
SwapLongs((CARD32 *)(stuff + 1), LengthRestL(stuff))
|
|
|
|
|
2011-09-23 03:55:19 +02:00
|
|
|
#if defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
|
2012-03-21 20:55:09 +01:00
|
|
|
void __attribute__ ((error("wrong sized variable passed to swap")))
|
|
|
|
wrong_size(void);
|
2011-08-17 01:07:24 +02:00
|
|
|
#else
|
2012-03-21 20:55:09 +01:00
|
|
|
static inline void
|
|
|
|
wrong_size(void)
|
2011-08-17 01:07:24 +02:00
|
|
|
{
|
|
|
|
}
|
2011-09-23 03:55:19 +02:00
|
|
|
#endif
|
2011-08-17 01:19:24 +02:00
|
|
|
|
2011-10-28 23:32:56 +02:00
|
|
|
#if !(defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)))
|
2012-03-21 20:55:09 +01:00
|
|
|
static inline int
|
|
|
|
__builtin_constant_p(int x)
|
2011-08-17 01:19:24 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
return 0;
|
2011-08-17 01:19:24 +02:00
|
|
|
}
|
2011-08-17 01:07:24 +02:00
|
|
|
#endif
|
|
|
|
|
2017-03-27 23:59:06 +02:00
|
|
|
static inline uint64_t
|
|
|
|
bswap_64(uint64_t x)
|
2013-07-12 01:09:34 +02:00
|
|
|
{
|
2017-03-27 23:59:06 +02:00
|
|
|
return (((x & 0xFF00000000000000ull) >> 56) |
|
|
|
|
((x & 0x00FF000000000000ull) >> 40) |
|
|
|
|
((x & 0x0000FF0000000000ull) >> 24) |
|
|
|
|
((x & 0x000000FF00000000ull) >> 8) |
|
|
|
|
((x & 0x00000000FF000000ull) << 8) |
|
|
|
|
((x & 0x0000000000FF0000ull) << 24) |
|
|
|
|
((x & 0x000000000000FF00ull) << 40) |
|
|
|
|
((x & 0x00000000000000FFull) << 56));
|
2013-07-12 01:09:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#define swapll(x) do { \
|
|
|
|
if (sizeof(*(x)) != 8) \
|
|
|
|
wrong_size(); \
|
2017-04-21 21:03:45 +02:00
|
|
|
*(x) = bswap_64(*(x)); \
|
2013-07-12 01:09:34 +02:00
|
|
|
} while (0)
|
|
|
|
|
2017-03-27 23:59:06 +02:00
|
|
|
static inline uint32_t
|
|
|
|
bswap_32(uint32_t x)
|
2011-08-17 01:03:26 +02:00
|
|
|
{
|
2017-03-27 23:59:06 +02:00
|
|
|
return (((x & 0xFF000000) >> 24) |
|
|
|
|
((x & 0x00FF0000) >> 8) |
|
|
|
|
((x & 0x0000FF00) << 8) |
|
|
|
|
((x & 0x000000FF) << 24));
|
2011-08-17 01:03:26 +02:00
|
|
|
}
|
|
|
|
|
2017-09-19 02:34:32 +02:00
|
|
|
static inline Bool
|
|
|
|
checked_int64_add(int64_t *out, int64_t a, int64_t b)
|
|
|
|
{
|
|
|
|
/* Do the potentially overflowing math as uint64_t, as signed
|
|
|
|
* integers in C are undefined on overflow (and the compiler may
|
|
|
|
* optimize out our overflow check below, otherwise)
|
|
|
|
*/
|
|
|
|
int64_t result = (uint64_t)a + (uint64_t)b;
|
|
|
|
/* signed addition overflows if operands have the same sign, and
|
|
|
|
* the sign of the result doesn't match the sign of the inputs.
|
|
|
|
*/
|
|
|
|
Bool overflow = (a < 0) == (b < 0) && (a < 0) != (result < 0);
|
|
|
|
|
|
|
|
*out = result;
|
|
|
|
|
|
|
|
return overflow;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Bool
|
|
|
|
checked_int64_subtract(int64_t *out, int64_t a, int64_t b)
|
|
|
|
{
|
|
|
|
int64_t result = (uint64_t)a - (uint64_t)b;
|
|
|
|
Bool overflow = (a < 0) != (b < 0) && (a < 0) != (result < 0);
|
|
|
|
|
|
|
|
*out = result;
|
|
|
|
|
|
|
|
return overflow;
|
|
|
|
}
|
|
|
|
|
2011-08-04 21:35:41 +02:00
|
|
|
#define swapl(x) do { \
|
2011-08-17 01:07:24 +02:00
|
|
|
if (sizeof(*(x)) != 4) \
|
|
|
|
wrong_size(); \
|
2017-04-21 21:03:45 +02:00
|
|
|
*(x) = bswap_32(*(x)); \
|
2011-08-04 21:35:41 +02:00
|
|
|
} while (0)
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2017-03-27 23:59:06 +02:00
|
|
|
static inline uint16_t
|
|
|
|
bswap_16(uint16_t x)
|
2011-08-17 01:03:26 +02:00
|
|
|
{
|
2017-03-27 23:59:06 +02:00
|
|
|
return (((x & 0xFF00) >> 8) |
|
|
|
|
((x & 0x00FF) << 8));
|
2011-08-17 01:03:26 +02:00
|
|
|
}
|
|
|
|
|
2011-08-04 21:35:41 +02:00
|
|
|
#define swaps(x) do { \
|
2011-08-17 01:07:24 +02:00
|
|
|
if (sizeof(*(x)) != 2) \
|
|
|
|
wrong_size(); \
|
2017-04-21 21:03:45 +02:00
|
|
|
*(x) = bswap_16(*(x)); \
|
2011-08-04 21:35:41 +02:00
|
|
|
} while (0)
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
/* copy 32-bit value from src to dst byteswapping on the way */
|
2011-08-17 01:12:21 +02:00
|
|
|
#define cpswapl(src, dst) do { \
|
2011-08-17 01:07:24 +02:00
|
|
|
if (sizeof((src)) != 4 || sizeof((dst)) != 4) \
|
|
|
|
wrong_size(); \
|
2017-03-27 23:59:06 +02:00
|
|
|
(dst) = bswap_32((src)); \
|
2011-08-17 01:12:21 +02:00
|
|
|
} while (0)
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
/* copy short from src to dst byteswapping on the way */
|
2011-08-17 01:12:21 +02:00
|
|
|
#define cpswaps(src, dst) do { \
|
2011-08-17 01:07:24 +02:00
|
|
|
if (sizeof((src)) != 2 || sizeof((dst)) != 2) \
|
|
|
|
wrong_size(); \
|
2017-03-27 23:59:06 +02:00
|
|
|
(dst) = bswap_16((src)); \
|
2011-08-17 01:12:21 +02:00
|
|
|
} while (0)
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
extern _X_EXPORT void SwapLongs(CARD32 *list, unsigned long count);
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
extern _X_EXPORT void SwapShorts(short *list, unsigned long count);
|
2003-11-14 16:54:54 +01:00
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
extern _X_EXPORT void MakePredeclaredAtoms(void);
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
extern _X_EXPORT int Ones(unsigned long /*mask */ );
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
typedef struct _xPoint *DDXPointPtr;
|
2007-05-12 22:58:54 +02:00
|
|
|
typedef struct pixman_box16 *BoxPtr;
|
2003-11-14 16:54:54 +01:00
|
|
|
typedef struct _xEvent *xEventPtr;
|
|
|
|
typedef struct _xRectangle *xRectanglePtr;
|
|
|
|
typedef struct _GrabRec *GrabPtr;
|
|
|
|
|
|
|
|
/* typedefs from other places - duplicated here to minimize the amount
|
|
|
|
* of unnecessary junk that one would normally have to include to get
|
|
|
|
* these symbols defined
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _XTYPEDEF_CHARINFOPTR
|
2012-03-21 20:55:09 +01:00
|
|
|
typedef struct _CharInfo *CharInfoPtr; /* also in fonts/include/font.h */
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
#define _XTYPEDEF_CHARINFOPTR
|
|
|
|
#endif
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
extern _X_EXPORT unsigned long globalSerialNumber;
|
|
|
|
extern _X_EXPORT unsigned long serverGeneration;
|
|
|
|
|
2011-12-05 05:02:51 +01:00
|
|
|
/* Don't use this directly, use BUG_WARN or BUG_WARN_MSG instead */
|
|
|
|
#define __BUG_WARN_MSG(cond, with_msg, ...) \
|
2011-11-09 05:37:26 +01:00
|
|
|
do { if (cond) { \
|
2012-04-16 18:47:42 +02:00
|
|
|
ErrorFSigSafe("BUG: triggered 'if (" #cond ")'\n"); \
|
|
|
|
ErrorFSigSafe("BUG: %s:%u in %s()\n", \
|
|
|
|
__FILE__, __LINE__, __func__); \
|
|
|
|
if (with_msg) ErrorFSigSafe(__VA_ARGS__); \
|
2011-11-09 05:37:26 +01:00
|
|
|
xorg_backtrace(); \
|
|
|
|
} } while(0)
|
|
|
|
|
2011-12-15 01:19:26 +01:00
|
|
|
#define BUG_WARN_MSG(cond, ...) \
|
|
|
|
__BUG_WARN_MSG(cond, 1, __VA_ARGS__)
|
2011-12-05 05:02:51 +01:00
|
|
|
|
|
|
|
#define BUG_WARN(cond) __BUG_WARN_MSG(cond, 0, NULL)
|
|
|
|
|
2012-05-10 03:48:05 +02:00
|
|
|
#define BUG_RETURN(cond) \
|
|
|
|
do { if (cond) { __BUG_WARN_MSG(cond, 0, NULL); return; } } while(0)
|
|
|
|
|
|
|
|
#define BUG_RETURN_MSG(cond, ...) \
|
|
|
|
do { if (cond) { __BUG_WARN_MSG(cond, 1, __VA_ARGS__); return; } } while(0)
|
|
|
|
|
|
|
|
#define BUG_RETURN_VAL(cond, val) \
|
|
|
|
do { if (cond) { __BUG_WARN_MSG(cond, 0, NULL); return (val); } } while(0)
|
|
|
|
|
|
|
|
#define BUG_RETURN_VAL_MSG(cond, val, ...) \
|
|
|
|
do { if (cond) { __BUG_WARN_MSG(cond, 1, __VA_ARGS__); return (val); } } while(0)
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
#endif /* MISC_H */
|