RFR: 8214976: Warn about uses of functions replaced for portability
Kim Barrett
kbarrett at openjdk.java.net
Fri Jan 28 23:06:05 UTC 2022
On Thu, 27 Jan 2022 19:18:10 GMT, Harold Seigel <hseigel at openjdk.org> wrote:
> Please review this new attempt to resolve JDK-8214976. This fix adds Pragmas to generate compilation errors, when using gcc, if calling a native system function instead of the os:: version of the function. The fix includes changes to calls in non-shared code because it is cleaner than adding PRAGMAs and, for some cases, the os:: version of a function has added value, such as asserts and RESTARTABLE. This fix slightly changes the signature of os::abort() so it wouldn't conflict with native abort() functions. Changes to Windows code is left for a future RFE.
>
> This fix was tested with Mach5 tiers 1-2 on Linux, Mac OS, and Windows, Mach5 tiers 3-5 on Linux x64, and Mach5 builds of Zero, PPC, and s390.
>
> Thanks, Harold
Changes requested by kbarrett (Reviewer).
src/hotspot/share/utilities/compilerWarnings_gcc.hpp line 109:
> 107: FORBID_C_FUNCTION(ssize_t write(int, const void*, size_t ), "use os::write");
> 108:
> 109: FORBID_C_FUNCTION(char* strtok(char*, const char*), "use strtok_r");
Some of these functions are portable and ought to be forbidden in a platform agnostic location, so the restriction also applies if/when we have real support on other platforms. I think almost none are gcc (or clang) specific, but are instead probably posix and not windows, so maybe should go in a different place as well. Basically I think the structure / placement considerations need some more work.
src/hotspot/share/utilities/compilerWarnings_gcc.hpp line 114:
> 112:
> 113: #define FORBID_C_FUNCTION(signature, alternative)
> 114: #define PRAGMA_PERMIT_FORBIDDEN_C_FUNCTION(name)
These aren't needed. The default empty definitions in compilerWarnings.hpp cover this case.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7248
More information about the hotspot-dev
mailing list