jaydio
jaydio copied to clipboard
get C macro values from the compiler
macro values may vary across OSes
Hey, thanks for the PR! Could you provide some comments on which OSes deviate from the constants here? Originally this project is targeted primarily at Linux and I'm not aware of which other OSes support O_DIRECT; e.g. I don't see it in BSD.
Also, I'm not too fond of the idea of spinning up another process in a statically-scoped context, but it's been a while since I've used Java so maybe this sort of thing is standard practice? Either way I'd prefer a different approach that doesn't require spawning other processes, and that has the current constants available as a fallback in case something goes wrong.
My comment was not clear, I meant across Linux distros. The hardcoded macro value in Jaydio
was triggering a bug. In that particular distro, it was for O_DIRECTORY
instead of O_DIRECT
.
I do not know of any way to obtain the values without gcc
.
We could try to scan the system C headers with Java code, but that can get complicated, a macro symbol can be defined as another macro symbol, which must be resolved to get the value.
Thanks for the extra context! Which distro had different constants from the hardcoded ones?
It's Ubuntu 20.04.4 LTS (GNU/Linux 5.11.0-1028-aws aarch64)
. The CPU is Arm-based AWS Graviton2.