4 ms·
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
by beefhash 7y ago
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.
- pcwalton 7y agoHack 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.
- fluffything 7y ago> 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
- dmitrygr 7y agoLook 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