mirror of
https://github.com/fluencelabs/musl
synced 2025-06-09 04:51:34 +00:00
I intend to add more Linux workarounds that depend on using these pathnames, and some of them will be in "syscall" functions that, from an anti-bloat standpoint, should not depend on the whole snprintf framework.
14 lines
253 B
C
14 lines
253 B
C
void __procfdname(char *buf, unsigned fd)
|
|
{
|
|
unsigned i, j;
|
|
for (i=0; (buf[i] = "/proc/self/fd/"[i]); i++);
|
|
if (!fd) {
|
|
buf[i] = '0';
|
|
buf[i+1] = 0;
|
|
return;
|
|
}
|
|
for (j=fd; j; j/=10, i++);
|
|
buf[i] = 0;
|
|
for (; fd; fd/=10) buf[--i] = '0' + fd%10;
|
|
}
|