[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZZ_hhT6N9tqKuB2c@chrisdown.name>
Date: Thu, 11 Jan 2024 12:39:33 +0000
From: Chris Down <chris@...isdown.name>
To: "H. Peter Anvin" <hpa@...or.com>
Cc: Peter Zijlstra <peterz@...radead.org>,
David Howells <dhowells@...hat.com>, linux-kernel@...r.kernel.org,
pinskia@...il.com
Subject: Re: [PATCH 00/45] C++: Convert the kernel to C++
H. Peter Anvin writes:
>We already *do* use constructors and *especially* destructors for a
>lot of objects, we just call them out.
>
>Note that modern C++ also has the ability to construct and destruct
>objects in-place, so allocation and construction/destruction aren't
>necessarily related.
>
>There is no reason you can't do static initialization where possible;
>even constructors can be evaluated at compile time if they are
>constexpr.
Side note for the constructor and destructor discussion: should we be more
widely marketing the __cleanup() infrastructure that Peter added a year or so
ago? It likely helps a lot with at least some of these cases. In systemd we use
__attribute__((cleanup)) pretty widely and my experience is that it's made the
code a lot easier to both create and consume.
Powered by blists - more mailing lists