[libcamera-devel] libcamera: v4l2_videodevice: Don't use std::atomic specialization

Message ID 20200306231050.7986-1-laurent.pinchart@ideasonboard.com
State Accepted
Commit 2cc90af8c7b6ac90b62ed9794d6176562b788292
Headers show
Series
  • [libcamera-devel] libcamera: v4l2_videodevice: Don't use std::atomic specialization
Related show

Commit Message

Laurent Pinchart March 6, 2020, 11:10 p.m. UTC
The std::atomic_uint64_t specialization was missing from C++14, and only
added to C++17 (see LWG 2441). It was treated as a Defect Report and
backported to earlier C++ standards by gcc and clang, but is missing
from libstdc++ shipped with gcc 5 and gcc 6. Fix the compilation error
by using std::atomic<uint64_t> instead.

Fixes: 4e0d1eca10b7 ("libcamera: V4L2BufferCache: Improve cache eviction strategy")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/libcamera/include/v4l2_videodevice.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Niklas Söderlund March 6, 2020, 11:14 p.m. UTC | #1
Hi Laurent,

Thanks for your fix, sorry for breaking it in the first place.

On 2020-03-07 01:10:50 +0200, Laurent Pinchart wrote:
> The std::atomic_uint64_t specialization was missing from C++14, and only
> added to C++17 (see LWG 2441). It was treated as a Defect Report and
> backported to earlier C++ standards by gcc and clang, but is missing
> from libstdc++ shipped with gcc 5 and gcc 6. Fix the compilation error
> by using std::atomic<uint64_t> instead.
> 
> Fixes: 4e0d1eca10b7 ("libcamera: V4L2BufferCache: Improve cache eviction strategy")
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
>  src/libcamera/include/v4l2_videodevice.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h
> index 04802012d531..d051c9060f09 100644
> --- a/src/libcamera/include/v4l2_videodevice.h
> +++ b/src/libcamera/include/v4l2_videodevice.h
> @@ -9,6 +9,7 @@
>  
>  #include <atomic>
>  #include <memory>
> +#include <stdint.h>
>  #include <string>
>  #include <vector>
>  
> @@ -142,7 +143,7 @@ private:
>  		std::vector<Plane> planes_;
>  	};
>  
> -	std::atomic_uint64_t lastUsedCounter_;
> +	std::atomic<uint64_t> lastUsedCounter_;
>  	std::vector<Entry> cache_;
>  	/* \todo Expose the miss counter through an instrumentation API. */
>  	unsigned int missCounter_;
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h
index 04802012d531..d051c9060f09 100644
--- a/src/libcamera/include/v4l2_videodevice.h
+++ b/src/libcamera/include/v4l2_videodevice.h
@@ -9,6 +9,7 @@ 
 
 #include <atomic>
 #include <memory>
+#include <stdint.h>
 #include <string>
 #include <vector>
 
@@ -142,7 +143,7 @@  private:
 		std::vector<Plane> planes_;
 	};
 
-	std::atomic_uint64_t lastUsedCounter_;
+	std::atomic<uint64_t> lastUsedCounter_;
 	std::vector<Entry> cache_;
 	/* \todo Expose the miss counter through an instrumentation API. */
 	unsigned int missCounter_;