summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2024-07-03 22:26:35 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2024-07-04 14:03:40 +0300
commit45bd1f20f6a9c9b97972944358c75beb9dfafb9c (patch)
treea0238e86398738a5c60c30ef9b970a0ac68a7e80 /include
parent050e0d33d1f24be7a788cf71cc3cccd1f51b6d4e (diff)
libcamera: base: utils: Implement hex() for 8-bit and 16-bit values
The utils::hex() function is implemented for 32-bit and 64-bit integers, but not for 8-bit and 16-bit. This causes a link error (possibly at runtime for IPA modules due to lazy linking) when trying to print 8-bit or 16-bit integers. Implement additional specializations to fix it. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
Diffstat (limited to 'include')
-rw-r--r--include/libcamera/base/utils.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h
index 4ae02dc9..734ff81e 100644
--- a/include/libcamera/base/utils.h
+++ b/include/libcamera/base/utils.h
@@ -91,6 +91,30 @@ _hex hex(T value, unsigned int width = 0);
#ifndef __DOXYGEN__
template<>
+inline _hex hex<int8_t>(int8_t value, unsigned int width)
+{
+ return { static_cast<uint64_t>(value), width ? width : 2 };
+}
+
+template<>
+inline _hex hex<uint8_t>(uint8_t value, unsigned int width)
+{
+ return { static_cast<uint64_t>(value), width ? width : 2 };
+}
+
+template<>
+inline _hex hex<int16_t>(int16_t value, unsigned int width)
+{
+ return { static_cast<uint64_t>(value), width ? width : 4 };
+}
+
+template<>
+inline _hex hex<uint16_t>(uint16_t value, unsigned int width)
+{
+ return { static_cast<uint64_t>(value), width ? width : 4 };
+}
+
+template<>
inline _hex hex<int32_t>(int32_t value, unsigned int width)
{
return { static_cast<uint64_t>(value), width ? width : 8 };