Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
965abcf1
Commit
965abcf1
authored
Jul 09, 2015
by
antirez
Browse files
Geo: use ULL suffix for unsigned 64 bit constants.
parent
1e127842
Changes
1
Hide whitespace changes
Inline
Side-by-side
deps/geohash-int/geohash.c
View file @
965abcf1
...
...
@@ -50,9 +50,9 @@
* From: https://graphics.stanford.edu/~seander/bithacks.html#InterleaveBMN
*/
static
inline
uint64_t
interleave64
(
uint32_t
xlo
,
uint32_t
ylo
)
{
static
const
uint64_t
B
[]
=
{
0x5555555555555555
,
0x3333333333333333
,
0x0F0F0F0F0F0F0F0F
,
0x00FF00FF00FF00FF
,
0x0000FFFF0000FFFF
};
static
const
uint64_t
B
[]
=
{
0x5555555555555555
ULL
,
0x3333333333333333
ULL
,
0x0F0F0F0F0F0F0F0F
ULL
,
0x00FF00FF00FF00FF
ULL
,
0x0000FFFF0000FFFF
ULL
};
static
const
unsigned
int
S
[]
=
{
1
,
2
,
4
,
8
,
16
};
uint64_t
x
=
xlo
;
...
...
@@ -80,9 +80,9 @@ static inline uint64_t interleave64(uint32_t xlo, uint32_t ylo) {
* derived from http://stackoverflow.com/questions/4909263
*/
static
inline
uint64_t
deinterleave64
(
uint64_t
interleaved
)
{
static
const
uint64_t
B
[]
=
{
0x5555555555555555
,
0x3333333333333333
,
0x0F0F0F0F0F0F0F0F
,
0x00FF00FF00FF00FF
,
0x0000FFFF0000FFFF
,
0x00000000FFFFFFFF
};
static
const
uint64_t
B
[]
=
{
0x5555555555555555
ULL
,
0x3333333333333333
ULL
,
0x0F0F0F0F0F0F0F0F
ULL
,
0x00FF00FF00FF00FF
ULL
,
0x0000FFFF0000FFFF
ULL
,
0x00000000FFFFFFFF
ULL
};
static
const
unsigned
int
S
[]
=
{
0
,
1
,
2
,
4
,
8
,
16
};
uint64_t
x
=
interleaved
;
...
...
@@ -225,10 +225,10 @@ static void geohash_move_x(GeoHashBits *hash, int8_t d) {
if
(
d
==
0
)
return
;
uint64_t
x
=
hash
->
bits
&
0xaaaaaaaaaaaaaaaaLL
;
uint64_t
y
=
hash
->
bits
&
0x5555555555555555LL
;
uint64_t
x
=
hash
->
bits
&
0xaaaaaaaaaaaaaaaa
U
LL
;
uint64_t
y
=
hash
->
bits
&
0x5555555555555555
U
LL
;
uint64_t
zz
=
0x5555555555555555LL
>>
(
64
-
hash
->
step
*
2
);
uint64_t
zz
=
0x5555555555555555
U
LL
>>
(
64
-
hash
->
step
*
2
);
if
(
d
>
0
)
{
x
=
x
+
(
zz
+
1
);
...
...
@@ -237,7 +237,7 @@ static void geohash_move_x(GeoHashBits *hash, int8_t d) {
x
=
x
-
(
zz
+
1
);
}
x
&=
(
0xaaaaaaaaaaaaaaaaLL
>>
(
64
-
hash
->
step
*
2
));
x
&=
(
0xaaaaaaaaaaaaaaaa
U
LL
>>
(
64
-
hash
->
step
*
2
));
hash
->
bits
=
(
x
|
y
);
}
...
...
@@ -245,17 +245,17 @@ static void geohash_move_y(GeoHashBits *hash, int8_t d) {
if
(
d
==
0
)
return
;
uint64_t
x
=
hash
->
bits
&
0xaaaaaaaaaaaaaaaaLL
;
uint64_t
y
=
hash
->
bits
&
0x5555555555555555LL
;
uint64_t
x
=
hash
->
bits
&
0xaaaaaaaaaaaaaaaa
U
LL
;
uint64_t
y
=
hash
->
bits
&
0x5555555555555555
U
LL
;
uint64_t
zz
=
0xaaaaaaaaaaaaaaaaLL
>>
(
64
-
hash
->
step
*
2
);
uint64_t
zz
=
0xaaaaaaaaaaaaaaaa
U
LL
>>
(
64
-
hash
->
step
*
2
);
if
(
d
>
0
)
{
y
=
y
+
(
zz
+
1
);
}
else
{
y
=
y
|
zz
;
y
=
y
-
(
zz
+
1
);
}
y
&=
(
0x5555555555555555LL
>>
(
64
-
hash
->
step
*
2
));
y
&=
(
0x5555555555555555
U
LL
>>
(
64
-
hash
->
step
*
2
));
hash
->
bits
=
(
x
|
y
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment