diff mercurial/util.h @ 29444:284d742e5611

internals: move the bitmanipulation routines into its own file This is to allow more flexibility with the C sources -- now the bitmanipulation routines can be safely imported without importing Python.h
author Maciej Fijalkowski <fijall@gmail.com>
date Mon, 06 Jun 2016 13:08:13 +0200
parents 14bf7679fb68
children d576b7394646
line wrap: on
line diff
--- a/mercurial/util.h	Fri Jun 24 16:12:05 2016 +0100
+++ b/mercurial/util.h	Mon Jun 06 13:08:13 2016 +0200
@@ -8,6 +8,8 @@
 #ifndef _HG_UTIL_H_
 #define _HG_UTIL_H_
 
+#include "compat.h"
+
 #if PY_MAJOR_VERSION >= 3
 
 #define IS_PY3K
@@ -57,40 +59,6 @@
 
 #endif /* PY_MAJOR_VERSION */
 
-#ifdef _WIN32
-#ifdef _MSC_VER
-/* msvc 6.0 has problems */
-#define inline __inline
-typedef signed char int8_t;
-typedef short int16_t;
-typedef long int32_t;
-typedef __int64 int64_t;
-typedef unsigned char uint8_t;
-typedef unsigned short uint16_t;
-typedef unsigned long uint32_t;
-typedef unsigned __int64 uint64_t;
-#else
-#include <stdint.h>
-#endif
-#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
-
 typedef struct {
 	PyObject_HEAD
 	char state;
@@ -102,53 +70,6 @@
 extern PyTypeObject dirstateTupleType;
 #define dirstate_tuple_check(op) (Py_TYPE(op) == &dirstateTupleType)
 
-static inline uint32_t getbe32(const char *c)
-{
-	const unsigned char *d = (const unsigned char *)c;
-
-	return ((d[0] << 24) |
-		(d[1] << 16) |
-		(d[2] << 8) |
-		(d[3]));
-}
-
-static inline int16_t getbeint16(const char *c)
-{
-	const unsigned char *d = (const unsigned char *)c;
-
-	return ((d[0] << 8) |
-		(d[1]));
-}
-
-static inline uint16_t getbeuint16(const char *c)
-{
-	const unsigned char *d = (const unsigned char *)c;
-
-	return ((d[0] << 8) |
-		(d[1]));
-}
-
-static inline void putbe32(uint32_t x, char *c)
-{
-	c[0] = (x >> 24) & 0xff;
-	c[1] = (x >> 16) & 0xff;
-	c[2] = (x >> 8) & 0xff;
-	c[3] = (x) & 0xff;
-}
-
-static inline double getbefloat64(const char *c)
-{
-	const unsigned char *d = (const unsigned char *)c;
-	double ret;
-	int i;
-	uint64_t t = 0;
-	for (i = 0; i < 8; i++) {
-		t = (t<<8) + d[i];
-	}
-	memcpy(&ret, &t, sizeof(t));
-	return ret;
-}
-
 /* This should be kept in sync with normcasespecs in encoding.py. */
 enum normcase_spec {
 	NORMCASE_LOWER = -1,