4 ms·
Have you even looked at the source code to glibc? It's stuffed full of macros and #ifdef hell. Not to mention symbol versioning, the use of gcc-specific compi
by reality_czech 11y ago
Have you even looked at the source code to glibc? It's stuffed full of macros and #ifdef hell. Not to mention symbol versioning, the use of gcc-specific compiler extensions, and ancient-UNIX-beard performance hacks. You'd have more success teaching a chimpanzee to play the violin, than automatically translating glibc into anything.
- 0xcde4c3db 11y agoI've seen a lot of weird preprocessor (ab)use in GNU code. The coreutils true/false (of all programs to invoke clever preprocessor tricks...) has this gem: in true.c (all told, an 80-line file): /* Act like "true" by default; false.c overrides this. */ #ifndef EXIT_STATUS # define EXIT_STATUS EXIT_SUCCESS #endif false.c, of course, contains only: #define EXIT_STATUS EXIT_FAILURE #include "true.c" On my current system, each of these represents a stately 27KB dynamically linked executable. By way of comparison, the OpenBSD version of true comprises nine lines with zero preprocessor directives: /* $OpenBSD: true.c,v 1.1 2015/11/11 19:05:28 deraadt Exp $ */ /* Public domain - Theo de Raadt */ int main(int argc, char *argv[]) { return (0); }
- CyberDildonics 11y agoIf I write something and make it simple, how will people know what a jenius I am?
- masklinn 11y agoBut BSD true doesn't support --version, how are you going to check your version of true without a locale-aware version string (and yes, gnu true is locale-aware, and contains 2k of strings including 48 encoding names and 36 format strings — 10 of which are duplicates, and for some reason refers to the SHA2 utilities) (I dimly remember an essay about similar issue in a similar mainframe command (maybe in JCL?) taking a bunch of revisions to actually get right?)
- CyberDildonics 11y agoThen what chance do we have of cleaning it up? It does seem to me though that if you pre-processed it for a common case and translated it to rust with anything going into unsafe if it has to and started from that you would be off to some sort of start. The whole thing seems moot though because there are already alternate libc implementations like musl as well as alternate malloc implementations like jemalloc. I actually still don't understand why libc is the undertaking it is made out to be, especially if you can plug in jemalloc which I would think would take care of the most difficult part.
- charlieflowers 11y agoSo I guess we need more than just a "transliteration" to a safer language. We really need to shed that cruft and write something clear and understandable. Could we also drop a lot of requirements that applied to older, more limited hardware? (Or, do certain constrained hardware situations still require most of those requirements to stick around?)