[PATCH 1/9] Use stdint.h instead of assuming the size of types

Adrian Johnson ajohnson at redneon.com
Tue Aug 9 05:35:53 PDT 2011


---
 configure.ac               |    1 +
 goo/gtypes.h               |   20 ++++++++++++++++++++
 poppler/CairoOutputDev.cc  |    2 --
 poppler/CairoRescaleBox.cc |    2 --
 4 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index b7af92b..8afb13b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -114,6 +114,7 @@ AC_DEFINE_DIR(POPPLER_DATADIR, "{datarootdir}/poppler", [Poppler data dir])
 dnl ##### Checks for header files.
 AC_PATH_XTRA
 AC_HEADER_DIRENT
+AC_CHECK_HEADERS([stdint.h])
 
 dnl ##### Switch over to C++.  This will make the checks below a little
 dnl ##### bit stricter (requiring function prototypes in include files).
diff --git a/goo/gtypes.h b/goo/gtypes.h
index b7a2dd2..3bc2092 100644
--- a/goo/gtypes.h
+++ b/goo/gtypes.h
@@ -24,6 +24,8 @@
 #ifndef GTYPES_H
 #define GTYPES_H
 
+#include "config.h"
+
 /*
  * These have stupid names to avoid conflicts with some (but not all)
  * C++ compilers which define them.
@@ -45,4 +47,22 @@ typedef unsigned short Gushort;
 typedef unsigned int Guint;
 typedef unsigned long Gulong;
 
+/*
+ * Define precise integer types.
+ */
+#if HAVE_STDINT_H
+#include <stdint.h>
+#elif _MSC_VER
+typedef signed   __int8  int8_t;
+typedef unsigned __int8  uint8_t;
+typedef signed   __int16 int16_t;
+typedef unsigned __int16 uint16_t;
+typedef signed   __int32 int32_t;
+typedef unsigned __int32 uint32_t;
+typedef signed   __int64 int64_t;
+typedef unsigned __int64 uint64_t;
+#else
+#error No stdint.h types defined
+#endif
+
 #endif
diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 477030a..6e7fd53 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -1343,8 +1343,6 @@ void CairoOutputDev::paintTransparencyGroup(GfxState * /*state*/, double * /*bbo
   popTransparencyGroup();
 }
 
-typedef unsigned int uint32_t;
-
 static uint32_t luminocity(uint32_t x)
 {
   int r = (x >> 16) & 0xff;
diff --git a/poppler/CairoRescaleBox.cc b/poppler/CairoRescaleBox.cc
index dce5ddd..fea5891 100644
--- a/poppler/CairoRescaleBox.cc
+++ b/poppler/CairoRescaleBox.cc
@@ -37,8 +37,6 @@
 #include "goo/gmem.h"
 #include "CairoRescaleBox.h"
 
-typedef unsigned short int      uint16_t;
-typedef unsigned int            uint32_t;
 
 /* we work in fixed point where 1. == 1 << 24 */
 #define FIXED_SHIFT 24
-- 
1.7.4.1


--------------010100010407070709080108
Content-Type: text/x-patch;
 name="0002-png-use-PNG_RESOLUTION_METER-instead-of-PNG_RESOLUTI.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename*0="0002-png-use-PNG_RESOLUTION_METER-instead-of-PNG_RESOLUTI.pa";
 filename*1="tch"



More information about the poppler mailing list