[libcamera-devel,0/5] libcamera: Switch to C++17
mbox series

Message ID 20200822200037.20892-1-laurent.pinchart@ideasonboard.com
Headers show
Series
  • libcamera: Switch to C++17
Related show

Message

Laurent Pinchart Aug. 22, 2020, 8 p.m. UTC
Hello,

In response to a popular request, this patch series moves libcamera from
C++14 to C++17. This allows new features of the language (such as
[[maybe_unused]]) and the standard library (such as std::clamp()). gcc 5
and gcc 6 can't be supported anymore, which isn't considered as an issue
given that all major distributions that we're targetting ship a recent
enough compiler.

Patch 1/5 switches to C++17. If you're using an existing build
directory, you will need to set the cpp_std option with

	meson configure -Dcpp_std=c++17

Patches 2/5 and 3/5 then update the code base to remove workarounds
needed by C++14 and older compilers. Patch 4/5 is a new attempt to drop
-Wno-unused-parameter, with the standard [[maybe_unused]] attribute this
time instead of commenting out the parameter name to the function. Patch
5/5 extends the usage of [[maybe_unused]] to remove void casts.

Laurent Pinchart (5):
  meson: Switch to C++17
  libcamera: Replace utils::clamp() with std::clamp()
  libcamera: Drop explicit construction of std::queue
  meson: Remove -Wno-unused-parameter
  ipa: raspberrypi: Replace void cast with [[maybe_unused]]

 include/libcamera/bound_method.h              |  2 +-
 include/libcamera/internal/utils.h            |  7 ------
 include/libcamera/signal.h                    |  2 +-
 include/libcamera/span.h                      |  4 ++--
 meson.build                                   |  3 +--
 src/android/camera3_hal.cpp                   | 11 +++++----
 src/android/camera_device.cpp                 |  5 ++--
 src/android/camera_ops.cpp                    |  5 ++--
 src/cam/main.cpp                              |  2 +-
 src/gstreamer/gstlibcamerapool.cpp            |  2 +-
 src/gstreamer/gstlibcameraprovider.cpp        |  2 +-
 src/gstreamer/gstlibcamerasrc.cpp             |  7 ++++--
 src/ipa/raspberrypi/controller/algorithm.cpp  | 16 +++++--------
 src/ipa/raspberrypi/controller/rpi/agc.cpp    |  3 ++-
 src/ipa/raspberrypi/controller/rpi/alsc.cpp   |  8 +++----
 .../raspberrypi/controller/rpi/contrast.cpp   |  4 ++--
 src/ipa/raspberrypi/controller/rpi/noise.cpp  |  5 ++--
 .../raspberrypi/controller/rpi/sharpen.cpp    |  5 ++--
 src/ipa/raspberrypi/raspberrypi.cpp           |  2 +-
 src/ipa/rkisp1/rkisp1.cpp                     | 24 ++++++++++---------
 src/ipa/vimc/vimc.cpp                         | 16 ++++++-------
 src/libcamera/device_enumerator_udev.cpp      |  2 +-
 src/libcamera/ipc_unixsocket.cpp              |  2 +-
 src/libcamera/pipeline/ipu3/cio2.cpp          |  4 +---
 src/libcamera/pipeline/ipu3/imgu.cpp          |  3 ++-
 src/libcamera/pipeline/ipu3/ipu3.cpp          | 12 +++++-----
 .../pipeline/raspberrypi/raspberrypi.cpp      | 10 ++++----
 src/libcamera/pipeline/rkisp1/rkisp1.cpp      |  2 +-
 src/libcamera/pipeline/rkisp1/timeline.cpp    |  2 +-
 src/libcamera/pipeline/vimc/vimc.cpp          |  2 +-
 src/libcamera/process.cpp                     |  2 +-
 src/libcamera/proxy/ipa_proxy_linux.cpp       | 23 ++++++++++--------
 src/libcamera/utils.cpp                       |  8 -------
 src/libcamera/v4l2_pixelformat.cpp            |  2 +-
 src/libcamera/v4l2_videodevice.cpp            |  4 ++--
 src/qcam/dng_writer.cpp                       |  5 ++--
 src/qcam/main.cpp                             |  2 +-
 src/v4l2/v4l2_camera.cpp                      |  2 +-
 test/camera/buffer_import.cpp                 |  3 ++-
 test/camera/capture.cpp                       |  3 ++-
 test/hotplug-cameras.cpp                      |  4 ++--
 test/ipa/ipa_wrappers_test.cpp                |  4 ++--
 test/libtest/test.h                           |  2 +-
 test/log/log_process.cpp                      |  3 ++-
 test/object-invoke.cpp                        |  2 +-
 test/process/process_test.cpp                 |  3 ++-
 test/timer-thread.cpp                         |  2 +-
 test/timer.cpp                                |  2 +-
 48 files changed, 122 insertions(+), 128 deletions(-)

Comments

Kieran Bingham Aug. 24, 2020, 9:42 a.m. UTC | #1
Hi Laurent,

On 22/08/2020 21:00, Laurent Pinchart wrote:
> Hello,
> 
> In response to a popular request, this patch series moves libcamera from
> C++14 to C++17. This allows new features of the language (such as
> [[maybe_unused]]) and the standard library (such as std::clamp()). gcc 5

      \o/                                                \o/

> and gcc 6 can't be supported anymore, which isn't considered as an issue
> given that all major distributions that we're targetting ship a recent
> enough compiler.

agreed here ;-)


> Patch 1/5 switches to C++17. If you're using an existing build
> directory, you will need to set the cpp_std option with
> 
> 	meson configure -Dcpp_std=c++17

Another part that meson doesn't catch to reconfigure then...


> Patches 2/5 and 3/5 then update the code base to remove workarounds
> needed by C++14 and older compilers. Patch 4/5 is a new attempt to drop
> -Wno-unused-parameter, with the standard [[maybe_unused]] attribute this
> time instead of commenting out the parameter name to the function. Patch
> 5/5 extends the usage of [[maybe_unused]] to remove void casts.
> 
> Laurent Pinchart (5):
>   meson: Switch to C++17
>   libcamera: Replace utils::clamp() with std::clamp()
>   libcamera: Drop explicit construction of std::queue
>   meson: Remove -Wno-unused-parameter
>   ipa: raspberrypi: Replace void cast with [[maybe_unused]]
> 
>  include/libcamera/bound_method.h              |  2 +-
>  include/libcamera/internal/utils.h            |  7 ------
>  include/libcamera/signal.h                    |  2 +-
>  include/libcamera/span.h                      |  4 ++--
>  meson.build                                   |  3 +--
>  src/android/camera3_hal.cpp                   | 11 +++++----
>  src/android/camera_device.cpp                 |  5 ++--
>  src/android/camera_ops.cpp                    |  5 ++--
>  src/cam/main.cpp                              |  2 +-
>  src/gstreamer/gstlibcamerapool.cpp            |  2 +-
>  src/gstreamer/gstlibcameraprovider.cpp        |  2 +-
>  src/gstreamer/gstlibcamerasrc.cpp             |  7 ++++--
>  src/ipa/raspberrypi/controller/algorithm.cpp  | 16 +++++--------
>  src/ipa/raspberrypi/controller/rpi/agc.cpp    |  3 ++-
>  src/ipa/raspberrypi/controller/rpi/alsc.cpp   |  8 +++----
>  .../raspberrypi/controller/rpi/contrast.cpp   |  4 ++--
>  src/ipa/raspberrypi/controller/rpi/noise.cpp  |  5 ++--
>  .../raspberrypi/controller/rpi/sharpen.cpp    |  5 ++--
>  src/ipa/raspberrypi/raspberrypi.cpp           |  2 +-
>  src/ipa/rkisp1/rkisp1.cpp                     | 24 ++++++++++---------
>  src/ipa/vimc/vimc.cpp                         | 16 ++++++-------
>  src/libcamera/device_enumerator_udev.cpp      |  2 +-
>  src/libcamera/ipc_unixsocket.cpp              |  2 +-
>  src/libcamera/pipeline/ipu3/cio2.cpp          |  4 +---
>  src/libcamera/pipeline/ipu3/imgu.cpp          |  3 ++-
>  src/libcamera/pipeline/ipu3/ipu3.cpp          | 12 +++++-----
>  .../pipeline/raspberrypi/raspberrypi.cpp      | 10 ++++----
>  src/libcamera/pipeline/rkisp1/rkisp1.cpp      |  2 +-
>  src/libcamera/pipeline/rkisp1/timeline.cpp    |  2 +-
>  src/libcamera/pipeline/vimc/vimc.cpp          |  2 +-
>  src/libcamera/process.cpp                     |  2 +-
>  src/libcamera/proxy/ipa_proxy_linux.cpp       | 23 ++++++++++--------
>  src/libcamera/utils.cpp                       |  8 -------
>  src/libcamera/v4l2_pixelformat.cpp            |  2 +-
>  src/libcamera/v4l2_videodevice.cpp            |  4 ++--
>  src/qcam/dng_writer.cpp                       |  5 ++--
>  src/qcam/main.cpp                             |  2 +-
>  src/v4l2/v4l2_camera.cpp                      |  2 +-
>  test/camera/buffer_import.cpp                 |  3 ++-
>  test/camera/capture.cpp                       |  3 ++-
>  test/hotplug-cameras.cpp                      |  4 ++--
>  test/ipa/ipa_wrappers_test.cpp                |  4 ++--
>  test/libtest/test.h                           |  2 +-
>  test/log/log_process.cpp                      |  3 ++-
>  test/object-invoke.cpp                        |  2 +-
>  test/process/process_test.cpp                 |  3 ++-
>  test/timer-thread.cpp                         |  2 +-
>  test/timer.cpp                                |  2 +-
>  48 files changed, 122 insertions(+), 128 deletions(-)
>
Laurent Pinchart Aug. 24, 2020, 5:46 p.m. UTC | #2
Hi Kieran,

On Mon, Aug 24, 2020 at 10:42:08AM +0100, Kieran Bingham wrote:
> On 22/08/2020 21:00, Laurent Pinchart wrote:
> > Hello,
> > 
> > In response to a popular request, this patch series moves libcamera from
> > C++14 to C++17. This allows new features of the language (such as
> > [[maybe_unused]]) and the standard library (such as std::clamp()). gcc 5
> 
>       \o/                                                \o/
> 
> > and gcc 6 can't be supported anymore, which isn't considered as an issue
> > given that all major distributions that we're targetting ship a recent
> > enough compiler.
> 
> agreed here ;-)
> 
> 
> > Patch 1/5 switches to C++17. If you're using an existing build
> > directory, you will need to set the cpp_std option with
> > 
> > 	meson configure -Dcpp_std=c++17
> 
> Another part that meson doesn't catch to reconfigure then...

I wonder how meson could handle this though. We're only changing the
default here. Reconfiguring when the default changes isn't always a good
idea. I suppose what's missing in meson is a way to force a minimum (or
particular) C++ standard. Or maybe that feature exists and we're just
not aware of it :-) I've asked in #mesonbuild.

> > Patches 2/5 and 3/5 then update the code base to remove workarounds
> > needed by C++14 and older compilers. Patch 4/5 is a new attempt to drop
> > -Wno-unused-parameter, with the standard [[maybe_unused]] attribute this
> > time instead of commenting out the parameter name to the function. Patch
> > 5/5 extends the usage of [[maybe_unused]] to remove void casts.
> > 
> > Laurent Pinchart (5):
> >   meson: Switch to C++17
> >   libcamera: Replace utils::clamp() with std::clamp()
> >   libcamera: Drop explicit construction of std::queue
> >   meson: Remove -Wno-unused-parameter
> >   ipa: raspberrypi: Replace void cast with [[maybe_unused]]
> > 
> >  include/libcamera/bound_method.h              |  2 +-
> >  include/libcamera/internal/utils.h            |  7 ------
> >  include/libcamera/signal.h                    |  2 +-
> >  include/libcamera/span.h                      |  4 ++--
> >  meson.build                                   |  3 +--
> >  src/android/camera3_hal.cpp                   | 11 +++++----
> >  src/android/camera_device.cpp                 |  5 ++--
> >  src/android/camera_ops.cpp                    |  5 ++--
> >  src/cam/main.cpp                              |  2 +-
> >  src/gstreamer/gstlibcamerapool.cpp            |  2 +-
> >  src/gstreamer/gstlibcameraprovider.cpp        |  2 +-
> >  src/gstreamer/gstlibcamerasrc.cpp             |  7 ++++--
> >  src/ipa/raspberrypi/controller/algorithm.cpp  | 16 +++++--------
> >  src/ipa/raspberrypi/controller/rpi/agc.cpp    |  3 ++-
> >  src/ipa/raspberrypi/controller/rpi/alsc.cpp   |  8 +++----
> >  .../raspberrypi/controller/rpi/contrast.cpp   |  4 ++--
> >  src/ipa/raspberrypi/controller/rpi/noise.cpp  |  5 ++--
> >  .../raspberrypi/controller/rpi/sharpen.cpp    |  5 ++--
> >  src/ipa/raspberrypi/raspberrypi.cpp           |  2 +-
> >  src/ipa/rkisp1/rkisp1.cpp                     | 24 ++++++++++---------
> >  src/ipa/vimc/vimc.cpp                         | 16 ++++++-------
> >  src/libcamera/device_enumerator_udev.cpp      |  2 +-
> >  src/libcamera/ipc_unixsocket.cpp              |  2 +-
> >  src/libcamera/pipeline/ipu3/cio2.cpp          |  4 +---
> >  src/libcamera/pipeline/ipu3/imgu.cpp          |  3 ++-
> >  src/libcamera/pipeline/ipu3/ipu3.cpp          | 12 +++++-----
> >  .../pipeline/raspberrypi/raspberrypi.cpp      | 10 ++++----
> >  src/libcamera/pipeline/rkisp1/rkisp1.cpp      |  2 +-
> >  src/libcamera/pipeline/rkisp1/timeline.cpp    |  2 +-
> >  src/libcamera/pipeline/vimc/vimc.cpp          |  2 +-
> >  src/libcamera/process.cpp                     |  2 +-
> >  src/libcamera/proxy/ipa_proxy_linux.cpp       | 23 ++++++++++--------
> >  src/libcamera/utils.cpp                       |  8 -------
> >  src/libcamera/v4l2_pixelformat.cpp            |  2 +-
> >  src/libcamera/v4l2_videodevice.cpp            |  4 ++--
> >  src/qcam/dng_writer.cpp                       |  5 ++--
> >  src/qcam/main.cpp                             |  2 +-
> >  src/v4l2/v4l2_camera.cpp                      |  2 +-
> >  test/camera/buffer_import.cpp                 |  3 ++-
> >  test/camera/capture.cpp                       |  3 ++-
> >  test/hotplug-cameras.cpp                      |  4 ++--
> >  test/ipa/ipa_wrappers_test.cpp                |  4 ++--
> >  test/libtest/test.h                           |  2 +-
> >  test/log/log_process.cpp                      |  3 ++-
> >  test/object-invoke.cpp                        |  2 +-
> >  test/process/process_test.cpp                 |  3 ++-
> >  test/timer-thread.cpp                         |  2 +-
> >  test/timer.cpp                                |  2 +-
> >  48 files changed, 122 insertions(+), 128 deletions(-)