Show More
@@ -0,0 +1,53 b'' | |||||
|
1 | #ifndef _HG_BITMANIPULATION_H_ | |||
|
2 | #define _HG_BITMANIPULATION_H_ | |||
|
3 | ||||
|
4 | #include "compat.h" | |||
|
5 | ||||
|
6 | static inline uint32_t getbe32(const char *c) | |||
|
7 | { | |||
|
8 | const unsigned char *d = (const unsigned char *)c; | |||
|
9 | ||||
|
10 | return ((d[0] << 24) | | |||
|
11 | (d[1] << 16) | | |||
|
12 | (d[2] << 8) | | |||
|
13 | (d[3])); | |||
|
14 | } | |||
|
15 | ||||
|
16 | static inline int16_t getbeint16(const char *c) | |||
|
17 | { | |||
|
18 | const unsigned char *d = (const unsigned char *)c; | |||
|
19 | ||||
|
20 | return ((d[0] << 8) | | |||
|
21 | (d[1])); | |||
|
22 | } | |||
|
23 | ||||
|
24 | static inline uint16_t getbeuint16(const char *c) | |||
|
25 | { | |||
|
26 | const unsigned char *d = (const unsigned char *)c; | |||
|
27 | ||||
|
28 | return ((d[0] << 8) | | |||
|
29 | (d[1])); | |||
|
30 | } | |||
|
31 | ||||
|
32 | static inline void putbe32(uint32_t x, char *c) | |||
|
33 | { | |||
|
34 | c[0] = (x >> 24) & 0xff; | |||
|
35 | c[1] = (x >> 16) & 0xff; | |||
|
36 | c[2] = (x >> 8) & 0xff; | |||
|
37 | c[3] = (x) & 0xff; | |||
|
38 | } | |||
|
39 | ||||
|
40 | static inline double getbefloat64(const char *c) | |||
|
41 | { | |||
|
42 | const unsigned char *d = (const unsigned char *)c; | |||
|
43 | double ret; | |||
|
44 | int i; | |||
|
45 | uint64_t t = 0; | |||
|
46 | for (i = 0; i < 8; i++) { | |||
|
47 | t = (t<<8) + d[i]; | |||
|
48 | } | |||
|
49 | memcpy(&ret, &t, sizeof(t)); | |||
|
50 | return ret; | |||
|
51 | } | |||
|
52 | ||||
|
53 | #endif |
@@ -0,0 +1,38 b'' | |||||
|
1 | #ifndef _HG_COMPAT_H_ | |||
|
2 | #define _HG_COMPAT_H_ | |||
|
3 | ||||
|
4 | #ifdef _WIN32 | |||
|
5 | #ifdef _MSC_VER | |||
|
6 | /* msvc 6.0 has problems */ | |||
|
7 | #define inline __inline | |||
|
8 | typedef signed char int8_t; | |||
|
9 | typedef short int16_t; | |||
|
10 | typedef long int32_t; | |||
|
11 | typedef __int64 int64_t; | |||
|
12 | typedef unsigned char uint8_t; | |||
|
13 | typedef unsigned short uint16_t; | |||
|
14 | typedef unsigned long uint32_t; | |||
|
15 | typedef unsigned __int64 uint64_t; | |||
|
16 | #else | |||
|
17 | #include <stdint.h> | |||
|
18 | #endif | |||
|
19 | #else | |||
|
20 | /* not windows */ | |||
|
21 | #include <sys/types.h> | |||
|
22 | #if defined __BEOS__ && !defined __HAIKU__ | |||
|
23 | #include <ByteOrder.h> | |||
|
24 | #else | |||
|
25 | #include <arpa/inet.h> | |||
|
26 | #endif | |||
|
27 | #include <inttypes.h> | |||
|
28 | #endif | |||
|
29 | ||||
|
30 | #if defined __hpux || defined __SUNPRO_C || defined _AIX | |||
|
31 | #define inline | |||
|
32 | #endif | |||
|
33 | ||||
|
34 | #ifdef __linux | |||
|
35 | #define inline __inline | |||
|
36 | #endif | |||
|
37 | ||||
|
38 | #endif |
@@ -16,6 +16,7 b'' | |||||
16 | #include <limits.h> |
|
16 | #include <limits.h> | |
17 |
|
17 | |||
18 | #include "util.h" |
|
18 | #include "util.h" | |
|
19 | #include "bitmanipulation.h" | |||
19 |
|
20 | |||
20 | struct line { |
|
21 | struct line { | |
21 | int hash, n, e; |
|
22 | int hash, n, e; |
@@ -26,6 +26,7 b'' | |||||
26 | #include <string.h> |
|
26 | #include <string.h> | |
27 |
|
27 | |||
28 | #include "util.h" |
|
28 | #include "util.h" | |
|
29 | #include "bitmanipulation.h" | |||
29 |
|
30 | |||
30 | static char mpatch_doc[] = "Efficient binary patching."; |
|
31 | static char mpatch_doc[] = "Efficient binary patching."; | |
31 | static PyObject *mpatch_Error; |
|
32 | static PyObject *mpatch_Error; |
@@ -13,6 +13,7 b'' | |||||
13 | #include <string.h> |
|
13 | #include <string.h> | |
14 |
|
14 | |||
15 | #include "util.h" |
|
15 | #include "util.h" | |
|
16 | #include "bitmanipulation.h" | |||
16 |
|
17 | |||
17 | static char *versionerrortext = "Python minor version mismatch"; |
|
18 | static char *versionerrortext = "Python minor version mismatch"; | |
18 |
|
19 |
@@ -8,6 +8,8 b'' | |||||
8 | #ifndef _HG_UTIL_H_ |
|
8 | #ifndef _HG_UTIL_H_ | |
9 | #define _HG_UTIL_H_ |
|
9 | #define _HG_UTIL_H_ | |
10 |
|
10 | |||
|
11 | #include "compat.h" | |||
|
12 | ||||
11 | #if PY_MAJOR_VERSION >= 3 |
|
13 | #if PY_MAJOR_VERSION >= 3 | |
12 |
|
14 | |||
13 | #define IS_PY3K |
|
15 | #define IS_PY3K | |
@@ -57,40 +59,6 b'' | |||||
57 |
|
59 | |||
58 | #endif /* PY_MAJOR_VERSION */ |
|
60 | #endif /* PY_MAJOR_VERSION */ | |
59 |
|
61 | |||
60 | #ifdef _WIN32 |
|
|||
61 | #ifdef _MSC_VER |
|
|||
62 | /* msvc 6.0 has problems */ |
|
|||
63 | #define inline __inline |
|
|||
64 | typedef signed char int8_t; |
|
|||
65 | typedef short int16_t; |
|
|||
66 | typedef long int32_t; |
|
|||
67 | typedef __int64 int64_t; |
|
|||
68 | typedef unsigned char uint8_t; |
|
|||
69 | typedef unsigned short uint16_t; |
|
|||
70 | typedef unsigned long uint32_t; |
|
|||
71 | typedef unsigned __int64 uint64_t; |
|
|||
72 | #else |
|
|||
73 | #include <stdint.h> |
|
|||
74 | #endif |
|
|||
75 | #else |
|
|||
76 | /* not windows */ |
|
|||
77 | #include <sys/types.h> |
|
|||
78 | #if defined __BEOS__ && !defined __HAIKU__ |
|
|||
79 | #include <ByteOrder.h> |
|
|||
80 | #else |
|
|||
81 | #include <arpa/inet.h> |
|
|||
82 | #endif |
|
|||
83 | #include <inttypes.h> |
|
|||
84 | #endif |
|
|||
85 |
|
||||
86 | #if defined __hpux || defined __SUNPRO_C || defined _AIX |
|
|||
87 | #define inline |
|
|||
88 | #endif |
|
|||
89 |
|
||||
90 | #ifdef __linux |
|
|||
91 | #define inline __inline |
|
|||
92 | #endif |
|
|||
93 |
|
||||
94 | typedef struct { |
|
62 | typedef struct { | |
95 | PyObject_HEAD |
|
63 | PyObject_HEAD | |
96 | char state; |
|
64 | char state; | |
@@ -102,53 +70,6 b' typedef struct {' | |||||
102 | extern PyTypeObject dirstateTupleType; |
|
70 | extern PyTypeObject dirstateTupleType; | |
103 | #define dirstate_tuple_check(op) (Py_TYPE(op) == &dirstateTupleType) |
|
71 | #define dirstate_tuple_check(op) (Py_TYPE(op) == &dirstateTupleType) | |
104 |
|
72 | |||
105 | static inline uint32_t getbe32(const char *c) |
|
|||
106 | { |
|
|||
107 | const unsigned char *d = (const unsigned char *)c; |
|
|||
108 |
|
||||
109 | return ((d[0] << 24) | |
|
|||
110 | (d[1] << 16) | |
|
|||
111 | (d[2] << 8) | |
|
|||
112 | (d[3])); |
|
|||
113 | } |
|
|||
114 |
|
||||
115 | static inline int16_t getbeint16(const char *c) |
|
|||
116 | { |
|
|||
117 | const unsigned char *d = (const unsigned char *)c; |
|
|||
118 |
|
||||
119 | return ((d[0] << 8) | |
|
|||
120 | (d[1])); |
|
|||
121 | } |
|
|||
122 |
|
||||
123 | static inline uint16_t getbeuint16(const char *c) |
|
|||
124 | { |
|
|||
125 | const unsigned char *d = (const unsigned char *)c; |
|
|||
126 |
|
||||
127 | return ((d[0] << 8) | |
|
|||
128 | (d[1])); |
|
|||
129 | } |
|
|||
130 |
|
||||
131 | static inline void putbe32(uint32_t x, char *c) |
|
|||
132 | { |
|
|||
133 | c[0] = (x >> 24) & 0xff; |
|
|||
134 | c[1] = (x >> 16) & 0xff; |
|
|||
135 | c[2] = (x >> 8) & 0xff; |
|
|||
136 | c[3] = (x) & 0xff; |
|
|||
137 | } |
|
|||
138 |
|
||||
139 | static inline double getbefloat64(const char *c) |
|
|||
140 | { |
|
|||
141 | const unsigned char *d = (const unsigned char *)c; |
|
|||
142 | double ret; |
|
|||
143 | int i; |
|
|||
144 | uint64_t t = 0; |
|
|||
145 | for (i = 0; i < 8; i++) { |
|
|||
146 | t = (t<<8) + d[i]; |
|
|||
147 | } |
|
|||
148 | memcpy(&ret, &t, sizeof(t)); |
|
|||
149 | return ret; |
|
|||
150 | } |
|
|||
151 |
|
||||
152 | /* This should be kept in sync with normcasespecs in encoding.py. */ |
|
73 | /* This should be kept in sync with normcasespecs in encoding.py. */ | |
153 | enum normcase_spec { |
|
74 | enum normcase_spec { | |
154 | NORMCASE_LOWER = -1, |
|
75 | NORMCASE_LOWER = -1, |
@@ -536,7 +536,9 b" packages = ['mercurial', 'mercurial.hgwe" | |||||
536 | 'hgext.fsmonitor.pywatchman', 'hgext.highlight', |
|
536 | 'hgext.fsmonitor.pywatchman', 'hgext.highlight', | |
537 | 'hgext.largefiles', 'hgext.zeroconf', 'hgext3rd'] |
|
537 | 'hgext.largefiles', 'hgext.zeroconf', 'hgext3rd'] | |
538 |
|
538 | |||
539 |
common_depends = ['mercurial/ |
|
539 | common_depends = ['mercurial/bitmanipulation.h', | |
|
540 | 'mercurial/compat.h', | |||
|
541 | 'mercurial/util.h'] | |||
540 |
|
542 | |||
541 | osutil_ldflags = [] |
|
543 | osutil_ldflags = [] | |
542 |
|
544 |
General Comments 0
You need to be logged in to leave comments.
Login now