From c8c0844f7fbcb955848ca84432e5ffcf71f1cef1 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Fri, 2 Aug 2013 12:59:45 -0400 Subject: 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. --- src/internal/procfdname.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/internal/procfdname.c (limited to 'src/internal') 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; +} -- cgit v1.2.1