diff options
authorRich Felker <>2018-10-18 13:53:44 -0400
committerRich Felker <>2018-10-18 13:59:17 -0400
commit8084d6ab57cdb0b8f328d3cdbad3b9d09eaaee04 (patch)
parentd8870dcf385a75ae8df2f8bb5bd5ee59525ed348 (diff)
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.
1 files changed, 2 insertions, 4 deletions
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;