util.h: unify some common platform tweaks
authorMatt Mackall <mpm@selenic.com>
Tue, 10 Apr 2012 12:07:14 -0500
changeset 16385 e501f45b0eba
parent 16384 8d821a173e4e
child 16386 ccc173d0914e
util.h: unify some common platform tweaks
mercurial/bdiff.c
mercurial/mpatch.c
mercurial/parsers.c
mercurial/util.h
--- a/mercurial/bdiff.c	Tue Apr 10 12:07:09 2012 -0500
+++ b/mercurial/bdiff.c	Tue Apr 10 12:07:14 2012 -0500
@@ -14,38 +14,6 @@
 #include <string.h>
 #include <limits.h>
 
-#if defined __hpux || defined __SUNPRO_C || defined _AIX
-#define inline
-#endif
-
-#ifdef __linux
-#define inline __inline
-#endif
-
-#ifdef _WIN32
-#ifdef _MSC_VER
-#define inline __inline
-typedef unsigned long uint32_t;
-#else
-#include <stdint.h>
-#endif
-static uint32_t htonl(uint32_t x)
-{
-	return ((x & 0x000000ffUL) << 24) |
-		((x & 0x0000ff00UL) <<  8) |
-		((x & 0x00ff0000UL) >>  8) |
-		((x & 0xff000000UL) >> 24);
-}
-#else
-#include <sys/types.h>
-#if defined __BEOS__ && !defined __HAIKU__
-#include <ByteOrder.h>
-#else
-#include <arpa/inet.h>
-#endif
-#include <inttypes.h>
-#endif
-
 #include "util.h"
 
 struct line {
--- a/mercurial/mpatch.c	Tue Apr 10 12:07:09 2012 -0500
+++ b/mercurial/mpatch.c	Tue Apr 10 12:07:14 2012 -0500
@@ -26,32 +26,6 @@
 
 #include "util.h"
 
-#ifdef _WIN32
-#ifdef _MSC_VER
-/* msvc 6.0 has problems */
-#define inline __inline
-typedef unsigned long uint32_t;
-#else
-#include <stdint.h>
-#endif
-static uint32_t ntohl(uint32_t x)
-{
-	return ((x & 0x000000ffUL) << 24) |
-		((x & 0x0000ff00UL) <<  8) |
-		((x & 0x00ff0000UL) >>  8) |
-		((x & 0xff000000UL) >> 24);
-}
-#else
-/* not windows */
-#include <sys/types.h>
-#if defined __BEOS__ && !defined __HAIKU__
-#include <ByteOrder.h>
-#else
-#include <arpa/inet.h>
-#endif
-#include <inttypes.h>
-#endif
-
 static char mpatch_doc[] = "Efficient binary patching.";
 static PyObject *mpatch_Error;
 
--- a/mercurial/parsers.c	Tue Apr 10 12:07:09 2012 -0500
+++ b/mercurial/parsers.c	Tue Apr 10 12:07:14 2012 -0500
@@ -135,33 +135,6 @@
 	return NULL;
 }
 
-#ifdef _WIN32
-#ifdef _MSC_VER
-/* msvc 6.0 has problems */
-#define inline __inline
-typedef unsigned long uint32_t;
-typedef unsigned __int64 uint64_t;
-#else
-#include <stdint.h>
-#endif
-static uint32_t ntohl(uint32_t x)
-{
-	return ((x & 0x000000ffUL) << 24) |
-	       ((x & 0x0000ff00UL) <<  8) |
-	       ((x & 0x00ff0000UL) >>  8) |
-	       ((x & 0xff000000UL) >> 24);
-}
-#else
-/* not windows */
-#include <sys/types.h>
-#if defined __BEOS__ && !defined __HAIKU__
-#include <ByteOrder.h>
-#else
-#include <arpa/inet.h>
-#endif
-#include <inttypes.h>
-#endif
-
 static PyObject *parse_dirstate(PyObject *self, PyObject *args)
 {
 	PyObject *dmap, *cmap, *parents = NULL, *ret = NULL;
--- a/mercurial/util.h	Tue Apr 10 12:07:09 2012 -0500
+++ b/mercurial/util.h	Tue Apr 10 12:07:14 2012 -0500
@@ -113,4 +113,39 @@
 #endif
 #endif
 
+#ifdef _WIN32
+#ifdef _MSC_VER
+/* msvc 6.0 has problems */
+#define inline __inline
+typedef unsigned long uint32_t;
+typedef unsigned __int64 uint64_t;
+#else
+#include <stdint.h>
+#endif
+static uint32_t ntohl(uint32_t x)
+{
+	return ((x & 0x000000ffUL) << 24) |
+	       ((x & 0x0000ff00UL) <<  8) |
+	       ((x & 0x00ff0000UL) >>  8) |
+	       ((x & 0xff000000UL) >> 24);
+}
+#else
+/* not windows */
+#include <sys/types.h>
+#if defined __BEOS__ && !defined __HAIKU__
+#include <ByteOrder.h>
+#else
+#include <arpa/inet.h>
+#endif
+#include <inttypes.h>
+#endif
+
+#if defined __hpux || defined __SUNPRO_C || defined _AIX
+#define inline
+#endif
+
+#ifdef __linux
+#define inline __inline
+#endif
+
 #endif /* _HG_UTIL_H_ */