diff options
author | Rich Felker <dalias@aerifal.cx> | 2013-08-02 12:59:45 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2013-08-02 12:59:45 -0400 |
commit | c8c0844f7fbcb955848ca84432e5ffcf71f1cef1 (patch) | |
tree | 57aee97670957a956d6a387d1b33d6fd987765e9 /src/internal/procfdname.c | |
parent | 0dc4824479e357a3e23a02d35527e23fca920343 (diff) | |
download | musl-c8c0844f7fbcb955848ca84432e5ffcf71f1cef1.tar.gz musl-c8c0844f7fbcb955848ca84432e5ffcf71f1cef1.tar.bz2 musl-c8c0844f7fbcb955848ca84432e5ffcf71f1cef1.tar.xz musl-c8c0844f7fbcb955848ca84432e5ffcf71f1cef1.zip |
debloat code that depends on /proc/self/fd/%d with shared function
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.
Diffstat (limited to 'src/internal/procfdname.c')
-rw-r--r-- | src/internal/procfdname.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/internal/procfdname.c b/src/internal/procfdname.c new file mode 100644 index 00000000..697e0bdc --- /dev/null +++ b/src/internal/procfdname.c @@ -0,0 +1,13 @@ +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; +} |