risp4ml: Use static at the beginning of inline functions
This doesn't change anything for current clang compiler, and avoids compilation error for gcc when kelvin support is added.
Change-Id: I8f65712cf5d6709caff0b9fa393ce1516aae5fc8
diff --git a/risp4ml/common/image.h b/risp4ml/common/image.h
index ca51610..a2eff9e 100644
--- a/risp4ml/common/image.h
+++ b/risp4ml/common/image.h
@@ -46,8 +46,8 @@
pixel_type_t* image_pixel(Image* image, uint16_t c, uint16_t y, uint16_t x);
-inline pixel_type_t image_pixel_val(Image* image, uint16_t c, uint16_t y,
- uint16_t x) {
+static inline pixel_type_t image_pixel_val(Image* image, uint16_t c, uint16_t y,
+ uint16_t x) {
return *image_pixel(image, c, y, x);
}
diff --git a/risp4ml/common/test_utils.h b/risp4ml/common/test_utils.h
index f0ff59a..68978f7 100644
--- a/risp4ml/common/test_utils.h
+++ b/risp4ml/common/test_utils.h
@@ -22,7 +22,7 @@
#include "risp4ml/common/image.h"
-inline pixel_type_t Pattern(uint16_t c, uint16_t y, uint16_t x) {
+static inline pixel_type_t Pattern(uint16_t c, uint16_t y, uint16_t x) {
return (pixel_type_t)(x + y * 100 + c * 10000);
}
@@ -37,8 +37,8 @@
}
// Initializes raw image to random value within min and max range
-inline void InitImageRandom(Image* image, pixel_type_t min_val,
- pixel_type_t max_val) {
+static inline void InitImageRandom(Image* image, pixel_type_t min_val,
+ pixel_type_t max_val) {
pixel_type_t range = max_val + 1 - min_val;
for (uint16_t c = 0; c < image->num_channels; ++c) {
for (uint16_t y = 0; y < image->height; ++y) {
@@ -52,7 +52,7 @@
}
// Initializes raw image to raw pixel value
-inline void InitImage(Image* image, pixel_type_t val) {
+static inline void InitImage(Image* image, pixel_type_t val) {
for (uint16_t c = 0; c < image->num_channels; ++c) {
for (uint16_t y = 0; y < image->height; ++y) {
for (uint16_t x = 0; x < image->width; ++x) {
diff --git a/risp4ml/common/utils.h b/risp4ml/common/utils.h
index c687d05..1d5e9be 100644
--- a/risp4ml/common/utils.h
+++ b/risp4ml/common/utils.h
@@ -40,17 +40,17 @@
// of bounds and mirrored across the boundary.
int BayerMirrorBoundary(int x, int size);
-inline uint32_t Clamp(uint32_t value, uint32_t low, uint32_t high) {
+static inline uint32_t Clamp(uint32_t value, uint32_t low, uint32_t high) {
return value < low ? low : (value > high ? high : value);
}
-inline uint16_t SubUnsignedZeroClamp(uint16_t lhs, uint16_t rhs) {
+static inline uint16_t SubUnsignedZeroClamp(uint16_t lhs, uint16_t rhs) {
return rhs < lhs ? lhs - rhs : 0;
}
// Count the number of consecutive zeros from LHS in N msbs of the number
// represented using BPP bits
-inline int ClzMsb(int in, int BPP, int N) {
+static inline int ClzMsb(int in, int BPP, int N) {
int lz = 0;
while (lz < N && (in & (1 << (BPP - lz - 1))) == 0) {
++lz;
@@ -58,7 +58,7 @@
return lz;
}
-inline float Roundf(float x) {
+static inline float Roundf(float x) {
int d = x < 0 ? x - 0.5 : x + 0.5;
return (float)d; // NOLINT(readability/casting)
}
@@ -66,8 +66,8 @@
// This function converts floating point value `x` to fixed point with the
// specified `integer_bit`, `frac_bit`, and `is_signed` flag.
// TODO(alexkaplan): Detect overflow/underflow.
-inline int FloatToFixedPoint(float x, int integer_bit, int frac_bit,
- bool is_signed) {
+static inline int FloatToFixedPoint(float x, int integer_bit, int frac_bit,
+ bool is_signed) {
float output_as_float = Roundf(x * (1 << frac_bit));
float min_value = 0;
float max_value = (1 << (frac_bit + integer_bit)) - 1;
@@ -87,7 +87,7 @@
}
// Helper function for fixed point rounding of values.
-inline int Round(int value, int right_shift) {
+static inline int Round(int value, int right_shift) {
int carry = right_shift == 0 ? 0 : (value >> (right_shift - 1)) & 1;
return (value >> right_shift) + carry;
}
@@ -95,7 +95,7 @@
// Helper function for linearly interpolating 2 values. When weight equals 0,
// output = val0. When weight equals 1.0 (when represented in floating point),
// output = val1.
-inline int Lerp(int val0, int val1, int weight, int weight_precision) {
+static inline int Lerp(int val0, int val1, int weight, int weight_precision) {
return val0 + Round((val1 - val0) * weight, weight_precision);
}