[{"id":11796,"web_url":"https://patchwork.libcamera.org/comment/11796/","msgid":"<20200803142547.GF5926@pendragon.ideasonboard.com>","date":"2020-08-03T14:25:47","subject":"Re: [libcamera-devel] [PATCH] libcamera: ipu3: Fix compilation\n\tissues with gcc5","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Mon, Aug 03, 2020 at 04:18:37PM +0200, Jacopo Mondi wrote:\n> GCC5 does not provide prototypes for the math library functions in\n> the std:: namespace.\n> \n> Remove the namespace specifier to fix build errors reported by\n> that compiler version.\n> \n> Fixes: 968ab9bad0ed (\"libcamera: ipu3: imgu: Calculate ImgU pipe configuration\")\n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n> \n> Laurent, can you test with gcc and confirm this fixes the issue ?\n\nIt does fix the compilation issue, but... see below.\n\n> ---\n>  src/libcamera/pipeline/ipu3/imgu.cpp | 14 +++++++-------\n>  1 file changed, 7 insertions(+), 7 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp\n> index b7593ceb3672..671a798e69d0 100644\n> --- a/src/libcamera/pipeline/ipu3/imgu.cpp\n> +++ b/src/libcamera/pipeline/ipu3/imgu.cpp\n> @@ -94,7 +94,7 @@ float findScaleFactor(float sf, const std::vector<float> &range,\n>  \tfloat bestDiff = std::numeric_limits<float>::max();\n>  \tunsigned int index = 0;\n>  \tfor (unsigned int i = 0; i < range.size(); ++i) {\n> -\t\tfloat diff = std::abs(sf - range[i]);\n> +\t\tfloat diff = abs(sf - range[i]);\n\nThe abs() function in the global namespace is, according to\nhttps://en.cppreference.com/w/c/numeric/math/abs,\n\n\tint abs( int n );\n\nThis will thus cast the argument to int, which is likely not what you\nwant. You need to use\n\n\tfloat fabsf( float arg );\n\ninstead (https://en.cppreference.com/w/c/numeric/math/fabs).\n\nSame below.\n\nThe math functions in the std:: namespace don't suffer for this, as\nmultiple overloads are defined:\n\nint       abs( int n );\nlong      abs( long n );\nlong long abs( long long n );\n\n(https://en.cppreference.com/w/cpp/numeric/math/abs)\n\nfloat       abs( float arg );\ndouble      abs( double arg );\nlong double abs( long double arg );\n\n(https://en.cppreference.com/w/cpp/numeric/math/fabs)\n\nbut they require <cmath>, not <math.h>.\n\nIt's up to you, but if you keep using math.h, you need fabsf() when the\nargument and result are floats. Similarly, fmod() should become fmodf(),\notherwise you'll cast the argument to double and cast the result back to\nfloat.\n\n>  \t\tif (diff < bestDiff) {\n>  \t\t\tbestDiff = diff;\n>  \t\t\tindex = i;\n> @@ -112,7 +112,7 @@ bool isSameRatio(const Size &in, const Size &out)\n>  \tfloat inRatio = static_cast<float>(in.width) / in.height;\n>  \tfloat outRatio = static_cast<float>(out.width) / out.height;\n> \n> -\tif (std::abs(inRatio - outRatio) > 0.1)\n> +\tif (abs(inRatio - outRatio) > 0.1)\n>  \t\treturn false;\n> \n>  \treturn true;\n> @@ -136,7 +136,7 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc\n>  \t\twhile (ifHeight >= minIFHeight && ifHeight / bdsSF >= minBDSHeight) {\n> \n>  \t\t\tbdsHeight = ifHeight / bdsSF;\n> -\t\t\tif (std::fmod(bdsHeight, 1.0) == 0) {\n> +\t\t\tif (fmod(bdsHeight, 1.0) == 0) {\n>  \t\t\t\tunsigned int bdsIntHeight = static_cast<unsigned int>(bdsHeight);\n> \n>  \t\t\t\tif (!(bdsIntHeight % BDS_ALIGN_H)) {\n> @@ -152,7 +152,7 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc\n>  \t\twhile (ifHeight <= iif.height && ifHeight / bdsSF >= minBDSHeight) {\n> \n>  \t\t\tbdsHeight = ifHeight / bdsSF;\n> -\t\t\tif (std::fmod(bdsHeight, 1.0) == 0) {\n> +\t\t\tif (fmod(bdsHeight, 1.0) == 0) {\n>  \t\t\t\tunsigned int bdsIntHeight = static_cast<unsigned int>(bdsHeight);\n> \n>  \t\t\t\tif (!(bdsIntHeight % BDS_ALIGN_H)) {\n> @@ -176,7 +176,7 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc\n>  \t\twhile (ifHeight > minIFHeight && ifHeight / bdsSF >= minBDSHeight) {\n> \n>  \t\t\tbdsHeight = ifHeight / bdsSF;\n> -\t\t\tif (std::fmod(ifHeight, 1.0) == 0 && std::fmod(bdsHeight, 1.0) == 0) {\n> +\t\t\tif (fmod(ifHeight, 1.0) == 0 && fmod(bdsHeight, 1.0) == 0) {\n>  \t\t\t\tunsigned int bdsIntHeight = static_cast<unsigned int>(bdsHeight);\n> \n>  \t\t\t\tif (!(ifHeight % IF_ALIGN_H) &&\n> @@ -199,7 +199,7 @@ void calculateBDS(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc, floa\n>  \twhile (sf <= BDS_SF_MAX && sf >= BDS_SF_MIN) {\n>  \t\tfloat bdsWidth = static_cast<float>(iif.width) / sf;\n> \n> -\t\tif (std::fmod(bdsWidth, 1.0) == 0) {\n> +\t\tif (fmod(bdsWidth, 1.0) == 0) {\n>  \t\t\tunsigned int bdsIntWidth = static_cast<unsigned int>(bdsWidth);\n>  \t\t\tif (!(bdsIntWidth % BDS_ALIGN_W) && bdsWidth >= minBDSWidth)\n>  \t\t\t\tcalculateBDSHeight(pipe, iif, gdc, bdsIntWidth, sf);\n> @@ -212,7 +212,7 @@ void calculateBDS(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc, floa\n>  \twhile (sf <= BDS_SF_MAX && sf >= BDS_SF_MIN) {\n>  \t\tfloat bdsWidth = static_cast<float>(iif.width) / sf;\n> \n> -\t\tif (std::fmod(bdsWidth, 1.0) == 0) {\n> +\t\tif (fmod(bdsWidth, 1.0) == 0) {\n>  \t\t\tunsigned int bdsIntWidth = static_cast<unsigned int>(bdsWidth);\n>  \t\t\tif (!(bdsIntWidth % BDS_ALIGN_W) && bdsWidth >= minBDSWidth)\n>  \t\t\t\tcalculateBDSHeight(pipe, iif, gdc, bdsIntWidth, sf);","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 18187BD86F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  3 Aug 2020 14:26:01 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A3549605A9;\n\tMon,  3 Aug 2020 16:26:00 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7BDEC60536\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  3 Aug 2020 16:25:59 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C9062543;\n\tMon,  3 Aug 2020 16:25:58 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"rBUmsADE\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1596464759;\n\tbh=YZA8l08ehSHAO6cj0tXIrJ0SsMR7b4wS/55AzL+81FU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=rBUmsADEDNzlcaVVjOvz+vKM5YhTegV+y4ZI2EKwxfPqRXXpQ497aJumGFtIkyB7W\n\tUNrN7FBYqXhIHNBSiR22dG7H2TSscW3UIgTvGHGZlic55Ay5Z2NE1H16DIoMV6f1dW\n\tDbK4RNHiGatNQ+5/Q3je2mBWmSURiTfADY+ViV/Y=","Date":"Mon, 3 Aug 2020 17:25:47 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<20200803142547.GF5926@pendragon.ideasonboard.com>","References":"<20200803141837.398158-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200803141837.398158-1-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH] libcamera: ipu3: Fix compilation\n\tissues with gcc5","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":11797,"web_url":"https://patchwork.libcamera.org/comment/11797/","msgid":"<20200803144326.jkbq35urrphlefln@uno.localdomain>","date":"2020-08-03T14:43:26","subject":"Re: [libcamera-devel] [PATCH] libcamera: ipu3: Fix compilation\n\tissues with gcc5","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent,\n\nOn Mon, Aug 03, 2020 at 05:25:47PM +0300, Laurent Pinchart wrote:\n> Hi Jacopo,\n>\n> Thank you for the patch.\n>\n> On Mon, Aug 03, 2020 at 04:18:37PM +0200, Jacopo Mondi wrote:\n> > GCC5 does not provide prototypes for the math library functions in\n> > the std:: namespace.\n> >\n> > Remove the namespace specifier to fix build errors reported by\n> > that compiler version.\n> >\n> > Fixes: 968ab9bad0ed (\"libcamera: ipu3: imgu: Calculate ImgU pipe configuration\")\n> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > ---\n> >\n> > Laurent, can you test with gcc and confirm this fixes the issue ?\n>\n> It does fix the compilation issue, but... see below.\n>\n> > ---\n> >  src/libcamera/pipeline/ipu3/imgu.cpp | 14 +++++++-------\n> >  1 file changed, 7 insertions(+), 7 deletions(-)\n> >\n> > diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp\n> > index b7593ceb3672..671a798e69d0 100644\n> > --- a/src/libcamera/pipeline/ipu3/imgu.cpp\n> > +++ b/src/libcamera/pipeline/ipu3/imgu.cpp\n> > @@ -94,7 +94,7 @@ float findScaleFactor(float sf, const std::vector<float> &range,\n> >  \tfloat bestDiff = std::numeric_limits<float>::max();\n> >  \tunsigned int index = 0;\n> >  \tfor (unsigned int i = 0; i < range.size(); ++i) {\n> > -\t\tfloat diff = std::abs(sf - range[i]);\n> > +\t\tfloat diff = abs(sf - range[i]);\n>\n> The abs() function in the global namespace is, according to\n> https://en.cppreference.com/w/c/numeric/math/abs,\n>\n> \tint abs( int n );\n>\n> This will thus cast the argument to int, which is likely not what you\n> want. You need to use\n>\n> \tfloat fabsf( float arg );\n>\n> instead (https://en.cppreference.com/w/c/numeric/math/fabs).\n>\n> Same below.\n>\n> The math functions in the std:: namespace don't suffer for this, as\n> multiple overloads are defined:\n>\n> int       abs( int n );\n> long      abs( long n );\n> long long abs( long long n );\n>\n> (https://en.cppreference.com/w/cpp/numeric/math/abs)\n>\n> float       abs( float arg );\n> double      abs( double arg );\n> long double abs( long double arg );\n>\n> (https://en.cppreference.com/w/cpp/numeric/math/fabs)\n>\n> but they require <cmath>, not <math.h>.\n>\n> It's up to you, but if you keep using math.h, you need fabsf() when the\n> argument and result are floats. Similarly, fmod() should become fmodf(),\n> otherwise you'll cast the argument to double and cast the result back to\n> float.\n\nWe had a rule, to use <foo.h> and not <cfoo>\n\nAll the rest of the code uses <math.h> but I don't want to try&shoot\nand introduce implicit casting errors in this rather fragile code.\n\nWith an ack, I'll use for this module <cmath>, contrary to the rest of\nthe codebase.\n\n>\n> >  \t\tif (diff < bestDiff) {\n> >  \t\t\tbestDiff = diff;\n> >  \t\t\tindex = i;\n> > @@ -112,7 +112,7 @@ bool isSameRatio(const Size &in, const Size &out)\n> >  \tfloat inRatio = static_cast<float>(in.width) / in.height;\n> >  \tfloat outRatio = static_cast<float>(out.width) / out.height;\n> >\n> > -\tif (std::abs(inRatio - outRatio) > 0.1)\n> > +\tif (abs(inRatio - outRatio) > 0.1)\n> >  \t\treturn false;\n> >\n> >  \treturn true;\n> > @@ -136,7 +136,7 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc\n> >  \t\twhile (ifHeight >= minIFHeight && ifHeight / bdsSF >= minBDSHeight) {\n> >\n> >  \t\t\tbdsHeight = ifHeight / bdsSF;\n> > -\t\t\tif (std::fmod(bdsHeight, 1.0) == 0) {\n> > +\t\t\tif (fmod(bdsHeight, 1.0) == 0) {\n> >  \t\t\t\tunsigned int bdsIntHeight = static_cast<unsigned int>(bdsHeight);\n> >\n> >  \t\t\t\tif (!(bdsIntHeight % BDS_ALIGN_H)) {\n> > @@ -152,7 +152,7 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc\n> >  \t\twhile (ifHeight <= iif.height && ifHeight / bdsSF >= minBDSHeight) {\n> >\n> >  \t\t\tbdsHeight = ifHeight / bdsSF;\n> > -\t\t\tif (std::fmod(bdsHeight, 1.0) == 0) {\n> > +\t\t\tif (fmod(bdsHeight, 1.0) == 0) {\n> >  \t\t\t\tunsigned int bdsIntHeight = static_cast<unsigned int>(bdsHeight);\n> >\n> >  \t\t\t\tif (!(bdsIntHeight % BDS_ALIGN_H)) {\n> > @@ -176,7 +176,7 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc\n> >  \t\twhile (ifHeight > minIFHeight && ifHeight / bdsSF >= minBDSHeight) {\n> >\n> >  \t\t\tbdsHeight = ifHeight / bdsSF;\n> > -\t\t\tif (std::fmod(ifHeight, 1.0) == 0 && std::fmod(bdsHeight, 1.0) == 0) {\n> > +\t\t\tif (fmod(ifHeight, 1.0) == 0 && fmod(bdsHeight, 1.0) == 0) {\n> >  \t\t\t\tunsigned int bdsIntHeight = static_cast<unsigned int>(bdsHeight);\n> >\n> >  \t\t\t\tif (!(ifHeight % IF_ALIGN_H) &&\n> > @@ -199,7 +199,7 @@ void calculateBDS(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc, floa\n> >  \twhile (sf <= BDS_SF_MAX && sf >= BDS_SF_MIN) {\n> >  \t\tfloat bdsWidth = static_cast<float>(iif.width) / sf;\n> >\n> > -\t\tif (std::fmod(bdsWidth, 1.0) == 0) {\n> > +\t\tif (fmod(bdsWidth, 1.0) == 0) {\n> >  \t\t\tunsigned int bdsIntWidth = static_cast<unsigned int>(bdsWidth);\n> >  \t\t\tif (!(bdsIntWidth % BDS_ALIGN_W) && bdsWidth >= minBDSWidth)\n> >  \t\t\t\tcalculateBDSHeight(pipe, iif, gdc, bdsIntWidth, sf);\n> > @@ -212,7 +212,7 @@ void calculateBDS(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc, floa\n> >  \twhile (sf <= BDS_SF_MAX && sf >= BDS_SF_MIN) {\n> >  \t\tfloat bdsWidth = static_cast<float>(iif.width) / sf;\n> >\n> > -\t\tif (std::fmod(bdsWidth, 1.0) == 0) {\n> > +\t\tif (fmod(bdsWidth, 1.0) == 0) {\n> >  \t\t\tunsigned int bdsIntWidth = static_cast<unsigned int>(bdsWidth);\n> >  \t\t\tif (!(bdsIntWidth % BDS_ALIGN_W) && bdsWidth >= minBDSWidth)\n> >  \t\t\t\tcalculateBDSHeight(pipe, iif, gdc, bdsIntWidth, sf);\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 60F10BD87A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  3 Aug 2020 14:39:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F273C6194A;\n\tMon,  3 Aug 2020 16:39:48 +0200 (CEST)","from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net\n\t[217.70.183.201])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 14F2F60536\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  3 Aug 2020 16:39:48 +0200 (CEST)","from uno.localdomain (93-34-118-233.ip49.fastwebnet.it\n\t[93.34.118.233]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 6DC871BF204;\n\tMon,  3 Aug 2020 14:39:47 +0000 (UTC)"],"X-Originating-IP":"93.34.118.233","Date":"Mon, 3 Aug 2020 16:43:26 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20200803144326.jkbq35urrphlefln@uno.localdomain>","References":"<20200803141837.398158-1-jacopo@jmondi.org>\n\t<20200803142547.GF5926@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200803142547.GF5926@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH] libcamera: ipu3: Fix compilation\n\tissues with gcc5","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":11798,"web_url":"https://patchwork.libcamera.org/comment/11798/","msgid":"<20200803144745.GG5926@pendragon.ideasonboard.com>","date":"2020-08-03T14:47:45","subject":"Re: [libcamera-devel] [PATCH] libcamera: ipu3: Fix compilation\n\tissues with gcc5","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn Mon, Aug 03, 2020 at 04:43:26PM +0200, Jacopo Mondi wrote:\n> On Mon, Aug 03, 2020 at 05:25:47PM +0300, Laurent Pinchart wrote:\n> > On Mon, Aug 03, 2020 at 04:18:37PM +0200, Jacopo Mondi wrote:\n> > > GCC5 does not provide prototypes for the math library functions in\n> > > the std:: namespace.\n> > >\n> > > Remove the namespace specifier to fix build errors reported by\n> > > that compiler version.\n> > >\n> > > Fixes: 968ab9bad0ed (\"libcamera: ipu3: imgu: Calculate ImgU pipe configuration\")\n> > > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > > ---\n> > >\n> > > Laurent, can you test with gcc and confirm this fixes the issue ?\n> >\n> > It does fix the compilation issue, but... see below.\n> >\n> > > ---\n> > >  src/libcamera/pipeline/ipu3/imgu.cpp | 14 +++++++-------\n> > >  1 file changed, 7 insertions(+), 7 deletions(-)\n> > >\n> > > diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp\n> > > index b7593ceb3672..671a798e69d0 100644\n> > > --- a/src/libcamera/pipeline/ipu3/imgu.cpp\n> > > +++ b/src/libcamera/pipeline/ipu3/imgu.cpp\n> > > @@ -94,7 +94,7 @@ float findScaleFactor(float sf, const std::vector<float> &range,\n> > >  \tfloat bestDiff = std::numeric_limits<float>::max();\n> > >  \tunsigned int index = 0;\n> > >  \tfor (unsigned int i = 0; i < range.size(); ++i) {\n> > > -\t\tfloat diff = std::abs(sf - range[i]);\n> > > +\t\tfloat diff = abs(sf - range[i]);\n> >\n> > The abs() function in the global namespace is, according to\n> > https://en.cppreference.com/w/c/numeric/math/abs,\n> >\n> > \tint abs( int n );\n> >\n> > This will thus cast the argument to int, which is likely not what you\n> > want. You need to use\n> >\n> > \tfloat fabsf( float arg );\n> >\n> > instead (https://en.cppreference.com/w/c/numeric/math/fabs).\n> >\n> > Same below.\n> >\n> > The math functions in the std:: namespace don't suffer for this, as\n> > multiple overloads are defined:\n> >\n> > int       abs( int n );\n> > long      abs( long n );\n> > long long abs( long long n );\n> >\n> > (https://en.cppreference.com/w/cpp/numeric/math/abs)\n> >\n> > float       abs( float arg );\n> > double      abs( double arg );\n> > long double abs( long double arg );\n> >\n> > (https://en.cppreference.com/w/cpp/numeric/math/fabs)\n> >\n> > but they require <cmath>, not <math.h>.\n> >\n> > It's up to you, but if you keep using math.h, you need fabsf() when the\n> > argument and result are floats. Similarly, fmod() should become fmodf(),\n> > otherwise you'll cast the argument to double and cast the result back to\n> > float.\n> \n> We had a rule, to use <foo.h> and not <cfoo>\n> \n> All the rest of the code uses <math.h> but I don't want to try&shoot\n> and introduce implicit casting errors in this rather fragile code.\n> \n> With an ack, I'll use for this module <cmath>, contrary to the rest of\n> the codebase.\n\nAck on either option, as I said, pick the one you like best :-)\n\n> > >  \t\tif (diff < bestDiff) {\n> > >  \t\t\tbestDiff = diff;\n> > >  \t\t\tindex = i;\n> > > @@ -112,7 +112,7 @@ bool isSameRatio(const Size &in, const Size &out)\n> > >  \tfloat inRatio = static_cast<float>(in.width) / in.height;\n> > >  \tfloat outRatio = static_cast<float>(out.width) / out.height;\n> > >\n> > > -\tif (std::abs(inRatio - outRatio) > 0.1)\n> > > +\tif (abs(inRatio - outRatio) > 0.1)\n> > >  \t\treturn false;\n> > >\n> > >  \treturn true;\n> > > @@ -136,7 +136,7 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc\n> > >  \t\twhile (ifHeight >= minIFHeight && ifHeight / bdsSF >= minBDSHeight) {\n> > >\n> > >  \t\t\tbdsHeight = ifHeight / bdsSF;\n> > > -\t\t\tif (std::fmod(bdsHeight, 1.0) == 0) {\n> > > +\t\t\tif (fmod(bdsHeight, 1.0) == 0) {\n> > >  \t\t\t\tunsigned int bdsIntHeight = static_cast<unsigned int>(bdsHeight);\n> > >\n> > >  \t\t\t\tif (!(bdsIntHeight % BDS_ALIGN_H)) {\n> > > @@ -152,7 +152,7 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc\n> > >  \t\twhile (ifHeight <= iif.height && ifHeight / bdsSF >= minBDSHeight) {\n> > >\n> > >  \t\t\tbdsHeight = ifHeight / bdsSF;\n> > > -\t\t\tif (std::fmod(bdsHeight, 1.0) == 0) {\n> > > +\t\t\tif (fmod(bdsHeight, 1.0) == 0) {\n> > >  \t\t\t\tunsigned int bdsIntHeight = static_cast<unsigned int>(bdsHeight);\n> > >\n> > >  \t\t\t\tif (!(bdsIntHeight % BDS_ALIGN_H)) {\n> > > @@ -176,7 +176,7 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc\n> > >  \t\twhile (ifHeight > minIFHeight && ifHeight / bdsSF >= minBDSHeight) {\n> > >\n> > >  \t\t\tbdsHeight = ifHeight / bdsSF;\n> > > -\t\t\tif (std::fmod(ifHeight, 1.0) == 0 && std::fmod(bdsHeight, 1.0) == 0) {\n> > > +\t\t\tif (fmod(ifHeight, 1.0) == 0 && fmod(bdsHeight, 1.0) == 0) {\n> > >  \t\t\t\tunsigned int bdsIntHeight = static_cast<unsigned int>(bdsHeight);\n> > >\n> > >  \t\t\t\tif (!(ifHeight % IF_ALIGN_H) &&\n> > > @@ -199,7 +199,7 @@ void calculateBDS(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc, floa\n> > >  \twhile (sf <= BDS_SF_MAX && sf >= BDS_SF_MIN) {\n> > >  \t\tfloat bdsWidth = static_cast<float>(iif.width) / sf;\n> > >\n> > > -\t\tif (std::fmod(bdsWidth, 1.0) == 0) {\n> > > +\t\tif (fmod(bdsWidth, 1.0) == 0) {\n> > >  \t\t\tunsigned int bdsIntWidth = static_cast<unsigned int>(bdsWidth);\n> > >  \t\t\tif (!(bdsIntWidth % BDS_ALIGN_W) && bdsWidth >= minBDSWidth)\n> > >  \t\t\t\tcalculateBDSHeight(pipe, iif, gdc, bdsIntWidth, sf);\n> > > @@ -212,7 +212,7 @@ void calculateBDS(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc, floa\n> > >  \twhile (sf <= BDS_SF_MAX && sf >= BDS_SF_MIN) {\n> > >  \t\tfloat bdsWidth = static_cast<float>(iif.width) / sf;\n> > >\n> > > -\t\tif (std::fmod(bdsWidth, 1.0) == 0) {\n> > > +\t\tif (fmod(bdsWidth, 1.0) == 0) {\n> > >  \t\t\tunsigned int bdsIntWidth = static_cast<unsigned int>(bdsWidth);\n> > >  \t\t\tif (!(bdsIntWidth % BDS_ALIGN_W) && bdsWidth >= minBDSWidth)\n> > >  \t\t\t\tcalculateBDSHeight(pipe, iif, gdc, bdsIntWidth, sf);","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id BB2ECBD86F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  3 Aug 2020 14:48:00 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 592FF605A9;\n\tMon,  3 Aug 2020 16:48:00 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C15B060536\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  3 Aug 2020 16:47:58 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EE544543;\n\tMon,  3 Aug 2020 16:47:56 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"TrKMwyVn\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1596466077;\n\tbh=2nWq4FaAInNeGsH6AApNxeInt9KOYesnqocZG0Vsglc=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=TrKMwyVnIldNg7UNDmYTpLsdgeLzveJOC1c9+x6aQM4NNGber4KAQ2TPz9WG1JbM2\n\tgqV5RhJRgcyGnfWMQRiNKqyISuUWwJXEDj9LPLTBhBCbeS1gUMmXgtUoPxHDfrnsG7\n\t5PDyuDynrvFgd3YPdaQxz6GXK8LV8K9FyByUr5Yc=","Date":"Mon, 3 Aug 2020 17:47:45 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<20200803144745.GG5926@pendragon.ideasonboard.com>","References":"<20200803141837.398158-1-jacopo@jmondi.org>\n\t<20200803142547.GF5926@pendragon.ideasonboard.com>\n\t<20200803144326.jkbq35urrphlefln@uno.localdomain>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200803144326.jkbq35urrphlefln@uno.localdomain>","Subject":"Re: [libcamera-devel] [PATCH] libcamera: ipu3: Fix compilation\n\tissues with gcc5","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]