# HG changeset patch # User Matt Mackall # Date 2012-04-10 17:07:14 # Node ID e501f45b0eba90e8ff71466404e350688a941172 # Parent 8d821a173e4ed2791fcb6057e82c966faf16cf4e util.h: unify some common platform tweaks diff --git a/mercurial/bdiff.c b/mercurial/bdiff.c --- a/mercurial/bdiff.c +++ b/mercurial/bdiff.c @@ -14,38 +14,6 @@ #include #include -#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 -#endif -static uint32_t htonl(uint32_t x) -{ - return ((x & 0x000000ffUL) << 24) | - ((x & 0x0000ff00UL) << 8) | - ((x & 0x00ff0000UL) >> 8) | - ((x & 0xff000000UL) >> 24); -} -#else -#include -#if defined __BEOS__ && !defined __HAIKU__ -#include -#else -#include -#endif -#include -#endif - #include "util.h" struct line { diff --git a/mercurial/mpatch.c b/mercurial/mpatch.c --- a/mercurial/mpatch.c +++ b/mercurial/mpatch.c @@ -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 -#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 -#if defined __BEOS__ && !defined __HAIKU__ -#include -#else -#include -#endif -#include -#endif - static char mpatch_doc[] = "Efficient binary patching."; static PyObject *mpatch_Error; diff --git a/mercurial/parsers.c b/mercurial/parsers.c --- a/mercurial/parsers.c +++ b/mercurial/parsers.c @@ -135,33 +135,6 @@ quit: 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 -#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 -#if defined __BEOS__ && !defined __HAIKU__ -#include -#else -#include -#endif -#include -#endif - static PyObject *parse_dirstate(PyObject *self, PyObject *args) { PyObject *dmap, *cmap, *parents = NULL, *ret = NULL; diff --git a/mercurial/util.h b/mercurial/util.h --- a/mercurial/util.h +++ b/mercurial/util.h @@ -113,4 +113,39 @@ typedef int Py_ssize_t; #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 +#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 +#if defined __BEOS__ && !defined __HAIKU__ +#include +#else +#include +#endif +#include +#endif + +#if defined __hpux || defined __SUNPRO_C || defined _AIX +#define inline +#endif + +#ifdef __linux +#define inline __inline +#endif + #endif /* _HG_UTIL_H_ */