lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

Dave Dodge wrote:
> #include <stdio.h>
> 
> int main(void)
> {
>         int ch;
>         while((ch = getc(stdin)) != EOF)
>                 putc(ch,stdout);
>         return 0;
> }

Maybe it's a coincidence ... but getc_unlocked and putc_unlocked
is about 4-5 times faster on my machine (with GCC, didn't try tcc).

Depending on compiler defines and some other things having to do
with glibc/libpthread startup magic and weak symbol resolving,
you may get the unlocked versions anyway. The unlocked variant
may or may not be inlined. The locked variant is never inlined,
but it may or may not use mutexes. glibc is full of wonders.

Bye,
     Mike