![]() | |||||||||||||
Messages in this thread |
Andi Kleen wrote: > torvalds@transmeta.com (Linus Torvalds) writes: > >>"putc()" is a standard function. If it sucks, let's get it fixed. And >>instead of changing bonnie, how about pinging the _real_ people who >>write sucky code? >> > > It is easy to fix. Just do #define putc putc_unlocked > There is just a slight problem: it'll fail if your application is threaded > and wants to use the same FILE from multiple threads. > > It is a common problem on all OS that eventually got threadsafe stdio. > I bet putc sucks on Solaris too. > > -Andi Interesting thread on this: http://sources.redhat.com/ml/bug-glibc/2001-11/msg00079.html for glibc 2.2.4 with the following program with input file of 354371 lines of text(/usr/share/doc/*), where the average line length was 37 chars. getc/putc real 2.181s user 2.150s sys 0.030s getc_unlocked/putc_unlocked real 0.326s user 0.280s sys 0.040s I.E. 669% faster! Padraig. ------------------- #include <stdio.h> #ifndef _REENTRANT # undef getc # define getc(x) getc_unlocked(x) # undef putc # define putc(x,y) putc_unlocked(x,y) #endif //_REENTRANT void main(void) { int c; while((c=getc(stdin))!=EOF) putc(c,stdout); } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ | ||||||||||||
| Last update: 2005-03-22 13:13 [from the cache] ©2003-2008 | |||||||||||||