C9x types
authorArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:55:00 +0000 (16:55 +0000)
committerArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:55:00 +0000 (16:55 +0000)
Author: jgg
Date: 1999-10-25 03:36:41 GMT
C9x types

apt-pkg/contrib/md5.cc
buildlib/config.h.in
buildlib/inttypes.h.in [new file with mode: 0644]
configure.in

index 0d0a596..e656f32 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: md5.cc,v 1.3 1999/08/02 03:07:47 jgg Exp $
+// $Id: md5.cc,v 1.4 1999/10/25 03:36:41 jgg Exp $
 /* ######################################################################
    
    MD5Sum - MD5 Message Digest Algorithm.
 #include <system.h>
 #include <unistd.h>
 #include <config.h>
+#include <inttypes.h>
                                                                        /*}}}*/
 
 // byteSwap - Swap bytes in a buffer                                   /*{{{*/
 // ---------------------------------------------------------------------
 /* This byteswap function will swap byte in a buffer of data */
 #ifdef WORDS_BIGENDIAN
-static void byteSwap(UINT32 *buf, unsigned words)
+static void byteSwap(uint32_t *buf, unsigned words)
 {
    unsigned char *p = (unsigned char *)buf;
    
    do 
    {
-      *buf++ = (UINT32)((unsigned)p[3] << 8 | p[2]) << 16 |
+      *buf++ = (uint32_t)((unsigned)p[3] << 8 | p[2]) << 16 |
         ((unsigned)p[1] << 8 | p[0]);
       p += 4;
    } while (--words);
@@ -83,9 +84,9 @@ static void byteSwap(UINT32 *buf, unsigned words)
 #define MD5STEP(f,w,x,y,z,in,s) \
         (w += f(x,y,z) + in, w = (w<<s | w>>(32-s)) + x)
 
-static void MD5Transform(UINT32 buf[4], UINT32 const in[16])
+static void MD5Transform(uint32_t buf[4], uint32_t const in[16])
 {
-   register UINT32 a, b, c, d;
+   register uint32_t a, b, c, d;
    
    a = buf[0];
    b = buf[1];
@@ -226,8 +227,8 @@ bool MD5SumValue::operator ==(const MD5SumValue &rhs) const
 /* This assigns the deep magic initial values */
 MD5Summation::MD5Summation()
 {
-   UINT32 *buf = (UINT32 *)Buf;
-   UINT32 *bytes = (UINT32 *)Bytes;
+   uint32_t *buf = (uint32_t *)Buf;
+   uint32_t *bytes = (uint32_t *)Bytes;
    
    buf[0] = 0x67452301;
    buf[1] = 0xefcdab89;
@@ -247,12 +248,12 @@ bool MD5Summation::Add(const unsigned char *data,unsigned long len)
    if (Done == true)
       return false;
 
-   UINT32 *buf = (UINT32 *)Buf;
-   UINT32 *bytes = (UINT32 *)Bytes;
-   UINT32 *in = (UINT32 *)In;
+   uint32_t *buf = (uint32_t *)Buf;
+   uint32_t *bytes = (uint32_t *)Bytes;
+   uint32_t *in = (uint32_t *)In;
 
    // Update byte count and carry (this could be done with a long long?)
-   UINT32 t = bytes[0];
+   uint32_t t = bytes[0];
    if ((bytes[0] = t + len) < t)
       bytes[1]++;      
 
@@ -311,9 +312,9 @@ bool MD5Summation::AddFD(int Fd,unsigned long Size)
    from calling add after. */
 MD5SumValue MD5Summation::Result()
 {
-   UINT32 *buf = (UINT32 *)Buf;
-   UINT32 *bytes = (UINT32 *)Bytes;
-   UINT32 *in = (UINT32 *)In;
+   uint32_t *buf = (uint32_t *)Buf;
+   uint32_t *bytes = (uint32_t *)Bytes;
+   uint32_t *in = (uint32_t *)In;
    
    if (Done == false)
    {
index 2c98a11..f882ca2 100644 (file)
 /* The package name string */
 #undef PACKAGE
 
-/* Generate the fixed bit size types */
-#if SIZEOF_INT == 4
-# define INT32 int
-# define UINT32 unsigned int
-#else
-# if SIZEOF_LONG == 4
-#  define INT32 long
-#  define UINT32 unsigned long
-# else
-#  if SIZEOF_SHORT == 4
-#   define INT32 short
-#   define UINT32 unsigned short
-#  else
-#   error Must have a form of 32-bit integer
-#  endif
-# endif
-#endif
-
-#if SIZEOF_INT == 2
-# define INT16 int
-# define UINT16 unsigned int
-#else
-# if SIZEOF_LONG == 2
-#  define INT16 long
-#  define UINT16 unsigned long
-# else
-#  if SIZEOF_SHORT == 2
-#   define INT16 short
-#   define UINT16 short
-#  else
-#   error Must have a form of 16-bit integer
-#  endif
-# endif
-#endif
diff --git a/buildlib/inttypes.h.in b/buildlib/inttypes.h.in
new file mode 100644 (file)
index 0000000..3be7207
--- /dev/null
@@ -0,0 +1,43 @@
+/* This is an ISO C 9X header file. We omit this copy to the include 
+   directory if the local platform does not have inttypes.h, it contains
+   [u]int[8,16,32]_t fixed width types */
+
+#include <config.h>
+
+/* Generate the fixed bit size types */
+#if SIZEOF_INT == 4
+  typedef int int32_t;
+  typedef unsigned int uint32_t;
+#else
+# if SIZEOF_LONG == 4
+  typedef long int32_t;
+  typedef unsigned long uint32_t;
+# else
+#  if SIZEOF_SHORT == 4
+    typedef short int32_t;
+    typedef unsigned short uint32_t;
+#  else
+#   error Must have a form of 32-bit integer
+#  endif
+# endif
+#endif
+
+#if SIZEOF_INT == 2
+  typedef int int16_t;
+  typedef unsigned int uint16_t;
+#else
+# if SIZEOF_LONG == 2
+   typedef long int16_t;
+   typedef unsigned long uint16_t;
+# else
+#  if SIZEOF_SHORT == 2
+    typedef short int16_t;
+    typedef unsigned short uint16_t;
+#  else
+#   error Must have a form of 16-bit integer
+#  endif
+# endif
+#endif
+
+typedef signed char int8_t;
+typedef unsigned char uint8_t;
index 4255525..66b9833 100644 (file)
@@ -77,29 +77,39 @@ fi
 AC_MSG_RESULT($archset)
 AC_DEFINE_UNQUOTED(ARCHITECTURE,"$archset")
 
+dnl We use C9x types if at all possible
+AC_CACHE_CHECK([for C9x integer types],c9x_ints,[
+    AC_TRY_COMPILE([#include <inttypes.h>],
+                   [uint8_t Foo1;uint16_t Foo2;uint32_t Foo3;uint64_t Foo],
+                  c9x_ints=yes,c9x_ints=no)])
+
 dnl Check the sizes etc. of the architecture
 changequote(,)
 if archline="`sed -ne 's/^'$archset':[         ]\+\(.*\)/\1/gp' $srcdir/buildlib/sizetable`"; then
-changequote([,])
-  set $archline
-  if test "$1" = "little"; then
-    ac_cv_c_bigendian=no
-  else
-    ac_cv_c_bigendian=yes
-  fi
-  size_char=$2
-  size_int=$3
-  size_short=$4
-  size_long=$5
+   changequote([,])
+   set $archline
+   if test "$1" = "little"; then
+      ac_cv_c_bigendian=no
+   else
+      ac_cv_c_bigendian=yes
+   fi
+   size_char=$2
+   size_int=$3
+   size_short=$4
+   size_long=$5
 fi
+
 if test "$cross_compiling" = "yes" -a "$archline" = ""; then
   AC_MSG_ERROR(When cross compiling, architecture must be present in sizetable)
 fi
 AC_C_BIGENDIAN
-AC_CHECK_SIZEOF(char,$size_char)
-AC_CHECK_SIZEOF(int,$size_int)
-AC_CHECK_SIZEOF(short,$size_short)
-AC_CHECK_SIZEOF(long,$size_long)
+   
+if test x"$c9x_ints" = x"no"; then
+   AC_CHECK_SIZEOF(char,$size_char)
+   AC_CHECK_SIZEOF(int,$size_int)
+   AC_CHECK_SIZEOF(short,$size_short)
+   AC_CHECK_SIZEOF(long,$size_long)
+fi
 
 dnl Check for debiandoc
 AC_CHECK_PROG(DEBIANDOC_HTML,debiandoc2html,"yes","")
@@ -108,4 +118,8 @@ AC_CHECK_PROG(DEBIANDOC_TEXT,debiandoc2text,"yes","")
 dnl Check for YODL
 AC_CHECK_PROG(YODL_MAN,yodl2man,"yes","")
 
-AC_OUTPUT(environment.mak:buildlib/environment.mak.in makefile:buildlib/makefile.in,make dirs)
+if test x"$c9x_ints" = x"no"; then
+   AC_OUTPUT(environment.mak:buildlib/environment.mak.in makefile:buildlib/makefile.in include/inttypes.h:buildlib/inttypes.h.in,make dirs)
+else
+   AC_OUTPUT(environment.mak:buildlib/environment.mak.in makefile:buildlib/makefile.in,make dirs)
+fi