Re: [PATCH 00/45] C++: Convert the kernel to C++
From: H. Peter Anvin
Date: Thu Jan 11 2024 - 21:55:01 EST
One thing I forgot to mention that would be quite useful is careful use
of namespaces. For example, putting init functions in their own
namespace would have not only make it a lot harder to call init
functions from non-init functions by mistake (calling init::func()
explicitly is a highly visible "I really do mean to do this."
However, it also let us do separate init versions of functions like
cpu_feature_enable() that contain optimizations that aren't actually
usable at init time (alternatives have not been applied.) The idea is
*not* to change the code, but rather the compiler will simply prefer
init:: functions from inside other init:: functions (a direct
consequence of how namespaces work.)
-hpa