Clean up some code

- Use good ELF technique in cosmo_dlopen()
- Make strerror() conform more to other libc impls
- Introduce __clear_cache() and use it in cosmo_dlopen()
- Remove libc/fmt/fmt.h header (trying to kill off LIBC_FMT)
This commit is contained in:
Justine Tunney 2023-11-16 16:34:53 -08:00
parent 7010a8081e
commit 68c7c9c1e0
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
244 changed files with 378 additions and 588 deletions

View file

@ -17,21 +17,20 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/dce.h"
#include "libc/fmt/fmt.h"
#include "libc/fmt/magnumstrs.internal.h"
#include "libc/intrin/safemacros.internal.h"
#include "libc/str/str.h"
_Alignas(1) static char strerror_buf[128];
/**
* Converts errno value to string non-reentrantly.
* Returns string describing `err`.
*
* The application shall not modify the string returned.
*
* @see strerror_r()
* @threadunsafe
*/
char *strerror(int err) {
if (IsTiny()) {
return (char *)firstnonnull(_strerrno(err), "EUNKNOWN");
} else {
_Alignas(1) static char buf[512];
strerror_r(err, buf, sizeof(buf));
return buf;
}
strerror_r(err, strerror_buf, sizeof(strerror_buf));
return strerror_buf;
}