RFR: 8271569: Clean up the use of CDS constants and field offsets [v7]

David Holmes dholmes at openjdk.java.net
Wed Sep 15 01:20:51 UTC 2021


On Tue, 14 Sep 2021 23:57:01 GMT, Ioi Lam <iklam at openjdk.org> wrote:

>> Yes, but it still failed for non-pch since cds.h is before cdsConstants.hpp. size_t in cds.h is not defined yet. Should I add it to cds.h?
>
> This is a bit complicated. The file is src/hotspot/share/include/cds.h, and the HotSpot convention for including files in this directory usually drops the "include/" part. E.g.,
> 
> 
> #include "jvm.h"
> 
> 
> But this will put `#include "cds.h"` at the very beginning of all includes, so it doesn't take up `size_t` which is indirectly declared later via globalDefinitions.hpp.
> 
> However, header files in src/hotspot/share/ may be included by C/C++ files outside of HotSpot. As a result, these headers cannot include other HotSpot headers. I.e., you cannot put `#include "utilities/globalDefinitions.hpp"` in cds.h, because cds.h is included by src/jdk.hotspot.agent/share/native/libsaproc/ps_core_common.c.
> 
> I think one compromise is to add `#include <stddefs.h>` in cds.h. Since cds.h can be included by C source code, we cannot use `#include <cstddef>` which is a C++ thing.  `<stddefs.h>` is part of ANSI C standard and we already include it inside share/utilities/debug.hpp, so we can safely assume that it exists for all compilers that can build HotSpot.

I agree with Ioi - use stddefs.h in cds.h

-------------

PR: https://git.openjdk.java.net/jdk/pull/5450


More information about the hotspot-runtime-dev mailing list