Deduplicating code in BsdUserDefinedFileAttributeView and LinuxUserDefinedFileAttributeView
Alan Bateman
Alan.Bateman at oracle.com
Mon Jan 25 14:00:06 UTC 2021
On 25/01/2021 08:30, Sebastian Stenzel wrote:
>
> I guess the pattern here is to assign the `my_methodhandle` to
> whatever applies during init(), as it is done e.g. for
> `my_futimens_func`? May I ask why this is done via dlsym()? Since the
> code is inside an #ifdef directive, so the compiler can't reach it if
> not applicable, can't I just assign my_futimens_func = futimens?
>
> Am I right that we're dealing with four platforms (Linux, Aix, BSD and
> macOS, the latter being a "special" BSD), that can be distinguished
> via #ifdef using one of these:
>
> ```
> __linux__
> _AIX
> _ALLBSD_SOURCE
> MACOSX
> ```
>
> What about `#ifdef __APPLE__`? I can see this used in various other
> places.
>
> If `_ALLBSD_SOURCE` is supposed to include all BSD flavours, can I
> simplify this:
>
> ```
> #if defined(__linux__) || defined(_AIX)
> #include <string.h>
> #endif
>
> #ifdef _ALLBSD_SOURCE
> #include <string.h>
> ...
> #endif
> ```
>
> to this:
>
> ```
> #include <string.h>
> ```
>
> ?
The xxx_func setup in the LinuxNativeDispatcher_init date when from when
the xattr functions weren't in the include files used at build-time. A
potential first step is to include <attr/xattr.h> and get that change
bedded in.
The _ALLBSD_SOURCE vs. MACOSX vs. ... is unfortunate and stems from how
the macOS port came into JDK 7u4. No objection to use _ALLBSD_SOURCE.
-Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20210125/76a19e5e/attachment.htm>
More information about the nio-dev
mailing list