Re: exact integral types

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 

Re: exact integral types



Here is a patch that should make Xmd.h use C99 when available.

--- /usr/include/X11/Xmd.h	2002-10-16 15:14:38.000000000 -0500
+++ Xmd.h	2002-10-19 14:23:33.000000000 -0500
@@ -47,6 +47,7 @@
 ******************************************************************/
 #ifndef XMD_H
 #define XMD_H 1
+
 /* $Xorg: Xmd.h,v 1.4 2001/02/09 02:03:22 xorgcvs Exp $ */
 /*
  *  Xmd.h: MACHINE DEPENDENT DECLARATIONS.
@@ -101,6 +102,36 @@
 #define SIZEOF(x) sz_/**/x
 #endif /* if ANSI C compiler else not */
 
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ == 199901L)
+
+#include <stdint.h>
+
+typedef uint8_t  CARD8;
+typedef uint16_t CARD16;
+typedef uint32_t CARD32;
+typedef uint64_t CARD64;
+
+typedef int8_t  INT8;
+typedef int16_t INT16;
+typedef int32_t INT32;
+typedef int64_t INT64;
+
+typedef CARD8 BYTE;
+typedef CARD8 BOOL;
+
+typedef CARD32 BITS32;
+typedef CARD16 BITS16;
+
+/*is there any reason why B32 and B16 cannot always be defined?*/
+# if defined(WORD64)
+#define B32 :32
+#define B16 :16
+# else
+#define B32
+#define B16
+# endif
+
+#else //__STDC_VERSION__
 /*
  * Bitfield suffixes for the protocol structure elements, if you
  * need them.  Note that bitfields are not guarranteed to be signed
@@ -165,6 +196,8 @@
 #define BOOL		CARD8
 #endif /* __EMX__ */
 
+#endif // __STDC_VERSION__
+
 /*
  * definitions for sign-extending bitfields on 64-bit architectures
  */


On Wednesday 16 October 2002 03:37 am, Dr Andrew C Aitchison wrote:
> On Wed, 16 Oct 2002, Warren Turkal wrote:
> > Why does X not use the exact integral types in its typedefs?
> >
> > For instance,
> > typedef uint32_t CARD32;
> > instead of all the magic in Xmd.h?
>
> These are the ISO C 9X integer types aren't they ?
>
> I don't think we have got as far as completely ansi'fing the code yet,
> never mind using C-9X features.
> It might be a worthwhile project to make that file use C-9X when
> available, and only then grovel deep inside systems for older compilers,
> but basically it is a case of "if it ain't broke, don't fix it".

-- 
Treasurer, GOLUM, Inc.
http://www.golum.org

_______________________________________________
Xpert mailing list
Xpert@xxxxxxxxxxx
http://XFree86.Org/mailman/listinfo/xpert




[Index of Archives]     [XFree86 Newbie]     [X.Org]     [XFree86]     [IETF Annouce]     [Bugtraq]     [Share Pictures]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [XFree86 Forum]