Bug#164917: xlibs-dev: moving away from Xmd.h arch dependencies
Here is a patch that includes the move toward arch independence and
includes a major cleanup of the preprocessor directives in Xmd.h. It
converts all #ifdef to #if defined(symbol) and #ifndef to #if !defined(symbol)
except for the header test at the top.
Warren
--- /usr/include/X11/Xmd.h 2002-10-08 01:05:41.000000000 -0500
+++ Xmd2.h 2002-10-15 23:28:16.000000000 -0500
@@ -55,20 +55,24 @@
/*
* Special per-machine configuration flags.
*/
-#ifdef CRAY
-#define WORD64 /* 64-bit architecture */
+#if !defined(WORD64) && defined(CRAY)
+# define WORD64 /* 64-bit architecture */
#endif
-#if defined(__alpha) || defined(__alpha__) || \
+
+#if !defined(LONG64)
+# if defined(__alpha) || defined(__alpha__) || \
defined(__ia64__) || defined(ia64) || \
defined(__sparc64__) || \
defined(__s390x__) || \
(defined(__hppa__) && defined(__LP64__))
-#define LONG64 /* 32/64-bit architecture */
-#endif
-#ifdef __sgi
-#if (_MIPS_SZLONG == 64)
-#define LONG64
+# define LONG64 /* 32/64-bit architecture */
+# endif
#endif
+
+#if !defined(LONG64) && defined(__sgi)
+# if (_MIPS_SZLONG == 64)
+# define LONG64
+# endif
#endif
/*
@@ -76,7 +80,7 @@
* on a 32-bit machine and must coorespond to the protocol.
*/
#ifdef WORD64
-#define MUSTCOPY
+# define MUSTCOPY
#endif /* WORD64 */
@@ -95,10 +99,10 @@
* expand correctly before the concatenation, rather than afterward.
*/
#if ((defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)) &&
!defined(UNIXCPP)) || defined(ANSICPP)
-#define _SIZEOF(x) sz_##x
-#define SIZEOF(x) _SIZEOF(x)
+# define _SIZEOF(x) sz_##x
+# define SIZEOF(x) _SIZEOF(x)
#else
-#define SIZEOF(x) sz_/**/x
+# define SIZEOF(x) sz_/**/x
#endif /* if ANSI C compiler else not */
/*
@@ -106,32 +110,32 @@
* need them. Note that bitfields are not guarranteed to be signed
* (or even unsigned) according to ANSI C.
*/
-#ifdef WORD64
+#if defined(WORD64)
typedef long INT64;
typedef unsigned long CARD64;
-#define B32 :32
-#define B16 :16
-#ifdef UNSIGNEDBITFIELDS
+# define B32 :32
+# define B16 :16
+# if defined(UNSIGNEDBITFIELDS)
typedef unsigned int INT32;
typedef unsigned int INT16;
-#else
-#ifdef __STDC__
+# else
+# if defined(__STDC__)
typedef signed int INT32;
typedef signed int INT16;
-#else
+# else
typedef int INT32;
typedef int INT16;
-#endif
-#endif
+# endif
+# endif
#else
-#define B32
-#define B16
-#ifdef LONG64
+# define B32
+# define B16
+# if defined(LONG64)
typedef long INT64;
typedef int INT32;
-#else
+# else
typedef long INT32;
-#endif
+# endif
typedef short INT16;
#endif
@@ -141,7 +145,7 @@
typedef char INT8;
#endif
-#ifdef LONG64
+#if defined(LONG64)
typedef unsigned long CARD64;
typedef unsigned int CARD32;
#else
@@ -153,7 +157,7 @@
typedef CARD32 BITS32;
typedef CARD16 BITS16;
-#ifndef __EMX__
+#if !defined(__EMX__)
typedef CARD8 BYTE;
typedef CARD8 BOOL;
#else /* __EMX__ */
@@ -161,33 +165,33 @@
* This is bad style, but the central include file <os2.h> declares them
* as well
*/
-#define BYTE CARD8
-#define BOOL CARD8
+# define BYTE CARD8
+# define BOOL CARD8
#endif /* __EMX__ */
/*
* definitions for sign-extending bitfields on 64-bit architectures
*/
#if defined(WORD64) && defined(UNSIGNEDBITFIELDS)
-#define cvtINT8toInt(val) (((val) & 0x00000080) ? ((val) |
0xffffffffffffff00) : (val))
-#define cvtINT16toInt(val) (((val) & 0x00008000) ? ((val) |
0xffffffffffff0000) : (val))
-#define cvtINT32toInt(val) (((val) & 0x80000000) ? ((val) |
0xffffffff00000000) : (val))
-#define cvtINT8toShort(val) cvtINT8toInt(val)
-#define cvtINT16toShort(val) cvtINT16toInt(val)
-#define cvtINT32toShort(val) cvtINT32toInt(val)
-#define cvtINT8toLong(val) cvtINT8toInt(val)
-#define cvtINT16toLong(val) cvtINT16toInt(val)
-#define cvtINT32toLong(val) cvtINT32toInt(val)
-#else
-#define cvtINT8toInt(val) (val)
-#define cvtINT16toInt(val) (val)
-#define cvtINT32toInt(val) (val)
-#define cvtINT8toShort(val) (val)
-#define cvtINT16toShort(val) (val)
-#define cvtINT32toShort(val) (val)
-#define cvtINT8toLong(val) (val)
-#define cvtINT16toLong(val) (val)
-#define cvtINT32toLong(val) (val)
+# define cvtINT8toInt(val) (((val) & 0x00000080) ? ((val) |
0xffffffffffffff00) : (val))
+# define cvtINT16toInt(val) (((val) & 0x00008000) ? ((val) |
0xffffffffffff0000) : (val))
+# define cvtINT32toInt(val) (((val) & 0x80000000) ? ((val) |
0xffffffff00000000) : (val))
+# define cvtINT8toShort(val) cvtINT8toInt(val)
+# define cvtINT16toShort(val) cvtINT16toInt(val)
+# define cvtINT32toShort(val) cvtINT32toInt(val)
+# define cvtINT8toLong(val) cvtINT8toInt(val)
+# define cvtINT16toLong(val) cvtINT16toInt(val)
+# define cvtINT32toLong(val) cvtINT32toInt(val)
+#else
+# define cvtINT8toInt(val) (val)
+# define cvtINT16toInt(val) (val)
+# define cvtINT32toInt(val) (val)
+# define cvtINT8toShort(val) (val)
+# define cvtINT16toShort(val) (val)
+# define cvtINT32toShort(val) (val)
+# define cvtINT8toLong(val) (val)
+# define cvtINT16toLong(val) (val)
+# define cvtINT32toLong(val) (val)
#endif /* WORD64 and UNSIGNEDBITFIELDS */
@@ -196,13 +200,13 @@
/*
* This macro must not cast or else pointers will get aligned and be wrong
*/
-#define NEXTPTR(p,t) (((char *) p) + SIZEOF(t))
+# define NEXTPTR(p,t) (((char *) p) + SIZEOF(t))
#else /* else not MUSTCOPY, this is used for 32-bit machines */
/*
* this version should leave result of type (t *), but that should only be
* used when not in MUSTCOPY
*/
-#define NEXTPTR(p,t) (((t *)(p)) + 1)
+# define NEXTPTR(p,t) (((t *)(p)) + 1)
#endif /* MUSTCOPY - used machines whose C structs don't line up with proto
*/
#endif /* XMD_H */
On Tuesday 15 October 2002 07:41 pm, Warren Turkal wrote:
> Package: xlibs-dev
> Version: 4.2.1-2
> Severity: wishlist
> Tags: upstream patch
>
> This patch is an effort to start moving X into a more architecture
> agnostic source code.
>
> I am going to join the xpert list and see if why they don't use exact
> integer types. This may kill the need for most or all of the
> architecture dependencies in Xmd.h
>
<snip>
>
> -- System Information:
> Debian Release: testing/unstable
> Architecture: i386
> Kernel: Linux braindead 2.5.42acpidebug #1 SMP Mon Oct 14 20:29:43 CDT 2002
> i686 Locale: LANG=C, LC_CTYPE=C
>
> Versions of packages xlibs-dev depends on:
> ii libc6-dev 2.2.5-15 GNU C Library: Development
> Librari ii xlibs 4.2.1-2 X Window System client
> libraries
>
> -- no debconf information
--
Treasurer, GOLUM, Inc.
http://www.golum.org
Reply to: