From: Rich Felker Date: Thu, 18 Oct 2018 17:53:44 +0000 (-0400) Subject: adjust types in FILE struct to make line buffering check less expensive X-Git-Tag: v1.1.21~37 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8084d6ab57cdb0b8f328d3cdbad3b9d09eaaee04;p=oweals%2Fmusl.git adjust types in FILE struct to make line buffering check less expensive the choice of signed char for lbf was a theoretically space-saving hack that was not helping, and was unwantedly expensive. while comparing bytes against a byte-sized member sounds easy, the trick here was that the byte to be compared was unsigned while the lbf member was signed, making it possible to set lbf negative to disable line buffering. however, this imposed a requirement to promote both operands, zero-extending one and sign-extending the other, in order to compare them. to fix this, repurpose the waiters count slot (unused since commit c21f750727515602a9e84f2a190ee8a0a2aeb2a1). while we're at it, switch mode (orientation) from signed char to int as well. this makes no semantic difference (its only possible values are -1, 0, and 1) but it might help on archs where byte access is awkward. --- diff --git a/src/internal/stdio_impl.h b/src/internal/stdio_impl.h index 055ef718..d7398f59 100644 --- a/src/internal/stdio_impl.h +++ b/src/internal/stdio_impl.h @@ -34,11 +34,9 @@ struct _IO_FILE { int fd; int pipe_pid; long lockcount; - short dummy3; - signed char mode; - signed char lbf; + int mode; volatile int lock; - volatile int waiters; + int lbf; void *cookie; off_t off; char *getln_buf;