+ typedef unsigned __int8 uint8_t;
+ typedef unsigned __int16 uint16_t;
+ typedef unsigned __int32 uint32_t;
+ typedef unsigned __int64 uint64_t;
+
+ typedef __int16 int16_t;
+ typedef __int32 int32_t;
+ typedef __int64 int64_t;
+#endif /*! _MSC_VER */
+
+/*
+ * Very roboust way at determining endianess at compile time: this handles
+ * almost every possible situation. Otherwise a runtime check has to be
+ * performed.
+ */
+#define GMQCC_BYTE_ORDER_LITTLE 1234
+#define GMQCC_BYTE_ORDER_BIG 4321
+
+#if defined (__GNUC__) || defined (__GNU_LIBRARY__)
+# if defined (__FreeBSD__) || defined (__OpenBSD__)
+# include <sys/endian.h>
+# elif defined (BSD) && (BSD >= 199103) || defined (__DJGPP__) || defined (__CYGWIN32__)
+# include <machine/endian.h>
+# elif defined (__APPLE__)
+# if defined (__BIG_ENDIAN__) && !defined(BIG_ENDIAN)
+# define BIG_ENDIAN
+# elif defined (__LITTLE_ENDIAN__) && !defined (LITTLE_ENDIAN)
+# define LITTLE_ENDIAN
+# endif /*! defined (__BIG_ENDIAN__) && !defined(BIG_ENDIAN) */
+# elif !defined (__MINGW32__)
+# include <endian.h>
+# if !defined (__BEOS__)
+# include <byteswap.h>
+# endif /*! !definde (__BEOS__) */
+# endif /*! defined (__FreeBSD__) || defined (__OpenBSD__) */
+#endif /*! defined (__GNUC__) || defined (__GNU_LIBRARY__) */
+#if !defined(PLATFORM_BYTE_ORDER)
+# if defined (LITTLE_ENDIAN) || defined (BIG_ENDIAN)
+# if defined (LITTLE_ENDIAN) && !defined(BIG_ENDIAN)
+# define PLATFORM_BYTE_ORDER GMQCC_BYTE_ORDER_LITTLE
+# elif !defined (LITTLE_ENDIAN) && defined (BIG_ENDIAN)
+# define PLATFORM_BYTE_ORDER GMQCC_BYTE_ORDER_BIG
+# elif defined (BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN)
+# define PLATFORM_BYTE_ORDER GMQCC_BYTE_ORDER_LITTLE
+# elif defined (BYTE_ORDER) && (BYTE_ORDER == BIG_ENDIAN)
+# define PLATFORM_BYTE_ORDER GMQCC_BYTE_ORDER_BIG
+# endif /*! defined (LITTLE_ENDIAN) && !defined(BIG_ENDIAN) */
+# elif defined (_LITTLE_ENDIAN) || defined (_BIG_ENDIAN)
+# if defined (_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)
+# define PLATFORM_BYTE_ORDER GMQCC_BYTE_ORDER_LITTLE
+# elif !defined (_LITTLE_ENDIAN) && defined (_BIG_ENDIAN)
+# define PLATFORM_BYTE_ORDER GMQCC_BYTE_ORDER_BIG
+# elif defined (_BYTE_ORDER) && (_BYTE_ORDER == _LITTLE_ENDIAN)
+# define PLATFORM_BYTE_ORDER GMQCC_BYTE_ORDER_LITTLE
+# elif defined (_BYTE_ORDER) && (_BYTE_ORDER == _BIG_ENDIAN)
+# define PLATFORM_BYTE_ORDER GMQCC_BYTE_ORDER_BIG
+# endif /*! defined (_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN) */
+# elif defined (__LITTLE_ENDIAN__) || defined (__BIG_ENDIAN__)
+# if defined (__LITTLE_ENDIAN__) && !defined (__BIG_ENDIAN__)
+# define PLATFORM_BYTE_ORDER GMQCC_BYTE_ORDER_LITTLE
+# elif !defined (__LITTLE_ENDIAN__) && defined (__BIG_ENDIAN__)
+# define PLATFORM_BYTE_ORDER GMQCC_BYTE_ORDER_BIG
+# elif defined (__BYTE_ORDER__) && (__BYTE_ORDER__ == __LITTLE_ENDIAN__)
+# define PLATFORM_BYTE_ORDER GMQCC_BYTE_ORDER_LITTLE
+# elif defined (__BYTE_ORDER__) && (__BYTE_ORDER__ == __BIG_ENDIAN__)
+# define PLATFORM_BYTE_ORDER GMQCC_BYTE_ORDER_BIG
+# endif /*! defined (__LITTLE_ENDIAN__) && !defined (__BIG_ENDIAN__) */
+# endif /*! defined(LITTLE_ENDIAN) || defined (BIG_ENDIAN) */
+#endif /*! !defined(PLATFORM_BYTE_ORDER) */
+#if !defined (PLATFORM_BYTE_ORDER)
+# if defined (__alpha__) || defined (__alpha) || defined (i386) || \
+ defined (__i386__) || defined (_M_I86) || defined (_M_IX86) || \
+ defined (__OS2__) || defined (sun386) || defined (__TURBOC__) || \
+ defined (vax) || defined (vms) || defined (VMS) || \
+ defined (__VMS) || defined (__x86_64__) || defined (_M_IA64) || \
+ defined (_M_X64) || defined (__i386) || defined (__x86_64)
+# define PLATFORM_BYTE_ORDER GMQCC_BYTE_ORDER_LITTLE
+# elif defined (AMIGA) || defined (applec) || defined (__AS400__) || \
+ defined (_CRAY) || defined (__hppa) || defined (__hp9000) || \
+ defined (ibm370) || defined (mc68000) || defined (m68k) || \
+ defined (__MRC__) || defined (__MVS__) || defined (__MWERKS__) || \
+ defined (sparc) || defined (__sparc) || defined (SYMANTEC_C) || \
+ defined (__TANDEM) || defined (THINK_C) || defined (__VMCMS__) || \
+ defined (__PPC__) || defined (__PPC) || defined (PPC)
+# define PLATFORM_BYTE_ORDER GMQCC_BYTE_ORDER_BIG
+# else
+# define PLATFORM_BYTE_ORDER -1
+# endif
+#endif /*! !defined (PLATFORM_BYTE_ORDER) */
+
+/*
+ * On windows systems where we're not compiling with MING32 we need a
+ * little extra help on dependinces for implementing our own dirent.h
+ * in fs.c.
+ */
+#if defined(_WIN32) && !defined(__MINGW32__)
+# define _WIN32_LEAN_AND_MEAN
+# include <windows.h>
+# include <io.h>
+# include <fcntl.h>
+
+ struct dirent {
+ long d_ino;
+ unsigned short d_reclen;
+ unsigned short d_namlen;
+ char d_name[FILENAME_MAX];
+ };
+
+ typedef struct {
+ struct _finddata_t dd_dta;
+ struct dirent dd_dir;
+ long dd_handle;
+ int dd_stat;
+ char dd_name[1];
+ } DIR;