[RFC] Consider adding a function to convert error name to errno
Rocket Ma
marocketbd@gmail.com
Thu May 7 17:37:53 GMT 2026
Now we have strerror() to convert errno to error description, and we
have strerrorname_np() to convert errno to error name. Sometimes I
need to convert the error name back to errno, and I made some effort
to construct a static hash table to efficiently match the pair. Now
with some help from LLM, I found an efficient hash algorithm
(basically (((h << 12) | (h >> 20)) ^ c) + 10 with a final folding)
could output a hash in 256; I tried it to construct an open-addressing
hash table and found that for 100+ errnos nowadays, only about 5 error
names may conflict.
Could I implement this function to do conversions like "EPERM" to 1?
If I'm allowed to do it, how could we name the function?
Rocket
More information about the Libc-alpha
mailing list