From 8084d6ab57cdb0b8f328d3cdbad3b9d09eaaee04 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Thu, 18 Oct 2018 13:53:44 -0400 Subject: [PATCH] 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. --- src/internal/stdio_impl.h | 6 ++---- 1 file 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; -- 2.25.1