scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 64c6767a017f7c7dd1b34fd7f6fe2a7e3060a35f
parent 6e5e998efb6bbb9f65cff011c2f99162bd883ff1
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon,  1 Oct 2018 09:16:54 +0100

[cc1] Improve ones()

This function is inspired in the function getbits() of k&r.

Diffstat:
Mcc1/fold.c | 6+-----
1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/cc1/fold.c b/cc1/fold.c @@ -9,11 +9,7 @@ static char sccsid[] = "@(#) ./cc1/fold.c"; TUINT ones(int nbytes) { - TUINT v; - - for (v = 0; nbytes--; v |= 255) - v <<= 8; - return v; + return (nbytes == 8) ? -1 : ~(-1ull << nbytes * 8); } static int