"os" - make this a real namespace?

Thomas Stüfe thomas.stuefe at gmail.com
Wed Oct 19 06:10:04 UTC 2016


Hi all,

a small question.

I sometimes stumble over the fact that "os" is a class, not a namespace.
And that we include the platform dependent additions into the middle of
this class.

This has a number of repercussions, like not being able to include the
platform dependent files (os_<os>_<cpu>) directly, not being able to
forward declare functions from the "os" namespace (e.g. os::malloc) etc. I
also cannot split implementations from "os" functions to different
implementation files without problems.

It seems to me all compiler nowadays support namespaces, would it not make
sense to convert "os" to a real namespace?

While we are at it, what is the reason for the "<os>" sub classes? e.g.
os::Bsd, os::Aix etc? It makes integrating patches between platforms
difficult and, to me, does not seem to serve any clear purpose.

If the purpose is to be a very low wrapper around OS particularities, it
makes no sense to have them in the "os" namespace and to make them visible
to the shared sections of the VM. E.g. there should be no reason to access
"os::Bsd" functions from outside os/bsd/vm, or to access "os::Posix"
functions outside implementations specific for Posix platforms.

Thanks, and Kind Regards, Thomas


More information about the hotspot-runtime-dev mailing list