[{"id":2701,"web_url":"https://patchwork.libcamera.org/comment/2701/","msgid":"<0b044787-4216-fea6-0e00-70d7b7cd4295@ideasonboard.com>","date":"2019-09-26T19:58:05","subject":"Re: [libcamera-devel] [PATCH 01/21] libcamera: utils: Provide an\n\tALIGN macro","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn 24/09/2019 18:24, Jacopo Mondi wrote:\n\nI know there's not much to say, but I always fear an empty commit\nmessage :-D\n\n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/libcamera/include/utils.h |  2 ++\n>  src/libcamera/utils.cpp       | 11 +++++++++++\n>  2 files changed, 13 insertions(+)\n> \n> diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h\n> index 52eee8ac2804..08323966b44e 100644\n> --- a/src/libcamera/include/utils.h\n> +++ b/src/libcamera/include/utils.h\n> @@ -63,6 +63,8 @@ using time_point = std::chrono::steady_clock::time_point;\n>  struct timespec duration_to_timespec(const duration &value);\n>  std::string time_point_to_string(const time_point &time);\n>  \n> +#define ALIGN(_s, _a) (((_s) + (_a - 1)) & ~(_a - 1))\n> +\n>  } /* namespace utils */\n>  \n>  } /* namespace libcamera */\n> diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\n> index 928db254ec67..c3188bfff03d 100644\n> --- a/src/libcamera/utils.cpp\n> +++ b/src/libcamera/utils.cpp\n> @@ -143,6 +143,17 @@ std::string time_point_to_string(const time_point &time)\n>  \treturn ossTimestamp.str();\n>  }\n>  \n> +/**\n> + * \\def ALIGN(_s, _a)\n> + * \\brief Align a size to a boundary\n> + * \\param[in] _s The size to align\n> + * \\param[in] _a The boundary to align size to\n> + *\n> + * Align the provide size \\a _s to a the provided boundary. The request\n> + * alignement should be a power of 2, and the aligned size is up aligned to\n\ns/alignement/alignment/\n\n> + * the given boundary.\n> + */\n\nI haven't yet seen how this macro is to be used, but C++11 has alignof()\nand alignas() keywords.\n\nHave you considered them?\n\nI guess it will depend on whether you are looking to reserve an area\nwhere the size is a power of 2, or if you are just trying to allocate on\nboundaries.\n\nI guess that might also suggest that merging this into a patch where it\nis used would clarify it's intended usage.\n\n> +\n>  } /* namespace utils */\n>  \n>  } /* namespace libcamera */\n>","headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CFD2860BB6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 Sep 2019 21:58:08 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 396C69BF;\n\tThu, 26 Sep 2019 21:58:08 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1569527888;\n\tbh=ezdHkRkHFiDSQGo1HEfZPtVAW/gJ0kzeyC/1qgBiiOc=;\n\th=Reply-To:Subject:To:References:From:Date:In-Reply-To:From;\n\tb=rEvd6HgpqlFiUA9Fx0wCuTIIJ7srCO+u5JLdLMHcJc9ht9bC21jRDiIceeQdPo6wb\n\tvOaogHvaFe0CdX7Jsi0d7XmKa+4aVZigKBWtKXHPFOUsxhKZRYofN6mqzZ6HlcGnOL\n\tNOUcTMVweo1BmOOTDJUML38Fecx9kjwZVy21OMrs=","Reply-To":"kieran.bingham@ideasonboard.com","To":"Jacopo Mondi <jacopo@jmondi.org>, libcamera-devel@lists.libcamera.org","References":"<20190924172503.30864-1-jacopo@jmondi.org>\n\t<20190924172503.30864-2-jacopo@jmondi.org>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Openpgp":"preference=signencrypt","Autocrypt":"addr=kieran.bingham@ideasonboard.com; keydata=\n\tmQINBFYE/WYBEACs1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eUPy2cngDUXzwrqiM5Sz6Od0qw5pCk\n\tNlXqI0W/who0iSVM+8+RmyY0OEkxEcci7rRLsGnM15B5PjLJjh1f2ULYkv8s4SnDwMZ/kE04\n\t/UqCMK/KnX8pwXEMCjz0h6qWNpGwJ0/tYIgQJZh6bqkvBrDogAvuhf60Sogw+mH8b+PBlx1L\n\toeTK396wc+4c3BfiC6pNtUS5GpsPMMjYMk7kVvEAEQEAAYkCJQQYAQoADwIbDAUCWcOUawUJ\n\tB4D+AgAKCRChHkZyEKRh/XJhEACr5iidt/0MZ0rWRMCbZFMWD7D2g6nZeOp+F2zY8CEUW+sd\n\tCDVd9BH9QX9KN5SZo6YtJzMzSzpcx45VwTvtQW0n/6Eujg9EUqblfU9xqvqDmbjEapr5d/OL\n\t21GTALb0owKhA5qDUGEcKGCphpQffKhTNo/BP99jvmJUj7IPSKH97qPypi8/ym8bAxB+uY31\n\tgHTMHf1jMJJ1pRo2tYYPeIIHGDqXBI4sp5GHHF+JcIhgR/e/A6w/dgzHYmQPl2ix5eZYEZbV\n\tTRP+gkX4NV8oHqa/lR+xPOlWElGB57viOSOoWriqxQbFy8XbG1GR8cWlkNtGBGVWaJaSoORP\n\tiowD7irXL91bCyFIqL+7BVk3Jy4uzP744PzE80KwxOp5SQAp9sPzFbgsJrLev90PZySjFHG0\n\twP144DK7nBjOj/J0g9OHVASP1JjK+nw7SDoKnETDIdRC0XmiHXk7TXzPdkvO0UkpHdEPjZUp\n\tWyuc0MqehjR/hTTPt4m/Y14XzEcy6JREIjOrFfUZVho2QpOdv9CNryGdieRTNjUtz463CIaZ\n\tdPBiw9mOMBoNffkn9FIoCjLnAaj9gUAnEHWBZOEviQ5NuyqpeP0YtzI4iaRbSUkYZHej99X3\n\tVmHrdLlMqd/ZgYYbPGSL4AN3FVACb5CxuxEHwo029VcE5U3CSjzqtCoX12tm7A==","Organization":"Ideas on Board","Message-ID":"<0b044787-4216-fea6-0e00-70d7b7cd4295@ideasonboard.com>","Date":"Thu, 26 Sep 2019 20:58:05 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101\n\tThunderbird/60.8.0","MIME-Version":"1.0","In-Reply-To":"<20190924172503.30864-2-jacopo@jmondi.org>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH 01/21] libcamera: utils: Provide an\n\tALIGN macro","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>","X-List-Received-Date":"Thu, 26 Sep 2019 19:58:09 -0000"}},{"id":2703,"web_url":"https://patchwork.libcamera.org/comment/2703/","msgid":"<20190926221032.mmflmpunhgzieefh@uno.localdomain>","date":"2019-09-26T22:10:32","subject":"Re: [libcamera-devel] [PATCH 01/21] libcamera: utils: Provide an\n\tALIGN macro","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Kieran,\n\nOn Thu, Sep 26, 2019 at 08:58:05PM +0100, Kieran Bingham wrote:\n> Hi Jacopo,\n>\n> On 24/09/2019 18:24, Jacopo Mondi wrote:\n>\n> I know there's not much to say, but I always fear an empty commit\n> message :-D\n\nYou shall fear no more!\nI'll add a commit message ;)\n\n>\n> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > ---\n> >  src/libcamera/include/utils.h |  2 ++\n> >  src/libcamera/utils.cpp       | 11 +++++++++++\n> >  2 files changed, 13 insertions(+)\n> >\n> > diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h\n> > index 52eee8ac2804..08323966b44e 100644\n> > --- a/src/libcamera/include/utils.h\n> > +++ b/src/libcamera/include/utils.h\n> > @@ -63,6 +63,8 @@ using time_point = std::chrono::steady_clock::time_point;\n> >  struct timespec duration_to_timespec(const duration &value);\n> >  std::string time_point_to_string(const time_point &time);\n> >\n> > +#define ALIGN(_s, _a) (((_s) + (_a - 1)) & ~(_a - 1))\n> > +\n> >  } /* namespace utils */\n> >\n> >  } /* namespace libcamera */\n> > diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\n> > index 928db254ec67..c3188bfff03d 100644\n> > --- a/src/libcamera/utils.cpp\n> > +++ b/src/libcamera/utils.cpp\n> > @@ -143,6 +143,17 @@ std::string time_point_to_string(const time_point &time)\n> >  \treturn ossTimestamp.str();\n> >  }\n> >\n> > +/**\n> > + * \\def ALIGN(_s, _a)\n> > + * \\brief Align a size to a boundary\n> > + * \\param[in] _s The size to align\n> > + * \\param[in] _a The boundary to align size to\n> > + *\n> > + * Align the provide size \\a _s to a the provided boundary. The request\n> > + * alignement should be a power of 2, and the aligned size is up aligned to\n>\n> s/alignement/alignment/\n>\n> > + * the given boundary.\n> > + */\n>\n> I haven't yet seen how this macro is to be used, but C++11 has alignof()\n> and alignas() keywords.\n>\n\nThe macro is used in the implementation of the Serializer class\n([03/21])\n\nDuring the serialization of DataValue and DataInfo, it is used to\nalign the sizes of the types a DataValue transport, and the min and\nmax DataValue a DataInfo transports. It is also used to calulculate\nthe size of the memory area to allocate to hold the serialized\ncontent.\n\n> Have you considered them?\n\nNo, I didn't know :)\n\n>\n> I guess it will depend on whether you are looking to reserve an area\n> where the size is a power of 2, or if you are just trying to allocate on\n> boundaries.\n\nI mostly use it to calulate sizes, which are used in the Serializer\nsub-class to advance the pointer where to store data and where to fish\ndata from...\n\nThose marcos seems to be type oriented, I'm not sure it's worth going\ndown that path in this case.. Or actually, DataInfo DataValue could be\nmade-sublcasses of a Serialized , defined with alignas(8).. It could\nactually work, as I could then use alignof() on the DataType to get\nthe right size... I could actually get rid of the ALIGN macro maybe?\n\nThanks\n  j\n\n>\n> I guess that might also suggest that merging this into a patch where it\n> is used would clarify it's intended usage.\n>\n> > +\n> >  } /* namespace utils */\n> >\n> >  } /* namespace libcamera */\n> >\n>\n> --\n> Regards\n> --\n> Kieran","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net\n\t[217.70.183.199])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2BDEC60BCF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 Sep 2019 00:09:00 +0200 (CEST)","from uno.localdomain\n\t(host71-63-dynamic.19-79-r.retail.telecomitalia.it [79.19.63.71])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 6791DFF806;\n\tThu, 26 Sep 2019 22:08:59 +0000 (UTC)"],"X-Originating-IP":"79.19.63.71","Date":"Fri, 27 Sep 2019 00:10:32 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190926221032.mmflmpunhgzieefh@uno.localdomain>","References":"<20190924172503.30864-1-jacopo@jmondi.org>\n\t<20190924172503.30864-2-jacopo@jmondi.org>\n\t<0b044787-4216-fea6-0e00-70d7b7cd4295@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"jfkwhlfco7dunfzp\"","Content-Disposition":"inline","In-Reply-To":"<0b044787-4216-fea6-0e00-70d7b7cd4295@ideasonboard.com>","User-Agent":"NeoMutt/20180716","Subject":"Re: [libcamera-devel] [PATCH 01/21] libcamera: utils: Provide an\n\tALIGN macro","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>","X-List-Received-Date":"Thu, 26 Sep 2019 22:09:00 -0000"}}]