Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AndroidSystemCore
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Werner Sembach
AndroidSystemCore
Commits
c52b3c08
Commit
c52b3c08
authored
Oct 22, 2015
by
Andy Hung
Committed by
Gerrit Code Review
Oct 22, 2015
Browse files
Options
Downloads
Plain Diff
Merge "Disable sanitization for LinearTransform"
parents
4a8d1255
13c19e77
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
libutils/LinearTransform.cpp
+19
-2
19 additions, 2 deletions
libutils/LinearTransform.cpp
with
19 additions
and
2 deletions
libutils/LinearTransform.cpp
+
19
−
2
View file @
c52b3c08
...
@@ -21,11 +21,24 @@
...
@@ -21,11 +21,24 @@
#include
<utils/LinearTransform.h>
#include
<utils/LinearTransform.h>
// disable sanitize as these functions may intentionally overflow (see comments below).
// the ifdef can be removed when host builds use clang.
#if defined(__clang__)
#define ATTRIBUTE_NO_SANITIZE_INTEGER __attribute__((no_sanitize("integer")))
#else
#define ATTRIBUTE_NO_SANITIZE_INTEGER
#endif
namespace
android
{
namespace
android
{
template
<
class
T
>
static
inline
T
ABS
(
T
x
)
{
return
(
x
<
0
)
?
-
x
:
x
;
}
// sanitize failure with T = int32_t and x = 0x80000000
template
<
class
T
>
ATTRIBUTE_NO_SANITIZE_INTEGER
static
inline
T
ABS
(
T
x
)
{
return
(
x
<
0
)
?
-
x
:
x
;
}
// Static math methods involving linear transformations
// Static math methods involving linear transformations
// remote sanitize failure on overflow case.
ATTRIBUTE_NO_SANITIZE_INTEGER
static
bool
scale_u64_to_u64
(
static
bool
scale_u64_to_u64
(
uint64_t
val
,
uint64_t
val
,
uint32_t
N
,
uint32_t
N
,
...
@@ -109,6 +122,8 @@ static bool scale_u64_to_u64(
...
@@ -109,6 +122,8 @@ static bool scale_u64_to_u64(
return
true
;
return
true
;
}
}
// at least one known sanitize failure (see comment below)
ATTRIBUTE_NO_SANITIZE_INTEGER
static
bool
linear_transform_s64_to_s64
(
static
bool
linear_transform_s64_to_s64
(
int64_t
val
,
int64_t
val
,
int64_t
basis1
,
int64_t
basis1
,
...
@@ -172,7 +187,7 @@ static bool linear_transform_s64_to_s64(
...
@@ -172,7 +187,7 @@ static bool linear_transform_s64_to_s64(
// (scaled_signbit XOR res_signbit)
// (scaled_signbit XOR res_signbit)
if
(
is_neg
)
if
(
is_neg
)
scaled
=
-
scaled
;
scaled
=
-
scaled
;
// known sanitize failure
res
=
scaled
+
basis2
;
res
=
scaled
+
basis2
;
if
((
scaled
^
basis2
^
INT64_MIN
)
&
(
scaled
^
res
)
&
INT64_MIN
)
if
((
scaled
^
basis2
^
INT64_MIN
)
&
(
scaled
^
res
)
&
INT64_MIN
)
...
@@ -250,6 +265,8 @@ template <class T> void LinearTransform::reduce(T* N, T* D) {
...
@@ -250,6 +265,8 @@ template <class T> void LinearTransform::reduce(T* N, T* D) {
template
void
LinearTransform
::
reduce
<
uint64_t
>(
uint64_t
*
N
,
uint64_t
*
D
);
template
void
LinearTransform
::
reduce
<
uint64_t
>(
uint64_t
*
N
,
uint64_t
*
D
);
template
void
LinearTransform
::
reduce
<
uint32_t
>(
uint32_t
*
N
,
uint32_t
*
D
);
template
void
LinearTransform
::
reduce
<
uint32_t
>(
uint32_t
*
N
,
uint32_t
*
D
);
// sanitize failure if *N = 0x80000000
ATTRIBUTE_NO_SANITIZE_INTEGER
void
LinearTransform
::
reduce
(
int32_t
*
N
,
uint32_t
*
D
)
{
void
LinearTransform
::
reduce
(
int32_t
*
N
,
uint32_t
*
D
)
{
if
(
N
&&
D
&&
*
D
)
{
if
(
N
&&
D
&&
*
D
)
{
if
(
*
N
<
0
)
{
if
(
*
N
<
0
)
{
...
...
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