Re:Ratification of the RISC-V Base ISA and Privileged Archit...
by beefhash on Thursday July 11, 2019 @12:42AM
(#20409186)
Not necessarily. The UNIX C syscall APIs all return 0 on success and anything not-zero is generally considered failure (usually -1). Even if it's wrong in C, it could possibly be more efficient in assembly to change the truthiness assumption around.
[ Parent
| on HN ]
Re:Ratification of the RISC-V Base ISA and Privileged Archit...
by pcwalton on Thursday July 11, 2019 @02:15AM
(#20409502)
Hack Clang to emit ~0 for true, recompile your kernel and userspace, and see how much of it breaks. I'm almost certain the system won't boot.
Re:Ratification of the RISC-V Base ISA and Privileged Archit...
by fluffything on Thursday July 11, 2019 @08:56AM
(#20411114)
> Hack Clang to emit ~0 for true, recompile your kernel and userspace, and see how much of it breaks.
The ABI of your platform might require special values for true and false, e.g., the SysV64 ABI explicitly requires 0 for false, and 1 for true.
So you would need to define a new platform for doing these tests, and then to test some code, you would need to port it to this new platform. AFAICT, if you port that code correctly, everything would work, and if something doesn't work, then you didn't port that code correctly.
So this experiment feels moot.
> I'm almost certain the system won't boot.
Clang can't compile the Linux kernel, so I hope you mean some other kernel. Otherwise, without a kernel, the system won't even boot :P
Re:Ratification of the RISC-V Base ISA and Privileged Archit...
by dmitrygr on Thursday July 11, 2019 @02:51AM
(#20409611)
Look at doom's source code for an idea of how often a bool is not just 0 or 1. I doubt doom is unique.
Spoiler: doom uses 2 values for bools: 0 for false, 1 for true, and -1 for not sure/unknown/error/something else