Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
3d98741f
Commit
3d98741f
authored
4 years ago
by
Marcus Comstedt
Browse files
Options
Downloads
Patches
Plain Diff
CritBit: Fix FloatTree with 128bit floats
parent
a6616abd
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/bitvector.h
+17
-0
17 additions, 0 deletions
src/bitvector.h
src/post_modules/CritBit/critbit/key_float.h
+9
-2
9 additions, 2 deletions
src/post_modules/CritBit/critbit/key_float.h
with
26 additions
and
2 deletions
src/bitvector.h
+
17
−
0
View file @
3d98741f
...
@@ -165,6 +165,23 @@ static INLINE unsigned INT64 ATTRIBUTE((unused)) bswap64(unsigned INT64 x) {
...
@@ -165,6 +165,23 @@ static INLINE unsigned INT64 ATTRIBUTE((unused)) bswap64(unsigned INT64 x) {
}
}
#endif
/* !HAVE___BSWAP64 && !HAVE_BSWAP64 */
#endif
/* !HAVE___BSWAP64 && !HAVE_BSWAP64 */
#if defined(__SIZEOF_INT128__) && __SIZEOF_INT128__ == 16
/**
* Counts the number of leading zeros in a 128-bit unsigned
* integer. Returns a value between 0 and 128.
*/
static
INLINE
unsigned
INT32
PIKE_UNUSED_ATTRIBUTE
clz128
(
unsigned
__int128
i
)
{
# if SIZEOF_LONG == 16 && defined(HAS___BUILTIN_CLZL)
return
i
?
__builtin_clzl
(
i
)
:
128
;
# elif SIZEOF_LONG_LONG == 16 && defined(HAS___BUILTIN_CLZLL)
return
i
?
__builtin_clzll
(
i
)
:
128
;
# else
unsigned
INT64
hi
=
i
>>
64
;
return
hi
?
clz64
(
hi
)
:
64
+
clz64
((
unsigned
INT64
)
i
);
# endif
}
#endif
/* __SIZEOF_INT128__ */
static
INLINE
unsigned
INT64
PIKE_UNUSED_ATTRIBUTE
round_up64
(
unsigned
INT64
v
)
{
static
INLINE
unsigned
INT64
PIKE_UNUSED_ATTRIBUTE
round_up64
(
unsigned
INT64
v
)
{
unsigned
INT32
i
;
unsigned
INT32
i
;
...
...
This diff is collapsed.
Click to expand it.
src/post_modules/CritBit/critbit/key_float.h
+
9
−
2
View file @
3d98741f
...
@@ -7,9 +7,14 @@
...
@@ -7,9 +7,14 @@
#if SIZEOF_FLOAT_TYPE == 8
#if SIZEOF_FLOAT_TYPE == 8
typedef
unsigned
INT64
CB_NAME
(
string
);
typedef
unsigned
INT64
CB_NAME
(
string
);
typedef
unsigned
INT64
CB_NAME
(
char
);
typedef
unsigned
INT64
CB_NAME
(
char
);
#el
se
#el
if SIZEOF_FLOAT_TYPE == 4
typedef
unsigned
INT32
CB_NAME
(
string
);
typedef
unsigned
INT32
CB_NAME
(
string
);
typedef
unsigned
INT32
CB_NAME
(
char
);
typedef
unsigned
INT32
CB_NAME
(
char
);
#elif SIZEOF_FLOAT_TYPE == 16 && defined(__SIZEOF_INT128__) && __SIZEOF_INT128__ == 16
typedef
unsigned
__int128
CB_NAME
(
string
);
typedef
unsigned
__int128
CB_NAME
(
char
);
#else
#error Size of FLOAT_TYPE not supported.
#endif
#endif
...
@@ -26,8 +31,10 @@ typedef unsigned INT32 CB_NAME(char);
...
@@ -26,8 +31,10 @@ typedef unsigned INT32 CB_NAME(char);
#ifdef CB_SOURCE
#ifdef CB_SOURCE
#if SIZEOF_FLOAT_TYPE == 4
#if SIZEOF_FLOAT_TYPE == 4
# define gclz(x) clz32(x)
# define gclz(x) clz32(x)
#el
se
#el
if SIZEOF_FLOAT_TYPE == 8
# define gclz(x) clz64(x)
# define gclz(x) clz64(x)
#else
# define gclz(x) clz128(x)
#endif
#endif
#define bitsof(x) (sizeof(x)*8)
#define bitsof(x) (sizeof(x)*8)
#define int2float(x) (*(FLOAT_TYPE*)&(x))
#define int2float(x) (*(FLOAT_TYPE*)&(x))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment