RFR: 8214976: Warn about uses of functions replaced for portability

Kim Barrett kim.barrett at oracle.com
Wed Jan 5 16:58:29 UTC 2022


> On Jan 5, 2022, at 11:16 AM, Harold Seigel <hseigel at openjdk.java.net> wrote:
> I don't think that FORBIDDEN_C_FUNCTION should be enforced for files os_aix.cpp, os_bsd.cpp, os_posix.cpp, and os_windows.cpp.  These are platform specific files that intentionally call multiple native functions.  For example, os_linux.cpp calls close_dir() fopen(), close(), readdir(), write(), lseek(), etc.

I disagree.  I think there are or will be functions we want to just forbid outright, and others we want
to forbid outside the implementation of the os:: wrapper because we consistently want some added
feature of the portability wrapper (such as asserts or common argument manipulation or whatever).

> Since PRAGMA_PERMIT_FORBIDDEN_C_FUNCTION ignores its argument and disables the warning for all native calls, I think it's reasonable to just specify  PRAGMA_PERMIT_FORBIDDEN_C_FUNCTION once at the beginning of the above files and not clutter them with many PRAGMA_DIAG_PUSH/POP's.

I disagree.

That behavior of the gcc version of the pragma is an artifact of its current implementation, and
not the desired behavior.  I couldn’t find a way to limit the disabling to the identifier in the argument
with gcc.  That doesn’t mean that won’t be possible for other platforms, or for a future version of
gcc, or for someone more clever than me.

Even with the limited gcc implementation the argument documents intent.

The purpose of the pragma is to permit the os:: portability wrapper for a function to be implemented
in terms of the corresponding native function.  If it weren’t for that requirement I wouldn’t want the
pragma to exist at all.



More information about the hotspot-dev mailing list