musl/src/stdio/putc.h, branch master musl - an implementation of the standard library for Linux-based systems further optimize getc/putc when locking is needed 2018年10月18日T17:09:33+00:00 Rich Felker dalias@aerifal.cx 2018年10月18日T16:47:26+00:00 9dd19122565c70bc6e0fff35724c91a61209a629 check whether the lock is free before loading the calling thread's tid. if so, just use a dummy tid value that cannot compare equal to any actual thread id (because it's one bit wider). this also avoids the need to save the tid and pass it to locking_getc or locking_putc, reducing register pressure. this change might slightly hurt the case where the caller already holds the lock, but it does not affect the single-threaded case, and may significantly improve the multi-threaded case, especially on archs where loading the thread pointer is disproportionately expensive like early mips and arm ISA levels. but even on i386 it helps, at least on some machines; I measured roughly a 10-15% improvement.
check whether the lock is free before loading the calling thread's
tid. if so, just use a dummy tid value that cannot compare equal to
any actual thread id (because it's one bit wider). this also avoids
the need to save the tid and pass it to locking_getc or locking_putc,
reducing register pressure.
this change might slightly hurt the case where the caller already
holds the lock, but it does not affect the single-threaded case, and
may significantly improve the multi-threaded case, especially on archs
where loading the thread pointer is disproportionately expensive like
early mips and arm ISA levels. but even on i386 it helps, at least on
some machines; I measured roughly a 10-15% improvement.
fix build regression due to missing file for putc changes 2018年10月18日T14:44:32+00:00 Rich Felker dalias@aerifal.cx 2018年10月18日T14:43:39+00:00 ab5e1e340890b95e61d7161d7178c6a26247ad61 commit d664061adb4d7f6647ab2059bc351daa394bf5da inadvertently omitted the new file putc.h.
commit d664061adb4d7f6647ab2059bc351daa394bf5da inadvertently omitted
the new file putc.h.

AltStyle によって変換されたページ (->オリジナル) /