diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-09-05 00:04:01 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-09-05 00:04:01 +0200 |
commit | 4411de699a6f294475eb5ea915f57d3c43de40e3 (patch) | |
tree | 67cfcd18517ca42df976e07a7f85f7f17291bb79 /src | |
parent | c0b6f5746434589c59c536ce2e7ad8bc8f79b5b9 (diff) |
Fix some integer-type bugs
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 6 | ||||
-rw-r--r-- | src/parser.y | 3 |
2 files changed, 5 insertions, 4 deletions
@@ -52,11 +52,11 @@ static bool eqnsolve(eqn_t *, uint64_t, uint64_t); static int eqnprint(eqn_t *); static void eqnfree(eqn_t *); -static uint64_t +static int popcnt(uint64_t n) { -#if __has_builtin(__builtin_popcount) - return __builtin_popcount(n); +#if !__has_builtin(__builtin_popcountg) + return __builtin_popcountg(n); #else uint64_t c; for (c = 0; n > 0; n &= n - 1) diff --git a/src/parser.y b/src/parser.y index e424068..07afbe7 100644 --- a/src/parser.y +++ b/src/parser.y @@ -1,6 +1,7 @@ %{ #include <ctype.h> #include <err.h> +#include <stdint.h> #include <stdio.h> #include <stdlib.h> @@ -80,7 +81,7 @@ expr: $$.eqn = xmalloc(sizeof(eqn_t)); $$.eqn->type = IDENT; $$.eqn->ch = $1; - $$.vars = 1 << (islower($1) ? $1-'a'+26 : $1-'A'); + $$.vars = UINT64_C(1) << (islower($1) ? $1-'a'+26 : $1-'A'); } | NOT expr { $$ = mkunop(NOT, $2); } | OPAR expr CPAR { $$ = mkunop(OPAR, $2); } |